1 //*****************************************************************************
2 // K32L3A60_cm4 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 // Declaration of external SystemInit function
44 //*****************************************************************************
45 #if defined (__USE_CMSIS)
46 extern void SystemInit(void);
47 #endif // (__USE_CMSIS)
48 
49 //*****************************************************************************
50 // Forward declaration of the core exception handlers.
51 // When the application defines a handler (with the same name), this will
52 // automatically take precedence over these weak definitions.
53 // If your application is a C++ one, then any interrupt handlers defined
54 // in C++ files within in your main application will need to have C linkage
55 // rather than C++ linkage. To do this, make sure that you are using extern "C"
56 // { .... } around the interrupt handler within your main application code.
57 //*****************************************************************************
58      void ResetISR(void);
59 WEAK void NMI_Handler(void);
60 WEAK void HardFault_Handler(void);
61 WEAK void SVC_Handler(void);
62 WEAK void PendSV_Handler(void);
63 WEAK void SysTick_Handler(void);
64 WEAK void IntDefaultHandler(void);
65 
66 //*****************************************************************************
67 // Forward declaration of the application IRQ handlers. When the application
68 // defines a handler (with the same name), this will automatically take
69 // precedence over weak definitions below
70 //*****************************************************************************
71 WEAK void CTI0_MCM0_IRQHandler(void);
72 WEAK void DMA0_IRQHandler(void);
73 WEAK void DMA1_IRQHandler(void);
74 WEAK void DMA2_IRQHandler(void);
75 WEAK void DMA3_IRQHandler(void);
76 WEAK void DMA4_IRQHandler(void);
77 WEAK void DMA5_IRQHandler(void);
78 WEAK void DMA6_IRQHandler(void);
79 WEAK void DMA7_IRQHandler(void);
80 WEAK void DMA8_IRQHandler(void);
81 WEAK void DMA9_IRQHandler(void);
82 WEAK void DMA10_IRQHandler(void);
83 WEAK void DMA11_IRQHandler(void);
84 WEAK void DMA12_IRQHandler(void);
85 WEAK void DMA13_IRQHandler(void);
86 WEAK void DMA14_IRQHandler(void);
87 WEAK void DMA15_IRQHandler(void);
88 WEAK void DMA0_Error_IRQHandler(void);
89 WEAK void MSMC_IRQHandler(void);
90 WEAK void EWM_IRQHandler(void);
91 WEAK void FTFE_Command_Complete_IRQHandler(void);
92 WEAK void FTFE_Read_Collision_IRQHandler(void);
93 WEAK void LLWU0_IRQHandler(void);
94 WEAK void MUA_IRQHandler(void);
95 WEAK void SPM_IRQHandler(void);
96 WEAK void WDOG0_IRQHandler(void);
97 WEAK void SCG_IRQHandler(void);
98 WEAK void LPIT0_IRQHandler(void);
99 WEAK void RTC_IRQHandler(void);
100 WEAK void LPTMR0_IRQHandler(void);
101 WEAK void LPTMR1_IRQHandler(void);
102 WEAK void TPM0_IRQHandler(void);
103 WEAK void TPM1_IRQHandler(void);
104 WEAK void TPM2_IRQHandler(void);
105 WEAK void EMVSIM0_IRQHandler(void);
106 WEAK void FLEXIO0_IRQHandler(void);
107 WEAK void LPI2C0_IRQHandler(void);
108 WEAK void LPI2C1_IRQHandler(void);
109 WEAK void LPI2C2_IRQHandler(void);
110 WEAK void I2S0_IRQHandler(void);
111 WEAK void USDHC0_IRQHandler(void);
112 WEAK void LPSPI0_IRQHandler(void);
113 WEAK void LPSPI1_IRQHandler(void);
114 WEAK void LPSPI2_IRQHandler(void);
115 WEAK void LPUART0_IRQHandler(void);
116 WEAK void LPUART1_IRQHandler(void);
117 WEAK void LPUART2_IRQHandler(void);
118 WEAK void USB0_IRQHandler(void);
119 WEAK void PORTA_IRQHandler(void);
120 WEAK void PORTB_IRQHandler(void);
121 WEAK void PORTC_IRQHandler(void);
122 WEAK void PORTD_IRQHandler(void);
123 WEAK void LPADC0_IRQHandler(void);
124 WEAK void LPCMP0_IRQHandler(void);
125 WEAK void LPDAC0_IRQHandler(void);
126 WEAK void CAU3_Task_Complete_IRQHandler(void);
127 WEAK void CAU3_Security_Violation_IRQHandler(void);
128 WEAK void TRNG_IRQHandler(void);
129 WEAK void LPIT1_IRQHandler(void);
130 WEAK void LPTMR2_IRQHandler(void);
131 WEAK void TPM3_IRQHandler(void);
132 WEAK void LPI2C3_IRQHandler(void);
133 WEAK void LPSPI3_IRQHandler(void);
134 WEAK void LPUART3_IRQHandler(void);
135 WEAK void PORTE_IRQHandler(void);
136 WEAK void LPCMP1_IRQHandler(void);
137 
138 //*****************************************************************************
139 // Forward declaration of the driver IRQ handlers. These are aliased
140 // to the IntDefaultHandler, which is a 'forever' loop. When the driver
141 // defines a handler (with the same name), this will automatically take
142 // precedence over these weak definitions
143 //*****************************************************************************
144 void CTI0_MCM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
145 void DMA0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
146 void DMA1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
147 void DMA2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
148 void DMA3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
149 void DMA4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
150 void DMA5_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
151 void DMA6_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
152 void DMA7_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
153 void DMA8_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
154 void DMA9_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
155 void DMA10_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
156 void DMA11_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
157 void DMA12_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
158 void DMA13_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
159 void DMA14_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
160 void DMA15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
161 void DMA0_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
162 void MSMC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
163 void EWM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
164 void FTFE_Command_Complete_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
165 void FTFE_Read_Collision_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
166 void LLWU0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
167 void MUA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
168 void SPM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
169 void WDOG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
170 void SCG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
171 void LPIT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
172 void RTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
173 void LPTMR0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
174 void LPTMR1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
175 void TPM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
176 void TPM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
177 void TPM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
178 void EMVSIM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
179 void FLEXIO0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
180 void LPI2C0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
181 void LPI2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
182 void LPI2C2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
183 void I2S0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
184 void USDHC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
185 void LPSPI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
186 void LPSPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
187 void LPSPI2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
188 void LPUART0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
189 void LPUART1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
190 void LPUART2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
191 void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
192 void PORTA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
193 void PORTB_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
194 void PORTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
195 void PORTD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
196 void LPADC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
197 void LPCMP0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
198 void LPDAC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
199 void CAU3_Task_Complete_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
200 void CAU3_Security_Violation_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
201 void TRNG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
202 void LPIT1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
203 void LPTMR2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
204 void TPM3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
205 void LPI2C3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
206 void LPSPI3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
207 void LPUART3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
208 void PORTE_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
209 void LPCMP1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
210 
211 //*****************************************************************************
212 // The entry point for the application.
213 // __main() is the entry point for Redlib based applications
214 // main() is the entry point for Newlib based applications
215 //*****************************************************************************
216 #if defined (__REDLIB__)
217 extern void __main(void);
218 #endif
219 extern int main(void);
220 
221 //*****************************************************************************
222 // External declaration for the pointer to the stack top from the Linker Script
223 //*****************************************************************************
224 extern void _vStackTop(void);
225 //*****************************************************************************
226 #if defined (__cplusplus)
227 } // extern "C"
228 #endif
229 //*****************************************************************************
230 // The vector table.
231 // This relies on the linker script to place at correct location in memory.
232 //*****************************************************************************
233 
234 
235 
236 extern void (* const g_pfnVectors[])(void);
237 extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
238 
239 __attribute__ ((used, section(".isr_vector")))
240 void (* const g_pfnVectors[])(void) = {
241     // Core Level - CM4
242     &_vStackTop,                       // The initial stack pointer
243     ResetISR,                          // The reset handler
244     NMI_Handler,                       // The NMI handler
245     HardFault_Handler,                 // The hard fault handler
246     0,                                 // Reserved
247     0,                                 // Reserved
248     0,                                 // Reserved
249     0,                                 // Reserved
250     0,                                 // Reserved
251     0,                                 // Reserved
252     0,                                 // Reserved
253     SVC_Handler,                       // SVCall handler
254     0,                                 // Reserved
255     0,                                 // Reserved
256     PendSV_Handler,                    // The PendSV handler
257     SysTick_Handler,                   // The SysTick handler
258 
259     // Chip Level - K32L3A60_cm4
260     CTI0_MCM0_IRQHandler,                // 16: Cross Trigger Interface 0 / Miscellaneous Control Module
261     DMA0_IRQHandler,                     // 17: DMA0 channel 0 transfer complete
262     DMA1_IRQHandler,                     // 18: DMA0 channel 1 transfer complete
263     DMA2_IRQHandler,                     // 19: DMA0 channel 2 transfer complete
264     DMA3_IRQHandler,                     // 20: DMA0 channel 3 transfer complete
265     DMA4_IRQHandler,                     // 21: DMA0 channel 4 transfer complete
266     DMA5_IRQHandler,                     // 22: DMA0 channel 5 transfer complete
267     DMA6_IRQHandler,                     // 23: DMA0 channel 6 transfer complete
268     DMA7_IRQHandler,                     // 24: DMA0 channel 7 transfer complete
269     DMA8_IRQHandler,                     // 25: DMA0 channel 8 transfer complete
270     DMA9_IRQHandler,                     // 26: DMA0 channel 9 transfer complete
271     DMA10_IRQHandler,                    // 27: DMA0 channel 10 transfer complete
272     DMA11_IRQHandler,                    // 28: DMA0 channel 11 transfer complete
273     DMA12_IRQHandler,                    // 29: DMA0 channel 12 transfer complete
274     DMA13_IRQHandler,                    // 30: DMA0 channel 13 transfer complete
275     DMA14_IRQHandler,                    // 31: DMA0 channel 14 transfer complete
276     DMA15_IRQHandler,                    // 32: DMA0 channel 15 transfer complete
277     DMA0_Error_IRQHandler,               // 33: DMA0 channel 0-15 error interrupt
278     MSMC_IRQHandler,                     // 34: MSMC (SMC0) interrupt
279     EWM_IRQHandler,                      // 35: EWM interrupt
280     FTFE_Command_Complete_IRQHandler,    // 36: FTFE interrupt
281     FTFE_Read_Collision_IRQHandler,      // 37: FTFE interrupt
282     LLWU0_IRQHandler,                    // 38: Low leakage wakeup 0
283     MUA_IRQHandler,                      // 39: MU Side A interrupt
284     SPM_IRQHandler,                      // 40: SPM
285     WDOG0_IRQHandler,                    // 41: WDOG0 interrupt
286     SCG_IRQHandler,                      // 42: SCG interrupt
287     LPIT0_IRQHandler,                    // 43: LPIT0 interrupt
288     RTC_IRQHandler,                      // 44: RTC Alarm interrupt
289     LPTMR0_IRQHandler,                   // 45: LPTMR0 interrupt
290     LPTMR1_IRQHandler,                   // 46: LPTMR1 interrupt
291     TPM0_IRQHandler,                     // 47: TPM0 single interrupt vector for all sources
292     TPM1_IRQHandler,                     // 48: TPM1 single interrupt vector for all sources
293     TPM2_IRQHandler,                     // 49: TPM2 single interrupt vector for all sources
294     EMVSIM0_IRQHandler,                  // 50: EMVSIM0 interrupt
295     FLEXIO0_IRQHandler,                  // 51: FLEXIO0
296     LPI2C0_IRQHandler,                   // 52: LPI2C0 interrupt
297     LPI2C1_IRQHandler,                   // 53: LPI2C1 interrupt
298     LPI2C2_IRQHandler,                   // 54: LPI2C2 interrupt
299     I2S0_IRQHandler,                     // 55: I2S0 interrupt
300     USDHC0_IRQHandler,                   // 56: SDHC0 interrupt
301     LPSPI0_IRQHandler,                   // 57: LPSPI0 single interrupt vector for all sources
302     LPSPI1_IRQHandler,                   // 58: LPSPI1 single interrupt vector for all sources
303     LPSPI2_IRQHandler,                   // 59: LPSPI2 single interrupt vector for all sources
304     LPUART0_IRQHandler,                  // 60: LPUART0 status and error
305     LPUART1_IRQHandler,                  // 61: LPUART1 status and error
306     LPUART2_IRQHandler,                  // 62: LPUART2 status and error
307     USB0_IRQHandler,                     // 63: USB0 interrupt
308     PORTA_IRQHandler,                    // 64: PORTA Pin detect
309     PORTB_IRQHandler,                    // 65: PORTB Pin detect
310     PORTC_IRQHandler,                    // 66: PORTC Pin detect
311     PORTD_IRQHandler,                    // 67: PORTD Pin detect
312     LPADC0_IRQHandler,                   // 68: LPADC0 interrupt
313     LPCMP0_IRQHandler,                   // 69: LPCMP0 interrupt
314     LPDAC0_IRQHandler,                   // 70: LPDAC0 interrupt
315     CAU3_Task_Complete_IRQHandler,       // 71: Cryptographic Acceleration Unit version 3 Task Complete
316     CAU3_Security_Violation_IRQHandler,  // 72: Cryptographic Acceleration Unit version 3 Security Violation
317     TRNG_IRQHandler,                     // 73: TRNG interrupt
318     LPIT1_IRQHandler,                    // 74: LPIT1 interrupt
319     LPTMR2_IRQHandler,                   // 75: LPTMR2 interrupt
320     TPM3_IRQHandler,                     // 76: TPM3 single interrupt vector for all sources
321     LPI2C3_IRQHandler,                   // 77: LPI2C3 interrupt
322     LPSPI3_IRQHandler,                   // 78: LPSPI3 single interrupt vector for all sources
323     LPUART3_IRQHandler,                  // 79: LPUART3 status and error
324     PORTE_IRQHandler,                    // 80: PORTE Pin detect
325     LPCMP1_IRQHandler,                   // 81: LPCMP1 interrupt
326 
327 
328 }; /* End of g_pfnVectors */
329 
330 //*****************************************************************************
331 // Functions to carry out the initialization of RW and BSS data sections. These
332 // are written as separate functions rather than being inlined within the
333 // ResetISR() function in order to cope with MCUs with multiple banks of
334 // memory.
335 //*****************************************************************************
336 __attribute__ ((section(".after_vectors.init_data")))
data_init(unsigned int romstart,unsigned int start,unsigned int len)337 void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
338     unsigned int *pulDest = (unsigned int*) start;
339     unsigned int *pulSrc = (unsigned int*) romstart;
340     unsigned int loop;
341     for (loop = 0; loop < len; loop = loop + 4)
342         *pulDest++ = *pulSrc++;
343 }
344 
345 __attribute__ ((section(".after_vectors.init_bss")))
bss_init(unsigned int start,unsigned int len)346 void bss_init(unsigned int start, unsigned int len) {
347     unsigned int *pulDest = (unsigned int*) start;
348     unsigned int loop;
349     for (loop = 0; loop < len; loop = loop + 4)
350         *pulDest++ = 0;
351 }
352 
353 //*****************************************************************************
354 // The following symbols are constructs generated by the linker, indicating
355 // the location of various points in the "Global Section Table". This table is
356 // created by the linker via the Code Red managed linker script mechanism. It
357 // contains the load address, execution address and length of each RW data
358 // section and the execution and length of each BSS (zero initialized) section.
359 //*****************************************************************************
360 extern unsigned int __data_section_table;
361 extern unsigned int __data_section_table_end;
362 extern unsigned int __bss_section_table;
363 extern unsigned int __bss_section_table_end;
364 
365 //*****************************************************************************
366 // Reset entry point for your code.
367 // Sets up a simple runtime environment and initializes the C/C++
368 // library.
369 //*****************************************************************************
370 __attribute__ ((naked, section(".after_vectors.reset")))
ResetISR(void)371 void ResetISR(void) {
372 
373     // Disable interrupts
374     __asm volatile ("cpsid i");
375 
376 
377 #if defined (__USE_CMSIS)
378 // If __USE_CMSIS defined, then call CMSIS SystemInit code
379     SystemInit();
380 
381 #else
382     // Disable Watchdog
383     // Write watchdog update key to unlock
384     *((volatile unsigned int *)0x41026004) = 0xD928C520;
385     // Set timeout value
386     *((volatile unsigned int *)0x41026008) = 0xFFFF;
387     // Now disable watchdog via control register
388     volatile unsigned int *WDOG_CS = (unsigned int *) 0x41026000;
389     *WDOG_CS = (*WDOG_CS & ~(1 << 7)) | (1 << 5);
390 #endif // (__USE_CMSIS)
391 
392     //
393     // Copy the data sections from flash to SRAM.
394     //
395     unsigned int LoadAddr, ExeAddr, SectionLen;
396     unsigned int *SectionTableAddr;
397 
398     // Load base address of Global Section Table
399     SectionTableAddr = &__data_section_table;
400 
401     // Copy the data sections from flash to SRAM.
402     while (SectionTableAddr < &__data_section_table_end) {
403         LoadAddr = *SectionTableAddr++;
404         ExeAddr = *SectionTableAddr++;
405         SectionLen = *SectionTableAddr++;
406         data_init(LoadAddr, ExeAddr, SectionLen);
407     }
408 
409     // At this point, SectionTableAddr = &__bss_section_table;
410     // Zero fill the bss segment
411     while (SectionTableAddr < &__bss_section_table_end) {
412         ExeAddr = *SectionTableAddr++;
413         SectionLen = *SectionTableAddr++;
414         bss_init(ExeAddr, SectionLen);
415     }
416 
417 #if !defined (__USE_CMSIS)
418 // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
419 // will enable the FPU
420 #if defined (__VFP_FP__) && !defined (__SOFTFP__)
421     //
422     // Code to enable the Cortex-M4 FPU only included
423     // if appropriate build options have been selected.
424     // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
425     //
426     // Read CPACR (located at address 0xE000ED88)
427     // Set bits 20-23 to enable CP10 and CP11 coprocessors
428     // Write back the modified value to the CPACR
429     asm volatile ("LDR.W R0, =0xE000ED88\n\t"
430                   "LDR R1, [R0]\n\t"
431                   "ORR R1, R1, #(0xF << 20)\n\t"
432                   "STR R1, [R0]");
433 #endif // (__VFP_FP__) && !(__SOFTFP__)
434 #endif // (__USE_CMSIS)
435 
436 
437 #if !defined (__USE_CMSIS)
438 // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
439 // will setup the VTOR register
440 
441     // Check to see if we are running the code from a non-zero
442     // address (eg RAM, external flash), in which case we need
443     // to modify the VTOR register to tell the CPU that the
444     // vector table is located at a non-0x0 address.
445     unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
446     if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
447         *pSCB_VTOR = (unsigned int)g_pfnVectors;
448     }
449 #endif // (__USE_CMSIS)
450 #if defined (__cplusplus)
451     //
452     // Call C++ library initialisation
453     //
454     __libc_init_array();
455 #endif
456 
457     // Reenable interrupts
458     __asm volatile ("cpsie i");
459 
460 #if defined (__REDLIB__)
461     // Call the Redlib library, which in turn calls main()
462     __main();
463 #else
464     main();
465 #endif
466 
467     //
468     // main() shouldn't return, but if it does, we'll just enter an infinite loop
469     //
470     while (1) {
471         ;
472     }
473 }
474 
475 //*****************************************************************************
476 // Default core exception handlers. Override the ones here by defining your own
477 // handler routines in your application code.
478 //*****************************************************************************
NMI_Handler(void)479 WEAK_AV void NMI_Handler(void)
480 { while(1) {}
481 }
482 
HardFault_Handler(void)483 WEAK_AV void HardFault_Handler(void)
484 { while(1) {}
485 }
486 
SVC_Handler(void)487 WEAK_AV void SVC_Handler(void)
488 { while(1) {}
489 }
490 
PendSV_Handler(void)491 WEAK_AV void PendSV_Handler(void)
492 { while(1) {}
493 }
494 
SysTick_Handler(void)495 WEAK_AV void SysTick_Handler(void)
496 { while(1) {}
497 }
498 
499 //*****************************************************************************
500 // Processor ends up here if an unexpected interrupt occurs or a specific
501 // handler is not present in the application code.
502 //*****************************************************************************
IntDefaultHandler(void)503 WEAK_AV void IntDefaultHandler(void)
504 { while(1) {}
505 }
506 
507 //*****************************************************************************
508 // Default application exception handlers. Override the ones here by defining
509 // your own handler routines in your application code. These routines call
510 // driver exception handlers or IntDefaultHandler() if no driver exception
511 // handler is included.
512 //*****************************************************************************
CTI0_MCM0_IRQHandler(void)513 WEAK void CTI0_MCM0_IRQHandler(void)
514 {   CTI0_MCM0_DriverIRQHandler();
515 }
516 
DMA0_IRQHandler(void)517 WEAK void DMA0_IRQHandler(void)
518 {   DMA0_DriverIRQHandler();
519 }
520 
DMA1_IRQHandler(void)521 WEAK void DMA1_IRQHandler(void)
522 {   DMA1_DriverIRQHandler();
523 }
524 
DMA2_IRQHandler(void)525 WEAK void DMA2_IRQHandler(void)
526 {   DMA2_DriverIRQHandler();
527 }
528 
DMA3_IRQHandler(void)529 WEAK void DMA3_IRQHandler(void)
530 {   DMA3_DriverIRQHandler();
531 }
532 
DMA4_IRQHandler(void)533 WEAK void DMA4_IRQHandler(void)
534 {   DMA4_DriverIRQHandler();
535 }
536 
DMA5_IRQHandler(void)537 WEAK void DMA5_IRQHandler(void)
538 {   DMA5_DriverIRQHandler();
539 }
540 
DMA6_IRQHandler(void)541 WEAK void DMA6_IRQHandler(void)
542 {   DMA6_DriverIRQHandler();
543 }
544 
DMA7_IRQHandler(void)545 WEAK void DMA7_IRQHandler(void)
546 {   DMA7_DriverIRQHandler();
547 }
548 
DMA8_IRQHandler(void)549 WEAK void DMA8_IRQHandler(void)
550 {   DMA8_DriverIRQHandler();
551 }
552 
DMA9_IRQHandler(void)553 WEAK void DMA9_IRQHandler(void)
554 {   DMA9_DriverIRQHandler();
555 }
556 
DMA10_IRQHandler(void)557 WEAK void DMA10_IRQHandler(void)
558 {   DMA10_DriverIRQHandler();
559 }
560 
DMA11_IRQHandler(void)561 WEAK void DMA11_IRQHandler(void)
562 {   DMA11_DriverIRQHandler();
563 }
564 
DMA12_IRQHandler(void)565 WEAK void DMA12_IRQHandler(void)
566 {   DMA12_DriverIRQHandler();
567 }
568 
DMA13_IRQHandler(void)569 WEAK void DMA13_IRQHandler(void)
570 {   DMA13_DriverIRQHandler();
571 }
572 
DMA14_IRQHandler(void)573 WEAK void DMA14_IRQHandler(void)
574 {   DMA14_DriverIRQHandler();
575 }
576 
DMA15_IRQHandler(void)577 WEAK void DMA15_IRQHandler(void)
578 {   DMA15_DriverIRQHandler();
579 }
580 
DMA0_Error_IRQHandler(void)581 WEAK void DMA0_Error_IRQHandler(void)
582 {   DMA0_Error_DriverIRQHandler();
583 }
584 
MSMC_IRQHandler(void)585 WEAK void MSMC_IRQHandler(void)
586 {   MSMC_DriverIRQHandler();
587 }
588 
EWM_IRQHandler(void)589 WEAK void EWM_IRQHandler(void)
590 {   EWM_DriverIRQHandler();
591 }
592 
FTFE_Command_Complete_IRQHandler(void)593 WEAK void FTFE_Command_Complete_IRQHandler(void)
594 {   FTFE_Command_Complete_DriverIRQHandler();
595 }
596 
FTFE_Read_Collision_IRQHandler(void)597 WEAK void FTFE_Read_Collision_IRQHandler(void)
598 {   FTFE_Read_Collision_DriverIRQHandler();
599 }
600 
LLWU0_IRQHandler(void)601 WEAK void LLWU0_IRQHandler(void)
602 {   LLWU0_DriverIRQHandler();
603 }
604 
MUA_IRQHandler(void)605 WEAK void MUA_IRQHandler(void)
606 {   MUA_DriverIRQHandler();
607 }
608 
SPM_IRQHandler(void)609 WEAK void SPM_IRQHandler(void)
610 {   SPM_DriverIRQHandler();
611 }
612 
WDOG0_IRQHandler(void)613 WEAK void WDOG0_IRQHandler(void)
614 {   WDOG0_DriverIRQHandler();
615 }
616 
SCG_IRQHandler(void)617 WEAK void SCG_IRQHandler(void)
618 {   SCG_DriverIRQHandler();
619 }
620 
LPIT0_IRQHandler(void)621 WEAK void LPIT0_IRQHandler(void)
622 {   LPIT0_DriverIRQHandler();
623 }
624 
RTC_IRQHandler(void)625 WEAK void RTC_IRQHandler(void)
626 {   RTC_DriverIRQHandler();
627 }
628 
LPTMR0_IRQHandler(void)629 WEAK void LPTMR0_IRQHandler(void)
630 {   LPTMR0_DriverIRQHandler();
631 }
632 
LPTMR1_IRQHandler(void)633 WEAK void LPTMR1_IRQHandler(void)
634 {   LPTMR1_DriverIRQHandler();
635 }
636 
TPM0_IRQHandler(void)637 WEAK void TPM0_IRQHandler(void)
638 {   TPM0_DriverIRQHandler();
639 }
640 
TPM1_IRQHandler(void)641 WEAK void TPM1_IRQHandler(void)
642 {   TPM1_DriverIRQHandler();
643 }
644 
TPM2_IRQHandler(void)645 WEAK void TPM2_IRQHandler(void)
646 {   TPM2_DriverIRQHandler();
647 }
648 
EMVSIM0_IRQHandler(void)649 WEAK void EMVSIM0_IRQHandler(void)
650 {   EMVSIM0_DriverIRQHandler();
651 }
652 
FLEXIO0_IRQHandler(void)653 WEAK void FLEXIO0_IRQHandler(void)
654 {   FLEXIO0_DriverIRQHandler();
655 }
656 
LPI2C0_IRQHandler(void)657 WEAK void LPI2C0_IRQHandler(void)
658 {   LPI2C0_DriverIRQHandler();
659 }
660 
LPI2C1_IRQHandler(void)661 WEAK void LPI2C1_IRQHandler(void)
662 {   LPI2C1_DriverIRQHandler();
663 }
664 
LPI2C2_IRQHandler(void)665 WEAK void LPI2C2_IRQHandler(void)
666 {   LPI2C2_DriverIRQHandler();
667 }
668 
I2S0_IRQHandler(void)669 WEAK void I2S0_IRQHandler(void)
670 {   I2S0_DriverIRQHandler();
671 }
672 
USDHC0_IRQHandler(void)673 WEAK void USDHC0_IRQHandler(void)
674 {   USDHC0_DriverIRQHandler();
675 }
676 
LPSPI0_IRQHandler(void)677 WEAK void LPSPI0_IRQHandler(void)
678 {   LPSPI0_DriverIRQHandler();
679 }
680 
LPSPI1_IRQHandler(void)681 WEAK void LPSPI1_IRQHandler(void)
682 {   LPSPI1_DriverIRQHandler();
683 }
684 
LPSPI2_IRQHandler(void)685 WEAK void LPSPI2_IRQHandler(void)
686 {   LPSPI2_DriverIRQHandler();
687 }
688 
LPUART0_IRQHandler(void)689 WEAK void LPUART0_IRQHandler(void)
690 {   LPUART0_DriverIRQHandler();
691 }
692 
LPUART1_IRQHandler(void)693 WEAK void LPUART1_IRQHandler(void)
694 {   LPUART1_DriverIRQHandler();
695 }
696 
LPUART2_IRQHandler(void)697 WEAK void LPUART2_IRQHandler(void)
698 {   LPUART2_DriverIRQHandler();
699 }
700 
USB0_IRQHandler(void)701 WEAK void USB0_IRQHandler(void)
702 {   USB0_DriverIRQHandler();
703 }
704 
PORTA_IRQHandler(void)705 WEAK void PORTA_IRQHandler(void)
706 {   PORTA_DriverIRQHandler();
707 }
708 
PORTB_IRQHandler(void)709 WEAK void PORTB_IRQHandler(void)
710 {   PORTB_DriverIRQHandler();
711 }
712 
PORTC_IRQHandler(void)713 WEAK void PORTC_IRQHandler(void)
714 {   PORTC_DriverIRQHandler();
715 }
716 
PORTD_IRQHandler(void)717 WEAK void PORTD_IRQHandler(void)
718 {   PORTD_DriverIRQHandler();
719 }
720 
LPADC0_IRQHandler(void)721 WEAK void LPADC0_IRQHandler(void)
722 {   LPADC0_DriverIRQHandler();
723 }
724 
LPCMP0_IRQHandler(void)725 WEAK void LPCMP0_IRQHandler(void)
726 {   LPCMP0_DriverIRQHandler();
727 }
728 
LPDAC0_IRQHandler(void)729 WEAK void LPDAC0_IRQHandler(void)
730 {   LPDAC0_DriverIRQHandler();
731 }
732 
CAU3_Task_Complete_IRQHandler(void)733 WEAK void CAU3_Task_Complete_IRQHandler(void)
734 {   CAU3_Task_Complete_DriverIRQHandler();
735 }
736 
CAU3_Security_Violation_IRQHandler(void)737 WEAK void CAU3_Security_Violation_IRQHandler(void)
738 {   CAU3_Security_Violation_DriverIRQHandler();
739 }
740 
TRNG_IRQHandler(void)741 WEAK void TRNG_IRQHandler(void)
742 {   TRNG_DriverIRQHandler();
743 }
744 
LPIT1_IRQHandler(void)745 WEAK void LPIT1_IRQHandler(void)
746 {   LPIT1_DriverIRQHandler();
747 }
748 
LPTMR2_IRQHandler(void)749 WEAK void LPTMR2_IRQHandler(void)
750 {   LPTMR2_DriverIRQHandler();
751 }
752 
TPM3_IRQHandler(void)753 WEAK void TPM3_IRQHandler(void)
754 {   TPM3_DriverIRQHandler();
755 }
756 
LPI2C3_IRQHandler(void)757 WEAK void LPI2C3_IRQHandler(void)
758 {   LPI2C3_DriverIRQHandler();
759 }
760 
LPSPI3_IRQHandler(void)761 WEAK void LPSPI3_IRQHandler(void)
762 {   LPSPI3_DriverIRQHandler();
763 }
764 
LPUART3_IRQHandler(void)765 WEAK void LPUART3_IRQHandler(void)
766 {   LPUART3_DriverIRQHandler();
767 }
768 
PORTE_IRQHandler(void)769 WEAK void PORTE_IRQHandler(void)
770 {   PORTE_DriverIRQHandler();
771 }
772 
LPCMP1_IRQHandler(void)773 WEAK void LPCMP1_IRQHandler(void)
774 {   LPCMP1_DriverIRQHandler();
775 }
776 
777 //*****************************************************************************
778 
779 #if defined (DEBUG)
780 #pragma GCC pop_options
781 #endif // (DEBUG)
782