Skip to content
Merged
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
9 changes: 9 additions & 0 deletions boards/native/nrf_bsim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ zephyr_library_sources(
argparse.c
nsi_if.c
native_remap.c
gpiote_nrfx_bsim.c
soc/nrfx_coredep.c
common/bstests_entry.c
common/cmsis/cmsis.c
common/trace_hook.c
)

# Include GPIOTE nrfx from real SOC code
zephyr_library_sources(${ZEPHYR_BASE}/soc/nordic/common/gpiote_nrfx.c)

# Include gppi_init from real SOC code if enabled
if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1)
zephyr_library_sources(${ZEPHYR_BASE}/soc/nordic/common/gppi_init.c)
endif()

# Include sync_rtc from real SOC code if enabled
zephyr_library_sources_ifdef(CONFIG_NRF53_SYNC_RTC
${ZEPHYR_BASE}/soc/nordic/nrf53/sync_rtc.c
Expand Down
2 changes: 1 addition & 1 deletion boards/native/nrf_bsim/common/cmsis/cmsis.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <stdint.h>
#include "cmsis_instr.h"
#if defined(CONFIG_SOC_COMPATIBLE_NRF52833)
#include "nrf52833.h"
#include "mdk/nrf52833.h"
#endif

#ifdef __cplusplus
Expand Down
39 changes: 39 additions & 0 deletions boards/native/nrf_bsim/gpiote_nrfx_bsim.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <nrfx_gpiote.h>
#include "gpiote_nrfx.h"

#define GPIOTE_NRFX_INST_IDX(idx) DT_CAT3(NRFX_GPIOTE, idx, _INST_IDX)
#define GPIOTE_INST_IDX(node_id) GPIOTE_NRFX_INST_IDX(DT_PROP(node_id, instance))
#define GPIOTE_INST_AND_COMMA(node_id) \
[GPIOTE_INST_IDX(node_id)] = &GPIOTE_NRFX_INST_BY_NODE(node_id),

/* Conversion of hardcoded DT addresses into the correct ones for simulation
* is done here rather than within `gpio` driver implementation because `gpio` driver
* operates on GPIO ports instances, which might or might not be associated
* with a GPIOTE instance. Additionally, single GPIOTE instance might be associated
* with multiple GPIO ports instances. This makes iterating over all enabled GPIOTE instances
* problematic in the `gpio` driver initialization function context.
*/
static int gpiote_bsim_init(void)
{
nrfx_gpiote_t *gpiote_instances[] = {
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpiote, GPIOTE_INST_AND_COMMA)
};

/* For simulated devices we need to convert the hardcoded DT address from the real
* peripheral into the correct one for simulation
*/
for (int inst = 0; inst < ARRAY_SIZE(gpiote_instances); inst++) {
gpiote_instances[inst]->p_reg =
nhw_convert_periph_base_addr(gpiote_instances[inst]->p_reg);
}

return 0;
}

SYS_INIT(gpiote_bsim_init, PRE_KERNEL_1, 0);
2 changes: 1 addition & 1 deletion boards/native/nrf_bsim/soc/soc_secure.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


#include <stdint.h>
#include <nrf.h>
#include <nrfx.h>
#include <hal/nrf_ficr.h>

static inline void soc_secure_read_deviceid(uint32_t deviceid[2])
Expand Down
6 changes: 3 additions & 3 deletions drivers/adc/adc_nrfx_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ static int init_adc(const struct device *dev)
{
const nrfx_adc_config_t config = NRFX_ADC_DEFAULT_CONFIG;

nrfx_err_t result = nrfx_adc_init(&config, event_handler);
int result = nrfx_adc_init(&config, event_handler);

if (result != NRFX_SUCCESS) {
if (result != 0) {
LOG_ERR("Failed to initialize device: %s",
dev->name);
return -EBUSY;
return result;
}

IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
Expand Down
Loading
Loading