//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);