Description:
Writes contents of buffer '*pBuf' to nRF24L01
Typically used to write TX payload, Rx/Tx address
/**************************************************/
uchar SPI_Write_Buf(BYTE reg, BYTE *pBuf,BYTE bytes)
{
ucharstatus,byte_ctr;
/**************************************************/
void SetRX_Mode(void)
{
CE=0;
SPI_Write_Buf(WRITE_REG+ RX_ADDR_P0, RX_ADDRESS, RX_ADR_WIDTH); // Use the same address on the RXdevice as the TX device
sta=SPI_Read(STATUS); // read register STATUS's value
if(RX_DR) // if receive dataready (RX_DR) interrupt
{
CE = 0;
SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);//read receive payload from RX_FIFO buffer
revale=1;//we have receive data
}
SPI_RW_Reg(WRITE_REG+STATUS,sta);//clear RX_DR or TX_DS or MAX_RT interrupt flag
Description:
This function initializes one nRF24L01 device to
TXmode, set TX address, set RX address for auto.ack,
fill TX payload, select RF channel, datarate & TX pwr.
PWR_UP is set, CRC(2 bytes) is enabled, & PRIM:TX.
ToDo:One high pulse(>10us) on CE will now send this
packetand expext an acknowledgment from the RX device.
/**************************************************/
void nRF24L01_TxPacket(unsigned char *tx_buf)
{
CE=0;