| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cr_startup_lpc11xx.c
Go to the documentation of this file.
1 //*****************************************************************************
2 // +--+
3 // | ++----+
4 // +-++ |
5 // | |
6 // +-+--+ |
7 // | +--+--+
8 // +----+ Copyright (c) 2011-12 Code Red Technologies Ltd.
9 //
10 // Microcontroller Startup code for use with Red Suite
11 //
12 // Version : 120126
13 //
14 // Software License Agreement
15 //
16 // The software is owned by Code Red Technologies and/or its suppliers, and is
17 // protected under applicable copyright laws. All rights are reserved. Any
18 // use in violation of the foregoing restrictions may subject the user to criminal
19 // sanctions under applicable laws, as well as to civil liability for the breach
20 // of the terms and conditions of this license.
21 //
22 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
23 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
24 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
25 // USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT
26 // TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH
27 // CODE RED TECHNOLOGIES LTD.
28 //
29 //*****************************************************************************
30 #if defined (__cplusplus)
31 #ifdef __REDLIB__
32 #error Redlib does not support C++
33 #else
34 //*****************************************************************************
35 //
36 // The entry point for the C++ library startup
37 //
38 //*****************************************************************************
39 extern "C" {
40 extern void __libc_init_array(void);
41 }
42 #endif
43 #endif
44
45 #define WEAK __attribute__ ((weak))
46 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
47 /* Include sys_config.h to get the CHIP_11* device identifier */
48 #include "sys_config.h"
49
50 // Code Red - if CMSIS is being used, then SystemInit() routine
51 // will be called by startup code rather than in application's main()
52 extern void SystemInit(void);
53
54 //*****************************************************************************
55 #if defined (__cplusplus)
56 extern "C" {
57 #endif
58
59 //*****************************************************************************
60 //
61 // Forward declaration of the default handlers. These are aliased.
62 // When the application defines a handler (with the same name), this will
63 // automatically take precedence over these weak definitions
64 //
65 //*****************************************************************************
66 void ResetISR(void);
67 WEAK void NMI_Handler(void);
68 WEAK void HardFault_Handler(void);
69 WEAK void SVC_Handler(void);
70 WEAK void PendSV_Handler(void);
71 WEAK void SysTick_Handler(void);
72 WEAK void IntDefaultHandler(void);
73
74 //*****************************************************************************
75 //
76 // Forward declaration of the specific IRQ handlers. These are aliased
77 // to the IntDefaultHandler, which is a 'forever' loop. When the application
78 // defines a handler (with the same name), this will automatically take
79 // precedence over these weak definitions
80 //
81 //*****************************************************************************
82
83 #if defined(CHIP_LPC110X)
84 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
85 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
86 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
87 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
88 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
89 void UART_IRQHandler (void) ALIAS(IntDefaultHandler);
90 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
91 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
92 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
93 void PIOINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
94 void PIOINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
95 void WAKEUP_IRQHandler (void) ALIAS(IntDefaultHandler);
96
97 #elif defined(CHIP_LPC11XXLV)
98 void I2C_IRQHandler (void) ALIAS(IntDefaultHandler);
99 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
100 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
101 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
102 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
103 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
104 void UART_IRQHandler (void) ALIAS(IntDefaultHandler);
105 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
106 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
107 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
108 void FMC_IRQHandler (void) ALIAS(IntDefaultHandler);
109 void PIOINT3_IRQHandler (void) ALIAS(IntDefaultHandler);
110 void PIOINT2_IRQHandler (void) ALIAS(IntDefaultHandler);
111 void PIOINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
112 void PIOINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
113 void WAKEUP_IRQHandler (void) ALIAS(IntDefaultHandler);
114
115 #elif defined(CHIP_LPC11AXX)
116 void PIN_INT0_IRQHandler (void) ALIAS(IntDefaultHandler);
117 void PIN_INT1_IRQHandler (void) ALIAS(IntDefaultHandler);
118 void PIN_INT2_IRQHandler (void) ALIAS(IntDefaultHandler);
119 void PIN_INT3_IRQHandler (void) ALIAS(IntDefaultHandler);
120 void PIN_INT4_IRQHandler (void) ALIAS(IntDefaultHandler);
121 void PIN_INT5_IRQHandler (void) ALIAS(IntDefaultHandler);
122 void PIN_INT6_IRQHandler (void) ALIAS(IntDefaultHandler);
123 void PIN_INT7_IRQHandler (void) ALIAS(IntDefaultHandler);
124 void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
125 void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
126 void ACMP_IRQHandler (void) ALIAS(IntDefaultHandler);
127 void DAC_IRQHandler (void) ALIAS(IntDefaultHandler);
128 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
129 void I2C_IRQHandler (void) ALIAS(IntDefaultHandler);
130 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
131 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
132 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
133 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
134 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
135 void USART_IRQHandler (void) ALIAS(IntDefaultHandler);
136 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
137 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
138 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
139 void FMC_IRQHandler (void) ALIAS(IntDefaultHandler);
140
141 #elif defined(CHIP_LPC11CXX)
142 void CAN_IRQHandler (void) ALIAS(IntDefaultHandler);
143 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
144 void I2C_IRQHandler (void) ALIAS(IntDefaultHandler);
145 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
146 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
147 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
148 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
149 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
150 void UART_IRQHandler (void) ALIAS(IntDefaultHandler);
151 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
152 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
153 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
154 void PIOINT3_IRQHandler (void) ALIAS(IntDefaultHandler);
155 void PIOINT2_IRQHandler (void) ALIAS(IntDefaultHandler);
156 void PIOINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
157 void PIOINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
158 void WAKEUP_IRQHandler (void) ALIAS(IntDefaultHandler);
159
160 #elif defined(CHIP_LPC11EXX)
161 void FLEX_INT0_IRQHandler (void) ALIAS(IntDefaultHandler);
162 void FLEX_INT1_IRQHandler (void) ALIAS(IntDefaultHandler);
163 void FLEX_INT2_IRQHandler (void) ALIAS(IntDefaultHandler);
164 void FLEX_INT3_IRQHandler (void) ALIAS(IntDefaultHandler);
165 void FLEX_INT4_IRQHandler (void) ALIAS(IntDefaultHandler);
166 void FLEX_INT5_IRQHandler (void) ALIAS(IntDefaultHandler);
167 void FLEX_INT6_IRQHandler (void) ALIAS(IntDefaultHandler);
168 void FLEX_INT7_IRQHandler (void) ALIAS(IntDefaultHandler);
169 void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
170 void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
171 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
172 void I2C_IRQHandler (void) ALIAS(IntDefaultHandler);
173 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
174 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
175 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
176 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
177 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
178 void UART_IRQHandler (void) ALIAS(IntDefaultHandler);
179 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
180 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
181 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
182 void FMC_IRQHandler (void) ALIAS(IntDefaultHandler);
183
184 #elif defined(CHIP_LPC11UXX)
185 void FLEX_INT0_IRQHandler (void) ALIAS(IntDefaultHandler);
186 void FLEX_INT1_IRQHandler (void) ALIAS(IntDefaultHandler);
187 void FLEX_INT2_IRQHandler (void) ALIAS(IntDefaultHandler);
188 void FLEX_INT3_IRQHandler (void) ALIAS(IntDefaultHandler);
189 void FLEX_INT4_IRQHandler (void) ALIAS(IntDefaultHandler);
190 void FLEX_INT5_IRQHandler (void) ALIAS(IntDefaultHandler);
191 void FLEX_INT6_IRQHandler (void) ALIAS(IntDefaultHandler);
192 void FLEX_INT7_IRQHandler (void) ALIAS(IntDefaultHandler);
193 void GINT0_IRQHandler (void) ALIAS(IntDefaultHandler);
194 void GINT1_IRQHandler (void) ALIAS(IntDefaultHandler);
195 void SSP1_IRQHandler (void) ALIAS(IntDefaultHandler);
196 void I2C_IRQHandler (void) ALIAS(IntDefaultHandler);
197 void TIMER16_0_IRQHandler (void) ALIAS(IntDefaultHandler);
198 void TIMER16_1_IRQHandler (void) ALIAS(IntDefaultHandler);
199 void TIMER32_0_IRQHandler (void) ALIAS(IntDefaultHandler);
200 void TIMER32_1_IRQHandler (void) ALIAS(IntDefaultHandler);
201 void SSP0_IRQHandler (void) ALIAS(IntDefaultHandler);
202 void UART_IRQHandler (void) ALIAS(IntDefaultHandler);
203 void USB_IRQHandler (void) ALIAS(IntDefaultHandler);
204 void USB_FIQHandler (void) ALIAS(IntDefaultHandler);
205 void ADC_IRQHandler (void) ALIAS(IntDefaultHandler);
206 void WDT_IRQHandler (void) ALIAS(IntDefaultHandler);
207 void BOD_IRQHandler (void) ALIAS(IntDefaultHandler);
208 void FMC_IRQHandler (void) ALIAS(IntDefaultHandler);
209 void USBWakeup_IRQHandler (void) ALIAS(IntDefaultHandler);
210
211 #else
212 #error No CHIP_11* device defined
213 #endif
214
215 //*****************************************************************************
216 //
217 // The entry point for the application.
218 // __main() is the entry point for redlib based applications
219 // main() is the entry point for newlib based applications
220 //
221 //*****************************************************************************
222 //
223 // The entry point for the application.
224 // __main() is the entry point for Redlib based applications
225 // main() is the entry point for Newlib based applications
226 //
227 //*****************************************************************************
228 #if defined (__REDLIB__)
229 extern void __main(void);
230 #endif
231 extern int main(void);
232 //*****************************************************************************
233 //
234 // External declaration for the pointer to the stack top from the Linker Script
235 //
236 //*****************************************************************************
237 extern void _vStackTop(void);
238
239 //*****************************************************************************
240 #if defined (__cplusplus)
241 } // extern "C"
242 #endif
243
244 //*****************************************************************************
245 //
246 // The vector table. Note that the proper constructs must be placed on this to
247 // ensure that it ends up at physical address 0x0000.0000.
248 //
249 //*****************************************************************************
250 extern void (* const g_pfnVectors[])(void);
251 __attribute__ ((section(".isr_vector")))
252 void (* const g_pfnVectors[])(void) = {
253 &_vStackTop, // The initial stack pointer
254 ResetISR, // The reset handler
255 NMI_Handler, // The NMI handler
256 HardFault_Handler, // The hard fault handler
257 0, // Reserved
258 0, // Reserved
259 0, // Reserved
260 0, // Reserved
261 0, // Reserved
262 0, // Reserved
263 0, // Reserved
264 SVC_Handler, // SVCall handler
265 0, // Reserved
266 0, // Reserved
267 PendSV_Handler, // The PendSV handler
268 SysTick_Handler, // The SysTick handler
269
270 #if defined(CHIP_LPC110X)
271 // Wakeup sources for the I/O pins:
272 // PIO0 (0:11)
273 // PIO1 (0)
274 WAKEUP_IRQHandler, // PIO0_0 Wakeup
275 0, // Reserved
276 0, // Reserved
277 0, // Reserved
278 0, // Reserved
279 0, // Reserved
280 0, // Reserved
281 0, // Reserved
282 WAKEUP_IRQHandler, // PIO0_8 Wakeup
283 WAKEUP_IRQHandler, // PIO0_9 Wakeup
284 WAKEUP_IRQHandler, // PIO0_10 Wakeup
285 WAKEUP_IRQHandler, // PIO0_11 Wakeup
286 WAKEUP_IRQHandler, // PIO1_0 Wakeup
287
288 0, // Reserved
289 0, // Reserved
290 0, // Reserved
291 TIMER16_0_IRQHandler, // CT16B0 (16-bit Timer 0)
292 TIMER16_1_IRQHandler, // CT16B1 (16-bit Timer 1)
293 TIMER32_0_IRQHandler, // CT32B0 (32-bit Timer 0)
294 TIMER32_1_IRQHandler, // CT32B1 (32-bit Timer 1)
295 SSP0_IRQHandler, // SPI/SSP0 Interrupt
296 UART_IRQHandler, // UART0
297
298 0, // Reserved
299 0, // Reserved
300
301 ADC_IRQHandler, // ADC (A/D Converter)
302 WDT_IRQHandler, // WDT (Watchdog Timer)
303 BOD_IRQHandler, // BOD (Brownout Detect)
304 0, // Reserved
305 0, // Reserved
306 0, // Reserved
307 PIOINT1_IRQHandler, // PIO INT1
308 PIOINT0_IRQHandler, // PIO INT0
309
310 #elif defined(CHIP_LPC11XXLV)
311 // Wakeup sources for the I/O pins:
312 // PIO0 (0:11)
313 // PIO1 (0)
314 WAKEUP_IRQHandler, // PIO0_0 Wakeup
315 WAKEUP_IRQHandler, // PIO0_1 Wakeup
316 WAKEUP_IRQHandler, // PIO0_2 Wakeup
317 WAKEUP_IRQHandler, // PIO0_3 Wakeup
318 WAKEUP_IRQHandler, // PIO0_4 Wakeup
319 WAKEUP_IRQHandler, // PIO0_5 Wakeup
320 WAKEUP_IRQHandler, // PIO0_6 Wakeup
321 WAKEUP_IRQHandler, // PIO0_7 Wakeup
322 WAKEUP_IRQHandler, // PIO0_8 Wakeup
323 WAKEUP_IRQHandler, // PIO0_9 Wakeup
324 WAKEUP_IRQHandler, // PIO0_10 Wakeup
325 WAKEUP_IRQHandler, // PIO0_11 Wakeup
326 WAKEUP_IRQHandler, // PIO1_0 Wakeup
327
328 0, // Reserved
329 0, // Reserved
330
331 I2C_IRQHandler, // I2C0
332 TIMER16_0_IRQHandler, // CT16B0 (16-bit Timer 0)
333 TIMER16_1_IRQHandler, // CT16B1 (16-bit Timer 1)
334 TIMER32_0_IRQHandler, // CT32B0 (32-bit Timer 0)
335 TIMER32_1_IRQHandler, // CT32B1 (32-bit Timer 1)
336 SSP0_IRQHandler, // SPI/SSP0 Interrupt
337 UART_IRQHandler, // UART0
338
339 0, // Reserved
340 0, // Reserved
341
342 ADC_IRQHandler, // ADC (A/D Converter)
343 WDT_IRQHandler, // WDT (Watchdog Timer)
344 BOD_IRQHandler, // BOD (Brownout Detect)
345 FMC_IRQHandler, // 16+27: IP2111 Flash Memory Controller
346 PIOINT3_IRQHandler, // PIO INT3
347 PIOINT2_IRQHandler, // PIO INT2
348 PIOINT1_IRQHandler, // PIO INT1
349 PIOINT0_IRQHandler, // PIO INT0
350
351 #elif defined(CHIP_LPC11AXX)
352 // LPC11A specific handlers
353 PIN_INT0_IRQHandler, // 16+ 0: Pin interrupt
354 PIN_INT1_IRQHandler, // 16+ 1: Pin interrupt
355 PIN_INT2_IRQHandler, // 16+ 2: Pin interrupt
356 PIN_INT3_IRQHandler, // 16+ 3: Pin interrupt
357 PIN_INT4_IRQHandler, // 16+ 4: Pin interrupt
358 PIN_INT5_IRQHandler, // 16+ 5: Pin interrupt
359 PIN_INT6_IRQHandler, // 16+ 6: Pin interrupt
360 PIN_INT7_IRQHandler, // 16+ 7: Pin interrupt
361 GINT0_IRQHandler, // 16+ 8: Port interrupt
362 GINT1_IRQHandler, // 16+ 9: Port interrupt
363 ACMP_IRQHandler, // 16+10: Analog Comparator
364 DAC_IRQHandler, // 16+11: D/A Converter
365 0, // 16+12: Reserved
366 0, // 16+13: Reserved
367 SSP1_IRQHandler, // 16+14: SSP1
368 I2C_IRQHandler, // 16+15: I2C
369 TIMER16_0_IRQHandler, // 16+16: 16-bit Timer0
370 TIMER16_1_IRQHandler, // 16+17: 16-bit Timer1
371 TIMER32_0_IRQHandler, // 16+18: 32-bit Timer0
372 TIMER32_1_IRQHandler, // 16+19: 32-bit Timer1
373 SSP0_IRQHandler, // 16+20: SSP0
374 USART_IRQHandler, // 16+21: USART
375 0, // 16+22: Reserved
376 0, // 16+23: Reserved
377 ADC_IRQHandler, // 16+24: A/D Converter
378 WDT_IRQHandler, // 16+25: Watchdog Timer
379 BOD_IRQHandler, // 16+26: Brown Out Detect
380 FMC_IRQHandler, // 16+27: IP2111 Flash Memory Controller
381 0, // 16+28: Reserved
382 0, // 16+29: ReserveD
383 0, // 16+30: Reserved
384 0, // 16+31: Reserved
385
386 #elif defined(CHIP_LPC11CXX)
387 // Wakeup sources for the I/O pins:
388 // PIO0 (0:11)
389 // PIO1 (0)
390 WAKEUP_IRQHandler, // PIO0_0 Wakeup
391 WAKEUP_IRQHandler, // PIO0_1 Wakeup
392 WAKEUP_IRQHandler, // PIO0_2 Wakeup
393 WAKEUP_IRQHandler, // PIO0_3 Wakeup
394 WAKEUP_IRQHandler, // PIO0_4 Wakeup
395 WAKEUP_IRQHandler, // PIO0_5 Wakeup
396 WAKEUP_IRQHandler, // PIO0_6 Wakeup
397 WAKEUP_IRQHandler, // PIO0_7 Wakeup
398 WAKEUP_IRQHandler, // PIO0_8 Wakeup
399 WAKEUP_IRQHandler, // PIO0_9 Wakeup
400 WAKEUP_IRQHandler, // PIO0_10 Wakeup
401 WAKEUP_IRQHandler, // PIO0_11 Wakeup
402 WAKEUP_IRQHandler, // PIO1_0 Wakeup
403
404 CAN_IRQHandler, // C_CAN Interrupt
405 SSP1_IRQHandler, // SPI/SSP1 Interrupt
406 I2C_IRQHandler, // I2C0
407 TIMER16_0_IRQHandler, // CT16B0 (16-bit Timer 0)
408 TIMER16_1_IRQHandler, // CT16B1 (16-bit Timer 1)
409 TIMER32_0_IRQHandler, // CT32B0 (32-bit Timer 0)
410 TIMER32_1_IRQHandler, // CT32B1 (32-bit Timer 1)
411 SSP0_IRQHandler, // SPI/SSP0 Interrupt
412 UART_IRQHandler, // UART0
413
414 0, // Reserved
415 0, // Reserved
416
417 ADC_IRQHandler, // ADC (A/D Converter)
418 WDT_IRQHandler, // WDT (Watchdog Timer)
419 BOD_IRQHandler, // BOD (Brownout Detect)
420 0, // Reserved
421 PIOINT3_IRQHandler, // PIO INT3
422 PIOINT2_IRQHandler, // PIO INT2
423 PIOINT1_IRQHandler, // PIO INT1
424 PIOINT0_IRQHandler, // PIO INT0
425
426 #elif defined(CHIP_LPC11EXX)
427 // LPC11E specific handlers
428 FLEX_INT0_IRQHandler, // 0 - GPIO pin interrupt 0
429 FLEX_INT1_IRQHandler, // 1 - GPIO pin interrupt 1
430 FLEX_INT2_IRQHandler, // 2 - GPIO pin interrupt 2
431 FLEX_INT3_IRQHandler, // 3 - GPIO pin interrupt 3
432 FLEX_INT4_IRQHandler, // 4 - GPIO pin interrupt 4
433 FLEX_INT5_IRQHandler, // 5 - GPIO pin interrupt 5
434 FLEX_INT6_IRQHandler, // 6 - GPIO pin interrupt 6
435 FLEX_INT7_IRQHandler, // 7 - GPIO pin interrupt 7
436 GINT0_IRQHandler, // 8 - GPIO GROUP0 interrupt
437 GINT1_IRQHandler, // 9 - GPIO GROUP1 interrupt
438 0, // 10 - Reserved
439 0, // 11 - Reserved
440 0, // 12 - Reserved
441 0, // 13 - Reserved
442 SSP1_IRQHandler, // 14 - SPI/SSP1 Interrupt
443 I2C_IRQHandler, // 15 - I2C0
444 TIMER16_0_IRQHandler, // 16 - CT16B0 (16-bit Timer 0)
445 TIMER16_1_IRQHandler, // 17 - CT16B1 (16-bit Timer 1)
446 TIMER32_0_IRQHandler, // 18 - CT32B0 (32-bit Timer 0)
447 TIMER32_1_IRQHandler, // 19 - CT32B1 (32-bit Timer 1)
448 SSP0_IRQHandler, // 20 - SPI/SSP0 Interrupt
449 UART_IRQHandler, // 21 - UART0
450 0, // 22 - Reserved
451 0, // 23 - Reserved
452 ADC_IRQHandler, // 24 - ADC (A/D Converter)
453 WDT_IRQHandler, // 25 - WDT (Watchdog Timer)
454 BOD_IRQHandler, // 26 - BOD (Brownout Detect)
455 FMC_IRQHandler, // 27 - IP2111 Flash Memory Controller
456 0, // 28 - Reserved
457 0, // 29 - Reserved
458 0, // 30 - Reserved
459 0, // 31 - Reserved
460
461 #elif defined(CHIP_LPC11UXX)
462 // LPC11U specific handlers
463 FLEX_INT0_IRQHandler, // 0 - GPIO pin interrupt 0
464 FLEX_INT1_IRQHandler, // 1 - GPIO pin interrupt 1
465 FLEX_INT2_IRQHandler, // 2 - GPIO pin interrupt 2
466 FLEX_INT3_IRQHandler, // 3 - GPIO pin interrupt 3
467 FLEX_INT4_IRQHandler, // 4 - GPIO pin interrupt 4
468 FLEX_INT5_IRQHandler, // 5 - GPIO pin interrupt 5
469 FLEX_INT6_IRQHandler, // 6 - GPIO pin interrupt 6
470 FLEX_INT7_IRQHandler, // 7 - GPIO pin interrupt 7
471 GINT0_IRQHandler, // 8 - GPIO GROUP0 interrupt
472 GINT1_IRQHandler, // 9 - GPIO GROUP1 interrupt
473 0, // 10 - Reserved
474 0, // 11 - Reserved
475 0, // 12 - Reserved
476 0, // 13 - Reserved
477 SSP1_IRQHandler, // 14 - SPI/SSP1 Interrupt
478 I2C_IRQHandler, // 15 - I2C0
479 TIMER16_0_IRQHandler, // 16 - CT16B0 (16-bit Timer 0)
480 TIMER16_1_IRQHandler, // 17 - CT16B1 (16-bit Timer 1)
481 TIMER32_0_IRQHandler, // 18 - CT32B0 (32-bit Timer 0)
482 TIMER32_1_IRQHandler, // 19 - CT32B1 (32-bit Timer 1)
483 SSP0_IRQHandler, // 20 - SPI/SSP0 Interrupt
484 UART_IRQHandler, // 21 - UART0
485 USB_IRQHandler, // 22 - USB IRQ
486 USB_FIQHandler, // 23 - USB FIQ
487 ADC_IRQHandler, // 24 - ADC (A/D Converter)
488 WDT_IRQHandler, // 25 - WDT (Watchdog Timer)
489 BOD_IRQHandler, // 26 - BOD (Brownout Detect)
490 FMC_IRQHandler, // 27 - IP2111 Flash Memory Controller
491 0, // 28 - Reserved
492 0, // 29 - Reserved
493 USBWakeup_IRQHandler, // 30 - USB wake-up interrupt
494 0, // 31 - Reserved
495
496 #else
497 #error No CHIP_11* device defined
498 #endif
499 };
500
501 //*****************************************************************************
502 // Functions to carry out the initialization of RW and BSS data sections. These
503 // are written as separate functions rather than being inlined within the
504 // ResetISR() function in order to cope with MCUs with multiple banks of
505 // memory.
506 //*****************************************************************************
507 __attribute__ ((section(".after_vectors")))
508 void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
509 unsigned int *pulDest = (unsigned int*) start;
510 unsigned int *pulSrc = (unsigned int*) romstart;
511 unsigned int loop;
512 for (loop = 0; loop < len; loop = loop + 4)
513 *pulDest++ = *pulSrc++;
514 }
515
516 __attribute__ ((section(".after_vectors")))
517 void bss_init(unsigned int start, unsigned int len) {
518 unsigned int *pulDest = (unsigned int*) start;
519 unsigned int loop;
520 for (loop = 0; loop < len; loop = loop + 4)
521 *pulDest++ = 0;
522 }
523
524 #ifndef USE_OLD_STYLE_DATA_BSS_INIT
525 //*****************************************************************************
526 // The following symbols are constructs generated by the linker, indicating
527 // the location of various points in the "Global Section Table". This table is
528 // created by the linker via the Code Red managed linker script mechanism. It
529 // contains the load address, execution address and length of each RW data
530 // section and the execution and length of each BSS (zero initialized) section.
531 //*****************************************************************************
532 extern unsigned int __data_section_table;
533 extern unsigned int __data_section_table_end;
534 extern unsigned int __bss_section_table;
535 extern unsigned int __bss_section_table_end;
536 #else
537 //*****************************************************************************
538 // The following symbols are constructs generated by the linker, indicating
539 // the load address, execution address and length of the RW data section and
540 // the execution and length of the BSS (zero initialized) section.
541 // Note that these symbols are not normally used by the managed linker script
542 // mechanism in Red Suite/LPCXpresso 3.6 (Windows) and LPCXpresso 3.8 (Linux).
543 // They are provide here simply so this startup code can be used with earlier
544 // versions of Red Suite which do not support the more advanced managed linker
545 // script mechanism introduced in the above version. To enable their use,
546 // define "USE_OLD_STYLE_DATA_BSS_INIT".
547 //*****************************************************************************
548 extern unsigned int _etext;
549 extern unsigned int _data;
550 extern unsigned int _edata;
551 extern unsigned int _bss;
552 extern unsigned int _ebss;
553 #endif
554
555
556 //*****************************************************************************
557 // Reset entry point for your code.
558 // Sets up a simple runtime environment and initializes the C/C++
559 // library.
560 //*****************************************************************************
561 __attribute__ ((section(".after_vectors")))
562 void
563 ResetISR(void) {
564
565 #ifndef USE_OLD_STYLE_DATA_BSS_INIT
566 //
567 // Copy the data sections from flash to SRAM.
568 //
569 unsigned int LoadAddr, ExeAddr, SectionLen;
570 unsigned int *SectionTableAddr;
571
572 // Load base address of Global Section Table
573 SectionTableAddr = &__data_section_table;
574
575 // Copy the data sections from flash to SRAM.
576 while (SectionTableAddr < &__data_section_table_end) {
577 LoadAddr = *SectionTableAddr++;
578 ExeAddr = *SectionTableAddr++;
579 SectionLen = *SectionTableAddr++;
580 data_init(LoadAddr, ExeAddr, SectionLen);
581 }
582 // At this point, SectionTableAddr = &__bss_section_table;
583 // Zero fill the bss segment
584 while (SectionTableAddr < &__bss_section_table_end) {
585 ExeAddr = *SectionTableAddr++;
586 SectionLen = *SectionTableAddr++;
587 bss_init(ExeAddr, SectionLen);
588 }
589 #else
590 // Use Old Style Data and BSS section initialization.
591 // This will only initialize a single RAM bank.
592 unsigned int * LoadAddr, *ExeAddr, *EndAddr, SectionLen;
593
594 // Copy the data segment from flash to SRAM.
595 LoadAddr = &_etext;
596 ExeAddr = &_data;
597 EndAddr = &_edata;
598 SectionLen = (void*)EndAddr - (void*)ExeAddr;
599 data_init((unsigned int)LoadAddr, (unsigned int)ExeAddr, SectionLen);
600 // Zero fill the bss segment
601 ExeAddr = &_bss;
602 EndAddr = &_ebss;
603 SectionLen = (void*)EndAddr - (void*)ExeAddr;
604 bss_init ((unsigned int)ExeAddr, SectionLen);
605 #endif
606
607 extern void SystemInit(void);
608 SystemInit();
609
610 #if defined (__cplusplus)
611 //
612 // Call C++ library initialisation
613 //
614 __libc_init_array();
615 #endif
616
617 #if defined (__REDLIB__)
618 // Call the Redlib library, which in turn calls main()
619 __main() ;
620 #else
621 main();
622 #endif
623 //
624 // main() shouldn't return, but if it does, we'll just enter an infinite loop
625 //
626 while (1) {
627 ;
628 }
629 }
630
631 //*****************************************************************************
632 // Default exception handlers. Override the ones here by defining your own
633 // handler routines in your application code.
634 //*****************************************************************************
635 __attribute__ ((section(".after_vectors")))
636 void NMI_Handler(void)
637 {
638 while(1)
639 {
640 }
641 }
642 __attribute__ ((section(".after_vectors")))
643 void HardFault_Handler(void)
644 {
645 while(1)
646 {
647 }
648 }
649 __attribute__ ((section(".after_vectors")))
650 void SVC_Handler(void)
651 {
652 while(1)
653 {
654 }
655 }
656 __attribute__ ((section(".after_vectors")))
657 void PendSV_Handler(void)
658 {
659 while(1)
660 {
661 }
662 }
663 __attribute__ ((section(".after_vectors")))
664 void SysTick_Handler(void)
665 {
666 while(1)
667 {
668 }
669 }
670
671 //*****************************************************************************
672 //
673 // Processor ends up here if an unexpected interrupt occurs or a specific
674 // handler is not present in the application code.
675 //
676 //*****************************************************************************
677 __attribute__ ((section(".after_vectors")))
678 void IntDefaultHandler(void)
679 {
680 while(1)
681 {
682 }
683 }
684