nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches
bm_irq.h
1/*
2 * Copyright (c) 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
13#ifndef BM_IRQ_H__
14#define BM_IRQ_H__
15
16#include <zephyr/irq.h>
17#include <zephyr/sys/util_macro.h>
18
26#if defined(_IRQ_PRIO_OFFSET)
27#define BM_IRQ_OFFSET _IRQ_PRIO_OFFSET
28#else
29#define BM_IRQ_OFFSET 0
30#endif
31
35#define IS_ZERO_LATENCY(_flags) \
36 COND_CODE_1(CONFIG_ZERO_LATENCY_IRQS, ((_flags) & IRQ_ZERO_LATENCY), (false))
37
52#define BM_IRQ_DIRECT_CONNECT(_irqn, _prio, _handler, _flags) \
53 IF_ENABLED(CONFIG_ZERO_LATENCY_IRQS, \
54 (BUILD_ASSERT(!IS_ZERO_LATENCY(_flags) || ((ZERO_LATENCY_LEVELS == 1) || \
55 ((_prio) < ZERO_LATENCY_LEVELS)), \
56 "IRQ priority of " STRINGIFY(_handler) \
57 " is >= " STRINGIFY(ZERO_LATENCY_LEVELS) " and zero latency"))); \
58 BUILD_ASSERT(IS_ZERO_LATENCY(_flags) || ((_prio) >= BM_IRQ_OFFSET), \
59 "IRQ priority of " STRINGIFY(_handler) " is < " STRINGIFY(BM_IRQ_OFFSET)); \
60 IRQ_DIRECT_CONNECT(_irqn, (IS_ZERO_LATENCY(_flags) ? (_prio) : (_prio - BM_IRQ_OFFSET)), \
61 _handler, (_flags))
62
74#define BM_IRQ_SET_PRIORITY(_irqn, _prio) \
75 BUILD_ASSERT(_prio >= BM_IRQ_OFFSET, \
76 "IRQ priority of " STRINGIFY(_irqn) " is < " STRINGIFY(BM_IRQ_OFFSET)); \
77 NVIC_SetPriority(_irqn, _prio)
78
79#endif /* BM_IRQ_H__ */
80