aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/MK66F18/mcuxpresso/startup_mk66f18.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MK66F18/mcuxpresso/startup_mk66f18.c')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/MK66F18/mcuxpresso/startup_mk66f18.c1040
1 files changed, 1040 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MK66F18/mcuxpresso/startup_mk66f18.c b/lib/chibios-contrib/ext/mcux-sdk/devices/MK66F18/mcuxpresso/startup_mk66f18.c
new file mode 100644
index 000000000..d0f0bb20c
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MK66F18/mcuxpresso/startup_mk66f18.c
@@ -0,0 +1,1040 @@
1//*****************************************************************************
2// MK66F18 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_DMA16_IRQHandler(void);
88WEAK void DMA1_DMA17_IRQHandler(void);
89WEAK void DMA2_DMA18_IRQHandler(void);
90WEAK void DMA3_DMA19_IRQHandler(void);
91WEAK void DMA4_DMA20_IRQHandler(void);
92WEAK void DMA5_DMA21_IRQHandler(void);
93WEAK void DMA6_DMA22_IRQHandler(void);
94WEAK void DMA7_DMA23_IRQHandler(void);
95WEAK void DMA8_DMA24_IRQHandler(void);
96WEAK void DMA9_DMA25_IRQHandler(void);
97WEAK void DMA10_DMA26_IRQHandler(void);
98WEAK void DMA11_DMA27_IRQHandler(void);
99WEAK void DMA12_DMA28_IRQHandler(void);
100WEAK void DMA13_DMA29_IRQHandler(void);
101WEAK void DMA14_DMA30_IRQHandler(void);
102WEAK void DMA15_DMA31_IRQHandler(void);
103WEAK void DMA_Error_IRQHandler(void);
104WEAK void MCM_IRQHandler(void);
105WEAK void FTFE_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 Reserved46_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 UART3_RX_TX_IRQHandler(void);
125WEAK void UART3_ERR_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 CMT_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 USBDCD_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 SPI2_IRQHandler(void);
153WEAK void UART4_RX_TX_IRQHandler(void);
154WEAK void UART4_ERR_IRQHandler(void);
155WEAK void Reserved84_IRQHandler(void);
156WEAK void Reserved85_IRQHandler(void);
157WEAK void CMP2_IRQHandler(void);
158WEAK void FTM3_IRQHandler(void);
159WEAK void DAC1_IRQHandler(void);
160WEAK void ADC1_IRQHandler(void);
161WEAK void I2C2_IRQHandler(void);
162WEAK void CAN0_ORed_Message_buffer_IRQHandler(void);
163WEAK void CAN0_Bus_Off_IRQHandler(void);
164WEAK void CAN0_Error_IRQHandler(void);
165WEAK void CAN0_Tx_Warning_IRQHandler(void);
166WEAK void CAN0_Rx_Warning_IRQHandler(void);
167WEAK void CAN0_Wake_Up_IRQHandler(void);
168WEAK void SDHC_IRQHandler(void);
169WEAK void ENET_1588_Timer_IRQHandler(void);
170WEAK void ENET_Transmit_IRQHandler(void);
171WEAK void ENET_Receive_IRQHandler(void);
172WEAK void ENET_Error_IRQHandler(void);
173WEAK void LPUART0_IRQHandler(void);
174WEAK void TSI0_IRQHandler(void);
175WEAK void TPM1_IRQHandler(void);
176WEAK void TPM2_IRQHandler(void);
177WEAK void USBHSDCD_IRQHandler(void);
178WEAK void I2C3_IRQHandler(void);
179WEAK void CMP3_IRQHandler(void);
180WEAK void USBHS_IRQHandler(void);
181WEAK void CAN1_ORed_Message_buffer_IRQHandler(void);
182WEAK void CAN1_Bus_Off_IRQHandler(void);
183WEAK void CAN1_Error_IRQHandler(void);
184WEAK void CAN1_Tx_Warning_IRQHandler(void);
185WEAK void CAN1_Rx_Warning_IRQHandler(void);
186WEAK void CAN1_Wake_Up_IRQHandler(void);
187
188//*****************************************************************************
189// Forward declaration of the driver IRQ handlers. These are aliased
190// to the IntDefaultHandler, which is a 'forever' loop. When the driver
191// defines a handler (with the same name), this will automatically take
192// precedence over these weak definitions
193//*****************************************************************************
194void DMA0_DMA16_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
195void DMA1_DMA17_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
196void DMA2_DMA18_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
197void DMA3_DMA19_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
198void DMA4_DMA20_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
199void DMA5_DMA21_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
200void DMA6_DMA22_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
201void DMA7_DMA23_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
202void DMA8_DMA24_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
203void DMA9_DMA25_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
204void DMA10_DMA26_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
205void DMA11_DMA27_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
206void DMA12_DMA28_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
207void DMA13_DMA29_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
208void DMA14_DMA30_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
209void DMA15_DMA31_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
210void DMA_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
211void MCM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
212void FTFE_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
213void Read_Collision_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
214void LVD_LVW_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
215void LLWU_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
216void WDOG_EWM_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
217void RNG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
218void I2C0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
219void I2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
220void SPI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
221void SPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
222void I2S0_Tx_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
223void I2S0_Rx_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
224void Reserved46_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
225void UART0_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
226void UART0_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
227void UART1_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
228void UART1_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
229void UART2_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
230void UART2_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
231void UART3_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
232void UART3_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
233void ADC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
234void CMP0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
235void CMP1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
236void FTM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
237void FTM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
238void FTM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
239void CMT_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
240void RTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
241void RTC_Seconds_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
242void PIT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
243void PIT1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
244void PIT2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
245void PIT3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
246void PDB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
247void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
248void USBDCD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
249void Reserved71_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
250void DAC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
251void MCG_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
252void LPTMR0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
253void PORTA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
254void PORTB_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
255void PORTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
256void PORTD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
257void PORTE_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
258void SWI_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
259void SPI2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
260void UART4_RX_TX_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
261void UART4_ERR_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
262void Reserved84_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
263void Reserved85_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
264void CMP2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
265void FTM3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
266void DAC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
267void ADC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
268void I2C2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
269void CAN0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
270void SDHC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
271void ENET_1588_Timer_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
272void ENET_Transmit_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
273void ENET_Receive_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
274void ENET_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
275void LPUART0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
276void TSI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
277void TPM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
278void TPM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
279void USBHSDCD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
280void I2C3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
281void CMP3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
282void USBHS_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
283void CAN1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
284
285//*****************************************************************************
286// The entry point for the application.
287// __main() is the entry point for Redlib based applications
288// main() is the entry point for Newlib based applications
289//*****************************************************************************
290#if defined (__REDLIB__)
291extern void __main(void);
292#endif
293extern int main(void);
294
295//*****************************************************************************
296// External declaration for the pointer to the stack top from the Linker Script
297//*****************************************************************************
298extern void _vStackTop(void);
299//*****************************************************************************
300#if defined (__cplusplus)
301} // extern "C"
302#endif
303//*****************************************************************************
304// The vector table.
305// This relies on the linker script to place at correct location in memory.
306//*****************************************************************************
307
308
309
310extern void (* const g_pfnVectors[])(void);
311extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
312
313__attribute__ ((used, section(".isr_vector")))
314void (* const g_pfnVectors[])(void) = {
315 // Core Level - CM4
316 &_vStackTop, // The initial stack pointer
317 ResetISR, // The reset handler
318 NMI_Handler, // The NMI handler
319 HardFault_Handler, // The hard fault handler
320 MemManage_Handler, // The MPU fault handler
321 BusFault_Handler, // The bus fault handler
322 UsageFault_Handler, // The usage fault handler
323 0, // Reserved
324 0, // Reserved
325 0, // Reserved
326 0, // Reserved
327 SVC_Handler, // SVCall handler
328 DebugMon_Handler, // Debug monitor handler
329 0, // Reserved
330 PendSV_Handler, // The PendSV handler
331 SysTick_Handler, // The SysTick handler
332
333 // Chip Level - MK66F18
334 DMA0_DMA16_IRQHandler, // 16 : DMA Channel 0, 16 Transfer Complete
335 DMA1_DMA17_IRQHandler, // 17 : DMA Channel 1, 17 Transfer Complete
336 DMA2_DMA18_IRQHandler, // 18 : DMA Channel 2, 18 Transfer Complete
337 DMA3_DMA19_IRQHandler, // 19 : DMA Channel 3, 19 Transfer Complete
338 DMA4_DMA20_IRQHandler, // 20 : DMA Channel 4, 20 Transfer Complete
339 DMA5_DMA21_IRQHandler, // 21 : DMA Channel 5, 21 Transfer Complete
340 DMA6_DMA22_IRQHandler, // 22 : DMA Channel 6, 22 Transfer Complete
341 DMA7_DMA23_IRQHandler, // 23 : DMA Channel 7, 23 Transfer Complete
342 DMA8_DMA24_IRQHandler, // 24 : DMA Channel 8, 24 Transfer Complete
343 DMA9_DMA25_IRQHandler, // 25 : DMA Channel 9, 25 Transfer Complete
344 DMA10_DMA26_IRQHandler, // 26 : DMA Channel 10, 26 Transfer Complete
345 DMA11_DMA27_IRQHandler, // 27 : DMA Channel 11, 27 Transfer Complete
346 DMA12_DMA28_IRQHandler, // 28 : DMA Channel 12, 28 Transfer Complete
347 DMA13_DMA29_IRQHandler, // 29 : DMA Channel 13, 29 Transfer Complete
348 DMA14_DMA30_IRQHandler, // 30 : DMA Channel 14, 30 Transfer Complete
349 DMA15_DMA31_IRQHandler, // 31 : DMA Channel 15, 31 Transfer Complete
350 DMA_Error_IRQHandler, // 32 : DMA Error Interrupt
351 MCM_IRQHandler, // 33 : Normal Interrupt
352 FTFE_IRQHandler, // 34 : FTFE Command complete interrupt
353 Read_Collision_IRQHandler, // 35 : Read Collision Interrupt
354 LVD_LVW_IRQHandler, // 36 : Low Voltage Detect, Low Voltage Warning
355 LLWU_IRQHandler, // 37 : Low Leakage Wakeup Unit
356 WDOG_EWM_IRQHandler, // 38 : WDOG Interrupt
357 RNG_IRQHandler, // 39 : RNG Interrupt
358 I2C0_IRQHandler, // 40 : I2C0 interrupt
359 I2C1_IRQHandler, // 41 : I2C1 interrupt
360 SPI0_IRQHandler, // 42 : SPI0 Interrupt
361 SPI1_IRQHandler, // 43 : SPI1 Interrupt
362 I2S0_Tx_IRQHandler, // 44 : I2S0 transmit interrupt
363 I2S0_Rx_IRQHandler, // 45 : I2S0 receive interrupt
364 Reserved46_IRQHandler, // 46 : Reserved interrupt
365 UART0_RX_TX_IRQHandler, // 47 : UART0 Receive/Transmit interrupt
366 UART0_ERR_IRQHandler, // 48 : UART0 Error interrupt
367 UART1_RX_TX_IRQHandler, // 49 : UART1 Receive/Transmit interrupt
368 UART1_ERR_IRQHandler, // 50 : UART1 Error interrupt
369 UART2_RX_TX_IRQHandler, // 51 : UART2 Receive/Transmit interrupt
370 UART2_ERR_IRQHandler, // 52 : UART2 Error interrupt
371 UART3_RX_TX_IRQHandler, // 53 : UART3 Receive/Transmit interrupt
372 UART3_ERR_IRQHandler, // 54 : UART3 Error interrupt
373 ADC0_IRQHandler, // 55 : ADC0 interrupt
374 CMP0_IRQHandler, // 56 : CMP0 interrupt
375 CMP1_IRQHandler, // 57 : CMP1 interrupt
376 FTM0_IRQHandler, // 58 : FTM0 fault, overflow and channels interrupt
377 FTM1_IRQHandler, // 59 : FTM1 fault, overflow and channels interrupt
378 FTM2_IRQHandler, // 60 : FTM2 fault, overflow and channels interrupt
379 CMT_IRQHandler, // 61 : CMT interrupt
380 RTC_IRQHandler, // 62 : RTC interrupt
381 RTC_Seconds_IRQHandler, // 63 : RTC seconds interrupt
382 PIT0_IRQHandler, // 64 : PIT timer channel 0 interrupt
383 PIT1_IRQHandler, // 65 : PIT timer channel 1 interrupt
384 PIT2_IRQHandler, // 66 : PIT timer channel 2 interrupt
385 PIT3_IRQHandler, // 67 : PIT timer channel 3 interrupt
386 PDB0_IRQHandler, // 68 : PDB0 Interrupt
387 USB0_IRQHandler, // 69 : USB0 interrupt
388 USBDCD_IRQHandler, // 70 : USBDCD Interrupt
389 Reserved71_IRQHandler, // 71 : Reserved interrupt
390 DAC0_IRQHandler, // 72 : DAC0 interrupt
391 MCG_IRQHandler, // 73 : MCG Interrupt
392 LPTMR0_IRQHandler, // 74 : LPTimer interrupt
393 PORTA_IRQHandler, // 75 : Port A interrupt
394 PORTB_IRQHandler, // 76 : Port B interrupt
395 PORTC_IRQHandler, // 77 : Port C interrupt
396 PORTD_IRQHandler, // 78 : Port D interrupt
397 PORTE_IRQHandler, // 79 : Port E interrupt
398 SWI_IRQHandler, // 80 : Software interrupt
399 SPI2_IRQHandler, // 81 : SPI2 Interrupt
400 UART4_RX_TX_IRQHandler, // 82 : UART4 Receive/Transmit interrupt
401 UART4_ERR_IRQHandler, // 83 : UART4 Error interrupt
402 Reserved84_IRQHandler, // 84 : Reserved interrupt
403 Reserved85_IRQHandler, // 85 : Reserved interrupt
404 CMP2_IRQHandler, // 86 : CMP2 interrupt
405 FTM3_IRQHandler, // 87 : FTM3 fault, overflow and channels interrupt
406 DAC1_IRQHandler, // 88 : DAC1 interrupt
407 ADC1_IRQHandler, // 89 : ADC1 interrupt
408 I2C2_IRQHandler, // 90 : I2C2 interrupt
409 CAN0_ORed_Message_buffer_IRQHandler, // 91 : CAN0 OR'd message buffers interrupt
410 CAN0_Bus_Off_IRQHandler, // 92 : CAN0 bus off interrupt
411 CAN0_Error_IRQHandler, // 93 : CAN0 error interrupt
412 CAN0_Tx_Warning_IRQHandler, // 94 : CAN0 Tx warning interrupt
413 CAN0_Rx_Warning_IRQHandler, // 95 : CAN0 Rx warning interrupt
414 CAN0_Wake_Up_IRQHandler, // 96 : CAN0 wake up interrupt
415 SDHC_IRQHandler, // 97 : SDHC interrupt
416 ENET_1588_Timer_IRQHandler, // 98 : Ethernet MAC IEEE 1588 Timer Interrupt
417 ENET_Transmit_IRQHandler, // 99 : Ethernet MAC Transmit Interrupt
418 ENET_Receive_IRQHandler, // 100: Ethernet MAC Receive Interrupt
419 ENET_Error_IRQHandler, // 101: Ethernet MAC Error and miscelaneous Interrupt
420 LPUART0_IRQHandler, // 102: LPUART0 status/error interrupt
421 TSI0_IRQHandler, // 103: TSI0 interrupt
422 TPM1_IRQHandler, // 104: TPM1 fault, overflow and channels interrupt
423 TPM2_IRQHandler, // 105: TPM2 fault, overflow and channels interrupt
424 USBHSDCD_IRQHandler, // 106: USBHSDCD, USBHS Phy Interrupt
425 I2C3_IRQHandler, // 107: I2C3 interrupt
426 CMP3_IRQHandler, // 108: CMP3 interrupt
427 USBHS_IRQHandler, // 109: USB high speed OTG interrupt
428 CAN1_ORed_Message_buffer_IRQHandler, // 110: CAN1 OR'd message buffers interrupt
429 CAN1_Bus_Off_IRQHandler, // 111: CAN1 bus off interrupt
430 CAN1_Error_IRQHandler, // 112: CAN1 error interrupt
431 CAN1_Tx_Warning_IRQHandler, // 113: CAN1 Tx warning interrupt
432 CAN1_Rx_Warning_IRQHandler, // 114: CAN1 Rx warning interrupt
433 CAN1_Wake_Up_IRQHandler, // 115: CAN1 wake up interrupt
434
435
436}; /* End of g_pfnVectors */
437
438//*****************************************************************************
439// Functions to carry out the initialization of RW and BSS data sections. These
440// are written as separate functions rather than being inlined within the
441// ResetISR() function in order to cope with MCUs with multiple banks of
442// memory.
443//*****************************************************************************
444__attribute__ ((section(".after_vectors.init_data")))
445void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
446 unsigned int *pulDest = (unsigned int*) start;
447 unsigned int *pulSrc = (unsigned int*) romstart;
448 unsigned int loop;
449 for (loop = 0; loop < len; loop = loop + 4)
450 *pulDest++ = *pulSrc++;
451}
452
453__attribute__ ((section(".after_vectors.init_bss")))
454void bss_init(unsigned int start, unsigned int len) {
455 unsigned int *pulDest = (unsigned int*) start;
456 unsigned int loop;
457 for (loop = 0; loop < len; loop = loop + 4)
458 *pulDest++ = 0;
459}
460
461//*****************************************************************************
462// The following symbols are constructs generated by the linker, indicating
463// the location of various points in the "Global Section Table". This table is
464// created by the linker via the Code Red managed linker script mechanism. It
465// contains the load address, execution address and length of each RW data
466// section and the execution and length of each BSS (zero initialized) section.
467//*****************************************************************************
468extern unsigned int __data_section_table;
469extern unsigned int __data_section_table_end;
470extern unsigned int __bss_section_table;
471extern unsigned int __bss_section_table_end;
472
473//*****************************************************************************
474// Reset entry point for your code.
475// Sets up a simple runtime environment and initializes the C/C++
476// library.
477//*****************************************************************************
478__attribute__ ((section(".after_vectors.reset")))
479void ResetISR(void) {
480
481 // Disable interrupts
482 __asm volatile ("cpsid i");
483
484
485#if defined (__USE_CMSIS)
486// If __USE_CMSIS defined, then call CMSIS SystemInit code
487 SystemInit();
488
489#else
490 // Disable Watchdog
491 // Write 0xC520 to watchdog unlock register
492 *((volatile unsigned short *)0x4005200E) = 0xC520;
493 // Followed by 0xD928 to complete the unlock
494 *((volatile unsigned short *)0x4005200E) = 0xD928;
495 // Now disable watchdog via STCTRLH register
496 *((volatile unsigned short *)0x40052000) = 0x01D2u;
497#endif // (__USE_CMSIS)
498
499 //
500 // Copy the data sections from flash to SRAM.
501 //
502 unsigned int LoadAddr, ExeAddr, SectionLen;
503 unsigned int *SectionTableAddr;
504
505 // Load base address of Global Section Table
506 SectionTableAddr = &__data_section_table;
507
508 // Copy the data sections from flash to SRAM.
509 while (SectionTableAddr < &__data_section_table_end) {
510 LoadAddr = *SectionTableAddr++;
511 ExeAddr = *SectionTableAddr++;
512 SectionLen = *SectionTableAddr++;
513 data_init(LoadAddr, ExeAddr, SectionLen);
514 }
515
516 // At this point, SectionTableAddr = &__bss_section_table;
517 // Zero fill the bss segment
518 while (SectionTableAddr < &__bss_section_table_end) {
519 ExeAddr = *SectionTableAddr++;
520 SectionLen = *SectionTableAddr++;
521 bss_init(ExeAddr, SectionLen);
522 }
523
524#if !defined (__USE_CMSIS)
525// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
526// will enable the FPU
527#if defined (__VFP_FP__) && !defined (__SOFTFP__)
528 //
529 // Code to enable the Cortex-M4 FPU only included
530 // if appropriate build options have been selected.
531 // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
532 //
533 // Read CPACR (located at address 0xE000ED88)
534 // Set bits 20-23 to enable CP10 and CP11 coprocessors
535 // Write back the modified value to the CPACR
536 asm volatile ("LDR.W R0, =0xE000ED88\n\t"
537 "LDR R1, [R0]\n\t"
538 "ORR R1, R1, #(0xF << 20)\n\t"
539 "STR R1, [R0]");
540#endif // (__VFP_FP__) && !(__SOFTFP__)
541#endif // (__USE_CMSIS)
542
543
544#if !defined (__USE_CMSIS)
545// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
546// will setup the VTOR register
547
548 // Check to see if we are running the code from a non-zero
549 // address (eg RAM, external flash), in which case we need
550 // to modify the VTOR register to tell the CPU that the
551 // vector table is located at a non-0x0 address.
552 unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
553 if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
554 *pSCB_VTOR = (unsigned int)g_pfnVectors;
555 }
556#endif // (__USE_CMSIS)
557#if defined (__cplusplus)
558 //
559 // Call C++ library initialisation
560 //
561 __libc_init_array();
562#endif
563
564 // Reenable interrupts
565 __asm volatile ("cpsie i");
566
567#if defined (__REDLIB__)
568 // Call the Redlib library, which in turn calls main()
569 __main();
570#else
571 main();
572#endif
573
574 //
575 // main() shouldn't return, but if it does, we'll just enter an infinite loop
576 //
577 while (1) {
578 ;
579 }
580}
581
582//*****************************************************************************
583// Default core exception handlers. Override the ones here by defining your own
584// handler routines in your application code.
585//*****************************************************************************
586WEAK_AV void NMI_Handler(void)
587{ while(1) {}
588}
589
590WEAK_AV void HardFault_Handler(void)
591{ while(1) {}
592}
593
594WEAK_AV void MemManage_Handler(void)
595{ while(1) {}
596}
597
598WEAK_AV void BusFault_Handler(void)
599{ while(1) {}
600}
601
602WEAK_AV void UsageFault_Handler(void)
603{ while(1) {}
604}
605
606WEAK_AV void SVC_Handler(void)
607{ while(1) {}
608}
609
610WEAK_AV void DebugMon_Handler(void)
611{ while(1) {}
612}
613
614WEAK_AV void PendSV_Handler(void)
615{ while(1) {}
616}
617
618WEAK_AV void SysTick_Handler(void)
619{ while(1) {}
620}
621
622//*****************************************************************************
623// Processor ends up here if an unexpected interrupt occurs or a specific
624// handler is not present in the application code.
625//*****************************************************************************
626WEAK_AV void IntDefaultHandler(void)
627{ while(1) {}
628}
629
630//*****************************************************************************
631// Default application exception handlers. Override the ones here by defining
632// your own handler routines in your application code. These routines call
633// driver exception handlers or IntDefaultHandler() if no driver exception
634// handler is included.
635//*****************************************************************************
636WEAK void DMA0_DMA16_IRQHandler(void)
637{ DMA0_DMA16_DriverIRQHandler();
638}
639
640WEAK void DMA1_DMA17_IRQHandler(void)
641{ DMA1_DMA17_DriverIRQHandler();
642}
643
644WEAK void DMA2_DMA18_IRQHandler(void)
645{ DMA2_DMA18_DriverIRQHandler();
646}
647
648WEAK void DMA3_DMA19_IRQHandler(void)
649{ DMA3_DMA19_DriverIRQHandler();
650}
651
652WEAK void DMA4_DMA20_IRQHandler(void)
653{ DMA4_DMA20_DriverIRQHandler();
654}
655
656WEAK void DMA5_DMA21_IRQHandler(void)
657{ DMA5_DMA21_DriverIRQHandler();
658}
659
660WEAK void DMA6_DMA22_IRQHandler(void)
661{ DMA6_DMA22_DriverIRQHandler();
662}
663
664WEAK void DMA7_DMA23_IRQHandler(void)
665{ DMA7_DMA23_DriverIRQHandler();
666}
667
668WEAK void DMA8_DMA24_IRQHandler(void)
669{ DMA8_DMA24_DriverIRQHandler();
670}
671
672WEAK void DMA9_DMA25_IRQHandler(void)
673{ DMA9_DMA25_DriverIRQHandler();
674}
675
676WEAK void DMA10_DMA26_IRQHandler(void)
677{ DMA10_DMA26_DriverIRQHandler();
678}
679
680WEAK void DMA11_DMA27_IRQHandler(void)
681{ DMA11_DMA27_DriverIRQHandler();
682}
683
684WEAK void DMA12_DMA28_IRQHandler(void)
685{ DMA12_DMA28_DriverIRQHandler();
686}
687
688WEAK void DMA13_DMA29_IRQHandler(void)
689{ DMA13_DMA29_DriverIRQHandler();
690}
691
692WEAK void DMA14_DMA30_IRQHandler(void)
693{ DMA14_DMA30_DriverIRQHandler();
694}
695
696WEAK void DMA15_DMA31_IRQHandler(void)
697{ DMA15_DMA31_DriverIRQHandler();
698}
699
700WEAK void DMA_Error_IRQHandler(void)
701{ DMA_Error_DriverIRQHandler();
702}
703
704WEAK void MCM_IRQHandler(void)
705{ MCM_DriverIRQHandler();
706}
707
708WEAK void FTFE_IRQHandler(void)
709{ FTFE_DriverIRQHandler();
710}
711
712WEAK void Read_Collision_IRQHandler(void)
713{ Read_Collision_DriverIRQHandler();
714}
715
716WEAK void LVD_LVW_IRQHandler(void)
717{ LVD_LVW_DriverIRQHandler();
718}
719
720WEAK void LLWU_IRQHandler(void)
721{ LLWU_DriverIRQHandler();
722}
723
724WEAK void WDOG_EWM_IRQHandler(void)
725{ WDOG_EWM_DriverIRQHandler();
726}
727
728WEAK void RNG_IRQHandler(void)
729{ RNG_DriverIRQHandler();
730}
731
732WEAK void I2C0_IRQHandler(void)
733{ I2C0_DriverIRQHandler();
734}
735
736WEAK void I2C1_IRQHandler(void)
737{ I2C1_DriverIRQHandler();
738}
739
740WEAK void SPI0_IRQHandler(void)
741{ SPI0_DriverIRQHandler();
742}
743
744WEAK void SPI1_IRQHandler(void)
745{ SPI1_DriverIRQHandler();
746}
747
748WEAK void I2S0_Tx_IRQHandler(void)
749{ I2S0_Tx_DriverIRQHandler();
750}
751
752WEAK void I2S0_Rx_IRQHandler(void)
753{ I2S0_Rx_DriverIRQHandler();
754}
755
756WEAK void Reserved46_IRQHandler(void)
757{ Reserved46_DriverIRQHandler();
758}
759
760WEAK void UART0_RX_TX_IRQHandler(void)
761{ UART0_RX_TX_DriverIRQHandler();
762}
763
764WEAK void UART0_ERR_IRQHandler(void)
765{ UART0_ERR_DriverIRQHandler();
766}
767
768WEAK void UART1_RX_TX_IRQHandler(void)
769{ UART1_RX_TX_DriverIRQHandler();
770}
771
772WEAK void UART1_ERR_IRQHandler(void)
773{ UART1_ERR_DriverIRQHandler();
774}
775
776WEAK void UART2_RX_TX_IRQHandler(void)
777{ UART2_RX_TX_DriverIRQHandler();
778}
779
780WEAK void UART2_ERR_IRQHandler(void)
781{ UART2_ERR_DriverIRQHandler();
782}
783
784WEAK void UART3_RX_TX_IRQHandler(void)
785{ UART3_RX_TX_DriverIRQHandler();
786}
787
788WEAK void UART3_ERR_IRQHandler(void)
789{ UART3_ERR_DriverIRQHandler();
790}
791
792WEAK void ADC0_IRQHandler(void)
793{ ADC0_DriverIRQHandler();
794}
795
796WEAK void CMP0_IRQHandler(void)
797{ CMP0_DriverIRQHandler();
798}
799
800WEAK void CMP1_IRQHandler(void)
801{ CMP1_DriverIRQHandler();
802}
803
804WEAK void FTM0_IRQHandler(void)
805{ FTM0_DriverIRQHandler();
806}
807
808WEAK void FTM1_IRQHandler(void)
809{ FTM1_DriverIRQHandler();
810}
811
812WEAK void FTM2_IRQHandler(void)
813{ FTM2_DriverIRQHandler();
814}
815
816WEAK void CMT_IRQHandler(void)
817{ CMT_DriverIRQHandler();
818}
819
820WEAK void RTC_IRQHandler(void)
821{ RTC_DriverIRQHandler();
822}
823
824WEAK void RTC_Seconds_IRQHandler(void)
825{ RTC_Seconds_DriverIRQHandler();
826}
827
828WEAK void PIT0_IRQHandler(void)
829{ PIT0_DriverIRQHandler();
830}
831
832WEAK void PIT1_IRQHandler(void)
833{ PIT1_DriverIRQHandler();
834}
835
836WEAK void PIT2_IRQHandler(void)
837{ PIT2_DriverIRQHandler();
838}
839
840WEAK void PIT3_IRQHandler(void)
841{ PIT3_DriverIRQHandler();
842}
843
844WEAK void PDB0_IRQHandler(void)
845{ PDB0_DriverIRQHandler();
846}
847
848WEAK void USB0_IRQHandler(void)
849{ USB0_DriverIRQHandler();
850}
851
852WEAK void USBDCD_IRQHandler(void)
853{ USBDCD_DriverIRQHandler();
854}
855
856WEAK void Reserved71_IRQHandler(void)
857{ Reserved71_DriverIRQHandler();
858}
859
860WEAK void DAC0_IRQHandler(void)
861{ DAC0_DriverIRQHandler();
862}
863
864WEAK void MCG_IRQHandler(void)
865{ MCG_DriverIRQHandler();
866}
867
868WEAK void LPTMR0_IRQHandler(void)
869{ LPTMR0_DriverIRQHandler();
870}
871
872WEAK void PORTA_IRQHandler(void)
873{ PORTA_DriverIRQHandler();
874}
875
876WEAK void PORTB_IRQHandler(void)
877{ PORTB_DriverIRQHandler();
878}
879
880WEAK void PORTC_IRQHandler(void)
881{ PORTC_DriverIRQHandler();
882}
883
884WEAK void PORTD_IRQHandler(void)
885{ PORTD_DriverIRQHandler();
886}
887
888WEAK void PORTE_IRQHandler(void)
889{ PORTE_DriverIRQHandler();
890}
891
892WEAK void SWI_IRQHandler(void)
893{ SWI_DriverIRQHandler();
894}
895
896WEAK void SPI2_IRQHandler(void)
897{ SPI2_DriverIRQHandler();
898}
899
900WEAK void UART4_RX_TX_IRQHandler(void)
901{ UART4_RX_TX_DriverIRQHandler();
902}
903
904WEAK void UART4_ERR_IRQHandler(void)
905{ UART4_ERR_DriverIRQHandler();
906}
907
908WEAK void Reserved84_IRQHandler(void)
909{ Reserved84_DriverIRQHandler();
910}
911
912WEAK void Reserved85_IRQHandler(void)
913{ Reserved85_DriverIRQHandler();
914}
915
916WEAK void CMP2_IRQHandler(void)
917{ CMP2_DriverIRQHandler();
918}
919
920WEAK void FTM3_IRQHandler(void)
921{ FTM3_DriverIRQHandler();
922}
923
924WEAK void DAC1_IRQHandler(void)
925{ DAC1_DriverIRQHandler();
926}
927
928WEAK void ADC1_IRQHandler(void)
929{ ADC1_DriverIRQHandler();
930}
931
932WEAK void I2C2_IRQHandler(void)
933{ I2C2_DriverIRQHandler();
934}
935
936WEAK void CAN0_ORed_Message_buffer_IRQHandler(void)
937{ CAN0_DriverIRQHandler();
938}
939
940WEAK void CAN0_Bus_Off_IRQHandler(void)
941{ CAN0_DriverIRQHandler();
942}
943
944WEAK void CAN0_Error_IRQHandler(void)
945{ CAN0_DriverIRQHandler();
946}
947
948WEAK void CAN0_Tx_Warning_IRQHandler(void)
949{ CAN0_DriverIRQHandler();
950}
951
952WEAK void CAN0_Rx_Warning_IRQHandler(void)
953{ CAN0_DriverIRQHandler();
954}
955
956WEAK void CAN0_Wake_Up_IRQHandler(void)
957{ CAN0_DriverIRQHandler();
958}
959
960WEAK void SDHC_IRQHandler(void)
961{ SDHC_DriverIRQHandler();
962}
963
964WEAK void ENET_1588_Timer_IRQHandler(void)
965{ ENET_1588_Timer_DriverIRQHandler();
966}
967
968WEAK void ENET_Transmit_IRQHandler(void)
969{ ENET_Transmit_DriverIRQHandler();
970}
971
972WEAK void ENET_Receive_IRQHandler(void)
973{ ENET_Receive_DriverIRQHandler();
974}
975
976WEAK void ENET_Error_IRQHandler(void)
977{ ENET_Error_DriverIRQHandler();
978}
979
980WEAK void LPUART0_IRQHandler(void)
981{ LPUART0_DriverIRQHandler();
982}
983
984WEAK void TSI0_IRQHandler(void)
985{ TSI0_DriverIRQHandler();
986}
987
988WEAK void TPM1_IRQHandler(void)
989{ TPM1_DriverIRQHandler();
990}
991
992WEAK void TPM2_IRQHandler(void)
993{ TPM2_DriverIRQHandler();
994}
995
996WEAK void USBHSDCD_IRQHandler(void)
997{ USBHSDCD_DriverIRQHandler();
998}
999
1000WEAK void I2C3_IRQHandler(void)
1001{ I2C3_DriverIRQHandler();
1002}
1003
1004WEAK void CMP3_IRQHandler(void)
1005{ CMP3_DriverIRQHandler();
1006}
1007
1008WEAK void USBHS_IRQHandler(void)
1009{ USBHS_DriverIRQHandler();
1010}
1011
1012WEAK void CAN1_ORed_Message_buffer_IRQHandler(void)
1013{ CAN1_DriverIRQHandler();
1014}
1015
1016WEAK void CAN1_Bus_Off_IRQHandler(void)
1017{ CAN1_DriverIRQHandler();
1018}
1019
1020WEAK void CAN1_Error_IRQHandler(void)
1021{ CAN1_DriverIRQHandler();
1022}
1023
1024WEAK void CAN1_Tx_Warning_IRQHandler(void)
1025{ CAN1_DriverIRQHandler();
1026}
1027
1028WEAK void CAN1_Rx_Warning_IRQHandler(void)
1029{ CAN1_DriverIRQHandler();
1030}
1031
1032WEAK void CAN1_Wake_Up_IRQHandler(void)
1033{ CAN1_DriverIRQHandler();
1034}
1035
1036//*****************************************************************************
1037
1038#if defined (DEBUG)
1039#pragma GCC pop_options
1040#endif // (DEBUG)