From a27417c4970ac2028c156076f2dddf998dc5517d Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 2 Dec 2019 08:26:17 +0100 Subject: [PATCH] X9D+ 2019 Bootloader: wait needed before detecting trims are pressed as done on Horus... --- radio/src/targets/common/arm/stm32/bootloader/boot.cpp | 8 ++++---- radio/src/targets/horus/hal.h | 2 ++ radio/src/targets/taranis/hal.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 6f5bab83c..90166ffdd 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -69,13 +69,13 @@ FlashCheckRes valid; MemoryType memoryType; uint32_t unlocked = 0; -void interrupt10ms(void) +void interrupt10ms() { - tenms |= 1; // 10 mS has passed + tenms |= 1u; // 10 mS has passed uint8_t index = 0; uint8_t in = readKeys(); - for (uint8_t i = 1; i != uint8_t(1 << TRM_BASE); i <<= 1) { + for (uint8_t i = 1; i != uint8_t(1u << TRM_BASE); i <<= 1) { uint8_t value = (in & i); keys[index].input(value); ++index; @@ -210,7 +210,7 @@ int main() pwrInit(); keysInit(); -#if defined(PCBHORUS) +#if defined(BOOTLOADER_WAIT_BEFORE_READ_TRIMS) // wait a bit for the inputs to stabilize... if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) { for (uint32_t i = 0; i < 150000; i++) { diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index e7afa6ddb..64259dc09 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -140,6 +140,8 @@ #define SWITCHES_GPIO_PIN_J GPIO_Pin_0 // PB.00 #endif +#define BOOTLOADER_WAIT_BEFORE_READ_TRIMS + // Trims #if defined(PCBX12S) #define TRIMS_GPIO_REG_RHL GPIOC->IDR diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 235e5eefb..6b890b5e2 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -228,6 +228,7 @@ #define TRIMS_GPIO_REG_RHL GPIOD->IDR #define TRIMS_GPIO_PIN_RHL GPIO_Pin_9 // PD.09 #elif defined(PCBX9DP) && PCBREV >= 2019 + #define BOOTLOADER_WAIT_BEFORE_READ_TRIMS #define TRIMS_GPIO_REG_LHL GPIOE->IDR #define TRIMS_GPIO_PIN_LHL GPIO_Pin_3 // PE.03 #define TRIMS_GPIO_REG_LHR GPIOE->IDR -- 2.11.4.GIT