@@ -22,7 +22,7 @@ NOTICE: This file has been modified by Nordic Semiconductor ASA.
22
22
23
23
/* NOTE: Template files (including this one) are application specific and therefore expected to
24
24
be copied into the application project folder prior to its use! */
25
-
25
+
26
26
#include <stdint.h>
27
27
#include <stdbool.h>
28
28
#include "nrf.h"
@@ -76,15 +76,15 @@ void SystemInit(void)
76
76
NRF_P0 -> PIN_CNF [11 ] = (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_P1 -> PIN_CNF [9 ] = (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
#endif
79
-
79
+
80
80
/* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
81
81
for your device located at https://infocenter.nordicsemi.com/ */
82
82
if (errata_36 ()){
83
83
NRF_CLOCK -> EVENTS_DONE = 0 ;
84
84
NRF_CLOCK -> EVENTS_CTTO = 0 ;
85
85
NRF_CLOCK -> CTIV = 0 ;
86
86
}
87
-
87
+
88
88
/* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document
89
89
for your device located at https://infocenter.nordicsemi.com/ */
90
90
if (errata_66 ()){
@@ -106,39 +106,39 @@ void SystemInit(void)
106
106
NRF_TEMP -> T3 = NRF_FICR -> TEMP .T3 ;
107
107
NRF_TEMP -> T4 = NRF_FICR -> TEMP .T4 ;
108
108
}
109
-
109
+
110
110
/* Workaround for Errata 98 "NFCT: Not able to communicate with the peer" found at the Errata document
111
111
for your device located at https://infocenter.nordicsemi.com/ */
112
112
if (errata_98 ()){
113
113
* (volatile uint32_t * )0x4000568Cul = 0x00038148ul ;
114
114
}
115
-
115
+
116
116
/* Workaround for Errata 103 "CCM: Wrong reset value of CCM MAXPACKETSIZE" found at the Errata document
117
117
for your device located at https://infocenter.nordicsemi.com/ */
118
118
if (errata_103 ()){
119
119
NRF_CCM -> MAXPACKETSIZE = 0xFBul ;
120
120
}
121
-
121
+
122
122
/* Workaround for Errata 115 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document
123
123
for your device located at https://infocenter.nordicsemi.com/ */
124
124
if (errata_115 ()){
125
125
* (volatile uint32_t * )0x40000EE4 = (* (volatile uint32_t * )0x40000EE4 & 0xFFFFFFF0 ) | (* (uint32_t * )0x10000258 & 0x0000000F );
126
126
}
127
-
127
+
128
128
/* Workaround for Errata 120 "QSPI: Data read or written is corrupted" found at the Errata document
129
129
for your device located at https://infocenter.nordicsemi.com/ */
130
130
if (errata_120 ()){
131
131
* (volatile uint32_t * )0x40029640ul = 0x200ul ;
132
132
}
133
-
133
+
134
134
/* Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be" found at the Errata document
135
135
for your device located at https://infocenter.nordicsemi.com/ */
136
136
if (errata_136 ()){
137
137
if (NRF_POWER -> RESETREAS & POWER_RESETREAS_RESETPIN_Msk ){
138
138
NRF_POWER -> RESETREAS = ~POWER_RESETREAS_RESETPIN_Msk ;
139
139
}
140
140
}
141
-
141
+
142
142
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
143
143
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
144
144
* operations are not used in your code. */
@@ -192,6 +192,29 @@ void SystemInit(void)
192
192
while (NRF_CLOCK -> EVENTS_LFCLKSTARTED == 0 ) {
193
193
// Do nothing.
194
194
}
195
+
196
+ /**
197
+ * Mbed HAL specific code section.
198
+ *
199
+ * The ITM has to be initialized before the SoftDevice which weren't guaranteed using the normal API.
200
+ */
201
+ #if defined (DEVICE_ITM )
202
+ /* Enable SWO trace functionality */
203
+ CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
204
+ NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
205
+
206
+ /* set SWO clock speed to 4 MHz */
207
+ NRF_CLOCK -> TRACECONFIG = (NRF_CLOCK -> TRACECONFIG & ~CLOCK_TRACECONFIG_TRACEPORTSPEED_Msk ) |
208
+ (CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos );
209
+
210
+ /* set SWO pin */
211
+ NRF_P0 -> PIN_CNF [18 ] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos ) |
212
+ (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos ) |
213
+ (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos );
214
+
215
+ /* set prescaler */
216
+ TPI -> ACPR = 0 ;
217
+ #endif
195
218
}
196
219
197
220
@@ -200,7 +223,7 @@ static bool errata_36(void)
200
223
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
201
224
return true;
202
225
}
203
-
226
+
204
227
return false;
205
228
}
206
229
@@ -210,7 +233,7 @@ static bool errata_66(void)
210
233
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
211
234
return true;
212
235
}
213
-
236
+
214
237
return false;
215
238
}
216
239
@@ -220,7 +243,7 @@ static bool errata_98(void)
220
243
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
221
244
return true;
222
245
}
223
-
246
+
224
247
return false;
225
248
}
226
249
@@ -230,7 +253,7 @@ static bool errata_103(void)
230
253
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
231
254
return true;
232
255
}
233
-
256
+
234
257
return false;
235
258
}
236
259
@@ -240,7 +263,7 @@ static bool errata_115(void)
240
263
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
241
264
return true;
242
265
}
243
-
266
+
244
267
return false;
245
268
}
246
269
@@ -250,7 +273,7 @@ static bool errata_120(void)
250
273
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
251
274
return true;
252
275
}
253
-
276
+
254
277
return false;
255
278
}
256
279
@@ -260,7 +283,7 @@ static bool errata_136(void)
260
283
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
261
284
return true;
262
285
}
263
-
286
+
264
287
return false;
265
288
}
266
289
0 commit comments