From f9a45515a6f5f8d4d60b8661fad10c9873f2d03c Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Fri, 21 Jun 2024 12:47:42 +0300 Subject: [PATCH] gpio: tle9104: minor cleanups --- firmware/hw_layer/drivers/gpio/tle9104.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/hw_layer/drivers/gpio/tle9104.cpp b/firmware/hw_layer/drivers/gpio/tle9104.cpp index 8b45766cd8..c87c362cbb 100644 --- a/firmware/hw_layer/drivers/gpio/tle9104.cpp +++ b/firmware/hw_layer/drivers/gpio/tle9104.cpp @@ -354,6 +354,8 @@ int Tle9104::init() { // disable outputs 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 */ for (int i = 0; i < 4; i++) { @@ -364,11 +366,11 @@ int Tle9104::init() { writePad(i, false); } - // Reset the chip - m_resn.setValue(false); - chThdSleepMilliseconds(1); - m_resn.setValue(true); - chThdSleepMilliseconds(1); + if (isBrainPinValid(cfg->resn)) { + chThdSleepMilliseconds(1); + m_resn.setValue(true); + chThdSleepMilliseconds(1); + } // read ID register uint8_t id; @@ -378,7 +380,7 @@ int Tle9104::init() { return ret; } // No chip detected if ID is wrong - if ((id & 0xFF) != 0xB1) { + if (id != 0xB1) { return -1; }