Ejemplo n.º 1
0
nrf_radio_signal_callback_return_param_t *radio_cb (uint8_t sig)
{
  switch (sig)
  {
    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_START:
      /* TIMER0 setup */
      NRF_TIMER0->TASKS_CLEAR = 1;
      NRF_TIMER0->EVENTS_COMPARE[0] = 0;
      NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk;
      NRF_TIMER0->CC[0] = m_timeslot_req_normal.params.normal.length_us - 500;  

      ll_scan_start ();

      m_signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE;
      break;

    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO:
      radio_event_cb ();
      break;

    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0:
      /* Check the timeslot cleanup counter */
      if (NRF_TIMER0->EVENTS_COMPARE[0] != 0)
      {
        ll_scan_stop ();
        
        NRF_TIMER0->EVENTS_COMPARE[0] = 0;
        NRF_TIMER0->INTENCLR = TIMER_INTENCLR_COMPARE0_Msk;
        NVIC_DisableIRQ(TIMER0_IRQn);
        
        m_signal_callback_return_param.params.request.p_next = &m_timeslot_req_normal;
        m_signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END;
      }
      
      /* Check the timeout counter */
      if (NRF_TIMER0->EVENTS_COMPARE[1] != 0)
      {
        NRF_TIMER0->EVENTS_COMPARE[1] = 0;
        NRF_TIMER0->INTENCLR = TIMER_INTENCLR_COMPARE1_Msk;
        
        radio_timeout_cb ();
      }
      break;

    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED:
      break;

    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED:
      break;
  }
  return &m_signal_callback_return_param;
}
Ejemplo n.º 2
0
int main(void)
{
	log_init();
	ll_init(&addr);

	DBG("End init");

	ll_scan_start(LL_SCAN_PASSIVE, SCAN_INTERVAL, SCAN_WINDOW,
							adv_report_cb);

	evt_loop_run();

	return 0;
}