Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ config ARCH_POSIX
select BARRIER_OPERATIONS_BUILTIN
# POSIX arch based targets get their memory cleared on entry by the host OS
select SKIP_BSS_CLEAR
# Backed by the posix_sw_*_pending_IRQ() board interface.
select ARCH_HAS_IRQ_PENDING_OPS
help
POSIX (native) architecture

Expand Down
15 changes: 15 additions & 0 deletions arch/posix/core/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ int arch_irq_is_enabled(unsigned int irq)
return posix_irq_is_enabled(irq);
}

void arch_irq_set_pending(unsigned int irq)
{
posix_sw_set_pending_IRQ(irq);
}

void arch_irq_clear_pending(unsigned int irq)
{
posix_sw_clear_pending_IRQ(irq);
}

bool arch_irq_is_pending(unsigned int irq)
{
return posix_sw_is_pending_IRQ(irq) != 0;
}

#ifdef CONFIG_DYNAMIC_INTERRUPTS
/**
* Configure a dynamic interrupt.
Expand Down
9 changes: 9 additions & 0 deletions boards/native/native_sim/irq_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ void posix_sw_clear_pending_IRQ(unsigned int IRQn)
hw_irq_ctrl_clear_irq(IRQn);
}

/**
* Similar to ARM's NVIC_GetPendingIRQ
* report whether an irq is pending
*/
int posix_sw_is_pending_IRQ(unsigned int IRQn)
{
return (hw_irq_ctrl_get_irq_status() & (1ULL << IRQn)) != 0;
}

#ifdef CONFIG_IRQ_OFFLOAD
/**
* Storage for functions offloaded to IRQ
Expand Down
1 change: 1 addition & 0 deletions boards/native/native_sim/irq_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern "C" {

void posix_sw_set_pending_IRQ(unsigned int IRQn);
void posix_sw_clear_pending_IRQ(unsigned int IRQn);
int posix_sw_is_pending_IRQ(unsigned int IRQn);

#ifdef __cplusplus
}
Expand Down
9 changes: 9 additions & 0 deletions boards/native/nrf_bsim/irq_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ void posix_sw_clear_pending_IRQ(unsigned int IRQn)
hw_irq_ctrl_clear_irq(CONFIG_NATIVE_SIMULATOR_MCU_N, IRQn);
}

/**
* Similar to ARM's NVIC_GetPendingIRQ
* report whether an irq is pending
*/
int posix_sw_is_pending_IRQ(unsigned int IRQn)
{
return hw_irq_ctrl_is_irq_pending(CONFIG_NATIVE_SIMULATOR_MCU_N, IRQn);
}

#ifdef CONFIG_IRQ_OFFLOAD
/**
* Storage for functions offloaded to IRQ
Expand Down
6 changes: 3 additions & 3 deletions boards/qemu/cortex_m0/nrf_timer_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void prevent_false_prev_evt(void)
/* Clear interrupt that may have fired as we were setting the
* comparator.
*/
NVIC_ClearPendingIRQ(TIMER0_IRQn);
k_irq_clear_pending(TIMER0_IRQn);
}

/* If settings is next tick from now, function attempts to set next tick. If
Expand Down Expand Up @@ -207,7 +207,7 @@ void sys_clock_set_timeout(uint32_t ticks, bool idle)
* QEMU.
*/
event_clear();
NVIC_ClearPendingIRQ(TIMER0_IRQn);
k_irq_clear_pending(TIMER0_IRQn);

uint32_t now = counter();

Expand Down Expand Up @@ -255,7 +255,7 @@ static int sys_clock_driver_init(void)
}

event_clear();
NVIC_ClearPendingIRQ(TIMER0_IRQn);
k_irq_clear_pending(TIMER0_IRQn);
int_enable();

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/entropy/entropy_nrf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static int entropy_nrf5_get_entropy_isr(const struct device *dev,
* to 1 (the bit is set when NVIC pending IRQ status is
* changed from 0 to 1)
*/
NVIC_ClearPendingIRQ(IRQN);
k_irq_clear_pending(IRQN);

do {
int byte;
Expand All @@ -291,7 +291,7 @@ static int entropy_nrf5_get_entropy_isr(const struct device *dev,
}

byte = random_byte_get();
NVIC_ClearPendingIRQ(IRQN);
k_irq_clear_pending(IRQN);

if (byte < 0) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion drivers/serial/uart_nrfx_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ static void uart_nrfx_irq_tx_enable(const struct device *dev)
/* Due to HW limitation first TXDRDY interrupt shall be
* triggered by the software.
*/
NVIC_SetPendingIRQ(IRQN);
k_irq_set_pending(IRQN);
}
irq_unlock(key);
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/timer/nrf_rtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void compare_int_unlock(int32_t chan, bool key)
atomic_or(&int_mask, BIT(chan));
nrfy_rtc_int_enable(RTC, NRF_RTC_CHANNEL_INT_MASK(chan));
if (atomic_get(&force_isr_mask) & BIT(chan)) {
NVIC_SetPendingIRQ(RTC_IRQn);
k_irq_set_pending(RTC_IRQn);
}
}
}
Expand Down Expand Up @@ -723,7 +723,7 @@ void sys_clock_disable(void)
nrf_rtc_task_trigger(RTC, NRF_RTC_TASK_STOP);
irq_disable(RTC_IRQn);
int_event_disable_rtc();
NVIC_ClearPendingIRQ(RTC_IRQn);
k_irq_clear_pending(RTC_IRQn);
}

static int sys_clock_driver_init(void)
Expand All @@ -741,7 +741,7 @@ static int sys_clock_driver_init(void)
nrfy_rtc_int_enable(RTC, NRF_RTC_INT_OVERFLOW_MASK);
#endif

NVIC_ClearPendingIRQ(RTC_IRQn);
k_irq_clear_pending(RTC_IRQn);

IRQ_CONNECT(RTC_IRQn, DT_IRQ(DT_NODELABEL(RTC_LABEL), priority),
rtc_nrf_isr, 0, 0);
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "nrf_usbd_common.h"
#include "nrf_usbd_common_errata.h"
#include <string.h>
#include <zephyr/irq.h>
#include <zephyr/kernel.h>

#include <zephyr/logging/log.h>
Expand Down Expand Up @@ -589,7 +590,7 @@ static void usbd_ep_abort_all(void)
*/
static inline void usbd_int_rise(void)
{
NVIC_SetPendingIRQ(USBD_IRQn);
k_irq_set_pending(USBD_IRQn);
}

/**
Expand Down Expand Up @@ -1261,7 +1262,7 @@ static void nrf_usbd_common_stop(void)
__ASSERT_NO_MSG(m_drv_state == NRFX_DRV_STATE_POWERED_ON);

/* Clear interrupt */
NVIC_ClearPendingIRQ(USBD_IRQn);
k_irq_clear_pending(USBD_IRQn);

if (irq_is_enabled(USBD_IRQn)) {
/* Abort transfers */
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/udc/udc_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdio.h>
#include <soc.h>

#include <zephyr/irq.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/usb/udc.h>
#include <zephyr/drivers/clock_control.h>
Expand Down Expand Up @@ -391,7 +392,7 @@ static void usbd_ep_abort_all(void)
/* Rise USBD interrupt to trigger interrupt handler */
static inline void usbd_int_rise(void)
{
NVIC_SetPendingIRQ(USBD_IRQn);
k_irq_set_pending(USBD_IRQn);
}

static void ev_usbreset_handler(void)
Expand Down Expand Up @@ -951,7 +952,7 @@ static void nrf_usbd_legacy_start(bool enable_sof)
static void nrf_usbd_common_stop(void)
{
/* Clear interrupt */
NVIC_ClearPendingIRQ(USBD_IRQn);
k_irq_clear_pending(USBD_IRQn);

if (irq_is_enabled(USBD_IRQn)) {
/* Abort transfers */
Expand Down
1 change: 1 addition & 0 deletions include/zephyr/arch/posix/posix_soc_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void posix_irq_full_unlock(void);
int posix_get_current_irq(void);
void posix_sw_set_pending_IRQ(unsigned int IRQn);
void posix_sw_clear_pending_IRQ(unsigned int IRQn);
int posix_sw_is_pending_IRQ(unsigned int IRQn);
#ifdef CONFIG_IRQ_OFFLOAD
void posix_irq_offload(void (*routine)(const void *), const void *parameter);
#endif
Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/ecb.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdint.h>
#include <string.h>

#include <zephyr/irq.h>
#include <zephyr/sys/byteorder.h>

#include <hal/nrf_ecb.h>
Expand Down Expand Up @@ -191,7 +192,7 @@ void ecb_encrypt_nonblocking(struct ecb *e)
| ECB_INTENSET_ENDECB_Msk);

/* enable interrupt */
NVIC_ClearPendingIRQ(ECB_IRQn);
k_irq_clear_pending(ECB_IRQn);
irq_enable(ECB_IRQn);

/* start the encryption h/w */
Expand Down
11 changes: 6 additions & 5 deletions subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/irq.h>
#include <zephyr/toolchain.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/sys/byteorder.h>
Expand Down Expand Up @@ -1191,7 +1192,7 @@ uint32_t radio_tmr_isr_set(uint32_t start_us, radio_isr_cb_t cb, void *param)

nrf_timer_int_enable(EVENT_TIMER, TIMER_INTENSET_COMPARE2_Msk);

NVIC_ClearPendingIRQ(TIMER0_IRQn);
k_irq_clear_pending(TIMER0_IRQn);

irq_enable(TIMER0_IRQn);

Expand Down Expand Up @@ -2525,7 +2526,7 @@ uint32_t radio_ccm_is_done(void)
cpu_sleep();
}
nrf_ccm_int_disable(NRF_CCM, CCM_INTENCLR_ENDCRYPT_Msk);
NVIC_ClearPendingIRQ(nrfx_get_irq_number(NRF_CCM));
k_irq_clear_pending(nrfx_get_irq_number(NRF_CCM));

return (NRF_CCM->EVENTS_ERROR == 0);
}
Expand Down Expand Up @@ -2737,7 +2738,7 @@ uint32_t radio_ar_has_match(void)

nrf_aar_int_disable(NRF_AAR, AAR_INTENCLR_END_Msk);

NVIC_ClearPendingIRQ(nrfx_get_irq_number(NRF_AAR));
k_irq_clear_pending(nrfx_get_irq_number(NRF_AAR));

if (NRF_AAR->EVENTS_RESOLVED && !NRF_AAR->EVENTS_NOTRESOLVED) {
return 1U;
Expand Down Expand Up @@ -2777,7 +2778,7 @@ uint8_t radio_ar_resolve(const uint8_t *addr)
nrf_aar_event_clear(NRF_AAR, NRF_AAR_EVENT_RESOLVED);
nrf_aar_event_clear(NRF_AAR, NRF_AAR_EVENT_NOTRESOLVED);

NVIC_ClearPendingIRQ(nrfx_get_irq_number(NRF_AAR));
k_irq_clear_pending(nrfx_get_irq_number(NRF_AAR));

nrf_aar_int_enable(NRF_AAR, AAR_INTENSET_END_Msk);

Expand All @@ -2787,7 +2788,7 @@ uint8_t radio_ar_resolve(const uint8_t *addr)

nrf_aar_int_disable(NRF_AAR, AAR_INTENCLR_END_Msk);

NVIC_ClearPendingIRQ(nrfx_get_irq_number(NRF_AAR));
k_irq_clear_pending(nrfx_get_irq_number(NRF_AAR));

retval = (NRF_AAR->EVENTS_RESOLVED && !NRF_AAR->EVENTS_NOTRESOLVED) ?
1U : 0U;
Expand Down
8 changes: 5 additions & 3 deletions subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/swi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,24 @@

#endif

#include <zephyr/irq.h>

Comment on lines +66 to +67

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <zephyr/irq.h>

static inline void hal_swi_init(void)
{
/* No platform-specific initialization required. */
}

static inline void hal_swi_lll_pend(void)
{
NVIC_SetPendingIRQ(HAL_SWI_RADIO_IRQ);
k_irq_set_pending(HAL_SWI_RADIO_IRQ);
}

static inline void hal_swi_worker_pend(void)
{
NVIC_SetPendingIRQ(HAL_SWI_WORKER_IRQ);
k_irq_set_pending(HAL_SWI_WORKER_IRQ);
}

static inline void hal_swi_job_pend(void)
{
NVIC_SetPendingIRQ(HAL_SWI_JOB_IRQ);
k_irq_set_pending(HAL_SWI_JOB_IRQ);
}
Loading