diff options
Diffstat (limited to 'src/stm32f0/gpio.c')
-rw-r--r-- | src/stm32f0/gpio.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/stm32f0/gpio.c b/src/stm32f0/gpio.c index 74e2fb9e..859cd8d0 100644 --- a/src/stm32f0/gpio.c +++ b/src/stm32f0/gpio.c @@ -51,6 +51,7 @@ uint8_t const avail_pins[] = { static uint8_t gpio_check_pin(uint8_t pin) { + gpio_check_busy(pin); int i; for(i=0; i<ARRAY_SIZE(avail_pins); i++) { if (avail_pins[i] == pin) @@ -139,3 +140,22 @@ void gpio_init(void) __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); } + +void gpio_check_busy(uint8_t pin) +{ + // Increase to uint32_t and assert <32 on bigger chips + static uint16_t pinmap; + assert_param(sizeof(avail_pins)<16); + + for (int i = 0; i<sizeof(avail_pins); i++) { + if(avail_pins[i]==pin) { + if(pinmap&(1<<i)) { + break; + } else { + pinmap |= 1<<i; + return; + } + } + } + shutdown("GPIO check failed"); +} |