STM32在SPI读的时候是不是要发送一个数据才能读到啊,我现在SPI写能成功,读不到从设备的数据,SPI读函数如下uint8_t SpiReadRegister(uint8_t address) { uint8_t rdata; GPIO_ResetBits(GPIOA,GPIO_Pin_12); Delay(10); while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); SPI_I2S_SendData(SPI1,address); 发送从设备地址 while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); rdata=SPI_I2S_ReceiveData(SPI1);
Delay(10); GPIO_SetBits(GPIOA,GPIO_Pin_12);
return rdata;
} 读到的数据全是0x00 哪位大侠指导一下啊,我刚接触这东西,感激不尽!!
|