Annex IRQ Callback Setter
In addition to the swc_hal_t structure, the ported BSP must also provide callback setters to run Wireless Core code under specific IRQ event conditions. The functions below are part of the wireless_core interface in the BSP. The code block below illustrates the EVK1.4 hardware implementation which needs to be ported to the new hardware.
swc_radio_irq_handler
This is a Wireless Core function that must be called every time the transceiver IRQ pin triggers an interruption. To do so, the BSP must provide a callback setter function.
In the SDK, this is implemented by this EVK1.4 BSP function:
-
void evk_set_radio_irq_callback(irq_callback callback)
This function sets the function callback for the radio pin interrupt.
- Parameters:
callback – [in] External interrupt callback function pointer.
swc_radio_spi_receive_complete_handler
This is a Wireless Core function that must be called every time SPI DMA RX transfer complete triggers an interruption. To do so, the BSP must provide a callback setter function.
In the SDK, this is implemented by this EVK1.4 BSP function:
-
void evk_set_radio_dma_rx_callback(irq_callback callback)
This function sets the function callback for the DMA_RX ISR.
- Parameters:
callback – [in] External interrupt callback function pointer.
swc_connection_callbacks_processing_handler
This is a Wireless Core function that must be called every time there is a context switch in the MCU. To do so, the BSP must provide a callback setter function. The EVK1.4 platform uses an ARM Cortex MCU which has a built-in interrupt-driven request for system-level service called PendSV.
In the SDK, this is implemented by this EVK1.4 BSP function:
-
void evk_set_pendsv_callback(irq_callback callback)
This function sets the function callback for the pendsv.
- Parameters:
callback – [in] External interrupt callback function pointer.
41void iface_swc_handlers_init(void)
42{
43 evk_set_radio_irq_callback(swc_radio_irq_handler);
44 evk_set_radio_dma_rx_callback(swc_radio_spi_receive_complete_handler);
45 evk_set_pendsv_callback(swc_connection_callbacks_processing_handler);
46}
Note
The pulsar name is a placeholder name since the EVK1.4 does not support dual-transceiver operations.
hal->radio_hal[1].context_switch = pulsar_radio_2_context_switch;
hal->radio_hal[1].disable_radio_irq = pulsar_radio_2_disable_irq_it;
hal->radio_hal[1].enable_radio_irq = pulsar_radio_2_enable_irq_it;
hal->radio_hal[1].disable_radio_dma_irq = pulsar_radio_2_disable_dma_irq_it;
hal->radio_hal[1].enable_radio_dma_irq = pulsar_radio_2_enable_dma_irq_it;
hal->timer_start = pulsar_timer_multi_radio_timer_start;
hal->timer_stop = pulsar_timer_multi_radio_timer_stop;
hal->timer_set_period = pulsar_timer_multi_radio_timer_set_period;
hal->timer_set_max_period = multi_radio_timer_set_max_period;
hal->disable_timer_irq = pulsar_timer_multi_radio_timer_disable_irq;
hal->enable_timer_irq = pulsar_timer_multi_radio_timer_enable_irq;
hal->timer_frequency_hz = pulsar_clock_get_system_freq() / pulsar_timer_multi_radio_get_prescaler();
#endif
}
void iface_swc_handlers_init(void)
{
#if (WPS_RADIO_COUNT == 1)
pulsar_it_set_radio_1_irq_callback(swc_radio_irq_handler);
pulsar_it_set_radio_1_dma_rx_callback(swc_radio_spi_receive_complete_handler);
#elif (WPS_RADIO_COUNT == 2)
pulsar_it_set_radio_1_irq_callback(swc_radio1_irq_handler);
pulsar_it_set_radio_1_dma_rx_callback(swc_radio1_spi_receive_complete_handler);
pulsar_it_set_radio_2_irq_callback(swc_radio2_irq_handler);
swc_radio_synchronization_timer_callback
Once the timer reaches the compare value, the triggered interruption will be served with this function. To do so, the BSP must provide a callback setter for this IRQ.
In the SDK, this is implemented by this Pulsar BSP function:
-
void pulsar_timer_multi_radio_set_callback(void (*callback)(void))
Set the multi-radio timer callback.
- Parameters:
callback – [in] Multi-radio callback.