This commit is contained in:
Bertrand Songis
2019-11-15 08:24:13 +01:00
parent 3e2c274233
commit d9333ef001
+24 -15
View File
@@ -235,46 +235,55 @@ uint32_t switchState(uint8_t index)
} }
#endif #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() void keysInit()
{ {
GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
#if defined(PCBX9DP) && PCBREV == 2019
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
SET_PINS_HIGH(GPIOC);
SET_PINS_HIGH(GPIOE);
#endif
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
#if defined(KEYS_GPIOA_PINS) #if defined(KEYS_GPIOA_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOA_PINS; INIT_KEYS_PINS(GPIOA);
GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif #endif
#if defined(KEYS_GPIOB_PINS) #if defined(KEYS_GPIOB_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOB_PINS; INIT_KEYS_PINS(GPIOB);
GPIO_Init(GPIOB, &GPIO_InitStructure);
#endif #endif
#if defined(KEYS_GPIOC_PINS) #if defined(KEYS_GPIOC_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOC_PINS; INIT_KEYS_PINS(GPIOC);
GPIO_Init(GPIOC, &GPIO_InitStructure);
#endif #endif
#if defined(KEYS_GPIOD_PINS) #if defined(KEYS_GPIOD_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOD_PINS; INIT_KEYS_PINS(GPIOD);
GPIO_Init(GPIOD, &GPIO_InitStructure);
#endif #endif
#if defined(KEYS_GPIOE_PINS) #if defined(KEYS_GPIOE_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOE_PINS; INIT_KEYS_PINS(GPIOE);
GPIO_Init(GPIOE, &GPIO_InitStructure);
#endif #endif
#if defined(KEYS_GPIOF_PINS) #if defined(KEYS_GPIOF_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOF_PINS; INIT_KEYS_PINS(GPIOF);
GPIO_Init(GPIOF, &GPIO_InitStructure);
#endif #endif
#if defined(KEYS_GPIOG_PINS) #if defined(KEYS_GPIOG_PINS)
GPIO_InitStructure.GPIO_Pin = KEYS_GPIOG_PINS; INIT_KEYS_PINS(GPIOG);
GPIO_Init(GPIOG, &GPIO_InitStructure);
#endif #endif
} }