Added spi reset convenience function.
This commit is contained in:
parent
2b3f07ee08
commit
c49f505df4
@ -297,6 +297,7 @@
|
||||
|
||||
/* --- Function prototypes ------------------------------------------------- */
|
||||
|
||||
void spi_reset(u32 spi_peripheral);
|
||||
int spi_init_master(u32 spi, u32 br, u32 cpol, u32 cpha, u32 dff, u32 lsbfirst);
|
||||
void spi_enable(u32 spi);
|
||||
void spi_disable(u32 spi);
|
||||
|
@ -32,6 +32,24 @@
|
||||
* reg16 = spi_read(SPI1); // 16-bit read
|
||||
*/
|
||||
|
||||
void spi_reset(u32 spi_peripheral)
|
||||
{
|
||||
switch (spi_peripheral) {
|
||||
case SPI1:
|
||||
rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_SPI1RST);
|
||||
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);
|
||||
break;
|
||||
case SPI3:
|
||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB2RSTR_SPI3RST);
|
||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB2RSTR_SPI3RST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int spi_init_master(u32 spi, u32 br, u32 cpol, u32 cpha, u32 dff, u32 lsbfirst)
|
||||
{
|
||||
u32 reg32 = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user