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