新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > stm32 SPI 讀取和寫(xiě)入的問(wèn)題

stm32 SPI 讀取和寫(xiě)入的問(wèn)題

作者: 時(shí)間:2016-11-17 來(lái)源:網(wǎng)絡(luò) 收藏
stm32 SPI讀取和寫(xiě)入和USART 一樣需要判斷標(biāo)志位
unsigned char SPI1_ReadWrite(unsigned char writedat)
{
/* Loop while DR register in not emplty */
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE) == RESET);
/* Send byte through the SPI1 peripheral */
SPI_I2S_SendData(SPI1, writedat);
/* Wait to receive a byte */
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
/* Return the byte read from the SPI bus */
return SPI_I2S_ReceiveData(SPI1);
}



關(guān)鍵詞: stm32SPI讀取和寫(xiě)

評(píng)論


技術(shù)專區(qū)

關(guān)閉