|
发表于 2009-7-8 10:47:54
|
显示全部楼层
/**************************************************
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
} |
|