From 05d3ce22f4e54187c6821bc5310ae3d67b3153c3 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 6 Apr 2019 08:41:37 -0400 Subject: [PATCH] CONFIG_RESET_SWITCH_PORT flexibility --- firmware/config/boards/me7_pnp/!compile-me7_pnp.bat | 1 + firmware/config/stm32f1egt/efifeatures.h | 3 +++ firmware/config/stm32f4ems/efifeatures.h | 5 +++++ firmware/console/console_io.h | 6 +++++- firmware/hw_layer/hardware.cpp | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/firmware/config/boards/me7_pnp/!compile-me7_pnp.bat b/firmware/config/boards/me7_pnp/!compile-me7_pnp.bat index 628753733c..3d80cdbb46 100644 --- a/firmware/config/boards/me7_pnp/!compile-me7_pnp.bat +++ b/firmware/config/boards/me7_pnp/!compile-me7_pnp.bat @@ -9,6 +9,7 @@ set EXTRA_PARAMS=-DDUMMY -DSTM32F767xx ^ -DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED ^ -DEFI_COMMUNICATION_PIN=GPIOA_2 ^ -DEFI_FATAL_ERROR_PIN=GPIOA_5 ^ + -DCONFIG_RESET_SWITCH_PORT=NULL ^ -DEFI_ENABLE_ASSERTS=FALSE ^ -DCH_DBG_THREADS_PROFILING=FALSE rem set DEBUG_LEVEL_OPT="-O2" diff --git a/firmware/config/stm32f1egt/efifeatures.h b/firmware/config/stm32f1egt/efifeatures.h index 3a9774f34b..025579b310 100644 --- a/firmware/config/stm32f1egt/efifeatures.h +++ b/firmware/config/stm32f1egt/efifeatures.h @@ -46,7 +46,10 @@ #define CONSOLE_MAX_ACTIONS 32 +#ifndef CONFIG_RESET_SWITCH_PORT #define CONFIG_RESET_SWITCH_PORT GPIOD +#endif + #define CONFIG_RESET_SWITCH_PIN 6 /** diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index bd24a00cb4..a0ad22ae37 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -362,8 +362,13 @@ #define GPS_SERIAL_DEVICE &SD1 #define GPS_SERIAL_SPEED 38400 +#ifndef CONFIG_RESET_SWITCH_PORT #define CONFIG_RESET_SWITCH_PORT GPIOD +#endif + +#ifndef CONFIG_RESET_SWITCH_PIN #define CONFIG_RESET_SWITCH_PIN 6 +#endif /** * This is the size of the MemoryStream used by chvprintf diff --git a/firmware/console/console_io.h b/firmware/console/console_io.h index f3dcaf6ecc..d70e93594c 100644 --- a/firmware/console/console_io.h +++ b/firmware/console/console_io.h @@ -24,8 +24,12 @@ typedef void (*CommandHandler)(char *); #include "efifeatures.h" #include "datalogging.h" +#ifdef CONFIG_RESET_SWITCH_PORT // todo: make this pin configurable -#define SHOULD_INGORE_FLASH() (palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0) +#define SHOULD_INGORE_FLASH() (CONFIG_RESET_SWITCH_PORT != NULL && palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0) +#else +#define SHOULD_INGORE_FLASH() (false) +#endif BaseChannel * getConsoleChannel(void); diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index 6aebcf4e7a..2aeea4ff3f 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -375,6 +375,8 @@ void initHardware(Logging *l) { /** * this call reads configuration from flash memory or sets default configuration * if flash state does not look right. + * + * interesting fact that we have another read from flash before we get here */ if (SHOULD_INGORE_FLASH()) { engineConfiguration->engineType = DEFAULT_ENGINE_TYPE;