废话不说,上图两张。主函数只有一句话while(){SPI2_ReadWriteByte(0xAA);
发送接收函数如下:
uint8_t SPI2_ReadWriteByte(uint8_t TxData){ while (SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_TXE) == RESET);
/*!< Send byte through the SPI1 peripheral */ SPI_I2S_SendData(SPIx, TxData);
/*!< Wait to receive a byte */ while (SPI_I2S_GetFlagStatus(SPIx, SPI_I2S_FLAG_RXNE) == RESET);
/*!< Return the byte read from the SPI bus */ return SPI_I2S_ReceiveData(SPIx);} |