Ejemplo n.º 1
0
void SWI_IRQHandler(void)
{
    if (nrf_egu_event_check(SWI_EGU, NTF_EVENT))
    {
        nrf_egu_event_clear(SWI_EGU, NTF_EVENT);

        while (!ntf_queue_is_empty())
        {
            nrf_drv_radio802154_ntf_data_t * p_slot = &m_ntf_queue[m_ntf_r_ptr];

            switch (p_slot->type)
            {
                case NTF_TYPE_RECEIVED:
                    nrf_drv_radio802154_received_raw(p_slot->data.received.p_psdu,
                                                     p_slot->data.received.power,
                                                     p_slot->data.received.lqi);
                    break;

                case NTF_TYPE_RECEIVE_FAILED:
                    nrf_drv_radio802154_receive_failed(p_slot->data.receive_failed.error);
                    break;

                case NTF_TYPE_TRANSMITTED:
                    nrf_drv_radio802154_transmitted_raw(p_slot->data.transmitted.p_psdu,
                                                        p_slot->data.transmitted.power,
                                                        p_slot->data.transmitted.lqi);
                    break;

                case NTF_TYPE_TRANSMIT_FAILED:
                    nrf_drv_radio802154_transmit_failed(p_slot->data.transmit_failed.error);
                    break;

                case NTF_TYPE_ENERGY_DETECTED:
                    nrf_drv_radio802154_energy_detected(p_slot->data.energy_detected.result);
                    break;

                case NTF_TYPE_CCA:
                    nrf_drv_radio802154_cca_done(p_slot->data.cca.result);
                    break;

                default:
                    assert(false);
            }

            ntf_queue_ptr_increment(&m_ntf_r_ptr);
        }
    }

    if (nrf_egu_event_check(SWI_EGU, TIMESLOT_EXIT_EVENT))
    {
        nrf_raal_continuous_mode_exit();

        nrf_egu_event_clear(SWI_EGU, TIMESLOT_EXIT_EVENT);
    }

    if (nrf_egu_event_check(SWI_EGU, REQ_EVENT))
    {
        nrf_egu_event_clear(SWI_EGU, REQ_EVENT);

        while (!req_queue_is_empty())
        {
            nrf_drv_radio802154_req_data_t * p_slot = &m_req_queue[m_req_r_ptr];

            nrf_drv_radio802154_critical_section_enter();

            switch (p_slot->type)
            {
                case REQ_TYPE_SLEEP:
                    *(p_slot->data.sleep.p_result) = nrf_drv_radio802154_fsm_sleep();
                    break;

                case REQ_TYPE_RECEIVE:
                    *(p_slot->data.receive.p_result) = nrf_drv_radio802154_fsm_receive();
                    break;

                case REQ_TYPE_TRANSMIT:
                    *(p_slot->data.transmit.p_result) = nrf_drv_radio802154_fsm_transmit(
                            p_slot->data.transmit.p_data,
                            p_slot->data.transmit.cca);
                    break;

                case REQ_TYPE_ENERGY_DETECTION:
                    *(p_slot->data.energy_detection.p_result) =
                            nrf_drv_radio802154_fsm_energy_detection(
                                    p_slot->data.energy_detection.time_us);
                    break;

                case REQ_TYPE_CCA:
                    *(p_slot->data.cca.p_result) = nrf_drv_radio802154_fsm_cca();
                    break;

                case REQ_TYPE_CONTINUOUS_CARRIER:
                    *(p_slot->data.continuous_carrier.p_result) =
                            nrf_drv_radio802154_fsm_continuous_carrier();
                    break;

                case REQ_TYPE_BUFFER_FREE:
                    nrf_drv_radio802154_fsm_notify_buffer_free(p_slot->data.buffer_free.p_data);
                    break;

                case REQ_TYPE_CHANNEL_UPDATE:
                    nrf_drv_radio802154_fsm_channel_update();
                    break;

                case REQ_TYPE_CCA_CFG_UPDATE:
                    nrf_drv_radio802154_fsm_cca_cfg_update();
                    break;

                default:
                    assert(false);
            }

            nrf_drv_radio802154_critical_section_exit();

            req_queue_ptr_increment(&m_req_r_ptr);
        }
    }
}
void nrf_drv_radio802154_notify_received(uint8_t * p_data, int8_t power, int8_t lqi)
{
    nrf_drv_radio802154_received_raw(p_data, power, lqi);
}