Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 4febe84

Browse files
committed
nrf5x: Add support for both NRF52 and NRF53
Changes in CMakeLists, NRF_HW_model_top.c, nrfx_common.c and nrf_bsim_redef.h in order for the model to support both the NRF52 and the NRF53 series. Signed-off-by: Sletnes Bjørlo, Aurora <[email protected]>
1 parent 09035df commit 4febe84

File tree

4 files changed

+130
-1
lines changed

4 files changed

+130
-1
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# CMake file to compile this BabbleSim component as a west module in Zephyr
55

6-
if(CONFIG_BOARD_NRF52_BSIM)
6+
if(CONFIG_BOARD_NRF52_BSIM OR CONFIG_BOARD_NRF53_BSIM)
77

88
if (NOT DEFINED ENV{BSIM_COMPONENTS_PATH})
99
message(FATAL_ERROR "This Zephyr module requires the BabbleSim simulator.\
@@ -34,6 +34,15 @@ if(CONFIG_BOARD_NRF52_BSIM)
3434
zephyr_library_compile_definitions(NO_POSIX_CHEATS)
3535

3636
file(GLOB_RECURSE HW_MODEL_SRCS . src/*.c)
37+
if (CONFIG_BOARD_NRF52_BSIM)
38+
list(REMOVE_ITEM HW_MODEL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/HW_models/NRF_DPPI.c)
39+
list(REMOVE_ITEM HW_MODEL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/hal/nrf_dppi.c)
40+
elseif(CONFIG_BOARD_NRF53_BSIM)
41+
list(REMOVE_ITEM HW_MODEL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/HW_models/NRF_PPI.c)
42+
list(REMOVE_ITEM HW_MODEL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/nrfx/hal/nrf_ppi.c)
43+
else()
44+
message(FATAL_ERROR "Unknown board")
45+
endif()
3746
zephyr_library_sources(${HW_MODEL_SRCS})
3847

3948
zephyr_library_include_directories(

src/HW_models/NRF_HW_model_top.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818
#include "NRF_CLOCK.h"
1919
#include "NRF_RADIO.h"
2020
#include "NRF_FICR.h"
21+
#if defined(PPI_PRESENT)
2122
#include "NRF_PPI.h"
23+
#endif
2224
#include "NRF_TIMER.h"
2325
#include "irq_ctrl.h"
2426
#include "BLECrypt_if.h"
2527
#include "fake_timer.h"
28+
#if defined(DPPI_PRESENT)
29+
#include "NRF_DPPI.h"
30+
#endif
2631

2732
void nrf_hw_models_free_all(){
2833
nrf_clock_clean_up();
@@ -33,7 +38,11 @@ void nrf_hw_models_free_all(){
3338
nrf_aar_clean_up();
3439
nrf_radio_clean_up();
3540
nrf_ficr_clean_up();
41+
#if defined(DPPI_PRESENT)
42+
nrf_dppi_clean_up();
43+
#elif defined(PPI_PRESENT)
3644
nrf_ppi_clean_up();
45+
#endif
3746
nrf_timer_clean_up();
3847
}
3948

@@ -60,7 +69,12 @@ void nrf_hw_initialize(nrf_hw_sub_args_t *args){
6069
nrf_aar_init();
6170
nrf_radio_init();
6271
nrf_ficr_init();
72+
#if defined(DPPI_PRESENT)
73+
nrf_dppi_init();
74+
#elif defined(PPI_PRESENT)
6375
nrf_ppi_init();
76+
#endif
77+
6478
nrf_timer_init();
6579
nrf_hw_find_next_timer_to_trigger();
6680
}

src/nrfx/drivers/nrfx_common.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ IRQn_Type nrfx_get_irq_number(void const * p_reg){
2020
((intptr_t)p < (intptr_t)NRF_##per##nbr##_BASE + sizeof(NRF_##per##_Type))
2121

2222
if (IS_PERIPHERAL_REG(p_reg, POWER,)) {
23+
#if !defined(NRF53_SERIES)
2324
return POWER_CLOCK_IRQn;
2425
} else if (IS_PERIPHERAL_REG(p_reg, CLOCK,)) {
2526
return POWER_CLOCK_IRQn;
27+
#endif
28+
#if defined(NRF53_SERIES)
29+
return CLOCK_POWER_IRQn;
30+
} else if (IS_PERIPHERAL_REG(p_reg, CLOCK,)) {
31+
return CLOCK_POWER_IRQn;
32+
#endif
2633
} else if (IS_PERIPHERAL_REG(p_reg, RADIO,)) {
2734
return RADIO_IRQn;
2835
/*2-7*/
@@ -40,20 +47,35 @@ IRQn_Type nrfx_get_irq_number(void const * p_reg){
4047
} else if (IS_PERIPHERAL_REG(p_reg, ECB,)) {
4148
return ECB_IRQn;
4249
} else if (IS_PERIPHERAL_REG(p_reg, AAR,)) {
50+
#if !defined(NRF53_SERIES)
4351
return CCM_AAR_IRQn;
4452
} else if (IS_PERIPHERAL_REG(p_reg, CCM,)) {
4553
return CCM_AAR_IRQn;
54+
#endif
55+
#if defined(NRF53_SERIES)
56+
return AAR_CCM_IRQn;
57+
} else if (IS_PERIPHERAL_REG(p_reg, CCM,)) {
58+
return AAR_CCM_IRQn;
59+
#endif
4660
/*16*/
4761
} else if (IS_PERIPHERAL_REG(p_reg, RTC, 1)) {
4862
return RTC1_IRQn;
4963
/*18-25*/
64+
#if !defined(NRF53_SERIES)
5065
} else if (IS_PERIPHERAL_REG(p_reg, TIMER,3)) {
5166
return TIMER3_IRQn;
5267
} else if (IS_PERIPHERAL_REG(p_reg, TIMER,4)) {
5368
return TIMER4_IRQn;
69+
#endif
5470
/*28-30*/
71+
#if defined(PPI_PRESENT)
5572
} else if (IS_PERIPHERAL_REG(p_reg, PPI,)) {
5673
return 0x1F;
74+
#endif
75+
#if defined(DPPI_PRESENT)
76+
} else if (IS_PERIPHERAL_REG(p_reg, DPPIC,)) {
77+
return 0x1F;
78+
#endif
5779
/*32-..*/
5880
} else {
5981
bs_trace_error_time_line("Tried to get the peripheral number of an address unknown to this HW models\n");

src/nrfx/mdk_replacements/nrf_bsim_redef.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern "C" {
1919
/*
2020
* Redefine the base addresses.
2121
*/
22+
2223
extern NRF_AAR_Type NRF_AAR_regs;
2324
#undef NRF_AAR_BASE
2425
#define NRF_AAR_BASE (&NRF_AAR_regs)
@@ -48,9 +49,13 @@ extern NRF_CLOCK_Type NRF_CLOCK_regs;
4849
extern NRF_FICR_Type NRF_FICR_regs;
4950
#undef NRF_FICR_BASE
5051
#define NRF_FICR_BASE (&NRF_FICR_regs)
52+
53+
#if defined(NRF52_SERIES)
5154
extern NRF_PPI_Type NRF_PPI_regs;
5255
#undef NRF_PPI_BASE
5356
#define NRF_PPI_BASE (&NRF_PPI_regs)
57+
#endif
58+
5459
extern NRF_TIMER_Type NRF_TIMER_regs[];
5560
#undef NRF_TIMER0_BASE
5661
#define NRF_TIMER0_BASE (&NRF_TIMER_regs[0])
@@ -75,6 +80,84 @@ extern NRF_NVMC_Type NRF_NVMC_regs;
7580
#undef NRF_NVMC_BASE
7681
#define NRF_NVMC_BASE (&NRF_NVMC_regs)
7782

83+
#if defined(NRF53_SERIES)
84+
extern NRF_DPPIC_Type NRF_DPPI_regs;
85+
#undef NRF_DPPIC_BASE
86+
#define NRF_DPPIC_BASE (&NRF_DPPI_regs)
87+
extern NRF_EGU_Type NRF_EGU_regs;
88+
#undef NRF_EGU0_BASE
89+
#define NRF_EGU0_BASE (&NRF_EGU_regs)
90+
#endif //NRF53_SERIES
91+
92+
93+
#undef NRF_FICR
94+
#undef NRF_UICR
95+
#undef NRF_BPROT
96+
#undef NRF_POWER
97+
#undef NRF_CLOCK
98+
#undef NRF_RADIO
99+
#undef NRF_UARTE0
100+
#undef NRF_UART0
101+
#undef NRF_SPIM0
102+
#undef NRF_SPIS0
103+
#undef NRF_TWIM0
104+
#undef NRF_TWIS0
105+
#undef NRF_SPI0
106+
#undef NRF_TWI0
107+
#undef NRF_SPIM1
108+
#undef NRF_SPIS1
109+
#undef NRF_TWIM1
110+
#undef NRF_TWIS1
111+
#undef NRF_SPI1
112+
#undef NRF_TWI1
113+
#undef NRF_NFCT
114+
#undef NRF_GPIOTE
115+
#undef NRF_SAADC
116+
#undef NRF_TIMER0
117+
#undef NRF_TIMER1
118+
#undef NRF_TIMER2
119+
#undef NRF_RTC0
120+
#undef NRF_TEMP
121+
#undef NRF_RNG
122+
#undef NRF_ECB
123+
#undef NRF_CCM
124+
#undef NRF_AAR
125+
#undef NRF_WDT
126+
#undef NRF_RTC1
127+
#undef NRF_QDEC
128+
#undef NRF_COMP
129+
#undef NRF_LPCOMP
130+
#undef NRF_SWI0
131+
#undef NRF_EGU0
132+
#undef NRF_SWI1
133+
#undef NRF_EGU1
134+
#undef NRF_SWI2
135+
#undef NRF_EGU2
136+
#undef NRF_SWI3
137+
#undef NRF_EGU3
138+
#undef NRF_SWI4
139+
#undef NRF_EGU4
140+
#undef NRF_SWI5
141+
#undef NRF_EGU5
142+
#undef NRF_TIMER3
143+
#undef NRF_TIMER4
144+
#undef NRF_PWM0
145+
#undef NRF_PDM
146+
#undef NRF_NVMC
147+
#undef NRF_PPI
148+
#undef NRF_MWU
149+
#undef NRF_PWM1
150+
#undef NRF_PWM2
151+
#undef NRF_SPIM2
152+
#undef NRF_SPIS2
153+
#undef NRF_SPI2
154+
#undef NRF_RTC2
155+
#undef NRF_I2S
156+
#undef NRF_FPU
157+
#undef NRF_P0
158+
#undef NRF_DPPIC
159+
160+
78161
/*
79162
* Redefine the peripheral pointers
80163
*/
@@ -143,6 +226,7 @@ extern NRF_NVMC_Type NRF_NVMC_regs;
143226
#define NRF_I2S ((NRF_I2S_Type*) NRF_I2S_BASE)
144227
#define NRF_FPU ((NRF_FPU_Type*) NRF_FPU_BASE)
145228
#define NRF_P0 ((NRF_GPIO_Type*) NRF_P0_BASE)
229+
#define NRF_DPPIC ((NRF_DPPIC_Type*) NRF_DPPIC_BASE)
146230

147231
#ifdef __cplusplus
148232
}

0 commit comments

Comments
 (0)