Beispiel #1
0
/* Radio "interrupt" routine.
 * (but it is only manually called) */
void nrf_irq()
{
  uint8_t irq_flags;

  // Read and clear IRQ flags from radio.
  irq_flags = hal_nrf_get_clear_irq_flags();

  switch (irq_flags) {

    // Transmission success
    case (1 << (uint8_t)HAL_NRF_TX_DS):
      send_success = true;
      // Data has been sent
      break;

    // Transmission failed (maximum re-transmits)
    case (1 << (uint8_t)HAL_NRF_MAX_RT):
      hal_nrf_flush_tx();
      send_success = false;
      break;

    // Data received 
    case (1 << (uint8_t)HAL_NRF_RX_DR):
      // Read payload
      while (!hal_nrf_rx_fifo_empty()) { 
        hal_nrf_read_rx_payload(rcvd_buf);
      }
      packet_received = true;
      break;
  
    default:
      ;
  }
}
Beispiel #2
0
// Radio interrupt
NRF_ISR()
{
  uint8_t irq_flags;

  // Read and clear IRQ flags from radio
  irq_flags = hal_nrf_get_clear_irq_flags();

  // If data received
  if((irq_flags & (1<<(uint8_t)HAL_NRF_RX_DR)) > 0)
  {
    // Read payload
    while(!hal_nrf_rx_fifo_empty())
    {
      hal_nrf_read_rx_payload(payload);
    }

    // Write received payload[0] to port 0
    P0 = payload[0];
  }
}
Beispiel #3
0
/** Wait until the RX payload is valid, and read the RX payload.
 * Use this function to read the RX payload, the function will
 * stay in a while loop unless a RX payload is valid.
 *
 * @param *out_rx_pload The space to copy the RX payload.
  */
void epl_rf_en_wait_rcv_msg(unsigned char *out_rx_pload)
{
	epl_rf_en_enter_rx_mode();
	while (epl_rf_en_rx_pload_is_empty());
	hal_nrf_read_rx_payload(out_rx_pload);
}
Beispiel #4
0
/** Read the RX payload.
 * Use this function to read the RX payload.
 *
 * @param *out_rx_pload The space to copy the RX payload.
  */
void epl_rf_en_read_rx_pload(unsigned char *out_rx_pload)
{
	hal_nrf_read_rx_payload(out_rx_pload);
	//or hal_nrf_read_multibyte_reg(UINT8(HAL_NRF_RX_PLOAD), out_rx_pload);
}