aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018M/mcuxpresso/startup_lpc54s018m.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018M/mcuxpresso/startup_lpc54s018m.cpp')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018M/mcuxpresso/startup_lpc54s018m.cpp817
1 files changed, 817 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018M/mcuxpresso/startup_lpc54s018m.cpp b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018M/mcuxpresso/startup_lpc54s018m.cpp
new file mode 100644
index 000000000..0b9aa6719
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC54S018M/mcuxpresso/startup_lpc54s018m.cpp
@@ -0,0 +1,817 @@
1//*****************************************************************************
2// LPC54S018M 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// 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#include <NXP/crp.h>
48__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
49
50//*****************************************************************************
51// Declaration of external SystemInit function
52//*****************************************************************************
53#if defined (__USE_CMSIS)
54extern void SystemInit(void);
55#endif // (__USE_CMSIS)
56
57//*****************************************************************************
58// Forward declaration of the core exception handlers.
59// When the application defines a handler (with the same name), this will
60// automatically take precedence over these weak definitions.
61// If your application is a C++ one, then any interrupt handlers defined
62// in C++ files within in your main application will need to have C linkage
63// rather than C++ linkage. To do this, make sure that you are using extern "C"
64// { .... } around the interrupt handler within your main application code.
65//*****************************************************************************
66 void ResetISR(void);
67WEAK void NMI_Handler(void);
68WEAK void HardFault_Handler(void);
69WEAK void MemManage_Handler(void);
70WEAK void BusFault_Handler(void);
71WEAK void UsageFault_Handler(void);
72WEAK void SVC_Handler(void);
73WEAK void DebugMon_Handler(void);
74WEAK void PendSV_Handler(void);
75WEAK void SysTick_Handler(void);
76WEAK void IntDefaultHandler(void);
77
78//*****************************************************************************
79// Forward declaration of the application IRQ handlers. When the application
80// defines a handler (with the same name), this will automatically take
81// precedence over weak definitions below
82//*****************************************************************************
83WEAK void WDT_BOD_IRQHandler(void);
84WEAK void DMA0_IRQHandler(void);
85WEAK void GINT0_IRQHandler(void);
86WEAK void GINT1_IRQHandler(void);
87WEAK void PIN_INT0_IRQHandler(void);
88WEAK void PIN_INT1_IRQHandler(void);
89WEAK void PIN_INT2_IRQHandler(void);
90WEAK void PIN_INT3_IRQHandler(void);
91WEAK void UTICK0_IRQHandler(void);
92WEAK void MRT0_IRQHandler(void);
93WEAK void CTIMER0_IRQHandler(void);
94WEAK void CTIMER1_IRQHandler(void);
95WEAK void SCT0_IRQHandler(void);
96WEAK void CTIMER3_IRQHandler(void);
97WEAK void FLEXCOMM0_IRQHandler(void);
98WEAK void FLEXCOMM1_IRQHandler(void);
99WEAK void FLEXCOMM2_IRQHandler(void);
100WEAK void FLEXCOMM3_IRQHandler(void);
101WEAK void FLEXCOMM4_IRQHandler(void);
102WEAK void FLEXCOMM5_IRQHandler(void);
103WEAK void FLEXCOMM6_IRQHandler(void);
104WEAK void FLEXCOMM7_IRQHandler(void);
105WEAK void ADC0_SEQA_IRQHandler(void);
106WEAK void ADC0_SEQB_IRQHandler(void);
107WEAK void ADC0_THCMP_IRQHandler(void);
108WEAK void DMIC0_IRQHandler(void);
109WEAK void HWVAD0_IRQHandler(void);
110WEAK void USB0_NEEDCLK_IRQHandler(void);
111WEAK void USB0_IRQHandler(void);
112WEAK void RTC_IRQHandler(void);
113WEAK void FLEXCOMM10_IRQHandler(void);
114WEAK void Reserved47_IRQHandler(void);
115WEAK void PIN_INT4_IRQHandler(void);
116WEAK void PIN_INT5_IRQHandler(void);
117WEAK void PIN_INT6_IRQHandler(void);
118WEAK void PIN_INT7_IRQHandler(void);
119WEAK void CTIMER2_IRQHandler(void);
120WEAK void CTIMER4_IRQHandler(void);
121WEAK void RIT_IRQHandler(void);
122WEAK void SPIFI0_IRQHandler(void);
123WEAK void FLEXCOMM8_IRQHandler(void);
124WEAK void FLEXCOMM9_IRQHandler(void);
125WEAK void SDIO_IRQHandler(void);
126WEAK void CAN0_IRQ0_IRQHandler(void);
127WEAK void CAN0_IRQ1_IRQHandler(void);
128WEAK void CAN1_IRQ0_IRQHandler(void);
129WEAK void CAN1_IRQ1_IRQHandler(void);
130WEAK void USB1_IRQHandler(void);
131WEAK void USB1_NEEDCLK_IRQHandler(void);
132WEAK void ETHERNET_IRQHandler(void);
133WEAK void ETHERNET_PMT_IRQHandler(void);
134WEAK void ETHERNET_MACLP_IRQHandler(void);
135WEAK void Reserved68_IRQHandler(void);
136WEAK void LCD_IRQHandler(void);
137WEAK void SHA_IRQHandler(void);
138WEAK void SMARTCARD0_IRQHandler(void);
139WEAK void SMARTCARD1_IRQHandler(void);
140WEAK void Reserved73_IRQHandler(void);
141WEAK void PUF_IRQHandler(void);
142
143//*****************************************************************************
144// Forward declaration of the driver IRQ handlers. These are aliased
145// to the IntDefaultHandler, which is a 'forever' loop. When the driver
146// defines a handler (with the same name), this will automatically take
147// precedence over these weak definitions
148//*****************************************************************************
149void WDT_BOD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
150void DMA0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
151void GINT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
152void GINT1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
153void PIN_INT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
154void PIN_INT1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
155void PIN_INT2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
156void PIN_INT3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
157void UTICK0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
158void MRT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
159void CTIMER0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
160void CTIMER1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
161void SCT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
162void CTIMER3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
163void FLEXCOMM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
164void FLEXCOMM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
165void FLEXCOMM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
166void FLEXCOMM3_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
167void FLEXCOMM4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
168void FLEXCOMM5_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
169void FLEXCOMM6_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
170void FLEXCOMM7_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
171void ADC0_SEQA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
172void ADC0_SEQB_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
173void ADC0_THCMP_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
174void DMIC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
175void HWVAD0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
176void USB0_NEEDCLK_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
177void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
178void RTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
179void FLEXCOMM10_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
180void Reserved47_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
181void PIN_INT4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
182void PIN_INT5_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
183void PIN_INT6_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
184void PIN_INT7_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
185void CTIMER2_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
186void CTIMER4_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
187void RIT_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
188void SPIFI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
189void FLEXCOMM8_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
190void FLEXCOMM9_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
191void SDIO_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
192void CAN0_IRQ0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
193void CAN0_IRQ1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
194void CAN1_IRQ0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
195void CAN1_IRQ1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
196void USB1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
197void USB1_NEEDCLK_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
198void ETHERNET_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
199void ETHERNET_PMT_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
200void ETHERNET_MACLP_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
201void Reserved68_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
202void LCD_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
203void SHA_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
204void SMARTCARD0_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
205void SMARTCARD1_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
206void Reserved73_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
207void PUF_DriverIRQHandler(void) ALIAS(IntDefaultHandler);
208
209//*****************************************************************************
210// The entry point for the application.
211// __main() is the entry point for Redlib based applications
212// main() is the entry point for Newlib based applications
213//*****************************************************************************
214#if defined (__REDLIB__)
215extern void __main(void);
216#endif
217extern int main(void);
218
219//*****************************************************************************
220// External declaration for the pointer to the stack top from the Linker Script
221//*****************************************************************************
222extern void _vStackTop(void);
223extern void _image_size(void);
224//*****************************************************************************
225// External declaration for LPC MCU vector table checksum from Linker Script
226//*****************************************************************************
227WEAK extern void __valid_user_code_checksum();
228
229//*****************************************************************************
230// External declaration for image type and load address from Linker Script
231//*****************************************************************************
232WEAK extern void __imghdr_loadaddress();
233WEAK extern void __imghdr_imagetype();
234
235//*****************************************************************************
236#if defined (__cplusplus)
237} // extern "C"
238#endif
239#ifndef IMG_BAUDRATE
240#define IMG_BAUDRATE 0
241#endif
242//*****************************************************************************
243// The vector table.
244// This relies on the linker script to place at correct location in memory.
245//*****************************************************************************
246
247
248
249extern void (* const g_pfnVectors[])(void);
250extern void * __Vectors __attribute__ ((alias ("g_pfnVectors")));
251
252__attribute__ ((used, section(".isr_vector")))
253void (* const g_pfnVectors[])(void) = {
254 // Core Level - CM4
255 &_vStackTop, // The initial stack pointer
256 ResetISR, // The reset handler
257 NMI_Handler, // The NMI handler
258 HardFault_Handler, // The hard fault handler
259 MemManage_Handler, // The MPU fault handler
260 BusFault_Handler, // The bus fault handler
261 UsageFault_Handler, // The usage fault handler
262 __valid_user_code_checksum, // LPC MCU checksum
263 0, // ECRP
264 (void (*)(void))0xEDDC94BD, // Reserved
265 (void (*)(void))0x160, // Reserved
266 SVC_Handler, // SVCall handler
267 DebugMon_Handler, // Debug monitor handler
268 0, // Reserved
269 PendSV_Handler, // The PendSV handler
270 SysTick_Handler, // The SysTick handler
271
272 // Chip Level - LPC54S018M
273 WDT_BOD_IRQHandler, // 16: Windowed watchdog timer, Brownout detect
274 DMA0_IRQHandler, // 17: DMA controller
275 GINT0_IRQHandler, // 18: GPIO group 0
276 GINT1_IRQHandler, // 19: GPIO group 1
277 PIN_INT0_IRQHandler, // 20: Pin interrupt 0 or pattern match engine slice 0
278 PIN_INT1_IRQHandler, // 21: Pin interrupt 1or pattern match engine slice 1
279 PIN_INT2_IRQHandler, // 22: Pin interrupt 2 or pattern match engine slice 2
280 PIN_INT3_IRQHandler, // 23: Pin interrupt 3 or pattern match engine slice 3
281 UTICK0_IRQHandler, // 24: Micro-tick Timer
282 MRT0_IRQHandler, // 25: Multi-rate timer
283 CTIMER0_IRQHandler, // 26: Standard counter/timer CTIMER0
284 CTIMER1_IRQHandler, // 27: Standard counter/timer CTIMER1
285 SCT0_IRQHandler, // 28: SCTimer/PWM
286 CTIMER3_IRQHandler, // 29: Standard counter/timer CTIMER3
287 FLEXCOMM0_IRQHandler, // 30: Flexcomm Interface 0 (USART, SPI, I2C, FLEXCOMM)
288 FLEXCOMM1_IRQHandler, // 31: Flexcomm Interface 1 (USART, SPI, I2C, FLEXCOMM)
289 FLEXCOMM2_IRQHandler, // 32: Flexcomm Interface 2 (USART, SPI, I2C, FLEXCOMM)
290 FLEXCOMM3_IRQHandler, // 33: Flexcomm Interface 3 (USART, SPI, I2C, FLEXCOMM)
291 FLEXCOMM4_IRQHandler, // 34: Flexcomm Interface 4 (USART, SPI, I2C, FLEXCOMM)
292 FLEXCOMM5_IRQHandler, // 35: Flexcomm Interface 5 (USART, SPI, I2C,, FLEXCOMM)
293 FLEXCOMM6_IRQHandler, // 36: Flexcomm Interface 6 (USART, SPI, I2C, I2S,, FLEXCOMM)
294 FLEXCOMM7_IRQHandler, // 37: Flexcomm Interface 7 (USART, SPI, I2C, I2S,, FLEXCOMM)
295 ADC0_SEQA_IRQHandler, // 38: ADC0 sequence A completion.
296 ADC0_SEQB_IRQHandler, // 39: ADC0 sequence B completion.
297 ADC0_THCMP_IRQHandler, // 40: ADC0 threshold compare and error.
298 DMIC0_IRQHandler, // 41: Digital microphone and DMIC subsystem
299 HWVAD0_IRQHandler, // 42: Hardware Voice Activity Detector
300 USB0_NEEDCLK_IRQHandler, // 43: USB Activity Wake-up Interrupt
301 USB0_IRQHandler, // 44: USB device
302 RTC_IRQHandler, // 45: RTC alarm and wake-up interrupts
303 FLEXCOMM10_IRQHandler, // 46: Flexcomm Interface 10 (SPI, FLEXCOMM)
304 Reserved47_IRQHandler, // 47: Reserved interrupt
305 PIN_INT4_IRQHandler, // 48: Pin interrupt 4 or pattern match engine slice 4 int
306 PIN_INT5_IRQHandler, // 49: Pin interrupt 5 or pattern match engine slice 5 int
307 PIN_INT6_IRQHandler, // 50: Pin interrupt 6 or pattern match engine slice 6 int
308 PIN_INT7_IRQHandler, // 51: Pin interrupt 7 or pattern match engine slice 7 int
309 CTIMER2_IRQHandler, // 52: Standard counter/timer CTIMER2
310 CTIMER4_IRQHandler, // 53: Standard counter/timer CTIMER4
311 RIT_IRQHandler, // 54: Repetitive Interrupt Timer
312 SPIFI0_IRQHandler, // 55: SPI flash interface
313 FLEXCOMM8_IRQHandler, // 56: Flexcomm Interface 8 (USART, SPI, I2C, FLEXCOMM)
314 FLEXCOMM9_IRQHandler, // 57: Flexcomm Interface 9 (USART, SPI, I2C, FLEXCOMM)
315 SDIO_IRQHandler, // 58: SD/MMC
316 CAN0_IRQ0_IRQHandler, // 59: CAN0 interrupt0
317 CAN0_IRQ1_IRQHandler, // 60: CAN0 interrupt1
318 CAN1_IRQ0_IRQHandler, // 61: CAN1 interrupt0
319 CAN1_IRQ1_IRQHandler, // 62: CAN1 interrupt1
320 USB1_IRQHandler, // 63: USB1 interrupt
321 USB1_NEEDCLK_IRQHandler, // 64: USB1 activity
322 ETHERNET_IRQHandler, // 65: Ethernet
323 ETHERNET_PMT_IRQHandler, // 66: Ethernet power management interrupt
324 ETHERNET_MACLP_IRQHandler, // 67: Ethernet MAC interrupt
325 Reserved68_IRQHandler, // 68: Reserved interrupt
326 LCD_IRQHandler, // 69: LCD interrupt
327 SHA_IRQHandler, // 70: SHA interrupt
328 SMARTCARD0_IRQHandler, // 71: Smart card 0 interrupt
329 SMARTCARD1_IRQHandler, // 72: Smart card 1 interrupt
330 Reserved73_IRQHandler, // 73: Reserved interrupt
331 PUF_IRQHandler, // 74: PUF interrupt
332 0, // Reserved
333 0, // Reserved
334 0, // Reserved
335 0, // Reserved
336 0, // Reserved
337 0, // Reserved
338 0, // Reserved
339 0, // Reserved
340 0, // Reserved
341 0, // Reserved
342 0, // Reserved
343 0, // Reserved
344 0, // Reserved
345 (void (*)(void))0xFEEDA5A5, // Header Marker
346
347#if defined (ADD_CRC)
348 (__imghdr_imagetype - 1), // (0x04) Image Type
349 __imghdr_loadaddress, // (0x08) Load_address
350#else
351 __imghdr_imagetype, // (0x04) Image Type
352 __imghdr_loadaddress, // (0x08) Load_address
353#endif
354 (void (*)(void))(((unsigned)_image_size) - 4), // (0x0C) load_length, exclude 4 bytes CRC field.
355 0, // (0x10) CRC value (only applicable to NON Non-secure images).
356 0, // (0x14) Version (only applicable to DUAL_ENH image type.
357 0, // (0x18) EMC static memory configuration settings, required for EMC boot
358 (void (*)(void))IMG_BAUDRATE, // (0x1C) image baudrate
359 0, // (0x20) reserved
360 (void (*)(void))0xEDDC94BD, // (0x24) Image_marker
361 0, // (0x28) reserved
362 0, // (0x2C) reserved
363
364 /* SPI Descriptor - Winbond W25Q32JV */
365 (void (*)(void))0x00000000, // 0xFFFFFFFF to default 1-bit SPI mode ;DevStrAdr
366 (void (*)(void))0x001640EF, // mfgId + extCount
367 (void (*)(void))0x00000000, // extid 0-3
368 (void (*)(void))0x00000000, // reserved
369 (void (*)(void))0x1301001D, // caps
370 (void (*)(void))0x00000000, // Blks + RESV1
371 (void (*)(void))0x00000000, // blkSize
372 (void (*)(void))0x00000000, // reserved
373 (void (*)(void))0x00000100, // pageSize + RESV2
374 (void (*)(void))0x00000000, // maxReadSize
375 (void (*)(void))0x00000000, // maxClkRate,maxReadRate,maxHSReadRate,maxProgramRate
376 (void (*)(void))0x04030050, // maxHSProgramRate,initDeInitFxId,clearStatusFxId,getStatusFxId
377 (void (*)(void))0x14110D09, // setStatusFxId,setOptionsFxId,getReadCmdFxId,getWriteCmdFxId
378
379
380}; /* End of g_pfnVectors */
381
382//*****************************************************************************
383// Functions to carry out the initialization of RW and BSS data sections. These
384// are written as separate functions rather than being inlined within the
385// ResetISR() function in order to cope with MCUs with multiple banks of
386// memory.
387//*****************************************************************************
388__attribute__ ((section(".after_vectors.init_data")))
389void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
390 unsigned int *pulDest = (unsigned int*) start;
391 unsigned int *pulSrc = (unsigned int*) romstart;
392 unsigned int loop;
393 for (loop = 0; loop < len; loop = loop + 4)
394 *pulDest++ = *pulSrc++;
395}
396
397__attribute__ ((section(".after_vectors.init_bss")))
398void bss_init(unsigned int start, unsigned int len) {
399 unsigned int *pulDest = (unsigned int*) start;
400 unsigned int loop;
401 for (loop = 0; loop < len; loop = loop + 4)
402 *pulDest++ = 0;
403}
404
405//*****************************************************************************
406// The following symbols are constructs generated by the linker, indicating
407// the location of various points in the "Global Section Table". This table is
408// created by the linker via the Code Red managed linker script mechanism. It
409// contains the load address, execution address and length of each RW data
410// section and the execution and length of each BSS (zero initialized) section.
411//*****************************************************************************
412extern unsigned int __data_section_table;
413extern unsigned int __data_section_table_end;
414extern unsigned int __bss_section_table;
415extern unsigned int __bss_section_table_end;
416
417//*****************************************************************************
418// Reset entry point for your code.
419// Sets up a simple runtime environment and initializes the C/C++
420// library.
421//*****************************************************************************
422__attribute__ ((section(".after_vectors.reset")))
423void ResetISR(void) {
424
425 // Disable interrupts
426 __asm volatile ("cpsid i");
427
428
429 // Enable SRAM clock used by Stack
430 __asm volatile ("LDR R0, =0x40000220\n\t"
431 "MOV R1, #56\n\t"
432 "STR R1, [R0]");
433
434#if defined (__USE_CMSIS)
435// If __USE_CMSIS defined, then call CMSIS SystemInit code
436 SystemInit();
437
438#endif // (__USE_CMSIS)
439
440 //
441 // Copy the data sections from flash to SRAM.
442 //
443 unsigned int LoadAddr, ExeAddr, SectionLen;
444 unsigned int *SectionTableAddr;
445
446 // Load base address of Global Section Table
447 SectionTableAddr = &__data_section_table;
448
449 // Copy the data sections from flash to SRAM.
450 while (SectionTableAddr < &__data_section_table_end) {
451 LoadAddr = *SectionTableAddr++;
452 ExeAddr = *SectionTableAddr++;
453 SectionLen = *SectionTableAddr++;
454 data_init(LoadAddr, ExeAddr, SectionLen);
455 }
456
457 // At this point, SectionTableAddr = &__bss_section_table;
458 // Zero fill the bss segment
459 while (SectionTableAddr < &__bss_section_table_end) {
460 ExeAddr = *SectionTableAddr++;
461 SectionLen = *SectionTableAddr++;
462 bss_init(ExeAddr, SectionLen);
463 }
464
465#if !defined (__USE_CMSIS)
466// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
467// will enable the FPU
468#if defined (__VFP_FP__) && !defined (__SOFTFP__)
469 //
470 // Code to enable the Cortex-M4 FPU only included
471 // if appropriate build options have been selected.
472 // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
473 //
474 // Read CPACR (located at address 0xE000ED88)
475 // Set bits 20-23 to enable CP10 and CP11 coprocessors
476 // Write back the modified value to the CPACR
477 asm volatile ("LDR.W R0, =0xE000ED88\n\t"
478 "LDR R1, [R0]\n\t"
479 "ORR R1, R1, #(0xF << 20)\n\t"
480 "STR R1, [R0]");
481#endif // (__VFP_FP__) && !(__SOFTFP__)
482#endif // (__USE_CMSIS)
483
484
485#if !defined (__USE_CMSIS)
486// Assume that if __USE_CMSIS defined, then CMSIS SystemInit code
487// will setup the VTOR register
488
489 // Check to see if we are running the code from a non-zero
490 // address (eg RAM, external flash), in which case we need
491 // to modify the VTOR register to tell the CPU that the
492 // vector table is located at a non-0x0 address.
493 unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
494 if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
495 *pSCB_VTOR = (unsigned int)g_pfnVectors;
496 }
497#endif // (__USE_CMSIS)
498#if defined (__cplusplus)
499 //
500 // Call C++ library initialisation
501 //
502 __libc_init_array();
503#endif
504
505 // Reenable interrupts
506 __asm volatile ("cpsie i");
507
508#if defined (__REDLIB__)
509 // Call the Redlib library, which in turn calls main()
510 __main();
511#else
512 main();
513#endif
514
515 //
516 // main() shouldn't return, but if it does, we'll just enter an infinite loop
517 //
518 while (1) {
519 ;
520 }
521}
522
523//*****************************************************************************
524// Default core exception handlers. Override the ones here by defining your own
525// handler routines in your application code.
526//*****************************************************************************
527WEAK_AV void NMI_Handler(void)
528{ while(1) {}
529}
530
531WEAK_AV void HardFault_Handler(void)
532{ while(1) {}
533}
534
535WEAK_AV void MemManage_Handler(void)
536{ while(1) {}
537}
538
539WEAK_AV void BusFault_Handler(void)
540{ while(1) {}
541}
542
543WEAK_AV void UsageFault_Handler(void)
544{ while(1) {}
545}
546
547WEAK_AV void SVC_Handler(void)
548{ while(1) {}
549}
550
551WEAK_AV void DebugMon_Handler(void)
552{ while(1) {}
553}
554
555WEAK_AV void PendSV_Handler(void)
556{ while(1) {}
557}
558
559WEAK_AV void SysTick_Handler(void)
560{ while(1) {}
561}
562
563//*****************************************************************************
564// Processor ends up here if an unexpected interrupt occurs or a specific
565// handler is not present in the application code.
566//*****************************************************************************
567WEAK_AV void IntDefaultHandler(void)
568{ while(1) {}
569}
570
571//*****************************************************************************
572// Default application exception handlers. Override the ones here by defining
573// your own handler routines in your application code. These routines call
574// driver exception handlers or IntDefaultHandler() if no driver exception
575// handler is included.
576//*****************************************************************************
577WEAK void WDT_BOD_IRQHandler(void)
578{ WDT_BOD_DriverIRQHandler();
579}
580
581WEAK void DMA0_IRQHandler(void)
582{ DMA0_DriverIRQHandler();
583}
584
585WEAK void GINT0_IRQHandler(void)
586{ GINT0_DriverIRQHandler();
587}
588
589WEAK void GINT1_IRQHandler(void)
590{ GINT1_DriverIRQHandler();
591}
592
593WEAK void PIN_INT0_IRQHandler(void)
594{ PIN_INT0_DriverIRQHandler();
595}
596
597WEAK void PIN_INT1_IRQHandler(void)
598{ PIN_INT1_DriverIRQHandler();
599}
600
601WEAK void PIN_INT2_IRQHandler(void)
602{ PIN_INT2_DriverIRQHandler();
603}
604
605WEAK void PIN_INT3_IRQHandler(void)
606{ PIN_INT3_DriverIRQHandler();
607}
608
609WEAK void UTICK0_IRQHandler(void)
610{ UTICK0_DriverIRQHandler();
611}
612
613WEAK void MRT0_IRQHandler(void)
614{ MRT0_DriverIRQHandler();
615}
616
617WEAK void CTIMER0_IRQHandler(void)
618{ CTIMER0_DriverIRQHandler();
619}
620
621WEAK void CTIMER1_IRQHandler(void)
622{ CTIMER1_DriverIRQHandler();
623}
624
625WEAK void SCT0_IRQHandler(void)
626{ SCT0_DriverIRQHandler();
627}
628
629WEAK void CTIMER3_IRQHandler(void)
630{ CTIMER3_DriverIRQHandler();
631}
632
633WEAK void FLEXCOMM0_IRQHandler(void)
634{ FLEXCOMM0_DriverIRQHandler();
635}
636
637WEAK void FLEXCOMM1_IRQHandler(void)
638{ FLEXCOMM1_DriverIRQHandler();
639}
640
641WEAK void FLEXCOMM2_IRQHandler(void)
642{ FLEXCOMM2_DriverIRQHandler();
643}
644
645WEAK void FLEXCOMM3_IRQHandler(void)
646{ FLEXCOMM3_DriverIRQHandler();
647}
648
649WEAK void FLEXCOMM4_IRQHandler(void)
650{ FLEXCOMM4_DriverIRQHandler();
651}
652
653WEAK void FLEXCOMM5_IRQHandler(void)
654{ FLEXCOMM5_DriverIRQHandler();
655}
656
657WEAK void FLEXCOMM6_IRQHandler(void)
658{ FLEXCOMM6_DriverIRQHandler();
659}
660
661WEAK void FLEXCOMM7_IRQHandler(void)
662{ FLEXCOMM7_DriverIRQHandler();
663}
664
665WEAK void ADC0_SEQA_IRQHandler(void)
666{ ADC0_SEQA_DriverIRQHandler();
667}
668
669WEAK void ADC0_SEQB_IRQHandler(void)
670{ ADC0_SEQB_DriverIRQHandler();
671}
672
673WEAK void ADC0_THCMP_IRQHandler(void)
674{ ADC0_THCMP_DriverIRQHandler();
675}
676
677WEAK void DMIC0_IRQHandler(void)
678{ DMIC0_DriverIRQHandler();
679}
680
681WEAK void HWVAD0_IRQHandler(void)
682{ HWVAD0_DriverIRQHandler();
683}
684
685WEAK void USB0_NEEDCLK_IRQHandler(void)
686{ USB0_NEEDCLK_DriverIRQHandler();
687}
688
689WEAK void USB0_IRQHandler(void)
690{ USB0_DriverIRQHandler();
691}
692
693WEAK void RTC_IRQHandler(void)
694{ RTC_DriverIRQHandler();
695}
696
697WEAK void FLEXCOMM10_IRQHandler(void)
698{ FLEXCOMM10_DriverIRQHandler();
699}
700
701WEAK void Reserved47_IRQHandler(void)
702{ Reserved47_DriverIRQHandler();
703}
704
705WEAK void PIN_INT4_IRQHandler(void)
706{ PIN_INT4_DriverIRQHandler();
707}
708
709WEAK void PIN_INT5_IRQHandler(void)
710{ PIN_INT5_DriverIRQHandler();
711}
712
713WEAK void PIN_INT6_IRQHandler(void)
714{ PIN_INT6_DriverIRQHandler();
715}
716
717WEAK void PIN_INT7_IRQHandler(void)
718{ PIN_INT7_DriverIRQHandler();
719}
720
721WEAK void CTIMER2_IRQHandler(void)
722{ CTIMER2_DriverIRQHandler();
723}
724
725WEAK void CTIMER4_IRQHandler(void)
726{ CTIMER4_DriverIRQHandler();
727}
728
729WEAK void RIT_IRQHandler(void)
730{ RIT_DriverIRQHandler();
731}
732
733WEAK void SPIFI0_IRQHandler(void)
734{ SPIFI0_DriverIRQHandler();
735}
736
737WEAK void FLEXCOMM8_IRQHandler(void)
738{ FLEXCOMM8_DriverIRQHandler();
739}
740
741WEAK void FLEXCOMM9_IRQHandler(void)
742{ FLEXCOMM9_DriverIRQHandler();
743}
744
745WEAK void SDIO_IRQHandler(void)
746{ SDIO_DriverIRQHandler();
747}
748
749WEAK void CAN0_IRQ0_IRQHandler(void)
750{ CAN0_IRQ0_DriverIRQHandler();
751}
752
753WEAK void CAN0_IRQ1_IRQHandler(void)
754{ CAN0_IRQ1_DriverIRQHandler();
755}
756
757WEAK void CAN1_IRQ0_IRQHandler(void)
758{ CAN1_IRQ0_DriverIRQHandler();
759}
760
761WEAK void CAN1_IRQ1_IRQHandler(void)
762{ CAN1_IRQ1_DriverIRQHandler();
763}
764
765WEAK void USB1_IRQHandler(void)
766{ USB1_DriverIRQHandler();
767}
768
769WEAK void USB1_NEEDCLK_IRQHandler(void)
770{ USB1_NEEDCLK_DriverIRQHandler();
771}
772
773WEAK void ETHERNET_IRQHandler(void)
774{ ETHERNET_DriverIRQHandler();
775}
776
777WEAK void ETHERNET_PMT_IRQHandler(void)
778{ ETHERNET_PMT_DriverIRQHandler();
779}
780
781WEAK void ETHERNET_MACLP_IRQHandler(void)
782{ ETHERNET_MACLP_DriverIRQHandler();
783}
784
785WEAK void Reserved68_IRQHandler(void)
786{ Reserved68_DriverIRQHandler();
787}
788
789WEAK void LCD_IRQHandler(void)
790{ LCD_DriverIRQHandler();
791}
792
793WEAK void SHA_IRQHandler(void)
794{ SHA_DriverIRQHandler();
795}
796
797WEAK void SMARTCARD0_IRQHandler(void)
798{ SMARTCARD0_DriverIRQHandler();
799}
800
801WEAK void SMARTCARD1_IRQHandler(void)
802{ SMARTCARD1_DriverIRQHandler();
803}
804
805WEAK void Reserved73_IRQHandler(void)
806{ Reserved73_DriverIRQHandler();
807}
808
809WEAK void PUF_IRQHandler(void)
810{ PUF_DriverIRQHandler();
811}
812
813//*****************************************************************************
814
815#if defined (DEBUG)
816#pragma GCC pop_options
817#endif // (DEBUG)