gpio: tle9104: minor cleanups

This commit is contained in:
Andrey Gusakov 2024-06-21 12:47:42 +03:00 committed by rusefillc
parent f4321c065c
commit f9a45515a6
1 changed files with 8 additions and 6 deletions

View File

@ -354,6 +354,8 @@ int Tle9104::init() {
// disable outputs // disable outputs
m_en.setValue(false); m_en.setValue(false);
// Reset the chip
m_resn.setValue(false);
/* TODO: ensure all direct_io pins valid, otherwise support manipulationg output states over SPI */ /* TODO: ensure all direct_io pins valid, otherwise support manipulationg output states over SPI */
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
@ -364,11 +366,11 @@ int Tle9104::init() {
writePad(i, false); writePad(i, false);
} }
// Reset the chip if (isBrainPinValid(cfg->resn)) {
m_resn.setValue(false); chThdSleepMilliseconds(1);
chThdSleepMilliseconds(1); m_resn.setValue(true);
m_resn.setValue(true); chThdSleepMilliseconds(1);
chThdSleepMilliseconds(1); }
// read ID register // read ID register
uint8_t id; uint8_t id;
@ -378,7 +380,7 @@ int Tle9104::init() {
return ret; return ret;
} }
// No chip detected if ID is wrong // No chip detected if ID is wrong
if ((id & 0xFF) != 0xB1) { if (id != 0xB1) {
return -1; return -1;
} }