diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 196118e124..467d96daf8 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -316,6 +316,8 @@ void OutputPin::setValue(int logicValue) { } else { /* external pin */ gpiochips_writePad(this->brainPin, logicValue); + /* TODO: check return value */ + currentLogicValue = logicValue; } #else if (port != GPIO_NULL) { diff --git a/firmware/hw_layer/drivers/gpio/tle6240.c b/firmware/hw_layer/drivers/gpio/tle6240.c index 0b7814c27f..41b33f5506 100644 --- a/firmware/hw_layer/drivers/gpio/tle6240.c +++ b/firmware/hw_layer/drivers/gpio/tle6240.c @@ -24,6 +24,7 @@ #include "gpio/gpio_ext.h" #include "gpio/tle6240.h" #include "pin_repository.h" +#include "rfiutil.h" #if (BOARD_TLE6240_COUNT > 0) @@ -312,7 +313,17 @@ static int tle6240_wake_driver(struct tle6240_priv *chip) { (void)chip; - chSemSignal(&tle6240_wake); + if (isIsrContext()) { + // this is for normal runtime + int wasLocked = lockAnyContext(); + chSemSignalI(&tle6240_wake); + if (!wasLocked) { + unlockAnyContext(); + } + } else { + // this is for start-up to not hang up + chSemSignal(&tle6240_wake); + } return 0; } diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index 2b2376bde5..89c2914c56 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -215,11 +215,6 @@ void initPinRepository(void) { initialized = true; - #if (BOARD_EXT_GPIOCHIPS > 0) - /* external chip init */ - gpiochips_init(); - #endif - addConsoleAction("pins", reportPins); } diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp index f2adb0c3b8..c575b49678 100644 --- a/firmware/hw_layer/smart_gpio.cpp +++ b/firmware/hw_layer/smart_gpio.cpp @@ -11,6 +11,7 @@ #include "smart_gpio.h" #include "efi_gpio.h" #include "engine_configuration.h" +#include "hardware.h" #include "gpio_ext.h" #include "drivers/gpio/tle6240.h" #include "drivers/gpio/mc33972.h" @@ -19,7 +20,7 @@ EXTERN_CONFIG; #if (BOARD_TLE6240_COUNT > 0) -const struct tle6240_config tle6240 = { +struct tle6240_config tle6240 = { .spi_bus = NULL /* TODO software lookup &SPID4 */, .spi_config = { .circular = false, @@ -58,7 +59,7 @@ const struct tle6240_config tle6240 = { #endif /* (BOARD_TLE6240_COUNT > 0) */ #if (BOARD_MC33972_COUNT > 0) -const struct mc33972_config mc33972 = { +struct mc33972_config mc33972 = { .spi_bus = NULL /* TODO software lookup &SPID4 */, .spi_config = { .circular = false, @@ -107,6 +108,11 @@ void initSmartGpio() { initTle8888(PASS_ENGINE_PARAMETER_SIGNATURE); #endif /* (BOARD_TLE6240_COUNT > 0) */ + +#if (BOARD_EXT_GPIOCHIPS > 0) + /* external chip init */ + gpiochips_init(); +#endif } #endif /* EFI_PROD_CODE */