光等待TBE标志是不够的,下面是例程中的函数:
/* Exchange a byte */
static
BYTE xchg_spi (
BYTE dat /* Data to send */
)
{
while(RESET == spi_i2s_flag_get(SPI1, SPI_FLAG_TBE));
spi_i2s_data_transmit(SPI1, dat);
while(RESET == spi_i2s_flag_get(SPI1, SPI_FLAG_RBNE));
return(spi_i2s_data_receive(SPI1)); /* Return received byte */
}
|