diff options
author | Eugene Krashtan <Eugene.Krashtan@opensynergy.com> | 2019-03-13 17:39:46 +0200 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-03-24 12:10:19 -0400 |
commit | 45f0ea29a6f79d500a902d8f73da65d1d230f902 (patch) | |
tree | 44b550713f83b7d69979da2464b12579a707affe /src/stm32f0/gpio.c | |
parent | b79db3e3d6d16e25af6483a6064cd3691387a1c8 (diff) | |
download | kutter-45f0ea29a6f79d500a902d8f73da65d1d230f902.tar.gz kutter-45f0ea29a6f79d500a902d8f73da65d1d230f902.tar.xz kutter-45f0ea29a6f79d500a902d8f73da65d1d230f902.zip |
stm32f0: SPI and i2c interfaces added
Signed-off-by: Eugene Krashtan <eug.krashtan@gmail.com>
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"); +} |