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