Skip to content

Commit ad1e5ac

Browse files
nika-nordiccarlescufi
authored andcommitted
nordic: update and align to nrfx 4.0.1
New nrfx release contains major rework of nrfx drivers instantiation making it easier to integrate with dts nodes. Now, nrfx driver instances can no longer be `const` because they contain driver runtime state. Additionally, all nrfx drivers return `errno` error codes instead of deprecated `nrfx_err_t`. Signed-off-by: Nikodem Kastelik <[email protected]>
1 parent 8ae3880 commit ad1e5ac

File tree

143 files changed

+1810
-5254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+1810
-5254
lines changed

boards/native/nrf_bsim/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,21 @@ zephyr_library_sources(
2525
argparse.c
2626
nsi_if.c
2727
native_remap.c
28+
gpiote_nrfx_bsim.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 GPIOTE nrfx from real SOC code
36+
zephyr_library_sources(${ZEPHYR_BASE}/soc/nordic/common/gpiote_nrfx.c)
37+
38+
# Include gppi_init from real SOC code if enabled
39+
if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1)
40+
zephyr_library_sources(${ZEPHYR_BASE}/soc/nordic/common/gppi_init.c)
41+
endif()
42+
3443
# Include sync_rtc from real SOC code if enabled
3544
zephyr_library_sources_ifdef(CONFIG_NRF53_SYNC_RTC
3645
${ZEPHYR_BASE}/soc/nordic/nrf53/sync_rtc.c

boards/native/nrf_bsim/common/cmsis/cmsis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <stdint.h>
1616
#include "cmsis_instr.h"
1717
#if defined(CONFIG_SOC_COMPATIBLE_NRF52833)
18-
#include "nrf52833.h"
18+
#include "mdk/nrf52833.h"
1919
#endif
2020

2121
#ifdef __cplusplus
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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_INST_IDX(idx) DT_CAT3(NRFX_GPIOTE, idx, _INST_IDX)
11+
#define GPIOTE_INST_IDX(node_id) GPIOTE_NRFX_INST_IDX(DT_PROP(node_id, instance))
12+
#define GPIOTE_INST_AND_COMMA(node_id) \
13+
[GPIOTE_INST_IDX(node_id)] = &GPIOTE_NRFX_INST_BY_NODE(node_id),
14+
15+
/* Conversion of hardcoded DT addresses into the correct ones for simulation
16+
* is done here rather than within `gpio` driver implementation because `gpio` driver
17+
* operates on GPIO ports instances, which might or might not be associated
18+
* with a GPIOTE instance. Additionally, single GPIOTE instance might be associated
19+
* with multiple GPIO ports instances. This makes iterating over all enabled GPIOTE instances
20+
* problematic in the `gpio` driver initialization function context.
21+
*/
22+
static int gpiote_bsim_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 simulated devices we need to convert the hardcoded DT address from the real
29+
* peripheral into the correct one for simulation
30+
*/
31+
for (int inst = 0; inst < ARRAY_SIZE(gpiote_instances); inst++) {
32+
gpiote_instances[inst]->p_reg =
33+
nhw_convert_periph_base_addr(gpiote_instances[inst]->p_reg);
34+
}
35+
36+
return 0;
37+
}
38+
39+
SYS_INIT(gpiote_bsim_init, PRE_KERNEL_1, 0);

boards/native/nrf_bsim/soc/soc_secure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
#include <stdint.h>
15-
#include <nrf.h>
15+
#include <nrfx.h>
1616
#include <hal/nrf_ficr.h>
1717

1818
static inline void soc_secure_read_deviceid(uint32_t deviceid[2])

drivers/adc/adc_nrfx_adc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ static int init_adc(const struct device *dev)
265265
{
266266
const nrfx_adc_config_t config = NRFX_ADC_DEFAULT_CONFIG;
267267

268-
nrfx_err_t result = nrfx_adc_init(&config, event_handler);
268+
int result = nrfx_adc_init(&config, event_handler);
269269

270-
if (result != NRFX_SUCCESS) {
270+
if (result != 0) {
271271
LOG_ERR("Failed to initialize device: %s",
272272
dev->name);
273-
return -EBUSY;
273+
return result;
274274
}
275275

276276
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),

0 commit comments

Comments
 (0)