u8 NRF24L01_Read_Buf(u8 reg,u8 *pBuf,u8 len)
{
u8 status,u8_ctr;
NRF24L01_CSN = 0; //ê1ÄüSPI′«êä
status=SPI1_ReadWriteByte(reg);//·¢Ëí¼Ä′æÆ÷Öμ(λÖÃ),2¢¶áè¡×′ì¬Öμ
for(u8_ctr=0;u8_ctr<len;u8_ctr++)pBuf[u8_ctr]=SPI1_ReadWriteByte(0XFF);//¶á3öêy¾Y
NRF24L01_CSN=1; //1رÕSPI′«êä
return status; //·μ»Ø¶áμ½μÄ×′ì¬Öμ
}
有人知道这的for(u8_ctr=0;u8_ctr<len;u8_ctr++)pBuf[u8_ctr]=SPI1_ReadWriteByte(0XFF);中写入0xFF是为什么吗?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
u8 SPI1_ReadWriteByte(u8 TxData)
{
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET){}//μè′y·¢ËíÇø¿Õ£Sè·±£SR¼Ä′æÆ÷Îa0
SPI_I2S_SendData(SPI1, TxData); //í¨1yíaéèSPIx·¢Ëíò»¸öbyte êy¾Y
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET){} //μè′y½óêÕíêò»¸öbyte
return SPI_I2S_ReceiveData(SPI1); //·μ»Øí¨1ySPIx×î½ü½óêÕμÄêy¾Y
}
一周热门 更多>