/*****************************************************************************
* @name :u8 SPI_WriteByte(SPI_TypeDef* SPIx,u8 Byte)
* @date :2018-08-09
* @function :Write a byte of data using STM32's hardware SPI
* @parameters :SPIx: SPI type,x for 1,2,3
Byte:Data to be written
* @retvalue :Data received by the bus
******************************************************************************/
u8 SPI_WriteByte(SPI_TypeDef* SPIx,u8 Byte)
{
while((SPIx->SR&SPI_I2S_FLAG_TXE)==RESET); //等待发送区空
SPIx->DR=Byte; //发送一个byte
while((SPIx->SR&SPI_I2S_FLAG_RXNE)==RESET);//等待接收完一个byte
return SPIx->DR; //返回收到的数据
}