笔者最近工作的时候遇到了同一组SPI总线挂接了两种SPI芯片,
一种是上升沿获取数据,一种是下降沿获取数据。
明明有其他SPI总线可以用,在此就不吐槽硬件同学了。
由于这两个芯片在程序运行中会反复查询,所以SPI会反复初始化。
在调试的时候一般都是使用stm32f10x_spi.c中的这个函数
void SPI_Init(SPI_TypeDef* p_SPIx, const SPI_InitTypeDef* p_SPI_InitStruct)
不停地对SPI初始为两种情况,关于STM32 SPI的初始化我会在另一篇文章里讲解。
可是实际调试的时候发现,并不是每次初始能够成功,往往使SPI状态固定为一种情况。
于是又看了看库函数stm32f10x_spi.c
发现了一个注销初始化的函数如下
/**
* @brief Deinitialize the SPIx peripheral registers to their default reset values.
* @param SPIx: To select the SPIx/I2Sx peripheral, where x can be: 1, 2 or 3
* in SPI mode or 2 or 3 in I2S mode.
*
* @note The extended I2S blocks (ie. I2S2ext and I2S3ext blocks) are deinitialized
* when the relative I2S peripheral is deinitialized (the extended block's clock