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