Skip to content

Commit ec77270

Browse files
aescolarcarlescufi
authored andcommitted
native: nrf52 changes to HAL to support running on simulated HW
Conditionally compiled changes to the NRF52 HAL so it can run on simulated HW on the native port. (HW models are not included in this commit) All changes are under ifdefs and therefore will not have any effect on normal builds Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent aca1f17 commit ec77270

File tree

6 files changed

+180
-0
lines changed

6 files changed

+180
-0
lines changed

subsys/bluetooth/controller/hal/nrf5/cntr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ void cntr_init(void)
2424
RTC_EVTENSET_COMPARE1_Msk);
2525
NRF_RTC->INTENSET = (RTC_INTENSET_COMPARE0_Msk |
2626
RTC_INTENSET_COMPARE1_Msk);
27+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
28+
NRF_RTC0_regw_sideeffects();
29+
#endif
2730
}
2831

2932
u32_t cntr_start(void)
@@ -33,6 +36,9 @@ u32_t cntr_start(void)
3336
}
3437

3538
NRF_RTC->TASKS_START = 1;
39+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
40+
NRF_RTC0_regw_sideeffects();
41+
#endif
3642

3743
return 0;
3844
}
@@ -46,6 +52,9 @@ u32_t cntr_stop(void)
4652
}
4753

4854
NRF_RTC->TASKS_STOP = 1;
55+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
56+
NRF_RTC0_regw_sideeffects();
57+
#endif
4958

5059
return 0;
5160
}

subsys/bluetooth/controller/hal/nrf5/ecb.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#include <string.h>
99
#include <soc.h>
10+
#if !defined(CONFIG_ARCH_POSIX)
1011
#include <arch/arm/cortex_m/cmsis.h>
12+
#endif
1113

1214
#include "util/mem.h"
1315
#include "hal/ecb.h"
@@ -29,12 +31,23 @@ static void do_ecb(struct ecb_param *ecb)
2931
NRF_ECB->EVENTS_ENDECB = 0;
3032
NRF_ECB->EVENTS_ERRORECB = 0;
3133
NRF_ECB->TASKS_STARTECB = 1;
34+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
35+
NRF_ECB_regw_sideeffects_TASKS_STOPECB();
36+
NRF_ECB_regw_sideeffects_TASKS_STARTECB();
37+
#endif
3238
while ((NRF_ECB->EVENTS_ENDECB == 0) &&
3339
(NRF_ECB->EVENTS_ERRORECB == 0) &&
3440
(NRF_ECB->ECBDATAPTR != 0)) {
41+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
42+
__WFE();
43+
#else
3544
/*__WFE();*/
45+
#endif
3646
}
3747
NRF_ECB->TASKS_STOPECB = 1;
48+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
49+
NRF_ECB_regw_sideeffects_TASKS_STOPECB();
50+
#endif
3851
} while ((NRF_ECB->EVENTS_ERRORECB != 0) || (NRF_ECB->ECBDATAPTR == 0));
3952

4053
NRF_ECB->ECBDATAPTR = 0;
@@ -99,6 +112,10 @@ u32_t ecb_encrypt_nonblocking(struct ecb *ecb)
99112

100113
/* start the encryption h/w */
101114
NRF_ECB->TASKS_STARTECB = 1;
115+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
116+
NRF_ECB_regw_sideeffects_INTENSET();
117+
NRF_ECB_regw_sideeffects_TASKS_STARTECB();
118+
#endif
102119

103120
return 0;
104121
}
@@ -107,6 +124,9 @@ static void ecb_cleanup(void)
107124
{
108125
/* stop h/w */
109126
NRF_ECB->TASKS_STOPECB = 1;
127+
#if defined(CONFIG_BOARD_NRFXX_NWTSIM)
128+
NRF_ECB_regw_sideeffects_TASKS_STOPECB();
129+
#endif
110130

111131
/* cleanup interrupt */
112132
irq_disable(ECB_IRQn);

0 commit comments

Comments
 (0)