- uint8_t bsp_spi_sendbyte(uint8_t dat)
- {
- /*!< Loop while DAT register in not emplty */
- while (SPI_I2S_GetStatus(SPI1, SPI_I2S_TE_FLAG) == RESET)
- ;
- /*!< Send byte through the SPI1 peripheral */
- SPI_I2S_TransmitData(SPI1, dat);
- /*!< Wait to receive a byte */
- while (SPI_I2S_GetStatus(SPI1, SPI_I2S_RNE_FLAG) == RESET)
- ;
- /*!< Return the byte read from the SPI bus */
- return SPI_I2S_ReceiveData(SPI1);
- }
这个是使用官方提供的固件库进行的读写API。
以上代码经验证通过。
|