Skip to content

Commit d98826f

Browse files
committed
boards: native: nrf_bsim: align to nrfx 4.0
Shared resources (GPIOTE and GPPI) are now initialized globally. Align nRF BabbleSim targets to this scheme. Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
1 parent cc80136 commit d98826f

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

boards/native/nrf_bsim/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ zephyr_library_sources(
2525
argparse.c
2626
nsi_if.c
2727
native_remap.c
28+
gpiote_nrfx_native.c
2829
soc/nrfx_coredep.c
2930
common/bstests_entry.c
3031
common/cmsis/cmsis.c
3132
common/trace_hook.c
3233
)
3334

35+
# Include gppi_init from real SOC code if enabled
36+
if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1)
37+
zephyr_library_sources(${ZEPHYR_BASE}/soc/nordic/common/gppi_init.c)
38+
endif()
39+
3440
# Include sync_rtc from real SOC code if enabled
3541
zephyr_library_sources_ifdef(CONFIG_NRF53_SYNC_RTC
3642
${ZEPHYR_BASE}/soc/nordic/nrf53/sync_rtc.c
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/kernel.h>
7+
#include <nrfx_gpiote.h>
8+
#include "gpiote_nrfx.h"
9+
10+
#define GPIOTE_NRFX_NATIVE_INST_DEF(instname) \
11+
nrfx_gpiote_t instname;
12+
#define GPIOTE_NRFX_NATIVE_INST_DEFINE(node_id) \
13+
GPIOTE_NRFX_NATIVE_INST_DEF(GPIOTE_NRFX_INST_BY_NODE(node_id))
14+
15+
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpiote, GPIOTE_NRFX_NATIVE_INST_DEFINE)
16+
17+
#define GPIOTE_NRFX_INST_IDX(idx) _CONCAT(NRFX_GPIOTE, idx, _INST_IDX)
18+
#define GPIOTE_INST_IDX(node_id) DT_PROP(node_id, instance)
19+
#define GPIOTE_INST_AND_COMMA(node_id) \
20+
[GPIOTE_INST_IDX(node_id)] = &GPIOTE_NRFX_INST_BY_NODE(node_id),
21+
22+
static int gpiote_nrfx_native_init(void)
23+
{
24+
nrfx_gpiote_t *gpiote_instances[] = {
25+
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpiote, GPIOTE_INST_AND_COMMA)
26+
};
27+
28+
for (int inst = 0; inst < ARRAY_SIZE(gpiote_instances); inst++) {
29+
gpiote_instances[inst]->p_reg = &NRF_GPIOTE_regs[inst];
30+
gpiote_instances[inst]->cb.drv_inst_idx =
31+
NRFX_REG_TO_INSTANCE(GPIOTE, &NRF_GPIOTE_regs[inst]);
32+
}
33+
34+
return 0;
35+
}
36+
37+
SYS_INIT(gpiote_nrfx_native_init, PRE_KERNEL_1, 0);

0 commit comments

Comments
 (0)