Contiki-NG
Loading...
Searching...
No Matches
nrf_802154_platform_irq.c
1/*
2 * Copyright (c) 2026, RISE Research Institutes of Sweden AB
3 * All rights reserved.
4 *
5 * Author: Joakim Eriksson <joakim.eriksson@ri.se>
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 * IRQ Abstraction Layer for nrf_802154 on nRF54L15.
10 * Stores ISR function pointers for RADIO and EGU10 and dispatches from
11 * the NVIC IRQ handlers.
12 */
13
14#include "platform/nrf_802154_irq.h"
15#include "nrf_802154_config.h"
16#include "nrf_802154_irq_handlers.h"
17#include "nrf.h"
18
19#include <nrfx.h>
20#include <stddef.h>
21
22/* Only two ISRs are used by the 802.15.4 driver: RADIO and EGU10 (SWI). */
23static nrf_802154_isr_t radio_isr;
24static nrf_802154_isr_t egu10_isr;
25/*---------------------------------------------------------------------------*/
26void
27nrf_802154_irq_init(uint32_t irqn, int32_t prio, nrf_802154_isr_t isr)
28{
29 if(prio < 0) {
30 /* Negative priorities are reserved by the driver for zero-latency IRQs.
31 * Bare-metal Contiki only exposes the NVIC priority value, so clamp to
32 * the highest programmable priority. */
33 prio = 0;
34 }
35
36 if(irqn == RADIO_0_IRQn || irqn == RADIO_1_IRQn
37#ifdef RADIO_IRQn
38 || irqn == RADIO_IRQn
39#endif
40 ) {
41 radio_isr = isr;
42 } else if(irqn == EGU10_IRQn) {
43 egu10_isr = isr;
44 }
45 NVIC_SetPriority((IRQn_Type)irqn, (uint32_t)prio);
46 NVIC_ClearPendingIRQ((IRQn_Type)irqn);
47}
48/*---------------------------------------------------------------------------*/
49void
50nrf_802154_irq_enable(uint32_t irqn)
51{
52 NVIC_EnableIRQ((IRQn_Type)irqn);
53}
54/*---------------------------------------------------------------------------*/
55void
56nrf_802154_irq_disable(uint32_t irqn)
57{
58 NVIC_DisableIRQ((IRQn_Type)irqn);
59}
60/*---------------------------------------------------------------------------*/
61void
62nrf_802154_irq_set_pending(uint32_t irqn)
63{
64 NVIC_SetPendingIRQ((IRQn_Type)irqn);
65}
66/*---------------------------------------------------------------------------*/
67void
68nrf_802154_irq_clear_pending(uint32_t irqn)
69{
70 NVIC_ClearPendingIRQ((IRQn_Type)irqn);
71}
72/*---------------------------------------------------------------------------*/
73bool
74nrf_802154_irq_is_enabled(uint32_t irqn)
75{
76 return NVIC_GetEnableIRQ((IRQn_Type)irqn) != 0;
77}
78/*---------------------------------------------------------------------------*/
79uint32_t
80nrf_802154_irq_priority_get(uint32_t irqn)
81{
82 return NVIC_GetPriority((IRQn_Type)irqn);
83}
84/*
85 * RADIO IRQ handler -- dispatch to the ISR registered by the 802.15.4 driver.
86 */
87volatile uint32_t radio_irq_count;
88/*---------------------------------------------------------------------------*/
89void
90RADIO_0_IRQHandler(void)
91{
92 radio_irq_count++;
93#if NRF_802154_INTERNAL_RADIO_IRQ_HANDLING
94 if(radio_isr != NULL) {
95 radio_isr();
96 }
97#else
98 nrf_802154_radio_irq_handler();
99#endif
100}
101/*---------------------------------------------------------------------------*/
102void
103RADIO_1_IRQHandler(void)
104{
105 radio_irq_count++;
106#if NRF_802154_INTERNAL_RADIO_IRQ_HANDLING
107 if(radio_isr != NULL) {
108 radio_isr();
109 }
110#else
111 nrf_802154_radio_irq_handler();
112#endif
113}
114/*
115 * EGU10 IRQ handler -- used by the SWI notification/request layer.
116 */
117volatile uint32_t egu10_irq_count;
118/*---------------------------------------------------------------------------*/
119void
120EGU10_IRQHandler(void)
121{
122 egu10_irq_count++;
123#if NRF_802154_INTERNAL_SWI_IRQ_HANDLING
124 if(egu10_isr != NULL) {
125 egu10_isr();
126 }
127#else
128 nrf_802154_swi_irq_handler();
129#endif
130}
131/*---------------------------------------------------------------------------*/