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
15 changes: 12 additions & 3 deletions drivers/console/console_bm_uarte.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@

#include <zephyr/sys/printk-hooks.h>
#include <zephyr/sys/libc-hooks.h>
#include <zephyr/irq.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

commit needs <blah>: <blah> format


#include <nrfx_uarte.h>

#include <board-config.h>

static const nrfx_uarte_t uarte_inst = NRFX_UARTE_INSTANCE(BOARD_CONSOLE_UARTE_INST);

ISR_DIRECT_DECLARE(console_uarte_isr)
{
NRFX_UARTE_INST_HANDLER_GET(BOARD_CONSOLE_UARTE_INST)();
return 0;
}

static int uarte_init(void)
{
int err;
Expand All @@ -33,10 +40,12 @@ static int uarte_init(void)
uarte_config.interrupt_priority = CONFIG_BM_UARTE_CONSOLE_UARTE_IRQ_PRIO;

/** We need to connect the IRQ ourselves. */
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(
NRF_UARTE_INST_GET(BOARD_CONSOLE_UARTE_INST)),
IRQ_DIRECT_CONNECT(
NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_CONSOLE_UARTE_INST)),
CONFIG_BM_UARTE_CONSOLE_UARTE_IRQ_PRIO,
NRFX_UARTE_INST_HANDLER_GET(BOARD_CONSOLE_UARTE_INST), 0, 0);
console_uarte_isr,
0
);

irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_CONSOLE_UARTE_INST)));

Expand Down
34 changes: 28 additions & 6 deletions lib/bm_buttons/bm_buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ static void gpiote_uninit(void)
#endif
}

#if defined(CONFIG_SOC_SERIES_NRF52X)
ISR_DIRECT_DECLARE(buttons_gpiote0_isr)
{
NRFX_GPIOTE_INST_HANDLER_GET(0)();
return 0;
}
#elif defined(CONFIG_SOC_SERIES_NRF54LX)
ISR_DIRECT_DECLARE(buttons_gpiote20_isr)
{
NRFX_GPIOTE_INST_HANDLER_GET(20)();
return 0;
}

ISR_DIRECT_DECLARE(buttons_gpiote30_isr)
{
NRFX_GPIOTE_INST_HANDLER_GET(30)();
return 0;
}
#endif

static int gpiote_init(void)
{
int err;
Expand All @@ -102,8 +122,8 @@ static int gpiote_init(void)
return -EIO;
}

IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE_INST_GET(0)), IRQ_PRIO,
NRFX_GPIOTE_INST_HANDLER_GET(0), 0, 0);
IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE_INST_GET(0)), IRQ_PRIO,
buttons_gpiote0_isr, 0);
}
#elif defined(CONFIG_SOC_SERIES_NRF54LX)
if (!nrfx_gpiote_init_check(&gpiote20_instance)) {
Expand All @@ -113,8 +133,9 @@ static int gpiote_init(void)
return -EIO;
}

IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE_INST_GET(20)) + NRF_GPIOTE_IRQ_GROUP,
IRQ_PRIO, NRFX_GPIOTE_INST_HANDLER_GET(20), 0, 0);
IRQ_DIRECT_CONNECT(
NRFX_IRQ_NUMBER_GET(NRF_GPIOTE_INST_GET(20)) + NRF_GPIOTE_IRQ_GROUP,
IRQ_PRIO, buttons_gpiote20_isr, 0);
}

if (!nrfx_gpiote_init_check(&gpiote30_instance)) {
Expand All @@ -124,8 +145,9 @@ static int gpiote_init(void)
return -EIO;
}

IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE_INST_GET(30)) + NRF_GPIOTE_IRQ_GROUP,
IRQ_PRIO, NRFX_GPIOTE_INST_HANDLER_GET(30), 0, 0);
IRQ_DIRECT_CONNECT(
NRFX_IRQ_NUMBER_GET(NRF_GPIOTE_INST_GET(30)) + NRF_GPIOTE_IRQ_GROUP,
IRQ_PRIO, buttons_gpiote30_isr, 0);
}
#endif
return 0;
Expand Down
4 changes: 4 additions & 0 deletions samples/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ config MULTITHREADING
# Need this when building without sysbuild
config PARTITION_MANAGER_ENABLED
default n

# All these samples use IRQ_DIRECT_CONNECT, so software ISR table is not needed
config GEN_SW_ISR_TABLE
default n if !UNITY
24 changes: 19 additions & 5 deletions samples/bluetooth/ble_nus/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,20 @@ static void ble_nus_evt_handler(const struct ble_nus_evt *evt)
}
}

#if defined(CONFIG_SOC_SERIES_NRF52X)
ISR_DIRECT_DECLARE(nus_uarte0_isr)
{
NRFX_UARTE_INST_HANDLER_GET(0)();
return 0;
}
#elif defined(CONFIG_SOC_SERIES_NRF54LX)
ISR_DIRECT_DECLARE(nus_uarte30_isr)
{
NRFX_UARTE_INST_HANDLER_GET(30)();
return 0;
}
#endif

/**
* @brief Initalize UARTE driver.
*/
Expand All @@ -307,13 +321,13 @@ static int uarte_init(void)

/** We need to connect the IRQ ourselves. */
#if defined(CONFIG_SOC_SERIES_NRF52X)
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(0)), CONFIG_BLE_UART_IRQ_PRIO,
NRFX_UARTE_INST_HANDLER_GET(0), 0, 0);
IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(0)), CONFIG_BLE_UART_IRQ_PRIO,
nus_uarte0_isr, 0);

irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(0)));
irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(0)));
#elif defined(CONFIG_SOC_SERIES_NRF54LX)
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(30)), CONFIG_BLE_UART_IRQ_PRIO,
NRFX_UARTE_INST_HANDLER_GET(30), 0, 0);
IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(30)), CONFIG_BLE_UART_IRQ_PRIO,
nus_uarte30_isr, 0);

irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(30)));
#endif
Expand Down
13 changes: 10 additions & 3 deletions samples/mcumgr/uart_mcumgr/src/uart_mcumgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ void uart_mcumgr_register(uart_mcumgr_recv_fn *cb)
uart_mcumgr_recv_cb = cb;
}

ISR_DIRECT_DECLARE(mcumgr_uarte_isr)
{
NRFX_UARTE_INST_HANDLER_GET(BOARD_APP_UARTE_INST)();
return 0;
}

/**
* @brief Initialize UARTE driver.
*/
Expand All @@ -230,9 +236,10 @@ static int uarte_init(void)
uarte_config.interrupt_priority = CONFIG_UARTE_IRQ_PRIO;

/** We need to connect the IRQ ourselves. */
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_APP_UARTE_INST)),
CONFIG_UARTE_IRQ_PRIO, NRFX_UARTE_INST_HANDLER_GET(BOARD_APP_UARTE_INST),
0, 0);
IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_APP_UARTE_INST)),
CONFIG_UARTE_IRQ_PRIO,
mcumgr_uarte_isr,
0);

irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_APP_UARTE_INST)));

Expand Down
12 changes: 9 additions & 3 deletions samples/peripherals/uarte/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ static void uarte_event_handler(nrfx_uarte_event_t const *event, void *ctx)
}
}

ISR_DIRECT_DECLARE(sample_uarte_isr)
{
NRFX_UARTE_INST_HANDLER_GET(BOARD_APP_UARTE_INST)();
return 0;
}

/* Initialize UARTE driver. */
static int uarte_init(void)
{
Expand All @@ -104,9 +110,9 @@ static int uarte_init(void)
uarte_config.interrupt_priority = CONFIG_UARTE_IRQ_PRIO;

/* We need to connect the IRQ ourselves. */
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_APP_UARTE_INST)),
CONFIG_UARTE_IRQ_PRIO,
NRFX_UARTE_INST_HANDLER_GET(BOARD_APP_UARTE_INST), 0, 0);
IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_APP_UARTE_INST)),
CONFIG_UARTE_IRQ_PRIO,
sample_uarte_isr, 0);

irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_APP_UARTE_INST)));

Expand Down
11 changes: 9 additions & 2 deletions subsys/logging/backends/log_backend_bm_uarte.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ static char uarte_tx_buf[CONFIG_LOG_BACKEND_BM_UARTE_BUFFER_SIZE];
static int log_out(uint8_t *data, size_t length, void *ctx);
LOG_OUTPUT_DEFINE(bm_lbu_output, log_out, lbu_buffer, CONFIG_LOG_BACKEND_BM_UARTE_BUFFER_SIZE);

ISR_DIRECT_DECLARE(log_uarte_isr)
{
NRFX_UARTE_INST_HANDLER_GET(BOARD_CONSOLE_UARTE_INST)();
return 0;
}

static int uarte_init(void)
{
int err;
Expand All @@ -42,10 +48,11 @@ static int uarte_init(void)
uarte_config.tx_cache.length = sizeof(uarte_tx_buf);

/** We need to connect the IRQ ourselves. */
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(
IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(
NRF_UARTE_INST_GET(BOARD_CONSOLE_UARTE_INST)),
CONFIG_LOG_BACKEND_BM_UARTE_IRQ_PRIO,
NRFX_UARTE_INST_HANDLER_GET(BOARD_CONSOLE_UARTE_INST), 0, 0);
log_uarte_isr,
0);

irq_enable(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(BOARD_CONSOLE_UARTE_INST)));

Expand Down
10 changes: 9 additions & 1 deletion subsys/softdevice_handler/irq_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ void relocate_vector_table(void)
/* Empty, but needed */
}

#ifdef CONFIG_NRF5_SDK_IRQ_CONNECT_GPIOTE
ISR_DIRECT_DECLARE(gpiote0_isr)
Copy link
Contributor

Choose a reason for hiding this comment

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

@bjarki-andreasen Why is this needed instead of providing nrfx_gpiote_0_irq_handler directly in IRQ_DIRECT_CONNECT?

Copy link
Author

Choose a reason for hiding this comment

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

Because the macro ISR_DIRECT_DECLARE() adds required header and footer to the function, its not as simple as a void fn(void)

Copy link
Contributor

Choose a reason for hiding this comment

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

SoftDevice interrupt forwarding is missing ISR_DIRECT_DECLARE(). Is that different or is this required there as well?

See

extern void CLOCK_POWER_IRQHandler(void);
extern void RADIO_0_IRQHandler(void);
extern void TIMER10_IRQHandler(void);
extern void GRTC_3_IRQHandler(void);
extern void ECB00_IRQHandler(void);
extern void AAR00_CCM00_IRQHandler(void);
extern void SWI00_IRQHandler(void);

IRQ_DIRECT_CONNECT(CLOCK_POWER_IRQn, PRIO_LOW, CLOCK_POWER_IRQHandler, IRQ_ZERO_LATENCY);
IRQ_DIRECT_CONNECT(RADIO_0_IRQn, PRIO_HIGH, RADIO_0_IRQHandler, IRQ_ZERO_LATENCY);
IRQ_DIRECT_CONNECT(TIMER10_IRQn, PRIO_HIGH, TIMER10_IRQHandler, IRQ_ZERO_LATENCY);
IRQ_DIRECT_CONNECT(GRTC_3_IRQn, PRIO_HIGH, GRTC_3_IRQHandler, IRQ_ZERO_LATENCY);
IRQ_DIRECT_CONNECT(ECB00_IRQn, PRIO_LOW, ECB00_IRQHandler, IRQ_ZERO_LATENCY);
IRQ_DIRECT_CONNECT(AAR00_CCM00_IRQn, PRIO_LOW, AAR00_CCM00_IRQHandler, IRQ_ZERO_LATENCY);
IRQ_DIRECT_CONNECT(SWI00_IRQn, PRIO_LOW, SWI00_IRQHandler, IRQ_ZERO_LATENCY);

Copy link
Author

@bjarki-andreasen bjarki-andreasen Aug 11, 2025

Choose a reason for hiding this comment

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

If TIMER10_IRQHandler etc. declare the appropriate attributes, like __attribute__((interrupt)) etc. then its no problem, especially given they are zero latency. But in general, the ISR_DIRECT_DECLARE macro should be used as it wraps the function in these attributes automatically

{
nrfx_gpiote_0_irq_handler();
return 0;
}
#endif

static int irq_init(void)
{
int err;
Expand All @@ -27,7 +35,7 @@ static int irq_init(void)

/** TODO: rework */
#ifdef CONFIG_NRF5_SDK_IRQ_CONNECT_GPIOTE
IRQ_CONNECT(GPIOTE_IRQn, 5, nrfx_isr, nrfx_gpiote_0_irq_handler, 0);
IRQ_DIRECT_CONNECT(GPIOTE_IRQn, 5, gpiote0_isr, 0);
#endif

err = sd_softdevice_vector_table_base_set(VECTOR_ADDRESS);
Expand Down
6 changes: 3 additions & 3 deletions subsys/softdevice_handler/nrf_sdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ void SD_EVT_IRQHandler(void)

#endif /* NRF_SDH_DISPATCH_MODEL */

static void isr_handler(const void *arg)
ISR_DIRECT_DECLARE(sd_evt_isr)
{
ARG_UNUSED(arg);
SD_EVT_IRQHandler();
return 0;
}

static int sd_irq_init(void)
{
IRQ_CONNECT(SD_EVT_IRQn, 4, isr_handler, NULL, 0);
IRQ_DIRECT_CONNECT(SD_EVT_IRQn, 4, sd_evt_isr, 0);
irq_enable(SD_EVT_IRQn);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ manifest:
projects:
- name: nrf
repo-path: sdk-nrf
revision: v3.1.0-rc1
revision: pull/23793/head
import:
name-allowlist:
- cmsis_6
Expand Down
Loading