unsigned char SPI_WriteByte(unsigned char data)
{
unsigned char Data = 0;
//Wait until the transmit buffer is empty
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)==RESET);
// Send the byte
SPI_I2S_SendData(SPI1,data);
//Wait until a data is received
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE)==RESET);
// Get the received data
Data = SPI_I2S_ReceiveData(SPI1);
// Return the shifted data
return Data;
}
这样可以吗?
|