aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/MK22F51212/mcuxpresso/startup_mk22f51212.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MK22F51212/mcuxpresso/startup_mk22f51212.cpp')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/MK22F51212/mcuxpresso/startup_mk22f51212.cpp868
1 files changed, 868 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MK22F51212/mcuxpresso/startup_mk22f51212.cpp b/lib/chibios-contrib/ext/mcux-sdk/devices/MK22F51212/mcuxpresso/startup_mk22f51212.cpp
new file mode 100644
index 000000000..3a20937f6
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MK22F51212/mcuxpresso/startup_mk22f51212.cpp
@@ -0,0 +1,868 @@
1//*****************************************************************************
2// MK22F51212 startup code for use with MCUXpresso IDE
3//
4// Version : 160420
5//*****************************************************************************
6//
7// Copyright 2016-2020 NXP
8// All rights reserved.
9//
10// SPDX-License-Identifier: BSD-3-Clause
11//*****************************************************************************
12
13#if defined (DEBUG)
14#pragma GCC push_options
15#pragma GCC optimize ("Og")
16#endif // (DEBUG)
17
18#if defined (__cplusplus)
19#ifdef __REDLIB__
20#error Redlib does not support C++
21#else
22//*****************************************************************************
23//
24// The entry point for the C++ library startup
25//
26//*****************************************************************************
27extern "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)
39extern "C" {
40#endif
41
42//*****************************************************************************
43// Flash Configuration block : 16-byte flash configuration field that stores
44// default protection settings (loaded on reset) and security information that
45// allows the MCU to restrict access to the Flash Memory module.
46// Placed at address 0x400 by the linker script.
47//*****************************************************************************
48__attribute__ ((used,section(".FlashConfig"))) const struct {
49 unsigned int word1;
50 unsigned int word2;
51 unsigned int word3;
52 unsigned int word4;
53} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE};
54//*****************************************************************************
55// Declaration of external SystemInit function
56//*****************************************************************************
57#if defined (__USE_CMSIS)
58extern void SystemInit(void);
59#endif // (__USE_CMSIS)
60
61//*****************************************************************************
62// Forward declaration of the core exception handlers.
63// When the application defines a handler (with the same name), this will
64// automatically take precedence over these weak definitions.
65// If your application is a C++ one, then any interrupt handlers defined
66// in C++ files within in your main application will need to have C linkage
67// rather than C++ linkage. To do this, make sure that you are using extern "C"
68// { .... } around the interrupt handler within your main application code.
69//*****************************************************************************
70 void ResetISR(void);
71WEAK void NMI_Handler(void);
72WEAK void HardFault_Handler(void);
73WEAK void MemManage_Handler(void);
74WEAK void BusFault_Handler(void);
75WEAK void UsageFault_Handler(void);
76WEAK void SVC_Handler(void);
77WEAK void DebugMon_Handler(void);
78WEAK void PendSV_Handler(void);
79WEAK void SysTick_Handler(void);
80WEAK void IntDefaultHandler(void);
81
82//*****************************************************************************
83// Forward declaration of the application IRQ handlers. When the application
84// defines a handler (with the same name), this will automatically take
85// precedence over weak definitions below
86//*****************************************************************************
87WEAK void DMA0_IRQHandler(void);
88WEAK void DMA1_IRQHandler(void);
89WEAK void DMA2_IRQHandler(void);
90WEAK void DMA3_IRQHandler(void);
91WEAK void DMA4_IRQHandler(void);
92WEAK void DMA5_IRQHandler(void);
93WEAK void DMA6_IRQHandler(void);
94WEAK void DMA7_IRQHandler(void);
95WEAK void DMA8_IRQHandler(void);
96WEAK void DMA9_IRQHandler(void);
97WEAK void DMA10_IRQHandler(void);
98WEAK void DMA11_IRQHandler(void);
99WEAK void DMA12_IRQHandler(void);
100WEAK void DMA13_IRQHandler(void);
101WEAK void DMA14_IRQHandler(void);
102WEAK void DMA15_IRQHandler(void);
103WEAK void DMA_Error_IRQHandler(void);
104WEAK void MCM_IRQHandler(void);
105WEAK void FTF_IRQHandler(void);
106WEAK void Read_Collision_IRQHandler(void);
107WEAK void LVD_LVW_IRQHandler(void);
108WEAK void LLWU_IRQHandler(void);
109WEAK void WDOG_EWM_IRQHandler(void);
110WEAK void RNG_IRQHandler(void);
111WEAK void I2C0_IRQHandler(void);
112WEAK void I2C1_IRQHandler(void);
113WEAK void SPI0_IRQHandler(void);
114WEAK void SPI1_IRQHandler(void);
115WEAK void I2S0_Tx_IRQHandler(void);
116WEAK void I2S0_Rx_IRQHandler(void);
117WEAK void LPUART0_IRQHandler(void);
118WEAK void UART0_RX_TX_IRQHandler(void);
119WEAK void UART0_ERR_IRQHandler(void);
120WEAK void UART1_RX_TX_IRQHandler(void);
121WEAK void UART1_ERR_IRQHandler(void);
122WEAK void UART2_RX_TX_IRQHandler(void);
123WEAK void UART2_ERR_IRQHandler(void);
124WEAK void Reserved53_IRQHandler(void);
125WEAK void Reserved54_IRQHandler(void);
126WEAK void ADC0_IRQHandler(void);
127WEAK void CMP0_IRQHandler(void);
128WEAK void CMP1_IRQHandler(void);
129WEAK void FTM0_IRQHandler(void);
130WEAK void FTM1_IRQHandler(void);
131WEAK void FTM2_IRQHandler(void);
132WEAK void Reserved61_IRQHandler(void);
133WEAK void RTC_IRQHandler(void);
134WEAK void RTC_Seconds_IRQHandler(void);
135WEAK void PIT0_IRQHandler(void);
136WEAK void PIT1_IRQHandler(void);
137WEAK void PIT2_IRQHandler(void);
138WEAK void PIT3_IRQHandler(void);
139WEAK void PDB0_IRQHandler(void);
140WEAK void USB0_IRQHandler(void);
141WEAK void Reserved70_IRQHandler(void);
142WEAK void Reserved71_IRQHandler(void);
143WEAK void DAC0_IRQHandler(void);
144WEAK void MCG_IRQHandler(void);
145WEAK void LPTMR0_IRQHandler(void);
146WEAK void PORTA_IRQHandler(void);
147WEAK void PORTB_IRQHandler(void);
148WEAK void PORTC_IRQHandler(void);
149WEAK void PORTD_IRQHandler(void);
150WEAK void PORTE_IRQHandler(void);
151WEAK void SWI_IRQHandler(void);
152WEAK void Reserved81_IRQHandler(void);
153WEAK void Reserved82_IRQHandler(void);
154WEAK void Reserved83_IRQHandler(void);
155WEAK void Reserved84_IRQHandler(void);
156WEAK void Reserved85_IRQHandler(void);
157WEAK void Reserved86_IRQHandler(void);
158WEAK void FTM3_IRQHandler(void);
159WEAK void DAC1_IRQHandler(void);
160WEAK void ADC1_IRQHandler(void);
161
162//*****************************************************************************
163// Forward declaration of the driver IRQ handlers. These are aliased
164// to the IntDefaultHandler, which is a 'forever' loop. When the driver
165// defines a handler (with the same name), this will automatically take
166// precedence over these weak definitions
167//*****************************************************************************
168void DMA0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
169void DMA1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
170void DMA2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
171void DMA3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
172void DMA4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
173void DMA5_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
174void DMA6_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
175void DMA7_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
176void DMA8_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
177void DMA9_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
178void DMA10_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
179void DMA11_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
180void DMA12_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
181void DMA13_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
182void DMA14_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
183void DMA15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
184void DMA_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
185void MCM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
186void FTF_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
187void Read_Collision_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
188void LVD_LVW_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
189void LLWU_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
190void WDOG_EWM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
191void RNG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
192void I2C0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
193void I2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
194void SPI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
195void SPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
196void I2S0_Tx_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
197void I2S0_Rx_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
198void LPUART0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
199void UART0_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
200void UART0_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
201void UART1_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
202void UART1_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
203void UART2_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
204void UART2_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
205void Reserved53_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
206void Reserved54_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
207void ADC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
208void CMP0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
209void CMP1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
210void FTM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
211void FTM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
212void FTM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
213void Reserved61_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
214void RTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
215void RTC_Seconds_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
216void PIT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
217void PIT1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
218void PIT2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
219void PIT3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
220void PDB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
221void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
222void Reserved70_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
223void Reserved71_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
224void DAC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
225void MCG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
226void LPTMR0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
227void PORTA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
228void PORTB_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
229void PORTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
230void PORTD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
231void PORTE_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
232void SWI_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
233void Reserved81_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
234void Reserved82_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
235void Reserved83_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
236void Reserved84_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
237void Reserved85_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
238void Reserved86_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
239void FTM3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
240void DAC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
241void ADC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
242
243//*****************************************************************************
244// The entry point for the application.
245// __main() is the entry point for Redlib based applications
246// main() is the entry point for Newlib based applications
247//*****************************************************************************
248#if defined (__REDLIB__)
249extern void __main(void);
250#endif
251extern int main(void);
252
253//*****************************************************************************
254// External declaration for the pointer to the stack top from the Linker Script
255//*****************************************************************************
256extern void _vStackTop(void);
257//*****************************************************************************
258#if defined (__cplusplus)
259} // extern "C"
260#endif
261//*****************************************************************************
262// The vector table.
263// This relies on the linker script to place at correct location in memory.
264//*****************************************************************************
265
266
267
268extern void (* const g_pfnVectors[])(void);
269extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
270
271__attribute__ ((used, section(".isr_vector")))
272void (* const g_pfnVectors[])(void) = {
273 // Core Level - CM4
274 &_vStackTop, // The initial stack pointer
275 ResetISR, // The reset handler
276 NMI_Handler, // The NMI handler
277 HardFault_Handler, // The hard fault handler
278 MemManage_Handler, // The MPU fault handler
279 BusFault_Handler, // The bus fault handler
280 UsageFault_Handler, // The usage fault handler
281 0, // Reserved
282 0, // Reserved
283 0, // Reserved
284 0, // Reserved
285 SVC_Handler, // SVCall handler
286 DebugMon_Handler, // Debug monitor handler
287 0, // Reserved
288 PendSV_Handler, // The PendSV handler
289 SysTick_Handler, // The SysTick handler
290
291 // Chip Level - MK22F51212
292 DMA0_IRQHandler, // 16: DMA Channel 0 Transfer Complete
293 DMA1_IRQHandler, // 17: DMA Channel 1 Transfer Complete
294 DMA2_IRQHandler, // 18: DMA Channel 2 Transfer Complete
295 DMA3_IRQHandler, // 19: DMA Channel 3 Transfer Complete
296 DMA4_IRQHandler, // 20: DMA Channel 4 Transfer Complete
297 DMA5_IRQHandler, // 21: DMA Channel 5 Transfer Complete
298 DMA6_IRQHandler, // 22: DMA Channel 6 Transfer Complete
299 DMA7_IRQHandler, // 23: DMA Channel 7 Transfer Complete
300 DMA8_IRQHandler, // 24: DMA Channel 8 Transfer Complete
301 DMA9_IRQHandler, // 25: DMA Channel 9 Transfer Complete
302 DMA10_IRQHandler, // 26: DMA Channel 10 Transfer Complete
303 DMA11_IRQHandler, // 27: DMA Channel 11 Transfer Complete
304 DMA12_IRQHandler, // 28: DMA Channel 12 Transfer Complete
305 DMA13_IRQHandler, // 29: DMA Channel 13 Transfer Complete
306 DMA14_IRQHandler, // 30: DMA Channel 14 Transfer Complete
307 DMA15_IRQHandler, // 31: DMA Channel 15 Transfer Complete
308 DMA_Error_IRQHandler, // 32: DMA Error Interrupt
309 MCM_IRQHandler, // 33: Normal Interrupt
310 FTF_IRQHandler, // 34: FTFA Command complete interrupt
311 Read_Collision_IRQHandler, // 35: Read Collision Interrupt
312 LVD_LVW_IRQHandler, // 36: Low Voltage Detect, Low Voltage Warning
313 LLWU_IRQHandler, // 37: Low Leakage Wakeup Unit
314 WDOG_EWM_IRQHandler, // 38: WDOG Interrupt
315 RNG_IRQHandler, // 39: RNG Interrupt
316 I2C0_IRQHandler, // 40: I2C0 interrupt
317 I2C1_IRQHandler, // 41: I2C1 interrupt
318 SPI0_IRQHandler, // 42: SPI0 Interrupt
319 SPI1_IRQHandler, // 43: SPI1 Interrupt
320 I2S0_Tx_IRQHandler, // 44: I2S0 transmit interrupt
321 I2S0_Rx_IRQHandler, // 45: I2S0 receive interrupt
322 LPUART0_IRQHandler, // 46: LPUART0 status/error interrupt
323 UART0_RX_TX_IRQHandler, // 47: UART0 Receive/Transmit interrupt
324 UART0_ERR_IRQHandler, // 48: UART0 Error interrupt
325 UART1_RX_TX_IRQHandler, // 49: UART1 Receive/Transmit interrupt
326 UART1_ERR_IRQHandler, // 50: UART1 Error interrupt
327 UART2_RX_TX_IRQHandler, // 51: UART2 Receive/Transmit interrupt
328 UART2_ERR_IRQHandler, // 52: UART2 Error interrupt
329 Reserved53_IRQHandler, // 53: Reserved interrupt
330 Reserved54_IRQHandler, // 54: Reserved interrupt
331 ADC0_IRQHandler, // 55: ADC0 interrupt
332 CMP0_IRQHandler, // 56: CMP0 interrupt
333 CMP1_IRQHandler, // 57: CMP1 interrupt
334 FTM0_IRQHandler, // 58: FTM0 fault, overflow and channels interrupt
335 FTM1_IRQHandler, // 59: FTM1 fault, overflow and channels interrupt
336 FTM2_IRQHandler, // 60: FTM2 fault, overflow and channels interrupt
337 Reserved61_IRQHandler, // 61: Reserved interrupt
338 RTC_IRQHandler, // 62: RTC interrupt
339 RTC_Seconds_IRQHandler, // 63: RTC seconds interrupt
340 PIT0_IRQHandler, // 64: PIT timer channel 0 interrupt
341 PIT1_IRQHandler, // 65: PIT timer channel 1 interrupt
342 PIT2_IRQHandler, // 66: PIT timer channel 2 interrupt
343 PIT3_IRQHandler, // 67: PIT timer channel 3 interrupt
344 PDB0_IRQHandler, // 68: PDB0 Interrupt
345 USB0_IRQHandler, // 69: USB0 interrupt
346 Reserved70_IRQHandler, // 70: Reserved interrupt
347 Reserved71_IRQHandler, // 71: Reserved interrupt
348 DAC0_IRQHandler, // 72: DAC0 interrupt
349 MCG_IRQHandler, // 73: MCG Interrupt
350 LPTMR0_IRQHandler, // 74: LPTimer interrupt
351 PORTA_IRQHandler, // 75: Port A interrupt
352 PORTB_IRQHandler, // 76: Port B interrupt
353 PORTC_IRQHandler, // 77: Port C interrupt
354 PORTD_IRQHandler, // 78: Port D interrupt
355 PORTE_IRQHandler, // 79: Port E interrupt
356 SWI_IRQHandler, // 80: Software interrupt
357 Reserved81_IRQHandler, // 81: Reserved interrupt
358 Reserved82_IRQHandler, // 82: Reserved interrupt
359 Reserved83_IRQHandler, // 83: Reserved interrupt
360 Reserved84_IRQHandler, // 84: Reserved interrupt
361 Reserved85_IRQHandler, // 85: Reserved interrupt
362 Reserved86_IRQHandler, // 86: Reserved interrupt
363 FTM3_IRQHandler, // 87: FTM3 fault, overflow and channels interrupt
364 DAC1_IRQHandler, // 88: DAC1 interrupt
365 ADC1_IRQHandler, // 89: ADC1 interrupt
366
367
368}; /* End of g_pfnVectors */
369
370//*****************************************************************************
371// Functions to carry out the initialization of RW and BSS data sections. These
372// are written as separate functions rather than being inlined within the
373// ResetISR() function in order to cope with MCUs with multiple banks of
374// memory.
375//*****************************************************************************
376__attribute__ ((section(".after_vectors.init_data")))
377void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
378 unsigned int *pulDest = (unsigned int*) start;
379 unsigned int *pulSrc = (unsigned int*) romstart;
380 unsigned int loop;
381 for (loop = 0; loop < len; loop = loop + 4)
382 *pulDest++ = *pulSrc++;
383}
384
385__attribute__ ((section(".after_vectors.init_bss")))
386void bss_init(unsigned int start, unsigned int len) {
387 unsigned int *pulDest = (unsigned int*) start;
388 unsigned int loop;
389 for (loop = 0; loop < len; loop = loop + 4)
390 *pulDest++ = 0;
391}
392
393//*****************************************************************************
394// The following symbols are constructs generated by the linker, indicating
395// the location of various points in the "Global Section Table". This table is
396// created by the linker via the Code Red managed linker script mechanism. It
397// contains the load address, execution address and length of each RW data
398// section and the execution and length of each BSS (zero initialized) section.
399//*****************************************************************************
400extern unsigned int __data_section_table;
401extern unsigned int __data_section_table_end;
402extern unsigned int __bss_section_table;
403extern unsigned int __bss_section_table_end;
404
405//*****************************************************************************
406// Reset entry point for your code.
407// Sets up a simple runtime environment and initializes the C/C++
408// library.
409//*****************************************************************************
410__attribute__ ((section(".after_vectors.reset")))
411void ResetISR(void) {
412
413 // Disable interrupts
414 __asm volatile ("cpsid i");
415
416
417#if defined (__USE_CMSIS)
418// If __USE_CMSIS defined, then call CMSIS SystemInit code
419 SystemInit();
420
421#else
422 // Disable Watchdog
423 // Write 0xC520 to watchdog unlock register
424 *((volatile unsigned short *)0x4005200E) = 0xC520;
425 // Followed by 0xD928 to complete the unlock
426 *((volatile unsigned short *)0x4005200E) = 0xD928;
427 // Now disable watchdog via STCTRLH register
428 *((volatile unsigned short *)0x40052000) = 0x01D2u;
429#endif // (__USE_CMSIS)
430
431 //
432 // Copy the data sections from flash to SRAM.
433 //
434 unsigned int LoadAddr, ExeAddr, SectionLen;
435 unsigned int *SectionTableAddr;
436
437 // Load base address of Global Section Table
438 SectionTableAddr = &__data_section_table;
439
440 // Copy the data sections from flash to SRAM.
441 while (SectionTableAddr < &__data_section_table_end) {
442 LoadAddr = *SectionTableAddr++;
443 ExeAddr = *SectionTableAddr++;
444 SectionLen = *SectionTableAddr++;
445 data_init(LoadAddr, ExeAddr, SectionLen);
446 }
447
448 // At this point, SectionTableAddr = &__bss_section_table;
449 // Zero fill the bss segment
450 while (SectionTableAddr < &__bss_section_table_end) {
451 ExeAddr = *SectionTableAddr++;
452 SectionLen = *SectionTableAddr++;
453 bss_init(ExeAddr, SectionLen);
454 }
455
456#if !defined (__USE_CMSIS)
457// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
458// will enable the FPU
459#if defined (__VFP_FP__) && !defined (__SOFTFP__)
460 //
461 // Code to enable the Cortex-M4 FPU only included
462 // if appropriate build options have been selected.
463 // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
464 //
465 // Read CPACR (located at address 0xE000ED88)
466 // Set bits 20-23 to enable CP10 and CP11 coprocessors
467 // Write back the modified value to the CPACR
468 asm volatile ("LDR.W R0, =0xE000ED88\n\t"
469 "LDR R1, [R0]\n\t"
470 "ORR R1, R1, #(0xF << 20)\n\t"
471 "STR R1, [R0]");
472#endif // (__VFP_FP__) && !(__SOFTFP__)
473#endif // (__USE_CMSIS)
474
475
476#if !defined (__USE_CMSIS)
477// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
478// will setup the VTOR register
479
480 // Check to see if we are running the code from a non-zero
481 // address (eg RAM, external flash), in which case we need
482 // to modify the VTOR register to tell the CPU that the
483 // vector table is located at a non-0x0 address.
484 unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
485 if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
486 *pSCB_VTOR = (unsigned int)g_pfnVectors;
487 }
488#endif // (__USE_CMSIS)
489#if defined (__cplusplus)
490 //
491 // Call C++ library initialisation
492 //
493 __libc_init_array();
494#endif
495
496 // Reenable interrupts
497 __asm volatile ("cpsie i");
498
499#if defined (__REDLIB__)
500 // Call the Redlib library, which in turn calls main()
501 __main();
502#else
503 main();
504#endif
505
506 //
507 // main() shouldn't return, but if it does, we'll just enter an infinite loop
508 //
509 while (1) {
510 ;
511 }
512}
513
514//*****************************************************************************
515// Default core exception handlers. Override the ones here by defining your own
516// handler routines in your application code.
517//*****************************************************************************
518WEAK_AV void NMI_Handler(void)
519{ while(1) {}
520}
521
522WEAK_AV void HardFault_Handler(void)
523{ while(1) {}
524}
525
526WEAK_AV void MemManage_Handler(void)
527{ while(1) {}
528}
529
530WEAK_AV void BusFault_Handler(void)
531{ while(1) {}
532}
533
534WEAK_AV void UsageFault_Handler(void)
535{ while(1) {}
536}
537
538WEAK_AV void SVC_Handler(void)
539{ while(1) {}
540}
541
542WEAK_AV void DebugMon_Handler(void)
543{ while(1) {}
544}
545
546WEAK_AV void PendSV_Handler(void)
547{ while(1) {}
548}
549
550WEAK_AV void SysTick_Handler(void)
551{ while(1) {}
552}
553
554//*****************************************************************************
555// Processor ends up here if an unexpected interrupt occurs or a specific
556// handler is not present in the application code.
557//*****************************************************************************
558WEAK_AV void IntDefaultHandler(void)
559{ while(1) {}
560}
561
562//*****************************************************************************
563// Default application exception handlers. Override the ones here by defining
564// your own handler routines in your application code. These routines call
565// driver exception handlers or IntDefaultHandler() if no driver exception
566// handler is included.
567//*****************************************************************************
568WEAK void DMA0_IRQHandler(void)
569{ DMA0_DriverIRQHandler();
570}
571
572WEAK void DMA1_IRQHandler(void)
573{ DMA1_DriverIRQHandler();
574}
575
576WEAK void DMA2_IRQHandler(void)
577{ DMA2_DriverIRQHandler();
578}
579
580WEAK void DMA3_IRQHandler(void)
581{ DMA3_DriverIRQHandler();
582}
583
584WEAK void DMA4_IRQHandler(void)
585{ DMA4_DriverIRQHandler();
586}
587
588WEAK void DMA5_IRQHandler(void)
589{ DMA5_DriverIRQHandler();
590}
591
592WEAK void DMA6_IRQHandler(void)
593{ DMA6_DriverIRQHandler();
594}
595
596WEAK void DMA7_IRQHandler(void)
597{ DMA7_DriverIRQHandler();
598}
599
600WEAK void DMA8_IRQHandler(void)
601{ DMA8_DriverIRQHandler();
602}
603
604WEAK void DMA9_IRQHandler(void)
605{ DMA9_DriverIRQHandler();
606}
607
608WEAK void DMA10_IRQHandler(void)
609{ DMA10_DriverIRQHandler();
610}
611
612WEAK void DMA11_IRQHandler(void)
613{ DMA11_DriverIRQHandler();
614}
615
616WEAK void DMA12_IRQHandler(void)
617{ DMA12_DriverIRQHandler();
618}
619
620WEAK void DMA13_IRQHandler(void)
621{ DMA13_DriverIRQHandler();
622}
623
624WEAK void DMA14_IRQHandler(void)
625{ DMA14_DriverIRQHandler();
626}
627
628WEAK void DMA15_IRQHandler(void)
629{ DMA15_DriverIRQHandler();
630}
631
632WEAK void DMA_Error_IRQHandler(void)
633{ DMA_Error_DriverIRQHandler();
634}
635
636WEAK void MCM_IRQHandler(void)
637{ MCM_DriverIRQHandler();
638}
639
640WEAK void FTF_IRQHandler(void)
641{ FTF_DriverIRQHandler();
642}
643
644WEAK void Read_Collision_IRQHandler(void)
645{ Read_Collision_DriverIRQHandler();
646}
647
648WEAK void LVD_LVW_IRQHandler(void)
649{ LVD_LVW_DriverIRQHandler();
650}
651
652WEAK void LLWU_IRQHandler(void)
653{ LLWU_DriverIRQHandler();
654}
655
656WEAK void WDOG_EWM_IRQHandler(void)
657{ WDOG_EWM_DriverIRQHandler();
658}
659
660WEAK void RNG_IRQHandler(void)
661{ RNG_DriverIRQHandler();
662}
663
664WEAK void I2C0_IRQHandler(void)
665{ I2C0_DriverIRQHandler();
666}
667
668WEAK void I2C1_IRQHandler(void)
669{ I2C1_DriverIRQHandler();
670}
671
672WEAK void SPI0_IRQHandler(void)
673{ SPI0_DriverIRQHandler();
674}
675
676WEAK void SPI1_IRQHandler(void)
677{ SPI1_DriverIRQHandler();
678}
679
680WEAK void I2S0_Tx_IRQHandler(void)
681{ I2S0_Tx_DriverIRQHandler();
682}
683
684WEAK void I2S0_Rx_IRQHandler(void)
685{ I2S0_Rx_DriverIRQHandler();
686}
687
688WEAK void LPUART0_IRQHandler(void)
689{ LPUART0_DriverIRQHandler();
690}
691
692WEAK void UART0_RX_TX_IRQHandler(void)
693{ UART0_RX_TX_DriverIRQHandler();
694}
695
696WEAK void UART0_ERR_IRQHandler(void)
697{ UART0_ERR_DriverIRQHandler();
698}
699
700WEAK void UART1_RX_TX_IRQHandler(void)
701{ UART1_RX_TX_DriverIRQHandler();
702}
703
704WEAK void UART1_ERR_IRQHandler(void)
705{ UART1_ERR_DriverIRQHandler();
706}
707
708WEAK void UART2_RX_TX_IRQHandler(void)
709{ UART2_RX_TX_DriverIRQHandler();
710}
711
712WEAK void UART2_ERR_IRQHandler(void)
713{ UART2_ERR_DriverIRQHandler();
714}
715
716WEAK void Reserved53_IRQHandler(void)
717{ Reserved53_DriverIRQHandler();
718}
719
720WEAK void Reserved54_IRQHandler(void)
721{ Reserved54_DriverIRQHandler();
722}
723
724WEAK void ADC0_IRQHandler(void)
725{ ADC0_DriverIRQHandler();
726}
727
728WEAK void CMP0_IRQHandler(void)
729{ CMP0_DriverIRQHandler();
730}
731
732WEAK void CMP1_IRQHandler(void)
733{ CMP1_DriverIRQHandler();
734}
735
736WEAK void FTM0_IRQHandler(void)
737{ FTM0_DriverIRQHandler();
738}
739
740WEAK void FTM1_IRQHandler(void)
741{ FTM1_DriverIRQHandler();
742}
743
744WEAK void FTM2_IRQHandler(void)
745{ FTM2_DriverIRQHandler();
746}
747
748WEAK void Reserved61_IRQHandler(void)
749{ Reserved61_DriverIRQHandler();
750}
751
752WEAK void RTC_IRQHandler(void)
753{ RTC_DriverIRQHandler();
754}
755
756WEAK void RTC_Seconds_IRQHandler(void)
757{ RTC_Seconds_DriverIRQHandler();
758}
759
760WEAK void PIT0_IRQHandler(void)
761{ PIT0_DriverIRQHandler();
762}
763
764WEAK void PIT1_IRQHandler(void)
765{ PIT1_DriverIRQHandler();
766}
767
768WEAK void PIT2_IRQHandler(void)
769{ PIT2_DriverIRQHandler();
770}
771
772WEAK void PIT3_IRQHandler(void)
773{ PIT3_DriverIRQHandler();
774}
775
776WEAK void PDB0_IRQHandler(void)
777{ PDB0_DriverIRQHandler();
778}
779
780WEAK void USB0_IRQHandler(void)
781{ USB0_DriverIRQHandler();
782}
783
784WEAK void Reserved70_IRQHandler(void)
785{ Reserved70_DriverIRQHandler();
786}
787
788WEAK void Reserved71_IRQHandler(void)
789{ Reserved71_DriverIRQHandler();
790}
791
792WEAK void DAC0_IRQHandler(void)
793{ DAC0_DriverIRQHandler();
794}
795
796WEAK void MCG_IRQHandler(void)
797{ MCG_DriverIRQHandler();
798}
799
800WEAK void LPTMR0_IRQHandler(void)
801{ LPTMR0_DriverIRQHandler();
802}
803
804WEAK void PORTA_IRQHandler(void)
805{ PORTA_DriverIRQHandler();
806}
807
808WEAK void PORTB_IRQHandler(void)
809{ PORTB_DriverIRQHandler();
810}
811
812WEAK void PORTC_IRQHandler(void)
813{ PORTC_DriverIRQHandler();
814}
815
816WEAK void PORTD_IRQHandler(void)
817{ PORTD_DriverIRQHandler();
818}
819
820WEAK void PORTE_IRQHandler(void)
821{ PORTE_DriverIRQHandler();
822}
823
824WEAK void SWI_IRQHandler(void)
825{ SWI_DriverIRQHandler();
826}
827
828WEAK void Reserved81_IRQHandler(void)
829{ Reserved81_DriverIRQHandler();
830}
831
832WEAK void Reserved82_IRQHandler(void)
833{ Reserved82_DriverIRQHandler();
834}
835
836WEAK void Reserved83_IRQHandler(void)
837{ Reserved83_DriverIRQHandler();
838}
839
840WEAK void Reserved84_IRQHandler(void)
841{ Reserved84_DriverIRQHandler();
842}
843
844WEAK void Reserved85_IRQHandler(void)
845{ Reserved85_DriverIRQHandler();
846}
847
848WEAK void Reserved86_IRQHandler(void)
849{ Reserved86_DriverIRQHandler();
850}
851
852WEAK void FTM3_IRQHandler(void)
853{ FTM3_DriverIRQHandler();
854}
855
856WEAK void DAC1_IRQHandler(void)
857{ DAC1_DriverIRQHandler();
858}
859
860WEAK void ADC1_IRQHandler(void)
861{ ADC1_DriverIRQHandler();
862}
863
864//*****************************************************************************
865
866#if defined (DEBUG)
867#pragma GCC pop_options
868#endif // (DEBUG)