示例#1
0
void InitializeNRF24L01()
{
    // NRF24L01 goes to RX mode by default;
    NRF24L01_Init(DEFAULT_CHANNEL, DEFAULT_PAYLOAD_SIZE);
    NRF24L01_SetRF(NRF24L01_DataRate_2M, NRF24L01_OutputPower_M18dBm);

    NRF24L01_SetMyAddress(MyAddress);
    NRF24L01_SetTxAddress(TxAddress);
}
示例#2
0
文件: main.c 项目: jesstr/smarthome
void retranslate(void)
{
/* Receiver address */
uint8_t TxAddress[] = {
   0xE7,
   0xE7,
   0xE7,
   0xE7,
   0xE7
};
/* My address */
uint8_t MyAddress[] = {
   0x7E,
   0x7E,
   0x7E,
   0x7E,
   0x7E
};


uint8_t dataIn[32];
NRF24L01_Transmit_Status_t transmissionStatus;
   /* Initialize NRF24L01+ on channel 15 and 32bytes of payload */
   /* By default 2Mbps data rate and 0dBm output power */
   /* NRF24L01 goes to RX mode by default */
   NRF24L01_Init(15, 32);

   /* Set RF settings, Data rate to 2Mbps, Output power to -18dBm */
   NRF24L01_SetRF(NRF24L01_DataRate_2M, NRF24L01_OutputPower_M18dBm);

   /* Set my address, 5 bytes */
   NRF24L01_SetMyAddress(MyAddress);
   /* Set TX address, 5 bytes */
   NRF24L01_SetTxAddress(TxAddress);

   LED1_ON;
   delay_(3600000);
   LED1_OFF;
      while (1)
      {
      /* If data is ready on NRF24L01+ */
      if (NRF24L01_DataReady())
         {
            /* Get data from NRF24L01+ */
            NRF24L01_GetData(dataIn);

            delay_(36000);

            /* Send it back, automatically goes to TX mode */
            NRF24L01_Transmit(dataIn);

            /* Start send */
            LED1_ON;;
            delay_(360000);
            /* Wait for data to be sent */
            do {
               transmissionStatus = NRF24L01_GetTransmissionStatus();
            } while (transmissionStatus == NRF24L01_Transmit_Status_Sending);
            /* Send done */
            LED1_OFF;

            /* Go back to RX Mode */
            NRF24L01_PowerUpRx();
         }
      }

}