From 199032e4eded33d4053e44ce065056e4f9d173f5 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Wed, 19 Feb 2025 09:57:07 -0500 Subject: [PATCH] mcu_standby() Lua function fix #7467 --- firmware/config/boards/hellen/alphax-4K-GDI/board.mk | 1 + firmware/config/boards/hellen/alphax-8chan-revA/board.mk | 1 + firmware/config/boards/hellen/alphax-8chan/board.mk | 2 ++ firmware/controllers/lua/lua_hooks_util.cpp | 4 +++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/firmware/config/boards/hellen/alphax-4K-GDI/board.mk b/firmware/config/boards/hellen/alphax-4K-GDI/board.mk index 8d98af7a04..16571b01a7 100644 --- a/firmware/config/boards/hellen/alphax-4K-GDI/board.mk +++ b/firmware/config/boards/hellen/alphax-4K-GDI/board.mk @@ -18,6 +18,7 @@ DDEFS += -DEFI_SENT_SUPPORT=TRUE # we have hellen board id BOARD_ID_GDI4CHAN_A DDEFS += -DHW_HELLEN_4K_GDI=1 +DDEFS += -DLUA_STM32_STANDBY=1 include $(BOARDS_DIR)/hellen/hellen-common-mega144.mk diff --git a/firmware/config/boards/hellen/alphax-8chan-revA/board.mk b/firmware/config/boards/hellen/alphax-8chan-revA/board.mk index eed28294ae..505f84a8e6 100644 --- a/firmware/config/boards/hellen/alphax-8chan-revA/board.mk +++ b/firmware/config/boards/hellen/alphax-8chan-revA/board.mk @@ -26,3 +26,4 @@ endif DDEFS += -DSTATIC_BOARD_ID=STATIC_BOARD_ID_ALPHAX_8CHAN DDEFS += -DHW_HELLEN_8CHAN=1 +DDEFS += -DLUA_STM32_STANDBY=1 diff --git a/firmware/config/boards/hellen/alphax-8chan/board.mk b/firmware/config/boards/hellen/alphax-8chan/board.mk index da09e0ec64..596e8c59b2 100644 --- a/firmware/config/boards/hellen/alphax-8chan/board.mk +++ b/firmware/config/boards/hellen/alphax-8chan/board.mk @@ -33,4 +33,6 @@ DDEFS += -DSTATIC_BOARD_ID=STATIC_BOARD_ID_ALPHAX_8CHAN DDEFS += -DHW_HELLEN_8CHAN=1 +DDEFS += -DLUA_STM32_STANDBY=1 + ONBOARD_MEMS_TYPE=LIS2DH12 diff --git a/firmware/controllers/lua/lua_hooks_util.cpp b/firmware/controllers/lua/lua_hooks_util.cpp index e0951ac6c2..ab740b4bcd 100644 --- a/firmware/controllers/lua/lua_hooks_util.cpp +++ b/firmware/controllers/lua/lua_hooks_util.cpp @@ -84,7 +84,9 @@ void configureRusefiLuaUtilHooks(lua_State* lState) { #define STARTUP_STANDBY_PROHIBITED_PERIOD_SEC 3 #endif -#if defined(STM32F4) || defined(STM32F7) +// works on STM32F4 and STM32F7 but only on specific boards +// (it's all about PA0 being not used by ADC etc) +#if defined(LUA_STM32_STANDBY) lua_register(lState, "mcu_standby", [](lua_State*) { if (getTimeNowS() < STARTUP_STANDBY_PROHIBITED_PERIOD_SEC) { criticalError("mcu_standby invoked right on start");