@@ -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"
@@ -59,23 +59,23 @@ void SystemInit(void)
59
59
{
60
60
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
61
61
Specification to see which one). */
62
- #if defined (ENABLE_SWO )
62
+ #if defined (ENABLE_SWO )
63
63
CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
64
64
NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
65
65
NRF_P1 -> PIN_CNF [0 ] = (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 );
66
- #endif
66
+ #endif
67
67
68
68
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
69
69
Specification to see which ones). */
70
- #if defined (ENABLE_TRACE )
70
+ #if defined (ENABLE_TRACE )
71
71
CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
72
72
NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
73
73
NRF_P0 -> PIN_CNF [7 ] = (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 );
74
74
NRF_P1 -> PIN_CNF [0 ] = (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 );
75
75
NRF_P0 -> PIN_CNF [12 ] = (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 );
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
- #endif
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/ */
@@ -84,7 +84,7 @@ void SystemInit(void)
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,52 +106,52 @@ 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. */
145
- #if (__FPU_USED == 1 )
145
+ #if (__FPU_USED == 1 )
146
146
SCB -> CPACR |= (3UL << 20 ) | (3UL << 22 );
147
147
__DSB ();
148
148
__ISB ();
149
- #endif
149
+ #endif
150
150
151
151
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
152
152
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
153
153
normal GPIOs. */
154
- #if defined (CONFIG_NFCT_PINS_AS_GPIOS )
154
+ #if defined (CONFIG_NFCT_PINS_AS_GPIOS )
155
155
if ((NRF_UICR -> NFCPINS & UICR_NFCPINS_PROTECT_Msk ) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos )){
156
156
NRF_NVMC -> CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos ;
157
157
while (NRF_NVMC -> READY == NVMC_READY_READY_Busy ){}
@@ -161,12 +161,12 @@ void SystemInit(void)
161
161
while (NRF_NVMC -> READY == NVMC_READY_READY_Busy ){}
162
162
NVIC_SystemReset ();
163
163
}
164
- #endif
164
+ #endif
165
165
166
166
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
167
167
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
168
168
reserved for PinReset and not available as normal GPIO. */
169
- #if defined (CONFIG_GPIO_AS_PINRESET )
169
+ #if defined (CONFIG_GPIO_AS_PINRESET )
170
170
if (((NRF_UICR -> PSELRESET [0 ] & UICR_PSELRESET_CONNECT_Msk ) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos )) ||
171
171
((NRF_UICR -> PSELRESET [1 ] & UICR_PSELRESET_CONNECT_Msk ) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos ))){
172
172
NRF_NVMC -> CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos ;
@@ -179,7 +179,7 @@ void SystemInit(void)
179
179
while (NRF_NVMC -> READY == NVMC_READY_READY_Busy ){}
180
180
NVIC_SystemReset ();
181
181
}
182
- #endif
182
+ #endif
183
183
184
184
SystemCoreClockUpdate ();
185
185
@@ -198,7 +198,7 @@ void SystemInit(void)
198
198
*
199
199
* The ITM has to be initialized before the SoftDevice which weren't guaranteed using the normal API.
200
200
*/
201
- #if defined (DEVICE_ITM )
201
+ #if defined (DEVICE_ITM )
202
202
/* Enable SWO trace functionality */
203
203
CoreDebug -> DEMCR |= CoreDebug_DEMCR_TRCENA_Msk ;
204
204
NRF_CLOCK -> TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos ;
@@ -214,7 +214,8 @@ void SystemInit(void)
214
214
215
215
/* set prescaler */
216
216
TPI -> ACPR = 0 ;
217
- #endif
217
+ #endif
218
+
218
219
}
219
220
220
221
@@ -223,7 +224,7 @@ static bool errata_36(void)
223
224
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
224
225
return true;
225
226
}
226
-
227
+
227
228
return false;
228
229
}
229
230
@@ -233,7 +234,7 @@ static bool errata_66(void)
233
234
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
234
235
return true;
235
236
}
236
-
237
+
237
238
return false;
238
239
}
239
240
@@ -243,7 +244,7 @@ static bool errata_98(void)
243
244
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
244
245
return true;
245
246
}
246
-
247
+
247
248
return false;
248
249
}
249
250
@@ -253,7 +254,7 @@ static bool errata_103(void)
253
254
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
254
255
return true;
255
256
}
256
-
257
+
257
258
return false;
258
259
}
259
260
@@ -263,7 +264,7 @@ static bool errata_115(void)
263
264
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
264
265
return true;
265
266
}
266
-
267
+
267
268
return false;
268
269
}
269
270
@@ -273,7 +274,7 @@ static bool errata_120(void)
273
274
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
274
275
return true;
275
276
}
276
-
277
+
277
278
return false;
278
279
}
279
280
@@ -283,7 +284,7 @@ static bool errata_136(void)
283
284
if ((* (uint32_t * )0x10000130ul == 0x8ul ) && (* (uint32_t * )0x10000134ul == 0x0ul )){
284
285
return true;
285
286
}
286
-
287
+
287
288
return false;
288
289
}
289
290
0 commit comments