diff --git a/firmware/hw_layer/lcd/lcd_HD44780.cpp b/firmware/hw_layer/lcd/lcd_HD44780.cpp index fb790b4386..ff527aa5c1 100644 --- a/firmware/hw_layer/lcd/lcd_HD44780.cpp +++ b/firmware/hw_layer/lcd/lcd_HD44780.cpp @@ -180,6 +180,15 @@ static void lcdInfo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { scheduleMsg(logger, "HD44780 D7=%s", hwPortname(CONFIGB(HD44780_db7))); } +void stopHD44780_pins() { + unregisterPin(engineConfiguration->bc.HD44780_rs, activeConfiguration.bc.HD44780_rs); + unregisterPin(engineConfiguration->bc.HD44780_e, activeConfiguration.bc.HD44780_e); + unregisterPin(engineConfiguration->bc.HD44780_db4, activeConfiguration.bc.HD44780_db4); + unregisterPin(engineConfiguration->bc.HD44780_db5, activeConfiguration.bc.HD44780_db5); + unregisterPin(engineConfiguration->bc.HD44780_db6, activeConfiguration.bc.HD44780_db6); + unregisterPin(engineConfiguration->bc.HD44780_db7, activeConfiguration.bc.HD44780_db7); +} + void lcd_HD44780_init(Logging *sharedLogger) { logger = sharedLogger; diff --git a/firmware/hw_layer/lcd/lcd_HD44780.h b/firmware/hw_layer/lcd/lcd_HD44780.h index b4dc7fd2c7..3c4fd1e214 100644 --- a/firmware/hw_layer/lcd/lcd_HD44780.h +++ b/firmware/hw_layer/lcd/lcd_HD44780.h @@ -13,6 +13,7 @@ extern "C" { #endif /* __cplusplus */ +void stopHD44780_pins(); void lcd_HD44780_init(Logging *sharedLogger); void lcd_HD44780_set_position(uint8_t row, uint8_t column); void lcd_HD44780_print_char(char data); diff --git a/firmware/hw_layer/sensors/joystick.cpp b/firmware/hw_layer/sensors/joystick.cpp index 8d069b494a..89b07d718c 100644 --- a/firmware/hw_layer/sensors/joystick.cpp +++ b/firmware/hw_layer/sensors/joystick.cpp @@ -98,6 +98,20 @@ static bool isJoystickEnabled() { CONFIGB(joystickDPin) != GPIO_UNASSIGNED; } +void stopJoystickPins() { + brain_pin_markUnused(CONFIGB(joystickCenterPin)); + brain_pin_markUnused(CONFIGB(joystickAPin)); + brain_pin_markUnused(CONFIGB(joystickDPin)); +} + +void startJoystickPins() { + efiSetPadMode("joy center", CONFIGB(joystickCenterPin), PAL_MODE_INPUT_PULLUP); + efiSetPadMode("joy A", CONFIGB(joystickAPin), PAL_MODE_INPUT_PULLUP); + // not used so far efiSetPadMode("joy B", CONFIGB(joystickBPin), PAL_MODE_INPUT_PULLUP); + // not used so far efiSetPadMode("joy C", CONFIGB(joystickCPin), PAL_MODE_INPUT_PULLUP); + efiSetPadMode("joy D", CONFIGB(joystickDPin), PAL_MODE_INPUT_PULLUP); +} + void initJoystick(Logging *shared) { addConsoleAction("joystickinfo", joystickInfo); if (!isJoystickEnabled()) @@ -110,11 +124,7 @@ void initJoystick(Logging *shared) { // not used so far applyPin(CONFIGB(joystickCPin)); enableExti(CONFIGB(joystickDPin), PAL_EVENT_MODE_RISING_EDGE, (palcallback_t)(void *)extCallback); - efiSetPadMode("joy center", CONFIGB(joystickCenterPin), PAL_MODE_INPUT_PULLUP); - efiSetPadMode("joy A", CONFIGB(joystickAPin), PAL_MODE_INPUT_PULLUP); - // not used so far efiSetPadMode("joy B", CONFIGB(joystickBPin), PAL_MODE_INPUT_PULLUP); - // not used so far efiSetPadMode("joy C", CONFIGB(joystickCPin), PAL_MODE_INPUT_PULLUP); - efiSetPadMode("joy D", CONFIGB(joystickDPin), PAL_MODE_INPUT_PULLUP); + startJoystickPins(); } #endif /* HAL_USE_PAL && EFI_JOYSTICK */ diff --git a/firmware/hw_layer/sensors/joystick.h b/firmware/hw_layer/sensors/joystick.h index 04bca2f595..3360c969f4 100644 --- a/firmware/hw_layer/sensors/joystick.h +++ b/firmware/hw_layer/sensors/joystick.h @@ -19,5 +19,7 @@ typedef enum { void onJoystick(joystick_button_e button); void initJoystick(Logging *shared); +void startJoystickPins(); +void stopJoystickPins(); #endif /* CONTROLLERS_JOYSTICK_H_ */