aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1011/mcuxpresso/startup_mimxrt1011.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1011/mcuxpresso/startup_mimxrt1011.cpp')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1011/mcuxpresso/startup_mimxrt1011.cpp890
1 files changed, 890 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1011/mcuxpresso/startup_mimxrt1011.cpp b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1011/mcuxpresso/startup_mimxrt1011.cpp
new file mode 100644
index 000000000..bcc2a93fb
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT1011/mcuxpresso/startup_mimxrt1011.cpp
@@ -0,0 +1,890 @@
1//*****************************************************************************
2// MIMXRT1011 startup code for use with MCUXpresso IDE
3//
4// Version : 101020
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// Variable to store CRP value in. Will be placed automatically
44// by the linker when "Enable Code Read Protect" selected.
45// See crp.h header for more information
46//*****************************************************************************
47//*****************************************************************************
48// Declaration of external SystemInit function
49//*****************************************************************************
50#if defined (__USE_CMSIS)
51extern void SystemInit(void);
52#endif // (__USE_CMSIS)
53
54//*****************************************************************************
55// Forward declaration of the core exception handlers.
56// When the application defines a handler (with the same name), this will
57// automatically take precedence over these weak definitions.
58// If your application is a C++ one, then any interrupt handlers defined
59// in C++ files within in your main application will need to have C linkage
60// rather than C++ linkage. To do this, make sure that you are using extern "C"
61// { .... } around the interrupt handler within your main application code.
62//*****************************************************************************
63 void ResetISR(void);
64WEAK void NMI_Handler(void);
65WEAK void HardFault_Handler(void);
66WEAK void MemManage_Handler(void);
67WEAK void BusFault_Handler(void);
68WEAK void UsageFault_Handler(void);
69WEAK void SVC_Handler(void);
70WEAK void DebugMon_Handler(void);
71WEAK void PendSV_Handler(void);
72WEAK void SysTick_Handler(void);
73WEAK void IntDefaultHandler(void);
74
75//*****************************************************************************
76// Forward declaration of the application IRQ handlers. When the application
77// defines a handler (with the same name), this will automatically take
78// precedence over weak definitions below
79//*****************************************************************************
80WEAK void DMA0_IRQHandler(void);
81WEAK void DMA1_IRQHandler(void);
82WEAK void DMA2_IRQHandler(void);
83WEAK void DMA3_IRQHandler(void);
84WEAK void DMA4_IRQHandler(void);
85WEAK void DMA5_IRQHandler(void);
86WEAK void DMA6_IRQHandler(void);
87WEAK void DMA7_IRQHandler(void);
88WEAK void DMA8_IRQHandler(void);
89WEAK void DMA9_IRQHandler(void);
90WEAK void DMA10_IRQHandler(void);
91WEAK void DMA11_IRQHandler(void);
92WEAK void DMA12_IRQHandler(void);
93WEAK void DMA13_IRQHandler(void);
94WEAK void DMA14_IRQHandler(void);
95WEAK void DMA15_IRQHandler(void);
96WEAK void DMA_ERROR_IRQHandler(void);
97WEAK void CTI0_ERROR_IRQHandler(void);
98WEAK void CTI1_ERROR_IRQHandler(void);
99WEAK void CORE_IRQHandler(void);
100WEAK void LPUART1_IRQHandler(void);
101WEAK void LPUART2_IRQHandler(void);
102WEAK void LPUART3_IRQHandler(void);
103WEAK void LPUART4_IRQHandler(void);
104WEAK void PIT_IRQHandler(void);
105WEAK void USB_OTG1_IRQHandler(void);
106WEAK void FLEXSPI_IRQHandler(void);
107WEAK void FLEXRAM_IRQHandler(void);
108WEAK void LPI2C1_IRQHandler(void);
109WEAK void LPI2C2_IRQHandler(void);
110WEAK void GPT1_IRQHandler(void);
111WEAK void GPT2_IRQHandler(void);
112WEAK void LPSPI1_IRQHandler(void);
113WEAK void LPSPI2_IRQHandler(void);
114WEAK void PWM1_0_IRQHandler(void);
115WEAK void PWM1_1_IRQHandler(void);
116WEAK void PWM1_2_IRQHandler(void);
117WEAK void PWM1_3_IRQHandler(void);
118WEAK void PWM1_FAULT_IRQHandler(void);
119WEAK void KPP_IRQHandler(void);
120WEAK void SRC_IRQHandler(void);
121WEAK void GPR_IRQ_IRQHandler(void);
122WEAK void CCM_1_IRQHandler(void);
123WEAK void CCM_2_IRQHandler(void);
124WEAK void EWM_IRQHandler(void);
125WEAK void WDOG2_IRQHandler(void);
126WEAK void SNVS_HP_WRAPPER_IRQHandler(void);
127WEAK void SNVS_HP_WRAPPER_TZ_IRQHandler(void);
128WEAK void SNVS_LP_WRAPPER_IRQHandler(void);
129WEAK void CSU_IRQHandler(void);
130WEAK void DCP_IRQHandler(void);
131WEAK void DCP_VMI_IRQHandler(void);
132WEAK void Reserved68_IRQHandler(void);
133WEAK void TRNG_IRQHandler(void);
134WEAK void Reserved70_IRQHandler(void);
135WEAK void Reserved71_IRQHandler(void);
136WEAK void SAI1_IRQHandler(void);
137WEAK void RTWDOG_IRQHandler(void);
138WEAK void SAI3_RX_IRQHandler(void);
139WEAK void SAI3_TX_IRQHandler(void);
140WEAK void SPDIF_IRQHandler(void);
141WEAK void PMU_IRQHandler(void);
142WEAK void XBAR1_IRQ_0_1_2_3_IRQHandler(void);
143WEAK void TEMP_LOW_HIGH_IRQHandler(void);
144WEAK void TEMP_PANIC_IRQHandler(void);
145WEAK void USB_PHY_IRQHandler(void);
146WEAK void GPC_IRQHandler(void);
147WEAK void ADC1_IRQHandler(void);
148WEAK void FLEXIO1_IRQHandler(void);
149WEAK void DCDC_IRQHandler(void);
150WEAK void GPIO1_Combined_0_15_IRQHandler(void);
151WEAK void GPIO1_Combined_16_31_IRQHandler(void);
152WEAK void GPIO2_Combined_0_15_IRQHandler(void);
153WEAK void GPIO5_Combined_0_15_IRQHandler(void);
154WEAK void WDOG1_IRQHandler(void);
155WEAK void ADC_ETC_IRQ0_IRQHandler(void);
156WEAK void ADC_ETC_IRQ1_IRQHandler(void);
157WEAK void ADC_ETC_IRQ2_IRQHandler(void);
158WEAK void ADC_ETC_IRQ3_IRQHandler(void);
159WEAK void ADC_ETC_ERROR_IRQ_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//*****************************************************************************
167void DMA0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
168void DMA1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
169void DMA2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
170void DMA3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
171void DMA4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
172void DMA5_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
173void DMA6_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
174void DMA7_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
175void DMA8_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
176void DMA9_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
177void DMA10_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
178void DMA11_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
179void DMA12_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
180void DMA13_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
181void DMA14_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
182void DMA15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
183void DMA_ERROR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
184void CTI0_ERROR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
185void CTI1_ERROR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
186void CORE_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
187void LPUART1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
188void LPUART2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
189void LPUART3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
190void LPUART4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
191void PIT_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
192void USB_OTG1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
193void FLEXSPI_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
194void FLEXRAM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
195void LPI2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
196void LPI2C2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
197void GPT1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
198void GPT2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
199void LPSPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
200void LPSPI2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
201void PWM1_0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
202void PWM1_1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
203void PWM1_2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
204void PWM1_3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
205void PWM1_FAULT_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
206void KPP_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
207void SRC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
208void GPR_IRQ_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
209void CCM_1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
210void CCM_2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
211void EWM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
212void WDOG2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
213void SNVS_HP_WRAPPER_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
214void SNVS_HP_WRAPPER_TZ_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
215void SNVS_LP_WRAPPER_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
216void CSU_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
217void DCP_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
218void DCP_VMI_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
219void Reserved68_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
220void TRNG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
221void Reserved70_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
222void Reserved71_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
223void SAI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
224void RTWDOG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
225void SAI3_RX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
226void SAI3_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
227void SPDIF_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
228void PMU_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
229void XBAR1_IRQ_0_1_2_3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
230void TEMP_LOW_HIGH_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
231void TEMP_PANIC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
232void USB_PHY_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
233void GPC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
234void ADC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
235void FLEXIO1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
236void DCDC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
237void GPIO1_Combined_0_15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
238void GPIO1_Combined_16_31_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
239void GPIO2_Combined_0_15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
240void GPIO5_Combined_0_15_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
241void WDOG1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
242void ADC_ETC_IRQ0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
243void ADC_ETC_IRQ1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
244void ADC_ETC_IRQ2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
245void ADC_ETC_IRQ3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
246void ADC_ETC_ERROR_IRQ_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
247
248//*****************************************************************************
249// The entry point for the application.
250// __main() is the entry point for Redlib based applications
251// main() is the entry point for Newlib based applications
252//*****************************************************************************
253#if defined (__REDLIB__)
254extern void __main(void);
255#endif
256extern int main(void);
257
258//*****************************************************************************
259// External declaration for the pointer to the stack top from the Linker Script
260//*****************************************************************************
261extern void _vStackTop(void);
262//*****************************************************************************
263#if defined (__cplusplus)
264} // extern "C"
265#endif
266//*****************************************************************************
267// The vector table.
268// This relies on the linker script to place at correct location in memory.
269//*****************************************************************************
270
271
272
273extern void (* const g_pfnVectors[])(void);
274extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
275
276__attribute__ ((used, section(".isr_vector")))
277void (* const g_pfnVectors[])(void) = {
278 // Core Level - CM7
279 &_vStackTop, // The initial stack pointer
280 ResetISR, // The reset handler
281 NMI_Handler, // The NMI handler
282 HardFault_Handler, // The hard fault handler
283 MemManage_Handler, // The MPU fault handler
284 BusFault_Handler, // The bus fault handler
285 UsageFault_Handler, // The usage fault handler
286 0, // Reserved
287 0, // Reserved
288 0, // Reserved
289 0, // Reserved
290 SVC_Handler, // SVCall handler
291 DebugMon_Handler, // Debug monitor handler
292 0, // Reserved
293 PendSV_Handler, // The PendSV handler
294 SysTick_Handler, // The SysTick handler
295
296 // Chip Level - MIMXRT1011
297 DMA0_IRQHandler, // 16: DMA channel 0 transfer complete
298 DMA1_IRQHandler, // 17: DMA channel 1 transfer complete
299 DMA2_IRQHandler, // 18: DMA channel 2 transfer complete
300 DMA3_IRQHandler, // 19: DMA channel 3 transfer complete
301 DMA4_IRQHandler, // 20: DMA channel 4 transfer complete
302 DMA5_IRQHandler, // 21: DMA channel 5 transfer complete
303 DMA6_IRQHandler, // 22: DMA channel 6 transfer complete
304 DMA7_IRQHandler, // 23: DMA channel 7 transfer complete
305 DMA8_IRQHandler, // 24: DMA channel 8 transfer complete
306 DMA9_IRQHandler, // 25: DMA channel 9 transfer complete
307 DMA10_IRQHandler, // 26: DMA channel 10 transfer complete
308 DMA11_IRQHandler, // 27: DMA channel 11 transfer complete
309 DMA12_IRQHandler, // 28: DMA channel 12 transfer complete
310 DMA13_IRQHandler, // 29: DMA channel 13 transfer complete
311 DMA14_IRQHandler, // 30: DMA channel 14 transfer complete
312 DMA15_IRQHandler, // 31: DMA channel 15 transfer complete
313 DMA_ERROR_IRQHandler, // 32: DMA error interrupt channels 0-15
314 CTI0_ERROR_IRQHandler, // 33: CTI trigger outputs
315 CTI1_ERROR_IRQHandler, // 34: CTI trigger outputs
316 CORE_IRQHandler, // 35: CorePlatform exception IRQ
317 LPUART1_IRQHandler, // 36: LPUART1 TX interrupt and RX interrupt
318 LPUART2_IRQHandler, // 37: LPUART2 TX interrupt and RX interrupt
319 LPUART3_IRQHandler, // 38: LPUART3 TX interrupt and RX interrupt
320 LPUART4_IRQHandler, // 39: LPUART4 TX interrupt and RX interrupt
321 PIT_IRQHandler, // 40: PIT interrupt
322 USB_OTG1_IRQHandler, // 41: USBO2 USB OTG1
323 FLEXSPI_IRQHandler, // 42: FlexSPI0 interrupt
324 FLEXRAM_IRQHandler, // 43: FlexRAM address out of range Or access hit IRQ
325 LPI2C1_IRQHandler, // 44: LPI2C1 interrupt
326 LPI2C2_IRQHandler, // 45: LPI2C2 interrupt
327 GPT1_IRQHandler, // 46: GPT1 interrupt
328 GPT2_IRQHandler, // 47: GPT2 interrupt
329 LPSPI1_IRQHandler, // 48: LPSPI1 single interrupt vector for all sources
330 LPSPI2_IRQHandler, // 49: LPSPI2 single interrupt vector for all sources
331 PWM1_0_IRQHandler, // 50: PWM1 capture 0, compare 0, or reload 0 interrupt
332 PWM1_1_IRQHandler, // 51: PWM1 capture 1, compare 1, or reload 0 interrupt
333 PWM1_2_IRQHandler, // 52: PWM1 capture 2, compare 2, or reload 0 interrupt
334 PWM1_3_IRQHandler, // 53: PWM1 capture 3, compare 3, or reload 0 interrupt
335 PWM1_FAULT_IRQHandler, // 54: PWM1 fault or reload error interrupt
336 KPP_IRQHandler, // 55: Keypad nterrupt
337 SRC_IRQHandler, // 56: SRC interrupt
338 GPR_IRQ_IRQHandler, // 57: Used to notify cores on exception condition while boot
339 CCM_1_IRQHandler, // 58: CCM IRQ1 interrupt
340 CCM_2_IRQHandler, // 59: CCM IRQ2 interrupt
341 EWM_IRQHandler, // 60: EWM interrupt
342 WDOG2_IRQHandler, // 61: WDOG2 interrupt
343 SNVS_HP_WRAPPER_IRQHandler, // 62: SNVS Functional Interrupt
344 SNVS_HP_WRAPPER_TZ_IRQHandler, // 63: SNVS Security Interrupt
345 SNVS_LP_WRAPPER_IRQHandler, // 64: ON-OFF button press shorter than 5 secs (pulse event)
346 CSU_IRQHandler, // 65: CSU interrupt
347 DCP_IRQHandler, // 66: Combined DCP channel interrupts(except channel 0) and CRC interrupt
348 DCP_VMI_IRQHandler, // 67: IRQ of DCP channel 0
349 Reserved68_IRQHandler, // 68: Reserved interrupt
350 TRNG_IRQHandler, // 69: TRNG interrupt
351 Reserved70_IRQHandler, // 70: Reserved interrupt
352 Reserved71_IRQHandler, // 71: Reserved interrupt
353 SAI1_IRQHandler, // 72: SAI1 interrupt
354 RTWDOG_IRQHandler, // 73: RTWDOG interrupt
355 SAI3_RX_IRQHandler, // 74: SAI3 interrupt
356 SAI3_TX_IRQHandler, // 75: SAI3 interrupt
357 SPDIF_IRQHandler, // 76: SPDIF interrupt
358 PMU_IRQHandler, // 77: PMU interrupt
359 XBAR1_IRQ_0_1_2_3_IRQHandler, // 78: XBAR1 interrupt
360 TEMP_LOW_HIGH_IRQHandler, // 79: TEMPMON interrupt
361 TEMP_PANIC_IRQHandler, // 80: TEMPMON interrupt
362 USB_PHY_IRQHandler, // 81: USBPHY (OTG1 UTMI), Interrupt
363 GPC_IRQHandler, // 82: GPC interrupt
364 ADC1_IRQHandler, // 83: ADC1 interrupt
365 FLEXIO1_IRQHandler, // 84: FLEXIO1 interrupt
366 DCDC_IRQHandler, // 85: DCDC interrupt
367 GPIO1_Combined_0_15_IRQHandler, // 86: Combined interrupt indication for GPIO1 signal 0 throughout 15
368 GPIO1_Combined_16_31_IRQHandler, // 87: Combined interrupt indication for GPIO1 signal 16 throughout 31
369 GPIO2_Combined_0_15_IRQHandler, // 88: Combined interrupt indication for GPIO2 signal 0 throughout 15
370 GPIO5_Combined_0_15_IRQHandler, // 89: Combined interrupt indication for GPIO5 signal 0 throughout 15
371 WDOG1_IRQHandler, // 90: WDOG1 interrupt
372 ADC_ETC_IRQ0_IRQHandler, // 91: ADCETC IRQ0 interrupt
373 ADC_ETC_IRQ1_IRQHandler, // 92: ADCETC IRQ1 interrupt
374 ADC_ETC_IRQ2_IRQHandler, // 93: ADCETC IRQ2 interrupt
375 ADC_ETC_IRQ3_IRQHandler, // 94: ADCETC IRQ3 interrupt
376 ADC_ETC_ERROR_IRQ_IRQHandler, // 95: ADCETC Error IRQ interrupt
377
378
379}; /* End of g_pfnVectors */
380
381//*****************************************************************************
382// Functions to carry out the initialization of RW and BSS data sections. These
383// are written as separate functions rather than being inlined within the
384// ResetISR() function in order to cope with MCUs with multiple banks of
385// memory.
386//*****************************************************************************
387__attribute__ ((section(".after_vectors.init_data")))
388void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
389 unsigned int *pulDest = (unsigned int*) start;
390 unsigned int *pulSrc = (unsigned int*) romstart;
391 unsigned int loop;
392 for (loop = 0; loop < len; loop = loop + 4)
393 *pulDest++ = *pulSrc++;
394}
395
396__attribute__ ((section(".after_vectors.init_bss")))
397void bss_init(unsigned int start, unsigned int len) {
398 unsigned int *pulDest = (unsigned int*) start;
399 unsigned int loop;
400 for (loop = 0; loop < len; loop = loop + 4)
401 *pulDest++ = 0;
402}
403
404//*****************************************************************************
405// The following symbols are constructs generated by the linker, indicating
406// the location of various points in the "Global Section Table". This table is
407// created by the linker via the Code Red managed linker script mechanism. It
408// contains the load address, execution address and length of each RW data
409// section and the execution and length of each BSS (zero initialized) section.
410//*****************************************************************************
411extern unsigned int __data_section_table;
412extern unsigned int __data_section_table_end;
413extern unsigned int __bss_section_table;
414extern unsigned int __bss_section_table_end;
415
416//*****************************************************************************
417// Reset entry point for your code.
418// Sets up a simple runtime environment and initializes the C/C++
419// library.
420//*****************************************************************************
421__attribute__ ((section(".after_vectors.reset")))
422void ResetISR(void) {
423
424 // Disable interrupts
425 __asm volatile ("cpsid i");
426
427 __asm volatile ("MSR MSP, %0" : : "r" (&_vStackTop) : );
428
429#if defined (__USE_CMSIS)
430// If __USE_CMSIS defined, then call CMSIS SystemInit code
431 SystemInit();
432#else
433 // Disable Watchdog
434 volatile unsigned int *WDOG1_WCR = (unsigned int *) 0x400B8000;
435 *WDOG1_WCR = *WDOG1_WCR & ~(1 << 2);
436 volatile unsigned int *WDOG2_WCR = (unsigned int *) 0x400D0000;
437 *WDOG2_WCR = *WDOG2_WCR & ~(1 << 2);
438 // Write watchdog update key to unlock
439 *((volatile unsigned int *)0x400BC004) = 0xD928C520;
440 // Set timeout value
441 *((volatile unsigned int *)0x400BC008) = 0xFFFF;
442 // Now disable watchdog via control register
443 volatile unsigned int *RTWDOG_CS = (unsigned int *) 0x400BC000;
444 *RTWDOG_CS = (*RTWDOG_CS & ~(1 << 7)) | (1 << 5);
445
446#endif // (__USE_CMSIS)
447
448 //
449 // Copy the data sections from flash to SRAM.
450 //
451 unsigned int LoadAddr, ExeAddr, SectionLen;
452 unsigned int *SectionTableAddr;
453
454 // Load base address of Global Section Table
455 SectionTableAddr = &__data_section_table;
456
457 // Copy the data sections from flash to SRAM.
458 while (SectionTableAddr < &__data_section_table_end) {
459 LoadAddr = *SectionTableAddr++;
460 ExeAddr = *SectionTableAddr++;
461 SectionLen = *SectionTableAddr++;
462 data_init(LoadAddr, ExeAddr, SectionLen);
463 }
464
465 // At this point, SectionTableAddr = &__bss_section_table;
466 // Zero fill the bss segment
467 while (SectionTableAddr < &__bss_section_table_end) {
468 ExeAddr = *SectionTableAddr++;
469 SectionLen = *SectionTableAddr++;
470 bss_init(ExeAddr, SectionLen);
471 }
472
473
474#if !defined (__USE_CMSIS)
475// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
476// will setup the VTOR register
477
478 // Check to see if we are running the code from a non-zero
479 // address (eg RAM, external flash), in which case we need
480 // to modify the VTOR register to tell the CPU that the
481 // vector table is located at a non-0x0 address.
482 unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
483 if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
484 *pSCB_VTOR = (unsigned int)g_pfnVectors;
485 }
486#endif // (__USE_CMSIS)
487#if defined (__cplusplus)
488 //
489 // Call C++ library initialisation
490 //
491 __libc_init_array();
492#endif
493
494 // Reenable interrupts
495 __asm volatile ("cpsie i");
496
497#if defined (__REDLIB__)
498 // Call the Redlib library, which in turn calls main()
499 __main();
500#else
501 main();
502#endif
503
504 //
505 // main() shouldn't return, but if it does, we'll just enter an infinite loop
506 //
507 while (1) {
508 ;
509 }
510}
511
512//*****************************************************************************
513// Default core exception handlers. Override the ones here by defining your own
514// handler routines in your application code.
515//*****************************************************************************
516WEAK_AV void NMI_Handler(void)
517{ while(1) {}
518}
519
520WEAK_AV void HardFault_Handler(void)
521{ while(1) {}
522}
523
524WEAK_AV void MemManage_Handler(void)
525{ while(1) {}
526}
527
528WEAK_AV void BusFault_Handler(void)
529{ while(1) {}
530}
531
532WEAK_AV void UsageFault_Handler(void)
533{ while(1) {}
534}
535
536WEAK_AV void SVC_Handler(void)
537{ while(1) {}
538}
539
540WEAK_AV void DebugMon_Handler(void)
541{ while(1) {}
542}
543
544WEAK_AV void PendSV_Handler(void)
545{ while(1) {}
546}
547
548WEAK_AV void SysTick_Handler(void)
549{ while(1) {}
550}
551
552//*****************************************************************************
553// Processor ends up here if an unexpected interrupt occurs or a specific
554// handler is not present in the application code.
555//*****************************************************************************
556WEAK_AV void IntDefaultHandler(void)
557{ while(1) {}
558}
559
560//*****************************************************************************
561// Default application exception handlers. Override the ones here by defining
562// your own handler routines in your application code. These routines call
563// driver exception handlers or IntDefaultHandler() if no driver exception
564// handler is included.
565//*****************************************************************************
566WEAK void DMA0_IRQHandler(void)
567{ DMA0_DriverIRQHandler();
568}
569
570WEAK void DMA1_IRQHandler(void)
571{ DMA1_DriverIRQHandler();
572}
573
574WEAK void DMA2_IRQHandler(void)
575{ DMA2_DriverIRQHandler();
576}
577
578WEAK void DMA3_IRQHandler(void)
579{ DMA3_DriverIRQHandler();
580}
581
582WEAK void DMA4_IRQHandler(void)
583{ DMA4_DriverIRQHandler();
584}
585
586WEAK void DMA5_IRQHandler(void)
587{ DMA5_DriverIRQHandler();
588}
589
590WEAK void DMA6_IRQHandler(void)
591{ DMA6_DriverIRQHandler();
592}
593
594WEAK void DMA7_IRQHandler(void)
595{ DMA7_DriverIRQHandler();
596}
597
598WEAK void DMA8_IRQHandler(void)
599{ DMA8_DriverIRQHandler();
600}
601
602WEAK void DMA9_IRQHandler(void)
603{ DMA9_DriverIRQHandler();
604}
605
606WEAK void DMA10_IRQHandler(void)
607{ DMA10_DriverIRQHandler();
608}
609
610WEAK void DMA11_IRQHandler(void)
611{ DMA11_DriverIRQHandler();
612}
613
614WEAK void DMA12_IRQHandler(void)
615{ DMA12_DriverIRQHandler();
616}
617
618WEAK void DMA13_IRQHandler(void)
619{ DMA13_DriverIRQHandler();
620}
621
622WEAK void DMA14_IRQHandler(void)
623{ DMA14_DriverIRQHandler();
624}
625
626WEAK void DMA15_IRQHandler(void)
627{ DMA15_DriverIRQHandler();
628}
629
630WEAK void DMA_ERROR_IRQHandler(void)
631{ DMA_ERROR_DriverIRQHandler();
632}
633
634WEAK void CTI0_ERROR_IRQHandler(void)
635{ CTI0_ERROR_DriverIRQHandler();
636}
637
638WEAK void CTI1_ERROR_IRQHandler(void)
639{ CTI1_ERROR_DriverIRQHandler();
640}
641
642WEAK void CORE_IRQHandler(void)
643{ CORE_DriverIRQHandler();
644}
645
646WEAK void LPUART1_IRQHandler(void)
647{ LPUART1_DriverIRQHandler();
648}
649
650WEAK void LPUART2_IRQHandler(void)
651{ LPUART2_DriverIRQHandler();
652}
653
654WEAK void LPUART3_IRQHandler(void)
655{ LPUART3_DriverIRQHandler();
656}
657
658WEAK void LPUART4_IRQHandler(void)
659{ LPUART4_DriverIRQHandler();
660}
661
662WEAK void PIT_IRQHandler(void)
663{ PIT_DriverIRQHandler();
664}
665
666WEAK void USB_OTG1_IRQHandler(void)
667{ USB_OTG1_DriverIRQHandler();
668}
669
670WEAK void FLEXSPI_IRQHandler(void)
671{ FLEXSPI_DriverIRQHandler();
672}
673
674WEAK void FLEXRAM_IRQHandler(void)
675{ FLEXRAM_DriverIRQHandler();
676}
677
678WEAK void LPI2C1_IRQHandler(void)
679{ LPI2C1_DriverIRQHandler();
680}
681
682WEAK void LPI2C2_IRQHandler(void)
683{ LPI2C2_DriverIRQHandler();
684}
685
686WEAK void GPT1_IRQHandler(void)
687{ GPT1_DriverIRQHandler();
688}
689
690WEAK void GPT2_IRQHandler(void)
691{ GPT2_DriverIRQHandler();
692}
693
694WEAK void LPSPI1_IRQHandler(void)
695{ LPSPI1_DriverIRQHandler();
696}
697
698WEAK void LPSPI2_IRQHandler(void)
699{ LPSPI2_DriverIRQHandler();
700}
701
702WEAK void PWM1_0_IRQHandler(void)
703{ PWM1_0_DriverIRQHandler();
704}
705
706WEAK void PWM1_1_IRQHandler(void)
707{ PWM1_1_DriverIRQHandler();
708}
709
710WEAK void PWM1_2_IRQHandler(void)
711{ PWM1_2_DriverIRQHandler();
712}
713
714WEAK void PWM1_3_IRQHandler(void)
715{ PWM1_3_DriverIRQHandler();
716}
717
718WEAK void PWM1_FAULT_IRQHandler(void)
719{ PWM1_FAULT_DriverIRQHandler();
720}
721
722WEAK void KPP_IRQHandler(void)
723{ KPP_DriverIRQHandler();
724}
725
726WEAK void SRC_IRQHandler(void)
727{ SRC_DriverIRQHandler();
728}
729
730WEAK void GPR_IRQ_IRQHandler(void)
731{ GPR_IRQ_DriverIRQHandler();
732}
733
734WEAK void CCM_1_IRQHandler(void)
735{ CCM_1_DriverIRQHandler();
736}
737
738WEAK void CCM_2_IRQHandler(void)
739{ CCM_2_DriverIRQHandler();
740}
741
742WEAK void EWM_IRQHandler(void)
743{ EWM_DriverIRQHandler();
744}
745
746WEAK void WDOG2_IRQHandler(void)
747{ WDOG2_DriverIRQHandler();
748}
749
750WEAK void SNVS_HP_WRAPPER_IRQHandler(void)
751{ SNVS_HP_WRAPPER_DriverIRQHandler();
752}
753
754WEAK void SNVS_HP_WRAPPER_TZ_IRQHandler(void)
755{ SNVS_HP_WRAPPER_TZ_DriverIRQHandler();
756}
757
758WEAK void SNVS_LP_WRAPPER_IRQHandler(void)
759{ SNVS_LP_WRAPPER_DriverIRQHandler();
760}
761
762WEAK void CSU_IRQHandler(void)
763{ CSU_DriverIRQHandler();
764}
765
766WEAK void DCP_IRQHandler(void)
767{ DCP_DriverIRQHandler();
768}
769
770WEAK void DCP_VMI_IRQHandler(void)
771{ DCP_VMI_DriverIRQHandler();
772}
773
774WEAK void Reserved68_IRQHandler(void)
775{ Reserved68_DriverIRQHandler();
776}
777
778WEAK void TRNG_IRQHandler(void)
779{ TRNG_DriverIRQHandler();
780}
781
782WEAK void Reserved70_IRQHandler(void)
783{ Reserved70_DriverIRQHandler();
784}
785
786WEAK void Reserved71_IRQHandler(void)
787{ Reserved71_DriverIRQHandler();
788}
789
790WEAK void SAI1_IRQHandler(void)
791{ SAI1_DriverIRQHandler();
792}
793
794WEAK void RTWDOG_IRQHandler(void)
795{ RTWDOG_DriverIRQHandler();
796}
797
798WEAK void SAI3_RX_IRQHandler(void)
799{ SAI3_RX_DriverIRQHandler();
800}
801
802WEAK void SAI3_TX_IRQHandler(void)
803{ SAI3_TX_DriverIRQHandler();
804}
805
806WEAK void SPDIF_IRQHandler(void)
807{ SPDIF_DriverIRQHandler();
808}
809
810WEAK void PMU_IRQHandler(void)
811{ PMU_DriverIRQHandler();
812}
813
814WEAK void XBAR1_IRQ_0_1_2_3_IRQHandler(void)
815{ XBAR1_IRQ_0_1_2_3_DriverIRQHandler();
816}
817
818WEAK void TEMP_LOW_HIGH_IRQHandler(void)
819{ TEMP_LOW_HIGH_DriverIRQHandler();
820}
821
822WEAK void TEMP_PANIC_IRQHandler(void)
823{ TEMP_PANIC_DriverIRQHandler();
824}
825
826WEAK void USB_PHY_IRQHandler(void)
827{ USB_PHY_DriverIRQHandler();
828}
829
830WEAK void GPC_IRQHandler(void)
831{ GPC_DriverIRQHandler();
832}
833
834WEAK void ADC1_IRQHandler(void)
835{ ADC1_DriverIRQHandler();
836}
837
838WEAK void FLEXIO1_IRQHandler(void)
839{ FLEXIO1_DriverIRQHandler();
840}
841
842WEAK void DCDC_IRQHandler(void)
843{ DCDC_DriverIRQHandler();
844}
845
846WEAK void GPIO1_Combined_0_15_IRQHandler(void)
847{ GPIO1_Combined_0_15_DriverIRQHandler();
848}
849
850WEAK void GPIO1_Combined_16_31_IRQHandler(void)
851{ GPIO1_Combined_16_31_DriverIRQHandler();
852}
853
854WEAK void GPIO2_Combined_0_15_IRQHandler(void)
855{ GPIO2_Combined_0_15_DriverIRQHandler();
856}
857
858WEAK void GPIO5_Combined_0_15_IRQHandler(void)
859{ GPIO5_Combined_0_15_DriverIRQHandler();
860}
861
862WEAK void WDOG1_IRQHandler(void)
863{ WDOG1_DriverIRQHandler();
864}
865
866WEAK void ADC_ETC_IRQ0_IRQHandler(void)
867{ ADC_ETC_IRQ0_DriverIRQHandler();
868}
869
870WEAK void ADC_ETC_IRQ1_IRQHandler(void)
871{ ADC_ETC_IRQ1_DriverIRQHandler();
872}
873
874WEAK void ADC_ETC_IRQ2_IRQHandler(void)
875{ ADC_ETC_IRQ2_DriverIRQHandler();
876}
877
878WEAK void ADC_ETC_IRQ3_IRQHandler(void)
879{ ADC_ETC_IRQ3_DriverIRQHandler();
880}
881
882WEAK void ADC_ETC_ERROR_IRQ_IRQHandler(void)
883{ ADC_ETC_ERROR_IRQ_DriverIRQHandler();
884}
885
886//*****************************************************************************
887
888#if defined (DEBUG)
889#pragma GCC pop_options
890#endif // (DEBUG)