From 378cfb7468b2ef17ed7a071e75b3bb95bb62ac5f Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 15 Nov 2019 08:33:12 +0100 Subject: [PATCH] Same fix than #7087 on X10 Express --- .../targets/common/arm/stm32/board_common.h | 9 +++++ radio/src/targets/horus/keys_driver.cpp | 38 +++++++++---------- radio/src/targets/taranis/keys_driver.cpp | 13 +------ 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/radio/src/targets/common/arm/stm32/board_common.h b/radio/src/targets/common/arm/stm32/board_common.h index add5ccbde..a576519f1 100644 --- a/radio/src/targets/common/arm/stm32/board_common.h +++ b/radio/src/targets/common/arm/stm32/board_common.h @@ -139,4 +139,13 @@ void delay_ms(uint32_t ms); } #endif +#define INIT_KEYS_PINS(GPIO) \ + GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \ + GPIO_Init(GPIO, &GPIO_InitStructure) + +#define SET_KEYS_PINS_HIGH(GPIO) \ + GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \ + GPIO_Init(GPIO, &GPIO_InitStructure); \ + GPIO_SetBits(GPIO, KEYS_ ## GPIO ## _PINS) + #endif diff --git a/radio/src/targets/horus/keys_driver.cpp b/radio/src/targets/horus/keys_driver.cpp index 52d862ad1..01673d7fd 100644 --- a/radio/src/targets/horus/keys_driver.cpp +++ b/radio/src/targets/horus/keys_driver.cpp @@ -199,34 +199,30 @@ uint32_t switchState(uint8_t index) void keysInit() { GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOB_PINS; - GPIO_Init(GPIOB, &GPIO_InitStructure); - -#if defined(KEYS_GPIOC_PINS) - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOC_PINS; - GPIO_Init(GPIOC, &GPIO_InitStructure); +#if defined(PCBX10) && defined(PCBREV_EXPRESS) + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + SET_KEYS_PINS_HIGH(GPIOB); + SET_KEYS_PINS_HIGH(GPIOD); + SET_KEYS_PINS_HIGH(GPIOG); + SET_KEYS_PINS_HIGH(GPIOJ); #endif - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOD_PINS; - GPIO_Init(GPIOD, &GPIO_InitStructure); + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOE_PINS; - GPIO_Init(GPIOE, &GPIO_InitStructure); + INIT_KEYS_PINS(GPIOB); - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOG_PINS; - GPIO_Init(GPIOG, &GPIO_InitStructure); +#if defined(KEYS_GPIOC_PINS) + INIT_KEYS_PINS(GPIOC); +#endif - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOH_PINS; - GPIO_Init(GPIOH, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOI_PINS; - GPIO_Init(GPIOI, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = KEYS_GPIOJ_PINS; - GPIO_Init(GPIOJ, &GPIO_InitStructure); + INIT_KEYS_PINS(GPIOD); + INIT_KEYS_PINS(GPIOE); + INIT_KEYS_PINS(GPIOG); + INIT_KEYS_PINS(GPIOH); + INIT_KEYS_PINS(GPIOI); + INIT_KEYS_PINS(GPIOJ); } diff --git a/radio/src/targets/taranis/keys_driver.cpp b/radio/src/targets/taranis/keys_driver.cpp index efa7f3004..b7b2b2d54 100644 --- a/radio/src/targets/taranis/keys_driver.cpp +++ b/radio/src/targets/taranis/keys_driver.cpp @@ -235,15 +235,6 @@ uint32_t switchState(uint8_t index) } #endif -#define INIT_KEYS_PINS(GPIO) \ - GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \ - GPIO_Init(GPIO, &GPIO_InitStructure) - -#define SET_PINS_HIGH(GPIO) \ - GPIO_InitStructure.GPIO_Pin = KEYS_ ## GPIO ## _PINS; \ - GPIO_Init(GPIO, &GPIO_InitStructure); \ - GPIO_SetBits(GPIO, KEYS_ ## GPIO ## _PINS) - void keysInit() { GPIO_InitTypeDef GPIO_InitStructure; @@ -253,8 +244,8 @@ void keysInit() #if defined(PCBX9DP) && PCBREV == 2019 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - SET_PINS_HIGH(GPIOC); - SET_PINS_HIGH(GPIOE); + SET_KEYS_PINS_HIGH(GPIOC); + SET_KEYS_PINS_HIGH(GPIOE); #endif GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;