diff --git a/lib/stm32/spi.c b/lib/stm32/spi.c index c97837c2..175b1827 100644 --- a/lib/stm32/spi.c +++ b/lib/stm32/spi.c @@ -18,6 +18,15 @@ */ #include +#if defined(STM32F1) +# include +#elif defined(STM32F2) +# include +#elif defined(STM32F4) +# include +#else +# error "stm32 family not defined." +#endif /* * SPI and I2S code. @@ -40,12 +49,12 @@ void spi_reset(u32 spi_peripheral) rcc_peripheral_clear_reset(&RCC_APB2RSTR, RCC_APB2RSTR_SPI1RST); break; case SPI2: - rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB2RSTR_SPI2RST); - rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB2RSTR_SPI2RST); + rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_SPI2RST); + rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_SPI2RST); break; case SPI3: - rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB2RSTR_SPI3RST); - rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB2RSTR_SPI3RST); + rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_SPI3RST); + rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_SPI3RST); break; } }