Пример #1
0
//Fetch the next act payload
//Return the payload length
char NRF24L01_RxPacket(char *payload)
{
  int len;
  int i;

  //Get the packet length
  RADIO_EN_CS();
  SPI_SendByte(CMD_RX_PL_WID);
  len = SPI_ReceiveByte();
  RADIO_DIS_CS();  
  
  if (len>0 && len<33)
  {
    //Read the packet from the RX buffer
    RADIO_EN_CS();
    SPI_SendByte(CMD_R_RX_PAYLOAD);
    for(i=0;i<len;i++)
      payload[i] = SPI_ReceiveByte();
    RADIO_DIS_CS();
  } else {
    len=0;
  }
  
  //Pulse CE
  //CE_PULSE();
  
  return len;
}
Пример #2
0
//Fetch the next act payload
//Return the payload length
char radioRxPacket(__xdata char *payload)
{
  int len;
  int i;

  //Get the packet length
  RADIO_EN_CS();
  spiRadioSend(CMD_RX_PL_WID);
  len = spiRadioReceive();
  RADIO_DIS_CS();  
  
  if (len>0 && len<33)
  {
    //Read the packet from the RX buffer
    RADIO_EN_CS();
    spiRadioSend(CMD_R_RX_PAYLOAD);
    for(i=0;i<len;i++)
      payload[i] = spiRadioReceive();
    RADIO_DIS_CS();
  } else {
    len=0;
  }
  
  //Pulse CE
  //CE_PULSE();
  
  return len;
}
Пример #3
0
//Set the TX and RX address
void radioSetAddress(__xdata char* address)
{
  int i;

  RADIO_EN_CS();
  spiRadioSend(CMD_W_REG | REG_TX_ADDR);
  for(i=0; i<5; i++)
    spiRadioSend(address[i]);
  RADIO_DIS_CS();

  RADIO_EN_CS();
  spiRadioSend(CMD_W_REG | REG_RX_ADDR_P0);
  for(i=0; i<5; i++)
    spiRadioSend(address[i]);
  RADIO_DIS_CS();
}
Пример #4
0
//Set the TX and RX address
void NRF24L01_SetAddress(char* address)
{
  int i;

  RADIO_EN_CS();
  SPI_SendByte(CMD_W_REG | REG_TX_ADDR);
  for(i=0; i<5; i++)
    SPI_SendByte(address[i]);
  RADIO_DIS_CS();

  RADIO_EN_CS();
  SPI_SendByte(CMD_W_REG | REG_RX_ADDR_P0);
  for(i=0; i<5; i++)
    SPI_SendByte(address[i]);
  RADIO_DIS_CS();
}
Пример #5
0
//Nop command, permit to get the status byte
char NRF24L01_Nop()
{
  char status;
  
  RADIO_EN_CS();
  status = SPI_SendByte(CMD_NOP);
  RADIO_DIS_CS();
  
  return status;
}
Пример #6
0
//Nop command, permit to get the status byte
char radioNop()
{
  char status;
  
  RADIO_EN_CS();
  status = spiRadioSend(CMD_NOP);
  RADIO_DIS_CS();
  
  return status;
}
Пример #7
0
char NRF24L01_FlushRx()
{
  char status;
  
  RADIO_EN_CS();
  status = SPI_SendByte(CMD_FLUSH_RX);
  RADIO_DIS_CS();
  
  return status;
}
Пример #8
0
char radioFlushRx()
{
  char status;
  
  RADIO_EN_CS();
  status = spiRadioSend(CMD_FLUSH_RX);
  RADIO_DIS_CS();
  
  return status;
}
Пример #9
0
unsigned char nrfFlushTx()
{
  unsigned char status;

  RADIO_EN_CS();
  status = spiSendByte(CMD_FLUSH_TX);
  RADIO_DIS_CS();

  return status;
}
Пример #10
0
/* Sent the NOP command. Used to get the status byte */
unsigned char nrfNop()
{
  unsigned char status;

  RADIO_EN_CS();
  status = spiSendByte(CMD_NOP);
  RADIO_DIS_CS();

  return status;
}
Пример #11
0
// Return the payload length
unsigned char nrfRxLength(unsigned int pipe)
{
  unsigned char length;

  RADIO_EN_CS();
  spiSendByte(CMD_RX_PL_WID);
  length = spiReceiveByte();
  RADIO_DIS_CS();

  return length;
}
Пример #12
0
char radioReadReg(char addr)
{
  char value;
  
  RADIO_EN_CS();
  spiRadioSend(CMD_R_REG | (addr&0x1F));
  value = spiRadioSend(0xA5);
  RADIO_DIS_CS();
  
  return value;
}
Пример #13
0
char radioWriteReg(char addr, char value)
{
  char status;
  
  RADIO_EN_CS();
  status = spiRadioSend(CMD_W_REG | (addr&0x1F));
  spiRadioSend(value);
  RADIO_DIS_CS();
  
  return value;
}
Пример #14
0
char NRF24L01_WriteReg(char addr, char value)
{
  char status;
  
  RADIO_EN_CS();
  status = SPI_SendByte(CMD_W_REG | (addr&0x1F));
  SPI_SendByte(value);
  RADIO_DIS_CS();
  
  return value;
}
Пример #15
0
char NRF24L01_ReadReg(char addr)
{
  char value;
  
  RADIO_EN_CS();
  SPI_SendByte(CMD_R_REG | (addr&0x1F));
  value = SPI_ReceiveByte();
  RADIO_DIS_CS();
  
  return value;
}
Пример #16
0
unsigned char nrfActivate()
{
  unsigned char status;
  
  RADIO_EN_CS();
  status = spiSendByte(CMD_ACTIVATE);
  spiSendByte(ACTIVATE_DATA);
  RADIO_DIS_CS();

  return status;
}
Пример #17
0
//Send a packet as acknowledgment payload
void radioAckPacket(char pipe, __xdata char* payload, char len)
{
  int i;

  RADIO_EN_CS();

  /* Send the read command with the address */
  spiRadioSend(CMD_W_ACK_PAYLOAD(pipe));
  /* Read LEN bytes */
  for(i=0; i<len; i++)
    spiRadioSend(payload[i]);

  RADIO_DIS_CS();
}
Пример #18
0
//Send a packed in no-ack mode
void NRF24L01_TxPacketNoAck(char *payload, char len)
{
  int i;

  //Send the packet in the TX buffer
  RADIO_EN_CS();
  SPI_SendByte(CMD_W_PAYLOAD_NO_ACK);
  for(i=0;i<len;i++)
    SPI_SendByte(payload[i]);
  RADIO_DIS_CS();
  
  //Pulse CE
  CE_PULSE();
  
  return;
}
Пример #19
0
//Send a packed in no-ack mode
void radioTxPacketNoAck(__xdata char *payload, char len)
{
  int i;

  //Send the packet in the TX buffer
  RADIO_EN_CS();
  spiRadioSend(CMD_W_TX_PAYLOAD_NO_ACK);
  for(i=0;i<len;i++)
    spiRadioSend(payload[i]);
  RADIO_DIS_CS();
  
  //Pulse CE
  CE_PULSE();
  
  return;
}
Пример #20
0
// Read the RX payload
unsigned char nrfReadRX(char *buffer, int len)
{
  unsigned char status;
  int i;

  RADIO_EN_CS();

  /* Send the read command with the address */
  status = spiSendByte(CMD_R_RX_PAYLOAD);
  /* Read LEN bytes */
  for(i=0; i<len; i++)
    buffer[i]=spiReceiveByte();

  RADIO_DIS_CS();

  return status;
}
Пример #21
0
/* Write len bytes a nRF24L register. 5 Bytes max */
unsigned char nrfWriteReg(unsigned char address, char *buffer, int len)
{
  unsigned char status;
  int i;

  RADIO_EN_CS();

  /* Send the write command with the address */
  status = spiSendByte( CMD_W_REG | (address&0x1F) );

  /* Write LEN bytes */
  for(i=0; i<len; i++)
    spiSendByte(buffer[i]);

  RADIO_DIS_CS();

  return status;
}
Пример #22
0
// Write the ack payload of the pipe 0
unsigned char nrfWriteAck(unsigned int pipe, char *buffer, int len)
{
  unsigned char status;
  int i;

  ASSERT(pipe<6);

  RADIO_EN_CS();

  /* Send the read command with the address */
  status = spiSendByte(CMD_W_ACK_PAYLOAD(pipe));
  /* Read LEN bytes */
  for(i=0; i<len; i++)
    spiSendByte(buffer[i]);

  RADIO_DIS_CS();

  return status;
}