stm32f0: SPI and i2c interfaces added
Signed-off-by: Eugene Krashtan <eug.krashtan@gmail.com>
This commit is contained in:
committed by
Kevin O'Connor
parent
b79db3e3d6
commit
45f0ea29a6
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user