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