CMSIS2000  0.0.7
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
startup_LPC17xx.s
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* startup_LPC17xx.s: Startup file for LPC17xx device series */
3 /*****************************************************************************/
4 /* Version: CodeSourcery Sourcery G++ Lite (with CS3) */
5 /*****************************************************************************/
6 
7 
8 /*
9 //*** <<< Use Configuration Wizard in Context Menu >>> ***
10 */
11 
12 
13 /*
14 // <h> Stack Configuration
15 // <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
16 // </h>
17 */
18 
19  .equ Stack_Size, 0x00000100
20  .section ".stack", "w"
21  .align 3
22  .globl __cs3_stack_mem
23  .globl __cs3_stack_size
25  .if Stack_Size
26  .space Stack_Size
27  .endif
30 
31 
32 /*
33 // <h> Heap Configuration
34 // <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
35 // </h>
36 */
37 
38  .equ Heap_Size, 0x00001000
39 
40  .section ".heap", "w"
41  .align 3
42  .globl __cs3_heap_start
43  .globl __cs3_heap_end
45  .if Heap_Size
46  .space Heap_Size
47  .endif
48 __cs3_heap_end:
49 
50 
51 /* Vector Table */
52 
53  .section ".cs3.interrupt_vector"
55  .type __cs3_interrupt_vector_cortex_m, %object
56 
58  .long __cs3_stack /* Top of Stack */
59  .long __cs3_reset /* Reset Handler */
60  .long NMI_Handler /* NMI Handler */
61  .long HardFault_Handler /* Hard Fault Handler */
62  .long MemManage_Handler /* MPU Fault Handler */
63  .long BusFault_Handler /* Bus Fault Handler */
64  .long UsageFault_Handler /* Usage Fault Handler */
65  .long 0 /* Reserved */
66  .long 0 /* Reserved */
67  .long 0 /* Reserved */
68  .long 0 /* Reserved */
69  .long SVC_Handler /* SVCall Handler */
70  .long DebugMon_Handler /* Debug Monitor Handler */
71  .long 0 /* Reserved */
72  .long PendSV_Handler /* PendSV Handler */
73  .long SysTick_Handler /* SysTick Handler */
74 
75  /* External Interrupts */
76  .long WDT_IRQHandler /* 16: Watchdog Timer */
77  .long TIMER0_IRQHandler /* 17: Timer0 */
78  .long TIMER1_IRQHandler /* 18: Timer1 */
79  .long TIMER2_IRQHandler /* 19: Timer2 */
80  .long TIMER3_IRQHandler /* 20: Timer3 */
81  .long UART0_IRQHandler /* 21: UART0 */
82  .long UART1_IRQHandler /* 22: UART1 */
83  .long UART2_IRQHandler /* 23: UART2 */
84  .long UART3_IRQHandler /* 24: UART3 */
85  .long PWM1_IRQHandler /* 25: PWM1 */
86  .long I2C0_IRQHandler /* 26: I2C0 */
87  .long I2C1_IRQHandler /* 27: I2C1 */
88  .long I2C2_IRQHandler /* 28: I2C2 */
89  .long SPI_IRQHandler /* 29: SPI */
90  .long SSP0_IRQHandler /* 30: SSP0 */
91  .long SSP1_IRQHandler /* 31: SSP1 */
92  .long PLL0_IRQHandler /* 32: PLL0 Lock (Main PLL) */
93  .long RTC_IRQHandler /* 33: Real Time Clock */
94  .long EINT0_IRQHandler /* 34: External Interrupt 0 */
95  .long EINT1_IRQHandler /* 35: External Interrupt 1 */
96  .long EINT2_IRQHandler /* 36: External Interrupt 2 */
97  .long EINT3_IRQHandler /* 37: External Interrupt 3 */
98  .long ADC_IRQHandler /* 38: A/D Converter */
99  .long BOD_IRQHandler /* 39: Brown-Out Detect */
100  .long USB_IRQHandler /* 40: USB */
101  .long CAN_IRQHandler /* 41: CAN */
102  .long DMA_IRQHandler /* 42: General Purpose DMA */
103  .long I2S_IRQHandler /* 43: I2S */
104  .long ENET_IRQHandler /* 44: Ethernet */
105  .long RIT_IRQHandler /* 45: Repetitive Interrupt Timer */
106  .long MCPWM_IRQHandler /* 46: Motor Control PWM */
107  .long QEI_IRQHandler /* 47: Quadrature Encoder Interface */
108  .long PLL1_IRQHandler /* 48: PLL1 Lock (USB PLL) */
109  .long USBActivity_IRQHandler /* 49: USB Activity */
110  .long CANActivity_IRQHandler /* 50: CAN Activity */
111 
113 
114 
115  .thumb
116 
117 
118 /* Reset Handler */
119 
120  .section .cs3.reset,"x",%progbits
121  .thumb_func
122  .globl __cs3_reset_cortex_m
123  .type __cs3_reset_cortex_m, %function
125  .fnstart
126 .if (RAM_MODE)
127 /* Clear .bss section (Zero init) */
128  MOV R0, #0
129  LDR R1, =__bss_start__
130  LDR R2, =__bss_end__
131  CMP R1,R2
132  BEQ BSSIsEmpty
133 LoopZI:
134  CMP R1, R2
135  BHS BSSIsEmpty
136  STR R0, [R1]
137  ADD R1, #4
138  BLO LoopZI
139 BSSIsEmpty:
140  LDR R0, =SystemInit
141  BLX R0
142  LDR R0,=main
143  BX R0
144 .else
145  LDR R0, =SystemInit
146  BLX R0
147  LDR R0,=_start
148  BX R0
149 .endif
150  .pool
151  .cantunwind
152  .fnend
154 
155  .section ".text"
156 
157 /* Exception Handlers */
158 
159  .weak NMI_Handler
160  .type NMI_Handler, %function
162  B .
163  .size NMI_Handler, . - NMI_Handler
164 
165  .weak HardFault_Handler
166  .type HardFault_Handler, %function
168  B .
170 
171  .weak MemManage_Handler
172  .type MemManage_Handler, %function
174  B .
176 
177  .weak BusFault_Handler
178  .type BusFault_Handler, %function
180  B .
182 
183  .weak UsageFault_Handler
184  .type UsageFault_Handler, %function
186  B .
188 
189  .weak SVC_Handler
190  .type SVC_Handler, %function
192  B .
193  .size SVC_Handler, . - SVC_Handler
194 
195  .weak DebugMon_Handler
196  .type DebugMon_Handler, %function
198  B .
200 
201  .weak PendSV_Handler
202  .type PendSV_Handler, %function
204  B .
205  .size PendSV_Handler, . - PendSV_Handler
206 
207  .weak SysTick_Handler
208  .type SysTick_Handler, %function
210  B .
212 
213 
214 /* IRQ Handlers */
215 
216  .globl Default_Handler
217  .type Default_Handler, %function
219  B .
221 
222  .macro IRQ handler
223  .weak \handler
224  .set \handler, Default_Handler
225  .endm
226 
227  IRQ WDT_IRQHandler
228  IRQ TIMER0_IRQHandler
229  IRQ TIMER1_IRQHandler
230  IRQ TIMER2_IRQHandler
231  IRQ TIMER3_IRQHandler
232  IRQ UART0_IRQHandler
233  IRQ UART1_IRQHandler
234  IRQ UART2_IRQHandler
235  IRQ UART3_IRQHandler
236  IRQ PWM1_IRQHandler
237  IRQ I2C0_IRQHandler
238  IRQ I2C1_IRQHandler
239  IRQ I2C2_IRQHandler
240  IRQ SPI_IRQHandler
241  IRQ SSP0_IRQHandler
242  IRQ SSP1_IRQHandler
243  IRQ PLL0_IRQHandler
244  IRQ RTC_IRQHandler
245  IRQ EINT0_IRQHandler
246  IRQ EINT1_IRQHandler
247  IRQ EINT2_IRQHandler
248  IRQ EINT3_IRQHandler
249  IRQ ADC_IRQHandler
250  IRQ BOD_IRQHandler
251  IRQ USB_IRQHandler
252  IRQ CAN_IRQHandler
253  IRQ DMA_IRQHandler
254  IRQ I2S_IRQHandler
255  IRQ ENET_IRQHandler
256  IRQ RIT_IRQHandler
257  IRQ MCPWM_IRQHandler
258  IRQ QEI_IRQHandler
259  IRQ PLL1_IRQHandler
260  IRQ USBActivity_IRQHandler
261  IRQ CANActivity_IRQHandler
262 
263  .end