1 //*****************************************************************************
2 // MIMX8MSCALE_M4 startup code for use with MCUXpresso IDE
3 //
4 // Version : 160922
5 //*****************************************************************************
6 //
7 // Copyright 2016, NXP
8 // All rights reserved.
9 //
10 // Software that is described herein is for illustrative purposes only
11 // which provides customers with programming information regarding the
12 // LPC products. This software is supplied "AS IS" without any warranties of
13 // any kind, and NXP Semiconductors and its licensor disclaim any and
14 // all warranties, express or implied, including all implied warranties of
15 // merchantability, fitness for a particular purpose and non-infringement of
16 // intellectual property rights. NXP Semiconductors assumes no responsibility
17 // or liability for the use of the software, conveys no license or rights under any
18 // patent, copyright, mask work right, or any other intellectual property rights in
19 // or to any products. NXP Semiconductors reserves the right to make changes
20 // in the software without notification. NXP Semiconductors also makes no
21 // representation or warranty that such application will be suitable for the
22 // specified use without further testing or modification.
23 //
24 // Permission to use, copy, modify, and distribute this software and its
25 // documentation is hereby granted, under NXP Semiconductors' and its
26 // licensor's relevant copyrights in the software, without fee, provided that it
27 // is used in conjunction with NXP Semiconductors microcontrollers. This
28 // copyright, permission, and disclaimer notice must appear in all copies of
29 // this code.
30 //*****************************************************************************
31
32 #if defined (DEBUG)
33 #pragma GCC push_options
34 #pragma GCC optimize ("Og")
35 #endif // (DEBUG)
36
37 #if defined (__cplusplus)
38 #ifdef __REDLIB__
39 #error Redlib does not support C++
40 #else
41 //*****************************************************************************
42 //
43 // The entry point for the C++ library startup
44 //
45 //*****************************************************************************
46 extern "C" {
47 extern void __libc_init_array(void);
48 }
49 #endif
50 #endif
51
52 #define WEAK __attribute__ ((weak))
53 #define WEAK_AV __attribute__ ((weak, section(".after_vectors")))
54 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
55
56 //*****************************************************************************
57 #if defined (__cplusplus)
58 extern "C" {
59 #endif
60
61 //*****************************************************************************
62 // Declaration of external SystemInit function
63 //*****************************************************************************
64 #if defined (__USE_CMSIS)
65 extern void SystemInit(void);
66 #endif // (__USE_CMSIS)
67
68 //*****************************************************************************
69 // Forward declaration of the core exception handlers.
70 // When the application defines a handler (with the same name), this will
71 // automatically take precedence over these weak definitions
72 //*****************************************************************************
73 void ResetISR(void);
74 WEAK void NMI_Handler(void);
75 WEAK void HardFault_Handler(void);
76 WEAK void MemManage_Handler(void);
77 WEAK void BusFault_Handler(void);
78 WEAK void UsageFault_Handler(void);
79 WEAK void SVC_Handler(void);
80 WEAK void DebugMon_Handler(void);
81 WEAK void PendSV_Handler(void);
82 WEAK void SysTick_Handler(void);
83 WEAK void IntDefaultHandler(void);
84 //*****************************************************************************
85 // Forward declaration of the application IRQ handlers. When the application
86 // defines a handler (with the same name), this will automatically take
87 // precedence over weak definitions below
88 //*****************************************************************************
89 WEAK void CTI0_IRQHandler(void);
90 WEAK void DMA0_0_4_IRQHandler(void);
91 WEAK void DMA0_1_5_IRQHandler(void);
92 WEAK void DMA0_2_6_IRQHandler(void);
93 WEAK void DMA0_3_7_IRQHandler(void);
94 WEAK void DMA0_8_12_IRQHandler(void);
95 WEAK void DMA0_9_13_IRQHandler(void);
96 WEAK void DMA0_10_14_IRQHandler(void);
97 WEAK void DMA0_11_15_IRQHandler(void);
98 WEAK void DMA0_16_20_IRQHandler(void);
99 WEAK void DMA0_17_21_IRQHandler(void);
100 WEAK void DMA0_18_22_IRQHandler(void);
101 WEAK void DMA0_19_23_IRQHandler(void);
102 WEAK void DMA0_24_28_IRQHandler(void);
103 WEAK void DMA0_25_29_IRQHandler(void);
104 WEAK void DMA0_26_30_IRQHandler(void);
105 WEAK void DMA0_27_31_IRQHandler(void);
106 WEAK void DMA0_Error_IRQHandler(void);
107 WEAK void MCM0_IRQHandler(void);
108 WEAK void EWM_IRQHandler(void);
109 WEAK void LLWU0_IRQHandler(void);
110 WEAK void SIM_IRQHandler(void);
111 WEAK void MU_A_IRQHandler(void);
112 WEAK void Reserved39_IRQHandler(void);
113 WEAK void Software1_IRQHandler(void);
114 WEAK void Software2_IRQHandler(void);
115 WEAK void WDOG0_IRQHandler(void);
116 WEAK void SCG0_IRQHandler(void);
117 WEAK void QSPI_IRQHandler(void);
118 WEAK void LTC_IRQHandler(void);
119 WEAK void Reserved46_IRQHandler(void);
120 WEAK void SNVS_IRQHandler(void);
121 WEAK void TRNG0_IRQHandler(void);
122 WEAK void LPIT0_IRQHandler(void);
123 WEAK void PMC0_IRQHandler(void);
124 WEAK void CMC0_IRQHandler(void);
125 WEAK void LPTMR0_IRQHandler(void);
126 WEAK void LPTMR1_IRQHandler(void);
127 WEAK void TPM0_IRQHandler(void);
128 WEAK void TPM1_IRQHandler(void);
129 WEAK void TPM2_IRQHandler(void);
130 WEAK void TPM3_IRQHandler(void);
131 WEAK void FLEXIO0_IRQHandler(void);
132 WEAK void LPI2C0_IRQHandler(void);
133 WEAK void LPI2C1_IRQHandler(void);
134 WEAK void LPI2C2_IRQHandler(void);
135 WEAK void LPI2C3_IRQHandler(void);
136 WEAK void SAI0_IRQHandler(void);
137 WEAK void SAI1_IRQHandler(void);
138 WEAK void LPSPI0_IRQHandler(void);
139 WEAK void LPSPI1_IRQHandler(void);
140 WEAK void LPUART0_IRQHandler(void);
141 WEAK void LPUART1_IRQHandler(void);
142 WEAK void LPUART2_IRQHandler(void);
143 WEAK void LPUART3_IRQHandler(void);
144 WEAK void DPM_IRQHandler(void);
145 WEAK void PCTLA_IRQHandler(void);
146 WEAK void PCTLB_IRQHandler(void);
147 WEAK void ADC0_IRQHandler(void);
148 WEAK void ADC1_IRQHandler(void);
149 WEAK void CMP0_IRQHandler(void);
150 WEAK void CMP1_IRQHandler(void);
151 WEAK void DAC0_IRQHandler(void);
152 WEAK void DAC1_IRQHandler(void);
153 WEAK void WDOG1_IRQHandler(void);
154 WEAK void USB0_IRQHandler(void);
155 WEAK void USB1_IRQHandler(void);
156 WEAK void Reserved83_IRQHandler(void);
157 WEAK void WDOG2_IRQHandler(void);
158 WEAK void USBPHY_IRQHandler(void);
159 WEAK void CMC1_IRQHandler(void);
160
161 //*****************************************************************************
162 // Forward declaration of the driver IRQ handlers. These are aliased
163 // to the IntDefaultHandler, which is a 'forever' loop. When the driver
164 // defines a handler (with the same name), this will automatically take
165 // precedence over these weak definitions
166 //*****************************************************************************
167 void CTI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
168 void DMA0_0_4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
169 void DMA0_1_5_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
170 void DMA0_2_6_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
171 void DMA0_3_7_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
172 void DMA0_8_12_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
173 void DMA0_9_13_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
174 void DMA0_10_14_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
175 void DMA0_11_15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
176 void DMA0_16_20_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
177 void DMA0_17_21_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
178 void DMA0_18_22_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
179 void DMA0_19_23_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
180 void DMA0_24_28_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
181 void DMA0_25_29_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
182 void DMA0_26_30_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
183 void DMA0_27_31_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
184 void DMA0_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
185 void MCM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
186 void EWM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
187 void LLWU0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
188 void SIM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
189 void MU_A_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
190 void Reserved39_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
191 void Software1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
192 void Software2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
193 void WDOG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
194 void SCG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
195 void QSPI_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
196 void LTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
197 void Reserved46_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
198 void SNVS_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
199 void TRNG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
200 void LPIT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
201 void PMC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
202 void CMC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
203 void LPTMR0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
204 void LPTMR1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
205 void TPM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
206 void TPM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
207 void TPM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
208 void TPM3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
209 void FLEXIO0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
210 void LPI2C0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
211 void LPI2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
212 void LPI2C2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
213 void LPI2C3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
214 void SAI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
215 void SAI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
216 void LPSPI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
217 void LPSPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
218 void LPUART0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
219 void LPUART1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
220 void LPUART2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
221 void LPUART3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
222 void DPM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
223 void PCTLA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
224 void PCTLB_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
225 void ADC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
226 void ADC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
227 void CMP0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
228 void CMP1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
229 void DAC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
230 void DAC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
231 void WDOG1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
232 void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
233 void USB1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
234 void Reserved83_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
235 void WDOG2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
236 void USBPHY_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
237 void CMC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
238
239 //*****************************************************************************
240 // The entry point for the application.
241 // __main() is the entry point for Redlib based applications
242 // main() is the entry point for Newlib based applications
243 //*****************************************************************************
244 #if defined (__REDLIB__)
245 extern void __main(void);
246 #endif
247 extern int main(void);
248
249 //*****************************************************************************
250 // External declaration for the pointer to the stack top from the Linker Script
251 //*****************************************************************************
252 extern void _vStackTop(void);
253
254 //*****************************************************************************
255 #if defined (__cplusplus)
256 } // extern "C"
257 #endif
258
259 //*****************************************************************************
260 // The vector table.
261 // This relies on the linker script to place at correct location in memory.
262 //*****************************************************************************
263 extern void (* const g_pfnVectors[])(void);
264 __attribute__ ((section(".isr_vector")))
265 void (* const g_pfnVectors[])(void) = {
266 &_vStackTop, // The initial stack pointer
267 ResetISR, // The reset handler
268 NMI_Handler, //NMI Handler
269 HardFault_Handler, //Hard Fault Handler
270 MemManage_Handler, //MPU Fault Handler
271 BusFault_Handler, //Bus Fault Handler
272 UsageFault_Handler, //Usage Fault Handler
273 0, //Reserved
274 0, //Reserved
275 0, //Reserved
276 0, //Reserved
277 SVC_Handler, //SVCall Handler
278 DebugMon_Handler, //Debug Monitor Handler
279 0, //Reserved
280 PendSV_Handler, //PendSV Handler
281 SysTick_Handler, //SysTick Handler
282 //External Interrupts
283 CTI0_IRQHandler, //Cross Trigger Interface for CM4
284 DMA0_0_4_IRQHandler, //DMA Channel 0, 4 Transfer Complete
285 DMA0_1_5_IRQHandler, //DMA Channel 1, 5 Transfer Complete
286 DMA0_2_6_IRQHandler, //DMA Channel 2, 6 Transfer Complete
287 DMA0_3_7_IRQHandler, //DMA Channel 3, 7 Transfer Complete
288 DMA0_8_12_IRQHandler, //DMA Channel 8, 12 Transfer Complete
289 DMA0_9_13_IRQHandler, //DMA Channel 9, 13 Transfer Complete
290 DMA0_10_14_IRQHandler, //DMA Channel 10, 14 Transfer Complete
291 DMA0_11_15_IRQHandler, //DMA Channel 11, 15 Transfer Complete
292 DMA0_16_20_IRQHandler, //DMA Channel 16, 20 Transfer Complete
293 DMA0_17_21_IRQHandler, //DMA Channel 17, 21 Transfer Complete
294 DMA0_18_22_IRQHandler, //DMA Channel 18, 22 Transfer Complete
295 DMA0_19_23_IRQHandler, //DMA Channel 19, 23 Transfer Complete
296 DMA0_24_28_IRQHandler, //DMA Channel 24, 28 Transfer Complete
297 DMA0_25_29_IRQHandler, //DMA Channel 25, 29 Transfer Complete
298 DMA0_26_30_IRQHandler, //DMA Channel 26, 30 Transfer Complete
299 DMA0_27_31_IRQHandler, //DMA Channel 27, 31 Transfer Complete
300 DMA0_Error_IRQHandler, //DMA Error Interrupt - All Channels
301 MCM0_IRQHandler, //MCM Interrupt
302 EWM_IRQHandler, //External Watchdog Monitor Interrupt
303 LLWU0_IRQHandler, //Low Leakage Wake Up
304 SIM_IRQHandler, //System Integation Module
305 MU_A_IRQHandler, //Messaging Unit - Side A
306 Reserved39_IRQHandler, //Secured JTAG Controller
307 Software1_IRQHandler, //Software Interrupt
308 Software2_IRQHandler, //Software Interrupt
309 WDOG0_IRQHandler, //Watchdog Interrupt
310 SCG0_IRQHandler, //System Clock Generator for M4 domain
311 QSPI_IRQHandler, //Quad Serial Peripheral Interface
312 LTC_IRQHandler, //Low Power Trusted Cryptography
313 Reserved46_IRQHandler, //Reserved
314 SNVS_IRQHandler, //Secure Non-Volatile Storage Consolidated Interrupt
315 TRNG0_IRQHandler, //Random Number Generator
316 LPIT0_IRQHandler, //Low Power Periodic Interrupt Timer
317 PMC0_IRQHandler, //Power Management Control interrupts for M4 domain
318 CMC0_IRQHandler, //Core Mode Controller interrupts for M4 domain
319 LPTMR0_IRQHandler, //Low Power Timer
320 LPTMR1_IRQHandler, //Low Power Timer
321 TPM0_IRQHandler, //Timer PWM module
322 TPM1_IRQHandler, //Timer PWM module
323 TPM2_IRQHandler, //Timer PWM module
324 TPM3_IRQHandler, //Timer PWM module
325 FLEXIO0_IRQHandler, //Flexible IO
326 LPI2C0_IRQHandler, //Inter-integrated circuit 0
327 LPI2C1_IRQHandler, //Inter-integrated circuit 1
328 LPI2C2_IRQHandler, //Inter-integrated circuit 2
329 LPI2C3_IRQHandler, //Inter-integrated circuit 3
330 SAI0_IRQHandler, //Serial Audio Interface
331 SAI1_IRQHandler, //Serial Audio Interface 1
332 LPSPI0_IRQHandler, //Low Power Serial Peripheral Interface
333 LPSPI1_IRQHandler, //Low Power Serial Peripheral Interface
334 LPUART0_IRQHandler, //Low Power UART
335 LPUART1_IRQHandler, //Low Power UART
336 LPUART2_IRQHandler, //Low Power UART
337 LPUART3_IRQHandler, //Low Power UART
338 DPM_IRQHandler, //Dynamic Process Monitor
339 PCTLA_IRQHandler, //Port A pin interrupt
340 PCTLB_IRQHandler, //Port B pin interrupt
341 ADC0_IRQHandler, //Analog to Digital Convertor
342 ADC1_IRQHandler, //Analog to Digital Convertor
343 CMP0_IRQHandler, //Comparator
344 CMP1_IRQHandler, //Comparator
345 DAC0_IRQHandler, //Digital to Analog Convertor
346 DAC1_IRQHandler, //Digital to Analog Convertor
347 WDOG1_IRQHandler, //Watchdog Interrupt from A7 subsystem
348 USB0_IRQHandler, //USB 0 Interrupt from A7 subsystem
349 USB1_IRQHandler, //USB 1 Interrupt from A7 subsystem
350 Reserved83_IRQHandler, //
351 WDOG2_IRQHandler, //Watchdog Interrupt from A7 subsystem
352 USBPHY_IRQHandler, //USB PHY (used in conjunction with USBOTG0)
353 CMC1_IRQHandler, //A7 resets
354 }; /* End of g_pfnVectors */
355
356 //*****************************************************************************
357 // Functions to carry out the initialization of RW and BSS data sections. These
358 // are written as separate functions rather than being inlined within the
359 // ResetISR() function in order to cope with MCUs with multiple banks of
360 // memory.
361 //*****************************************************************************
362 __attribute__ ((section(".after_vectors.init_data")))
data_init(unsigned int romstart,unsigned int start,unsigned int len)363 void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
364 unsigned int *pulDest = (unsigned int*) start;
365 unsigned int *pulSrc = (unsigned int*) romstart;
366 unsigned int loop;
367 for (loop = 0; loop < len; loop = loop + 4)
368 *pulDest++ = *pulSrc++;
369 }
370
371 __attribute__ ((section(".after_vectors.init_bss")))
bss_init(unsigned int start,unsigned int len)372 void bss_init(unsigned int start, unsigned int len) {
373 unsigned int *pulDest = (unsigned int*) start;
374 unsigned int loop;
375 for (loop = 0; loop < len; loop = loop + 4)
376 *pulDest++ = 0;
377 }
378
379 //*****************************************************************************
380 // The following symbols are constructs generated by the linker, indicating
381 // the location of various points in the "Global Section Table". This table is
382 // created by the linker via the Code Red managed linker script mechanism. It
383 // contains the load address, execution address and length of each RW data
384 // section and the execution and length of each BSS (zero initialized) section.
385 //*****************************************************************************
386 extern unsigned int __data_section_table;
387 extern unsigned int __data_section_table_end;
388 extern unsigned int __bss_section_table;
389 extern unsigned int __bss_section_table_end;
390
391 //*****************************************************************************
392 // Reset entry point for your code.
393 // Sets up a simple runtime environment and initializes the C/C++
394 // library.
395 //*****************************************************************************
396 __attribute__ ((naked, section(".after_vectors.reset")))
397 void
ResetISR(void)398 ResetISR(void) {
399 // Disable interrupts
400 __asm volatile ("cpsid i");
401
402 #if defined (__USE_CMSIS)
403 // If __USE_CMSIS defined, then call CMSIS SystemInit code
404 SystemInit();
405 #endif // (__USE_CMSIS)
406
407 //
408 // Copy the data sections from flash to SRAM.
409 //
410 unsigned int LoadAddr, ExeAddr, SectionLen;
411 unsigned int *SectionTableAddr;
412
413 // Load base address of Global Section Table
414 SectionTableAddr = &__data_section_table;
415
416 // Copy the data sections from flash to SRAM.
417 while (SectionTableAddr < &__data_section_table_end) {
418 LoadAddr = *SectionTableAddr++;
419 ExeAddr = *SectionTableAddr++;
420 SectionLen = *SectionTableAddr++;
421 data_init(LoadAddr, ExeAddr, SectionLen);
422 }
423
424 // At this point, SectionTableAddr = &__bss_section_table;
425 // Zero fill the bss segment
426 while (SectionTableAddr < &__bss_section_table_end) {
427 ExeAddr = *SectionTableAddr++;
428 SectionLen = *SectionTableAddr++;
429 bss_init(ExeAddr, SectionLen);
430 }
431
432 #if !defined (__USE_CMSIS)
433 // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
434 // will enable the FPU
435 #if defined (__VFP_FP__) && !defined (__SOFTFP__)
436 //
437 // Code to enable the Cortex-M4 FPU only included
438 // if appropriate build options have been selected.
439 // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
440 //
441 // Read CPACR (located at address 0xE000ED88)
442 // Set bits 20-23 to enable CP10 and CP11 coprocessors
443 // Write back the modified value to the CPACR
444 asm volatile ("LDR.W R0, =0xE000ED88\n\t"
445 "LDR R1, [R0]\n\t"
446 "ORR R1, R1, #(0xF << 20)\n\t"
447 "STR R1, [R0]");
448 #endif // (__VFP_FP__) && !(__SOFTFP__)
449 #endif // (__USE_CMSIS)
450
451 #if !defined (__USE_CMSIS)
452 // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
453 // will setup the VTOR register
454
455 // Check to see if we are running the code from a non-zero
456 // address (eg RAM, external flash), in which case we need
457 // to modify the VTOR register to tell the CPU that the
458 // vector table is located at a non-0x0 address.
459 unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
460 if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
461 *pSCB_VTOR = (unsigned int)g_pfnVectors;
462 }
463 #endif // (__USE_CMSIS)
464
465 #if defined (__cplusplus)
466 //
467 // Call C++ library initialisation
468 //
469 __libc_init_array();
470 #endif
471
472
473 // Reenable interrupts
474 __asm volatile ("cpsie i");
475
476 #if defined (__REDLIB__)
477 // Call the Redlib library, which in turn calls main()
478 __main() ;
479 #else
480 main();
481 #endif
482
483 //
484 // main() shouldn't return, but if it does, we'll just enter an infinite loop
485 //
486 while (1) {
487 ;
488 }
489 }
490
491 //*****************************************************************************
492 // Default core exception handlers. Override the ones here by defining your own
493 // handler routines in your application code.
494 //*****************************************************************************
NMI_Handler(void)495 WEAK void NMI_Handler(void) //NMI Handler
496 { while(1) {}
497 }
498
HardFault_Handler(void)499 WEAK void HardFault_Handler(void) //Hard Fault Handler
500 { while(1) {}
501 }
502
MemManage_Handler(void)503 WEAK void MemManage_Handler(void) //MPU Fault Handler
504 { while(1) {}
505 }
506
BusFault_Handler(void)507 WEAK void BusFault_Handler(void) //Bus Fault Handler
508 { while(1) {}
509 }
510
UsageFault_Handler(void)511 WEAK void UsageFault_Handler(void) //Usage Fault Handler
512 { while(1) {}
513 }
514
SVC_Handler(void)515 WEAK void SVC_Handler(void) //SVCall Handler
516 { while(1) {}
517 }
518
DebugMon_Handler(void)519 WEAK void DebugMon_Handler(void) //Debug Monitor Handler
520 { while(1) {}
521 }
522
PendSV_Handler(void)523 WEAK void PendSV_Handler(void) //PendSV Handler
524 { while(1) {}
525 }
526
SysTick_Handler(void)527 WEAK void SysTick_Handler(void) //SysTick Handler
528 { while(1) {}
529 }
530
531 //*****************************************************************************
532 // Processor ends up here if an unexpected interrupt occurs or a specific
533 // handler is not present in the application code.
534 //*****************************************************************************
IntDefaultHandler(void)535 WEAK_AV void IntDefaultHandler(void)
536 { while(1) {}
537 }
538
539 //*****************************************************************************
540 // Default application exception handlers. Override the ones here by defining
541 // your own handler routines in your application code. These routines call
542 // driver exception handlers or IntDefaultHandler() if no driver exception
543 // handler is included.
544 //*****************************************************************************
CTI0_IRQHandler(void)545 WEAK void CTI0_IRQHandler(void) //Cross Trigger Interface for CM4
546 { CTI0_DriverIRQHandler();
547 }
548
DMA0_0_4_IRQHandler(void)549 WEAK void DMA0_0_4_IRQHandler(void) //DMA Channel 0, 4 Transfer Complete
550 { DMA0_0_4_DriverIRQHandler();
551 }
552
DMA0_1_5_IRQHandler(void)553 WEAK void DMA0_1_5_IRQHandler(void) //DMA Channel 1, 5 Transfer Complete
554 { DMA0_1_5_DriverIRQHandler();
555 }
556
DMA0_2_6_IRQHandler(void)557 WEAK void DMA0_2_6_IRQHandler(void) //DMA Channel 2, 6 Transfer Complete
558 { DMA0_2_6_DriverIRQHandler();
559 }
560
DMA0_3_7_IRQHandler(void)561 WEAK void DMA0_3_7_IRQHandler(void) //DMA Channel 3, 7 Transfer Complete
562 { DMA0_3_7_DriverIRQHandler();
563 }
564
DMA0_8_12_IRQHandler(void)565 WEAK void DMA0_8_12_IRQHandler(void) //DMA Channel 8, 12 Transfer Complete
566 { DMA0_8_12_DriverIRQHandler();
567 }
568
DMA0_9_13_IRQHandler(void)569 WEAK void DMA0_9_13_IRQHandler(void) //DMA Channel 9, 13 Transfer Complete
570 { DMA0_9_13_DriverIRQHandler();
571 }
572
DMA0_10_14_IRQHandler(void)573 WEAK void DMA0_10_14_IRQHandler(void) //DMA Channel 10, 14 Transfer Complete
574 { DMA0_10_14_DriverIRQHandler();
575 }
576
DMA0_11_15_IRQHandler(void)577 WEAK void DMA0_11_15_IRQHandler(void) //DMA Channel 11, 15 Transfer Complete
578 { DMA0_11_15_DriverIRQHandler();
579 }
580
DMA0_16_20_IRQHandler(void)581 WEAK void DMA0_16_20_IRQHandler(void) //DMA Channel 16, 20 Transfer Complete
582 { DMA0_16_20_DriverIRQHandler();
583 }
584
DMA0_17_21_IRQHandler(void)585 WEAK void DMA0_17_21_IRQHandler(void) //DMA Channel 17, 21 Transfer Complete
586 { DMA0_17_21_DriverIRQHandler();
587 }
588
DMA0_18_22_IRQHandler(void)589 WEAK void DMA0_18_22_IRQHandler(void) //DMA Channel 18, 22 Transfer Complete
590 { DMA0_18_22_DriverIRQHandler();
591 }
592
DMA0_19_23_IRQHandler(void)593 WEAK void DMA0_19_23_IRQHandler(void) //DMA Channel 19, 23 Transfer Complete
594 { DMA0_19_23_DriverIRQHandler();
595 }
596
DMA0_24_28_IRQHandler(void)597 WEAK void DMA0_24_28_IRQHandler(void) //DMA Channel 24, 28 Transfer Complete
598 { DMA0_24_28_DriverIRQHandler();
599 }
600
DMA0_25_29_IRQHandler(void)601 WEAK void DMA0_25_29_IRQHandler(void) //DMA Channel 25, 29 Transfer Complete
602 { DMA0_25_29_DriverIRQHandler();
603 }
604
DMA0_26_30_IRQHandler(void)605 WEAK void DMA0_26_30_IRQHandler(void) //DMA Channel 26, 30 Transfer Complete
606 { DMA0_26_30_DriverIRQHandler();
607 }
608
DMA0_27_31_IRQHandler(void)609 WEAK void DMA0_27_31_IRQHandler(void) //DMA Channel 27, 31 Transfer Complete
610 { DMA0_27_31_DriverIRQHandler();
611 }
612
DMA0_Error_IRQHandler(void)613 WEAK void DMA0_Error_IRQHandler(void) //DMA Error Interrupt - All Channels
614 { DMA0_Error_DriverIRQHandler();
615 }
616
MCM0_IRQHandler(void)617 WEAK void MCM0_IRQHandler(void) //MCM Interrupt
618 { MCM0_DriverIRQHandler();
619 }
620
EWM_IRQHandler(void)621 WEAK void EWM_IRQHandler(void) //External Watchdog Monitor Interrupt
622 { EWM_DriverIRQHandler();
623 }
624
LLWU0_IRQHandler(void)625 WEAK void LLWU0_IRQHandler(void) //Low Leakage Wake Up
626 { LLWU0_DriverIRQHandler();
627 }
628
SIM_IRQHandler(void)629 WEAK void SIM_IRQHandler(void) //System Integation Module
630 { SIM_DriverIRQHandler();
631 }
632
MU_A_IRQHandler(void)633 WEAK void MU_A_IRQHandler(void) //Messaging Unit - Side A
634 { MU_A_DriverIRQHandler();
635 }
636
Software1_IRQHandler(void)637 WEAK void Software1_IRQHandler(void) //Software Interrupt
638 { Software1_DriverIRQHandler();
639 }
640
Software2_IRQHandler(void)641 WEAK void Software2_IRQHandler(void) //Software Interrupt
642 { Software2_DriverIRQHandler();
643 }
644
WDOG0_IRQHandler(void)645 WEAK void WDOG0_IRQHandler(void) //Watchdog Interrupt
646 { WDOG0_DriverIRQHandler();
647 }
648
SCG0_IRQHandler(void)649 WEAK void SCG0_IRQHandler(void) //System Clock Generator for M4 domain
650 { SCG0_DriverIRQHandler();
651 }
652
QSPI_IRQHandler(void)653 WEAK void QSPI_IRQHandler(void) //Quad Serial Peripheral Interface
654 { QSPI_DriverIRQHandler();
655 }
656
LTC_IRQHandler(void)657 WEAK void LTC_IRQHandler(void) //Low Power Trusted Cryptography
658 { LTC_DriverIRQHandler();
659 }
660
SNVS_IRQHandler(void)661 WEAK void SNVS_IRQHandler(void) //Secure Non-Volatile Storage Consolidated Interrupt
662 { SNVS_DriverIRQHandler();
663 }
664
TRNG0_IRQHandler(void)665 WEAK void TRNG0_IRQHandler(void) //Random Number Generator
666 { TRNG0_DriverIRQHandler();
667 }
668
LPIT0_IRQHandler(void)669 WEAK void LPIT0_IRQHandler(void) //Low Power Periodic Interrupt Timer
670 { LPIT0_DriverIRQHandler();
671 }
672
PMC0_IRQHandler(void)673 WEAK void PMC0_IRQHandler(void) //Power Management Control interrupts for M4 domain
674 { PMC0_DriverIRQHandler();
675 }
676
CMC0_IRQHandler(void)677 WEAK void CMC0_IRQHandler(void) //Core Mode Controller interrupts for M4 domain
678 { CMC0_DriverIRQHandler();
679 }
680
LPTMR0_IRQHandler(void)681 WEAK void LPTMR0_IRQHandler(void) //Low Power Timer
682 { LPTMR0_DriverIRQHandler();
683 }
684
LPTMR1_IRQHandler(void)685 WEAK void LPTMR1_IRQHandler(void) //Low Power Timer
686 { LPTMR1_DriverIRQHandler();
687 }
688
TPM0_IRQHandler(void)689 WEAK void TPM0_IRQHandler(void) //Timer PWM module
690 { TPM0_DriverIRQHandler();
691 }
692
TPM1_IRQHandler(void)693 WEAK void TPM1_IRQHandler(void) //Timer PWM module
694 { TPM1_DriverIRQHandler();
695 }
696
TPM2_IRQHandler(void)697 WEAK void TPM2_IRQHandler(void) //Timer PWM module
698 { TPM2_DriverIRQHandler();
699 }
700
TPM3_IRQHandler(void)701 WEAK void TPM3_IRQHandler(void) //Timer PWM module
702 { TPM3_DriverIRQHandler();
703 }
704
FLEXIO0_IRQHandler(void)705 WEAK void FLEXIO0_IRQHandler(void) //Flexible IO
706 { FLEXIO0_DriverIRQHandler();
707 }
708
LPI2C0_IRQHandler(void)709 WEAK void LPI2C0_IRQHandler(void) //Inter-integrated circuit 0
710 { LPI2C0_DriverIRQHandler();
711 }
712
LPI2C1_IRQHandler(void)713 WEAK void LPI2C1_IRQHandler(void) //Inter-integrated circuit 1
714 { LPI2C1_DriverIRQHandler();
715 }
716
LPI2C2_IRQHandler(void)717 WEAK void LPI2C2_IRQHandler(void) //Inter-integrated circuit 2
718 { LPI2C2_DriverIRQHandler();
719 }
720
LPI2C3_IRQHandler(void)721 WEAK void LPI2C3_IRQHandler(void) //Inter-integrated circuit 3
722 { LPI2C3_DriverIRQHandler();
723 }
724
SAI0_IRQHandler(void)725 WEAK void SAI0_IRQHandler(void) //Serial Audio Interface
726 { SAI0_DriverIRQHandler();
727 }
728
SAI1_IRQHandler(void)729 WEAK void SAI1_IRQHandler(void) //Serial Audio Interface 1
730 { SAI1_DriverIRQHandler();
731 }
732
LPSPI0_IRQHandler(void)733 WEAK void LPSPI0_IRQHandler(void) //Low Power Serial Peripheral Interface
734 { LPSPI0_DriverIRQHandler();
735 }
736
LPSPI1_IRQHandler(void)737 WEAK void LPSPI1_IRQHandler(void) //Low Power Serial Peripheral Interface
738 { LPSPI1_DriverIRQHandler();
739 }
740
LPUART0_IRQHandler(void)741 WEAK void LPUART0_IRQHandler(void) //Low Power UART
742 { LPUART0_DriverIRQHandler();
743 }
744
LPUART1_IRQHandler(void)745 WEAK void LPUART1_IRQHandler(void) //Low Power UART
746 { LPUART1_DriverIRQHandler();
747 }
748
LPUART2_IRQHandler(void)749 WEAK void LPUART2_IRQHandler(void) //Low Power UART
750 { LPUART2_DriverIRQHandler();
751 }
752
LPUART3_IRQHandler(void)753 WEAK void LPUART3_IRQHandler(void) //Low Power UART
754 { LPUART3_DriverIRQHandler();
755 }
756
DPM_IRQHandler(void)757 WEAK void DPM_IRQHandler(void) //Dynamic Process Monitor
758 { DPM_DriverIRQHandler();
759 }
760
PCTLA_IRQHandler(void)761 WEAK void PCTLA_IRQHandler(void) //Port A pin interrupt
762 { PCTLA_DriverIRQHandler();
763 }
764
PCTLB_IRQHandler(void)765 WEAK void PCTLB_IRQHandler(void) //Port B pin interrupt
766 { PCTLB_DriverIRQHandler();
767 }
768
ADC0_IRQHandler(void)769 WEAK void ADC0_IRQHandler(void) //Analog to Digital Convertor
770 { ADC0_DriverIRQHandler();
771 }
772
ADC1_IRQHandler(void)773 WEAK void ADC1_IRQHandler(void) //Analog to Digital Convertor
774 { ADC1_DriverIRQHandler();
775 }
776
CMP0_IRQHandler(void)777 WEAK void CMP0_IRQHandler(void) //Comparator
778 { CMP0_DriverIRQHandler();
779 }
780
CMP1_IRQHandler(void)781 WEAK void CMP1_IRQHandler(void) //Comparator
782 { CMP1_DriverIRQHandler();
783 }
784
DAC0_IRQHandler(void)785 WEAK void DAC0_IRQHandler(void) //Digital to Analog Convertor
786 { DAC0_DriverIRQHandler();
787 }
788
DAC1_IRQHandler(void)789 WEAK void DAC1_IRQHandler(void) //Digital to Analog Convertor
790 { DAC1_DriverIRQHandler();
791 }
792
WDOG1_IRQHandler(void)793 WEAK void WDOG1_IRQHandler(void) //Watchdog Interrupt from A7 subsystem
794 { WDOG1_DriverIRQHandler();
795 }
796
USB0_IRQHandler(void)797 WEAK void USB0_IRQHandler(void) //USB 0 Interrupt from A7 subsystem
798 { USB0_DriverIRQHandler();
799 }
800
USB1_IRQHandler(void)801 WEAK void USB1_IRQHandler(void) //USB 1 Interrupt from A7 subsystem
802 { USB1_DriverIRQHandler();
803 }
804
WDOG2_IRQHandler(void)805 WEAK void WDOG2_IRQHandler(void) //Watchdog Interrupt from A7 subsystem
806 { WDOG2_DriverIRQHandler();
807 }
808
USBPHY_IRQHandler(void)809 WEAK void USBPHY_IRQHandler(void) //USB PHY (used in conjunction with USBOTG0)
810 { USBPHY_DriverIRQHandler();
811 }
812
CMC1_IRQHandler(void)813 WEAK void CMC1_IRQHandler(void) //A7 resets
814 { CMC1_DriverIRQHandler();
815 }
816
817 //*****************************************************************************
818
819 #if defined (DEBUG)
820 #pragma GCC pop_options
821 #endif // (DEBUG)
822