diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/K32L2A41A/mcuxpresso/startup_k32l2a41a.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/K32L2A41A/mcuxpresso/startup_k32l2a41a.c | 669 |
1 files changed, 669 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/K32L2A41A/mcuxpresso/startup_k32l2a41a.c b/lib/chibios-contrib/ext/mcux-sdk/devices/K32L2A41A/mcuxpresso/startup_k32l2a41a.c new file mode 100644 index 000000000..df4d3af22 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/K32L2A41A/mcuxpresso/startup_k32l2a41a.c | |||
@@ -0,0 +1,669 @@ | |||
1 | //***************************************************************************** | ||
2 | // K32L2A41A startup code for use with MCUXpresso IDE | ||
3 | // | ||
4 | // Version : 160420 | ||
5 | //***************************************************************************** | ||
6 | // | ||
7 | // Copyright 2016-2020 NXP | ||
8 | // All rights reserved. | ||
9 | // | ||
10 | // SPDX-License-Identifier: BSD-3-Clause | ||
11 | //***************************************************************************** | ||
12 | |||
13 | #if defined (DEBUG) | ||
14 | #pragma GCC push_options | ||
15 | #pragma GCC optimize ("Og") | ||
16 | #endif // (DEBUG) | ||
17 | |||
18 | #if defined (__cplusplus) | ||
19 | #ifdef __REDLIB__ | ||
20 | #error Redlib does not support C++ | ||
21 | #else | ||
22 | //***************************************************************************** | ||
23 | // | ||
24 | // The entry point for the C++ library startup | ||
25 | // | ||
26 | //***************************************************************************** | ||
27 | extern "C" { | ||
28 | extern void __libc_init_array(void); | ||
29 | } | ||
30 | #endif | ||
31 | #endif | ||
32 | |||
33 | #define WEAK __attribute__ ((weak)) | ||
34 | #define WEAK_AV __attribute__ ((weak, section(".after_vectors"))) | ||
35 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) | ||
36 | |||
37 | //***************************************************************************** | ||
38 | #if defined (__cplusplus) | ||
39 | extern "C" { | ||
40 | #endif | ||
41 | |||
42 | //***************************************************************************** | ||
43 | // Flash Configuration block : 16-byte flash configuration field that stores | ||
44 | // default protection settings (loaded on reset) and security information that | ||
45 | // allows the MCU to restrict access to the Flash Memory module. | ||
46 | // Placed at address 0x400 by the linker script. | ||
47 | //***************************************************************************** | ||
48 | __attribute__ ((used,section(".FlashConfig"))) const struct { | ||
49 | unsigned int word1; | ||
50 | unsigned int word2; | ||
51 | unsigned int word3; | ||
52 | unsigned int word4; | ||
53 | } Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFF3DFE}; | ||
54 | //***************************************************************************** | ||
55 | // Declaration of external SystemInit function | ||
56 | //***************************************************************************** | ||
57 | #if defined (__USE_CMSIS) | ||
58 | extern void SystemInit(void); | ||
59 | #endif // (__USE_CMSIS) | ||
60 | |||
61 | //***************************************************************************** | ||
62 | // Forward declaration of the core exception handlers. | ||
63 | // When the application defines a handler (with the same name), this will | ||
64 | // automatically take precedence over these weak definitions. | ||
65 | // If your application is a C++ one, then any interrupt handlers defined | ||
66 | // in C++ files within in your main application will need to have C linkage | ||
67 | // rather than C++ linkage. To do this, make sure that you are using extern "C" | ||
68 | // { .... } around the interrupt handler within your main application code. | ||
69 | //***************************************************************************** | ||
70 | void ResetISR(void); | ||
71 | WEAK void NMI_Handler(void); | ||
72 | WEAK void HardFault_Handler(void); | ||
73 | WEAK void SVC_Handler(void); | ||
74 | WEAK void PendSV_Handler(void); | ||
75 | WEAK void SysTick_Handler(void); | ||
76 | WEAK void IntDefaultHandler(void); | ||
77 | |||
78 | //***************************************************************************** | ||
79 | // Forward declaration of the application IRQ handlers. When the application | ||
80 | // defines a handler (with the same name), this will automatically take | ||
81 | // precedence over weak definitions below | ||
82 | //***************************************************************************** | ||
83 | WEAK void DMA0_04_IRQHandler(void); | ||
84 | WEAK void DMA0_15_IRQHandler(void); | ||
85 | WEAK void DMA0_26_IRQHandler(void); | ||
86 | WEAK void DMA0_37_IRQHandler(void); | ||
87 | WEAK void CTI0_DMA0_Error_IRQHandler(void); | ||
88 | WEAK void FLEXIO0_IRQHandler(void); | ||
89 | WEAK void TPM0_IRQHandler(void); | ||
90 | WEAK void TPM1_IRQHandler(void); | ||
91 | WEAK void TPM2_IRQHandler(void); | ||
92 | WEAK void LPIT0_IRQHandler(void); | ||
93 | WEAK void LPSPI0_IRQHandler(void); | ||
94 | WEAK void LPSPI1_IRQHandler(void); | ||
95 | WEAK void LPUART0_IRQHandler(void); | ||
96 | WEAK void LPUART1_IRQHandler(void); | ||
97 | WEAK void LPI2C0_IRQHandler(void); | ||
98 | WEAK void LPI2C1_IRQHandler(void); | ||
99 | WEAK void Reserved32_IRQHandler(void); | ||
100 | WEAK void PORTA_IRQHandler(void); | ||
101 | WEAK void PORTB_IRQHandler(void); | ||
102 | WEAK void PORTC_IRQHandler(void); | ||
103 | WEAK void PORTD_IRQHandler(void); | ||
104 | WEAK void PORTE_IRQHandler(void); | ||
105 | WEAK void LLWU_IRQHandler(void); | ||
106 | WEAK void Reserved39_IRQHandler(void); | ||
107 | WEAK void USB0_IRQHandler(void); | ||
108 | WEAK void ADC0_IRQHandler(void); | ||
109 | WEAK void LPTMR0_IRQHandler(void); | ||
110 | WEAK void RTC_Seconds_IRQHandler(void); | ||
111 | WEAK void INTMUX0_0_IRQHandler(void); | ||
112 | WEAK void INTMUX0_1_IRQHandler(void); | ||
113 | WEAK void INTMUX0_2_IRQHandler(void); | ||
114 | WEAK void INTMUX0_3_IRQHandler(void); | ||
115 | WEAK void LPTMR1_IRQHandler(void); | ||
116 | WEAK void Reserved49_IRQHandler(void); | ||
117 | WEAK void Reserved50_IRQHandler(void); | ||
118 | WEAK void Reserved51_IRQHandler(void); | ||
119 | WEAK void LPSPI2_IRQHandler(void); | ||
120 | WEAK void LPUART2_IRQHandler(void); | ||
121 | WEAK void EMVSIM0_IRQHandler(void); | ||
122 | WEAK void LPI2C2_IRQHandler(void); | ||
123 | WEAK void TSI0_IRQHandler(void); | ||
124 | WEAK void PMC_IRQHandler(void); | ||
125 | WEAK void FTFA_IRQHandler(void); | ||
126 | WEAK void SCG_IRQHandler(void); | ||
127 | WEAK void WDOG0_IRQHandler(void); | ||
128 | WEAK void DAC0_IRQHandler(void); | ||
129 | WEAK void TRNG_IRQHandler(void); | ||
130 | WEAK void RCM_IRQHandler(void); | ||
131 | WEAK void CMP0_IRQHandler(void); | ||
132 | WEAK void CMP1_IRQHandler(void); | ||
133 | WEAK void RTC_IRQHandler(void); | ||
134 | |||
135 | //***************************************************************************** | ||
136 | // Forward declaration of the driver IRQ handlers. These are aliased | ||
137 | // to the IntDefaultHandler, which is a 'forever' loop. When the driver | ||
138 | // defines a handler (with the same name), this will automatically take | ||
139 | // precedence over these weak definitions | ||
140 | //***************************************************************************** | ||
141 | void DMA0_04_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
142 | void DMA0_15_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
143 | void DMA0_26_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
144 | void DMA0_37_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
145 | void CTI0_DMA0_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
146 | void FLEXIO0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
147 | void TPM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
148 | void TPM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
149 | void TPM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
150 | void LPIT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
151 | void LPSPI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
152 | void LPSPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
153 | void LPUART0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
154 | void LPUART1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
155 | void LPI2C0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
156 | void LPI2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
157 | void Reserved32_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
158 | void PORTA_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
159 | void PORTB_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
160 | void PORTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
161 | void PORTD_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
162 | void PORTE_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
163 | void LLWU_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
164 | void Reserved39_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
165 | void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
166 | void ADC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
167 | void LPTMR0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
168 | void RTC_Seconds_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
169 | void INTMUX0_0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
170 | void INTMUX0_1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
171 | void INTMUX0_2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
172 | void INTMUX0_3_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
173 | void LPTMR1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
174 | void Reserved49_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
175 | void Reserved50_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
176 | void Reserved51_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
177 | void LPSPI2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
178 | void LPUART2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
179 | void EMVSIM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
180 | void LPI2C2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
181 | void TSI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
182 | void PMC_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
183 | void FTFA_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
184 | void SCG_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
185 | void WDOG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
186 | void DAC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
187 | void TRNG_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
188 | void RCM_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
189 | void CMP0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
190 | void CMP1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
191 | void RTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
192 | |||
193 | //***************************************************************************** | ||
194 | // The entry point for the application. | ||
195 | // __main() is the entry point for Redlib based applications | ||
196 | // main() is the entry point for Newlib based applications | ||
197 | //***************************************************************************** | ||
198 | #if defined (__REDLIB__) | ||
199 | extern void __main(void); | ||
200 | #endif | ||
201 | extern int main(void); | ||
202 | |||
203 | //***************************************************************************** | ||
204 | // External declaration for the pointer to the stack top from the Linker Script | ||
205 | //***************************************************************************** | ||
206 | extern void _vStackTop(void); | ||
207 | //***************************************************************************** | ||
208 | #if defined (__cplusplus) | ||
209 | } // extern "C" | ||
210 | #endif | ||
211 | //***************************************************************************** | ||
212 | // The vector table. | ||
213 | // This relies on the linker script to place at correct location in memory. | ||
214 | //***************************************************************************** | ||
215 | |||
216 | |||
217 | |||
218 | extern void (* const g_pfnVectors[])(void); | ||
219 | extern void * __Vectors __attribute__ ((alias ("g_pfnVectors"))); | ||
220 | |||
221 | __attribute__ ((used, section(".isr_vector"))) | ||
222 | void (* const g_pfnVectors[])(void) = { | ||
223 | // Core Level - CM0P | ||
224 | &_vStackTop, // The initial stack pointer | ||
225 | ResetISR, // The reset handler | ||
226 | NMI_Handler, // The NMI handler | ||
227 | HardFault_Handler, // The hard fault handler | ||
228 | 0, // Reserved | ||
229 | 0, // Reserved | ||
230 | 0, // Reserved | ||
231 | 0, // Reserved | ||
232 | 0, // Reserved | ||
233 | 0, // Reserved | ||
234 | 0, // Reserved | ||
235 | SVC_Handler, // SVCall handler | ||
236 | 0, // Reserved | ||
237 | 0, // Reserved | ||
238 | PendSV_Handler, // The PendSV handler | ||
239 | SysTick_Handler, // The SysTick handler | ||
240 | |||
241 | // Chip Level - K32L2A41A | ||
242 | DMA0_04_IRQHandler, // 16: DMA0 channel 0/4 transfer complete | ||
243 | DMA0_15_IRQHandler, // 17: DMA0 channel 1/5 transfer complete | ||
244 | DMA0_26_IRQHandler, // 18: DMA0 channel 2/6 transfer complete | ||
245 | DMA0_37_IRQHandler, // 19: DMA0 channel 3/7 transfer complete | ||
246 | CTI0_DMA0_Error_IRQHandler, // 20: CTI0 or DMA0 error | ||
247 | FLEXIO0_IRQHandler, // 21: FLEXIO0 | ||
248 | TPM0_IRQHandler, // 22: TPM0 single interrupt vector for all sources | ||
249 | TPM1_IRQHandler, // 23: TPM1 single interrupt vector for all sources | ||
250 | TPM2_IRQHandler, // 24: TPM2 single interrupt vector for all sources | ||
251 | LPIT0_IRQHandler, // 25: LPIT0 interrupt | ||
252 | LPSPI0_IRQHandler, // 26: LPSPI0 single interrupt vector for all sources | ||
253 | LPSPI1_IRQHandler, // 27: LPSPI1 single interrupt vector for all sources | ||
254 | LPUART0_IRQHandler, // 28: LPUART0 status and error | ||
255 | LPUART1_IRQHandler, // 29: LPUART1 status and error | ||
256 | LPI2C0_IRQHandler, // 30: LPI2C0 interrupt | ||
257 | LPI2C1_IRQHandler, // 31: LPI2C1 interrupt | ||
258 | Reserved32_IRQHandler, // 32: Reserved interrupt | ||
259 | PORTA_IRQHandler, // 33: PORTA Pin detect | ||
260 | PORTB_IRQHandler, // 34: PORTB Pin detect | ||
261 | PORTC_IRQHandler, // 35: PORTC Pin detect | ||
262 | PORTD_IRQHandler, // 36: PORTD Pin detect | ||
263 | PORTE_IRQHandler, // 37: PORTE Pin detect | ||
264 | LLWU_IRQHandler, // 38: Low leakage wakeup | ||
265 | Reserved39_IRQHandler, // 39: Reserved interrupt | ||
266 | USB0_IRQHandler, // 40: USB0 interrupt | ||
267 | ADC0_IRQHandler, // 41: ADC0 interrupt | ||
268 | LPTMR0_IRQHandler, // 42: LPTMR0 interrupt | ||
269 | RTC_Seconds_IRQHandler, // 43: RTC seconds | ||
270 | INTMUX0_0_IRQHandler, // 44: INTMUX0 channel 0 interrupt | ||
271 | INTMUX0_1_IRQHandler, // 45: INTMUX0 channel 1 interrupt | ||
272 | INTMUX0_2_IRQHandler, // 46: INTMUX0 channel 2 interrupt | ||
273 | INTMUX0_3_IRQHandler, // 47: INTMUX0 channel 3 interrupt | ||
274 | LPTMR1_IRQHandler, // 48: LPTMR1 interrupt (INTMUX source IRQ0) | ||
275 | Reserved49_IRQHandler, // 49: Reserved interrupt | ||
276 | Reserved50_IRQHandler, // 50: Reserved interrupt | ||
277 | Reserved51_IRQHandler, // 51: Reserved interrupt | ||
278 | LPSPI2_IRQHandler, // 52: LPSPI2 single interrupt vector for all sources (INTMUX source IRQ4) | ||
279 | LPUART2_IRQHandler, // 53: LPUART2 status and error (INTMUX source IRQ5) | ||
280 | EMVSIM0_IRQHandler, // 54: EMVSIM0 interrupt (INTMUX source IRQ6) | ||
281 | LPI2C2_IRQHandler, // 55: LPI2C2 interrupt (INTMUX source IRQ7) | ||
282 | TSI0_IRQHandler, // 56: TSI0 interrupt (INTMUX source IRQ8) | ||
283 | PMC_IRQHandler, // 57: PMC interrupt (INTMUX source IRQ9) | ||
284 | FTFA_IRQHandler, // 58: FTFA interrupt (INTMUX source IRQ10) | ||
285 | SCG_IRQHandler, // 59: SCG interrupt (INTMUX source IRQ11) | ||
286 | WDOG0_IRQHandler, // 60: WDOG0 interrupt (INTMUX source IRQ12) | ||
287 | DAC0_IRQHandler, // 61: DAC0 interrupt (INTMUX source IRQ13) | ||
288 | TRNG_IRQHandler, // 62: TRNG interrupt (INTMUX source IRQ14) | ||
289 | RCM_IRQHandler, // 63: RCM interrupt (INTMUX source IRQ15) | ||
290 | CMP0_IRQHandler, // 64: CMP0 interrupt (INTMUX source IRQ16) | ||
291 | CMP1_IRQHandler, // 65: CMP1 interrupt (INTMUX source IRQ17) | ||
292 | RTC_IRQHandler, // 66: RTC Alarm interrupt (INTMUX source IRQ18) | ||
293 | |||
294 | |||
295 | }; /* End of g_pfnVectors */ | ||
296 | |||
297 | //***************************************************************************** | ||
298 | // Functions to carry out the initialization of RW and BSS data sections. These | ||
299 | // are written as separate functions rather than being inlined within the | ||
300 | // ResetISR() function in order to cope with MCUs with multiple banks of | ||
301 | // memory. | ||
302 | //***************************************************************************** | ||
303 | __attribute__ ((section(".after_vectors.init_data"))) | ||
304 | void data_init(unsigned int romstart, unsigned int start, unsigned int len) { | ||
305 | unsigned int *pulDest = (unsigned int*) start; | ||
306 | unsigned int *pulSrc = (unsigned int*) romstart; | ||
307 | unsigned int loop; | ||
308 | for (loop = 0; loop < len; loop = loop + 4) | ||
309 | *pulDest++ = *pulSrc++; | ||
310 | } | ||
311 | |||
312 | __attribute__ ((section(".after_vectors.init_bss"))) | ||
313 | void bss_init(unsigned int start, unsigned int len) { | ||
314 | unsigned int *pulDest = (unsigned int*) start; | ||
315 | unsigned int loop; | ||
316 | for (loop = 0; loop < len; loop = loop + 4) | ||
317 | *pulDest++ = 0; | ||
318 | } | ||
319 | |||
320 | //***************************************************************************** | ||
321 | // The following symbols are constructs generated by the linker, indicating | ||
322 | // the location of various points in the "Global Section Table". This table is | ||
323 | // created by the linker via the Code Red managed linker script mechanism. It | ||
324 | // contains the load address, execution address and length of each RW data | ||
325 | // section and the execution and length of each BSS (zero initialized) section. | ||
326 | //***************************************************************************** | ||
327 | extern unsigned int __data_section_table; | ||
328 | extern unsigned int __data_section_table_end; | ||
329 | extern unsigned int __bss_section_table; | ||
330 | extern unsigned int __bss_section_table_end; | ||
331 | |||
332 | //***************************************************************************** | ||
333 | // Reset entry point for your code. | ||
334 | // Sets up a simple runtime environment and initializes the C/C++ | ||
335 | // library. | ||
336 | //***************************************************************************** | ||
337 | __attribute__ ((section(".after_vectors.reset"))) | ||
338 | void ResetISR(void) { | ||
339 | |||
340 | // Disable interrupts | ||
341 | __asm volatile ("cpsid i"); | ||
342 | |||
343 | |||
344 | #if defined (__USE_CMSIS) | ||
345 | // If __USE_CMSIS defined, then call CMSIS SystemInit code | ||
346 | SystemInit(); | ||
347 | |||
348 | #else | ||
349 | // Disable Watchdog | ||
350 | // Write watchdog update key to unlock | ||
351 | *((volatile unsigned int *)0x40076004) = 0xD928C520; | ||
352 | // Set timeout value | ||
353 | *((volatile unsigned int *)0x40076008) = 0xFFFF; | ||
354 | // Now disable watchdog via control register | ||
355 | volatile unsigned int *WDOG_CS = (unsigned int *) 0x40076000; | ||
356 | *WDOG_CS = (*WDOG_CS & ~(1 << 7)) | (1 << 5); | ||
357 | #endif // (__USE_CMSIS) | ||
358 | |||
359 | // | ||
360 | // Copy the data sections from flash to SRAM. | ||
361 | // | ||
362 | unsigned int LoadAddr, ExeAddr, SectionLen; | ||
363 | unsigned int *SectionTableAddr; | ||
364 | |||
365 | // Load base address of Global Section Table | ||
366 | SectionTableAddr = &__data_section_table; | ||
367 | |||
368 | // Copy the data sections from flash to SRAM. | ||
369 | while (SectionTableAddr < &__data_section_table_end) { | ||
370 | LoadAddr = *SectionTableAddr++; | ||
371 | ExeAddr = *SectionTableAddr++; | ||
372 | SectionLen = *SectionTableAddr++; | ||
373 | data_init(LoadAddr, ExeAddr, SectionLen); | ||
374 | } | ||
375 | |||
376 | // At this point, SectionTableAddr = &__bss_section_table; | ||
377 | // Zero fill the bss segment | ||
378 | while (SectionTableAddr < &__bss_section_table_end) { | ||
379 | ExeAddr = *SectionTableAddr++; | ||
380 | SectionLen = *SectionTableAddr++; | ||
381 | bss_init(ExeAddr, SectionLen); | ||
382 | } | ||
383 | |||
384 | |||
385 | #if !defined (__USE_CMSIS) | ||
386 | // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code | ||
387 | // will setup the VTOR register | ||
388 | |||
389 | // Check to see if we are running the code from a non-zero | ||
390 | // address (eg RAM, external flash), in which case we need | ||
391 | // to modify the VTOR register to tell the CPU that the | ||
392 | // vector table is located at a non-0x0 address. | ||
393 | unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08; | ||
394 | if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) { | ||
395 | *pSCB_VTOR = (unsigned int)g_pfnVectors; | ||
396 | } | ||
397 | #endif // (__USE_CMSIS) | ||
398 | #if defined (__cplusplus) | ||
399 | // | ||
400 | // Call C++ library initialisation | ||
401 | // | ||
402 | __libc_init_array(); | ||
403 | #endif | ||
404 | |||
405 | // Reenable interrupts | ||
406 | __asm volatile ("cpsie i"); | ||
407 | |||
408 | #if defined (__REDLIB__) | ||
409 | // Call the Redlib library, which in turn calls main() | ||
410 | __main(); | ||
411 | #else | ||
412 | main(); | ||
413 | #endif | ||
414 | |||
415 | // | ||
416 | // main() shouldn't return, but if it does, we'll just enter an infinite loop | ||
417 | // | ||
418 | while (1) { | ||
419 | ; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | //***************************************************************************** | ||
424 | // Default core exception handlers. Override the ones here by defining your own | ||
425 | // handler routines in your application code. | ||
426 | //***************************************************************************** | ||
427 | WEAK_AV void NMI_Handler(void) | ||
428 | { while(1) {} | ||
429 | } | ||
430 | |||
431 | WEAK_AV void HardFault_Handler(void) | ||
432 | { while(1) {} | ||
433 | } | ||
434 | |||
435 | WEAK_AV void SVC_Handler(void) | ||
436 | { while(1) {} | ||
437 | } | ||
438 | |||
439 | WEAK_AV void PendSV_Handler(void) | ||
440 | { while(1) {} | ||
441 | } | ||
442 | |||
443 | WEAK_AV void SysTick_Handler(void) | ||
444 | { while(1) {} | ||
445 | } | ||
446 | |||
447 | //***************************************************************************** | ||
448 | // Processor ends up here if an unexpected interrupt occurs or a specific | ||
449 | // handler is not present in the application code. | ||
450 | //***************************************************************************** | ||
451 | WEAK_AV void IntDefaultHandler(void) | ||
452 | { while(1) {} | ||
453 | } | ||
454 | |||
455 | //***************************************************************************** | ||
456 | // Default application exception handlers. Override the ones here by defining | ||
457 | // your own handler routines in your application code. These routines call | ||
458 | // driver exception handlers or IntDefaultHandler() if no driver exception | ||
459 | // handler is included. | ||
460 | //***************************************************************************** | ||
461 | WEAK_AV void DMA0_04_IRQHandler(void) | ||
462 | { DMA0_04_DriverIRQHandler(); | ||
463 | } | ||
464 | |||
465 | WEAK_AV void DMA0_15_IRQHandler(void) | ||
466 | { DMA0_15_DriverIRQHandler(); | ||
467 | } | ||
468 | |||
469 | WEAK_AV void DMA0_26_IRQHandler(void) | ||
470 | { DMA0_26_DriverIRQHandler(); | ||
471 | } | ||
472 | |||
473 | WEAK_AV void DMA0_37_IRQHandler(void) | ||
474 | { DMA0_37_DriverIRQHandler(); | ||
475 | } | ||
476 | |||
477 | WEAK_AV void CTI0_DMA0_Error_IRQHandler(void) | ||
478 | { CTI0_DMA0_Error_DriverIRQHandler(); | ||
479 | } | ||
480 | |||
481 | WEAK_AV void FLEXIO0_IRQHandler(void) | ||
482 | { FLEXIO0_DriverIRQHandler(); | ||
483 | } | ||
484 | |||
485 | WEAK_AV void TPM0_IRQHandler(void) | ||
486 | { TPM0_DriverIRQHandler(); | ||
487 | } | ||
488 | |||
489 | WEAK_AV void TPM1_IRQHandler(void) | ||
490 | { TPM1_DriverIRQHandler(); | ||
491 | } | ||
492 | |||
493 | WEAK_AV void TPM2_IRQHandler(void) | ||
494 | { TPM2_DriverIRQHandler(); | ||
495 | } | ||
496 | |||
497 | WEAK_AV void LPIT0_IRQHandler(void) | ||
498 | { LPIT0_DriverIRQHandler(); | ||
499 | } | ||
500 | |||
501 | WEAK_AV void LPSPI0_IRQHandler(void) | ||
502 | { LPSPI0_DriverIRQHandler(); | ||
503 | } | ||
504 | |||
505 | WEAK_AV void LPSPI1_IRQHandler(void) | ||
506 | { LPSPI1_DriverIRQHandler(); | ||
507 | } | ||
508 | |||
509 | WEAK_AV void LPUART0_IRQHandler(void) | ||
510 | { LPUART0_DriverIRQHandler(); | ||
511 | } | ||
512 | |||
513 | WEAK_AV void LPUART1_IRQHandler(void) | ||
514 | { LPUART1_DriverIRQHandler(); | ||
515 | } | ||
516 | |||
517 | WEAK_AV void LPI2C0_IRQHandler(void) | ||
518 | { LPI2C0_DriverIRQHandler(); | ||
519 | } | ||
520 | |||
521 | WEAK_AV void LPI2C1_IRQHandler(void) | ||
522 | { LPI2C1_DriverIRQHandler(); | ||
523 | } | ||
524 | |||
525 | WEAK_AV void Reserved32_IRQHandler(void) | ||
526 | { Reserved32_DriverIRQHandler(); | ||
527 | } | ||
528 | |||
529 | WEAK_AV void PORTA_IRQHandler(void) | ||
530 | { PORTA_DriverIRQHandler(); | ||
531 | } | ||
532 | |||
533 | WEAK_AV void PORTB_IRQHandler(void) | ||
534 | { PORTB_DriverIRQHandler(); | ||
535 | } | ||
536 | |||
537 | WEAK_AV void PORTC_IRQHandler(void) | ||
538 | { PORTC_DriverIRQHandler(); | ||
539 | } | ||
540 | |||
541 | WEAK_AV void PORTD_IRQHandler(void) | ||
542 | { PORTD_DriverIRQHandler(); | ||
543 | } | ||
544 | |||
545 | WEAK_AV void PORTE_IRQHandler(void) | ||
546 | { PORTE_DriverIRQHandler(); | ||
547 | } | ||
548 | |||
549 | WEAK_AV void LLWU_IRQHandler(void) | ||
550 | { LLWU_DriverIRQHandler(); | ||
551 | } | ||
552 | |||
553 | WEAK_AV void Reserved39_IRQHandler(void) | ||
554 | { Reserved39_DriverIRQHandler(); | ||
555 | } | ||
556 | |||
557 | WEAK_AV void USB0_IRQHandler(void) | ||
558 | { USB0_DriverIRQHandler(); | ||
559 | } | ||
560 | |||
561 | WEAK_AV void ADC0_IRQHandler(void) | ||
562 | { ADC0_DriverIRQHandler(); | ||
563 | } | ||
564 | |||
565 | WEAK_AV void LPTMR0_IRQHandler(void) | ||
566 | { LPTMR0_DriverIRQHandler(); | ||
567 | } | ||
568 | |||
569 | WEAK_AV void RTC_Seconds_IRQHandler(void) | ||
570 | { RTC_Seconds_DriverIRQHandler(); | ||
571 | } | ||
572 | |||
573 | WEAK_AV void INTMUX0_0_IRQHandler(void) | ||
574 | { INTMUX0_0_DriverIRQHandler(); | ||
575 | } | ||
576 | |||
577 | WEAK_AV void INTMUX0_1_IRQHandler(void) | ||
578 | { INTMUX0_1_DriverIRQHandler(); | ||
579 | } | ||
580 | |||
581 | WEAK_AV void INTMUX0_2_IRQHandler(void) | ||
582 | { INTMUX0_2_DriverIRQHandler(); | ||
583 | } | ||
584 | |||
585 | WEAK_AV void INTMUX0_3_IRQHandler(void) | ||
586 | { INTMUX0_3_DriverIRQHandler(); | ||
587 | } | ||
588 | |||
589 | WEAK_AV void LPTMR1_IRQHandler(void) | ||
590 | { LPTMR1_DriverIRQHandler(); | ||
591 | } | ||
592 | |||
593 | WEAK_AV void Reserved49_IRQHandler(void) | ||
594 | { Reserved49_DriverIRQHandler(); | ||
595 | } | ||
596 | |||
597 | WEAK_AV void Reserved50_IRQHandler(void) | ||
598 | { Reserved50_DriverIRQHandler(); | ||
599 | } | ||
600 | |||
601 | WEAK_AV void Reserved51_IRQHandler(void) | ||
602 | { Reserved51_DriverIRQHandler(); | ||
603 | } | ||
604 | |||
605 | WEAK_AV void LPSPI2_IRQHandler(void) | ||
606 | { LPSPI2_DriverIRQHandler(); | ||
607 | } | ||
608 | |||
609 | WEAK_AV void LPUART2_IRQHandler(void) | ||
610 | { LPUART2_DriverIRQHandler(); | ||
611 | } | ||
612 | |||
613 | WEAK_AV void EMVSIM0_IRQHandler(void) | ||
614 | { EMVSIM0_DriverIRQHandler(); | ||
615 | } | ||
616 | |||
617 | WEAK_AV void LPI2C2_IRQHandler(void) | ||
618 | { LPI2C2_DriverIRQHandler(); | ||
619 | } | ||
620 | |||
621 | WEAK_AV void TSI0_IRQHandler(void) | ||
622 | { TSI0_DriverIRQHandler(); | ||
623 | } | ||
624 | |||
625 | WEAK_AV void PMC_IRQHandler(void) | ||
626 | { PMC_DriverIRQHandler(); | ||
627 | } | ||
628 | |||
629 | WEAK_AV void FTFA_IRQHandler(void) | ||
630 | { FTFA_DriverIRQHandler(); | ||
631 | } | ||
632 | |||
633 | WEAK_AV void SCG_IRQHandler(void) | ||
634 | { SCG_DriverIRQHandler(); | ||
635 | } | ||
636 | |||
637 | WEAK_AV void WDOG0_IRQHandler(void) | ||
638 | { WDOG0_DriverIRQHandler(); | ||
639 | } | ||
640 | |||
641 | WEAK_AV void DAC0_IRQHandler(void) | ||
642 | { DAC0_DriverIRQHandler(); | ||
643 | } | ||
644 | |||
645 | WEAK_AV void TRNG_IRQHandler(void) | ||
646 | { TRNG_DriverIRQHandler(); | ||
647 | } | ||
648 | |||
649 | WEAK_AV void RCM_IRQHandler(void) | ||
650 | { RCM_DriverIRQHandler(); | ||
651 | } | ||
652 | |||
653 | WEAK_AV void CMP0_IRQHandler(void) | ||
654 | { CMP0_DriverIRQHandler(); | ||
655 | } | ||
656 | |||
657 | WEAK_AV void CMP1_IRQHandler(void) | ||
658 | { CMP1_DriverIRQHandler(); | ||
659 | } | ||
660 | |||
661 | WEAK_AV void RTC_IRQHandler(void) | ||
662 | { RTC_DriverIRQHandler(); | ||
663 | } | ||
664 | |||
665 | //***************************************************************************** | ||
666 | |||
667 | #if defined (DEBUG) | ||
668 | #pragma GCC pop_options | ||
669 | #endif // (DEBUG) | ||