@@ -62,23 +62,23 @@ void SystemInit(void)
62
62
{
63
63
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
64
64
Specification to see which one). */
65
- #if defined (ENABLE_SWO )
65
+ #if defined (ENABLE_SWO )
66
66
CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
67
67
NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
68
68
NRF_P0 -> PIN_CNF [18 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
69
- #endif
69
+ #endif
70
70
71
71
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
72
72
Specification to see which ones). */
73
- #if defined (ENABLE_TRACE )
73
+ #if defined (ENABLE_TRACE )
74
74
CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
75
75
NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
76
76
NRF_P0 -> PIN_CNF [14 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
77
77
NRF_P0 -> PIN_CNF [15 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
78
78
NRF_P0 -> PIN_CNF [16 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
79
79
NRF_P0 -> PIN_CNF [18 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
80
80
NRF_P0 -> PIN_CNF [20 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
81
- #endif
81
+ #endif
82
82
83
83
/* Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated" found at the Errata document
84
84
for your device located at https://infocenter.nordicsemi.com/ */
@@ -166,16 +166,16 @@ void SystemInit(void)
166
166
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
167
167
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
168
168
* operations are not used in your code. */
169
- #if (__FPU_USED == 1 )
169
+ #if (__FPU_USED == 1 )
170
170
SCB -> CPACR |= (3UL << 20 ) | (3UL << 22 );
171
171
__DSB ();
172
172
__ISB ();
173
- #endif
173
+ #endif
174
174
175
175
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
176
176
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
177
177
normal GPIOs. */
178
- #if defined (CONFIG_NFCT_PINS_AS_GPIOS )
178
+ #if defined (CONFIG_NFCT_PINS_AS_GPIOS )
179
179
if ((NRF_UICR -> NFCPINS & UICR_NFCPINS_PROTECT_Msk ) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos )){
180
180
NRF_NVMC -> CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos ;
181
181
while (NRF_NVMC -> READY == NVMC_READY_READY_Busy ){}
@@ -185,12 +185,12 @@ void SystemInit(void)
185
185
while (NRF_NVMC -> READY == NVMC_READY_READY_Busy ){}
186
186
NVIC_SystemReset ();
187
187
}
188
- #endif
188
+ #endif
189
189
190
190
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
191
191
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
192
192
reserved for PinReset and not available as normal GPIO. */
193
- #if defined (CONFIG_GPIO_AS_PINRESET )
193
+ #if defined (CONFIG_GPIO_AS_PINRESET )
194
194
if (((NRF_UICR -> PSELRESET [0 ] & UICR_PSELRESET_CONNECT_Msk ) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos )) ||
195
195
((NRF_UICR -> PSELRESET [1 ] & UICR_PSELRESET_CONNECT_Msk ) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos ))){
196
196
NRF_NVMC -> CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos ;
@@ -203,7 +203,7 @@ void SystemInit(void)
203
203
while (NRF_NVMC -> READY == NVMC_READY_READY_Busy ){}
204
204
NVIC_SystemReset ();
205
205
}
206
- #endif
206
+ #endif
207
207
208
208
SystemCoreClockUpdate ();
209
209
@@ -216,6 +216,29 @@ void SystemInit(void)
216
216
while (NRF_CLOCK -> EVENTS_LFCLKSTARTED == 0 ) {
217
217
// Do nothing.
218
218
}
219
+
220
+ /**
221
+ * Mbed HAL specific code section.
222
+ *
223
+ * The ITM has to be initialized before the SoftDevice which weren't guaranteed using the normal API.
224
+ */
225
+ #if defined (DEVICE_ITM )
226
+ /* Enable SWO trace functionality */
227
+ CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
228
+ NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
229
+
230
+ /* set SWO clock speed to 4 MHz */
231
+ NRF_CLOCK -> TRACECONFIG = (NRF_CLOCK -> TRACECONFIG & ~CLOCK_TRACECONFIG_TRACEPORTSPEED_Msk ) |
232
+ (CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos );
233
+
234
+ /* set SWO pin */
235
+ NRF_P0 -> PIN_CNF [18 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) |
236
+ (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) |
237
+ (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
238
+
239
+ /* set prescaler */
240
+ TPI -> ACPR = 0 ;
241
+ #endif
219
242
}
220
243
221
244
0 commit comments