24L01 SPI的时序问题
24L01 spi的时序是不是 输出数据在上升沿之前 读取数据在上升沿之后?伪代码:
CSN = 0;
for (int i=0; i<8; i++)
{
//设置MOSI
SCK = 0;
SCK = 1;
//读取MISO
}
CSN = 1;
看到的代码都是直接用avr的spi端口的,用IO模拟SPI,所以想学习下。 24L01不是SPI接口的,是IIC接口的吧。 /**************************************************
Function: SPI_RW();
Description:
Writes one byte to nRF24L01, and return the byte read
from nRF24L01 during write, according to SPI protocol
**************************************************/
unsigned char SPI_RW(unsigned char byte)
{
unsigned char i;
nRF24L01_SCK = 0;
for(i=0;i<8;i++) // output 8-bit
{
nRF24L01_MOSI = (byte & 0x80)>>7;// output 'byte', MSB to MOSI
byte = byte<<1; // shift next bit into MSB..
nRF24L01_SCK = 1; // Set SCK high..
byte |=(nRF24L01_MISO_PIN&0X01); // capture current MISO bit
nRF24L01_SCK = 0; // ..then set SCK low again
}
return(byte); // return read byte
} 一楼。。。。。 无语了。 靠。。。。这个问题无语了。。。直接到我网站上。全面资料提供下载。
页:
[1]