]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/startup_NRF51822.s
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_NORDIC / TARGET_MCU_NRF51822 / TOOLCHAIN_GCC_ARM / startup_NRF51822.s
1 /*
2 Copyright (c) 2013, Nordic Semiconductor ASA
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10
11 * Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15 * Neither the name of Nordic Semiconductor ASA nor the names of its
16 contributors may be used to endorse or promote products derived from
17 this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /*
32 NOTE: Template files (including this one) are application specific and therefore
33 expected to be copied into the application project folder prior to its use!
34 */
35
36 .syntax unified
37 .arch armv6-m
38
39 .section .stack
40 .align 3
41 #ifdef __STACK_SIZE
42 .equ Stack_Size, __STACK_SIZE
43 #else
44 .equ Stack_Size, 2048
45 #endif
46 .globl __StackTop
47 .globl __StackLimit
48 __StackLimit:
49 .space Stack_Size
50 .size __StackLimit, . - __StackLimit
51 __StackTop:
52 .size __StackTop, . - __StackTop
53
54 .section .heap
55 .align 3
56 #ifdef __HEAP_SIZE
57 .equ Heap_Size, __HEAP_SIZE
58 #else
59 .equ Heap_Size, 2048
60 #endif
61 .globl __HeapBase
62 .globl __HeapLimit
63 __HeapBase:
64 .if Heap_Size
65 .space Heap_Size
66 .endif
67 .size __HeapBase, . - __HeapBase
68 __HeapLimit:
69 .size __HeapLimit, . - __HeapLimit
70
71 .section .Vectors
72 .align 2
73 .globl __Vectors
74 __Vectors:
75 .long __StackTop /* Top of Stack */
76 .long Reset_Handler /* Reset Handler */
77 .long NMI_Handler /* NMI Handler */
78 .long HardFault_Handler /* Hard Fault Handler */
79 .long 0 /* Reserved */
80 .long 0 /* Reserved */
81 .long 0 /* Reserved */
82 .long 0 /* Reserved */
83 .long 0 /* Reserved */
84 .long 0 /* Reserved */
85 .long 0 /* Reserved */
86 .long SVC_Handler /* SVCall Handler */
87 .long 0 /* Reserved */
88 .long 0 /* Reserved */
89 .long PendSV_Handler /* PendSV Handler */
90 .long SysTick_Handler /* SysTick Handler */
91
92 /* External Interrupts */
93 .long POWER_CLOCK_IRQHandler /*POWER_CLOCK */
94 .long RADIO_IRQHandler /*RADIO */
95 .long UART0_IRQHandler /*UART0 */
96 .long SPI0_TWI0_IRQHandler /*SPI0_TWI0 */
97 .long SPI1_TWI1_IRQHandler /*SPI1_TWI1 */
98 .long 0 /*Reserved */
99 .long GPIOTE_IRQHandler /*GPIOTE */
100 .long ADC_IRQHandler /*ADC */
101 .long TIMER0_IRQHandler /*TIMER0 */
102 .long TIMER1_IRQHandler /*TIMER1 */
103 .long TIMER2_IRQHandler /*TIMER2 */
104 .long RTC0_IRQHandler /*RTC0 */
105 .long TEMP_IRQHandler /*TEMP */
106 .long RNG_IRQHandler /*RNG */
107 .long ECB_IRQHandler /*ECB */
108 .long CCM_AAR_IRQHandler /*CCM_AAR */
109 .long WDT_IRQHandler /*WDT */
110 .long RTC1_IRQHandler /*RTC1 */
111 .long QDEC_IRQHandler /*QDEC */
112 .long LPCOMP_IRQHandler /*LPCOMP */
113 .long SWI0_IRQHandler /*SWI0 */
114 .long SWI1_IRQHandler /*SWI1 */
115 .long SWI2_IRQHandler /*SWI2 */
116 .long SWI3_IRQHandler /*SWI3 */
117 .long SWI4_IRQHandler /*SWI4 */
118 .long SWI5_IRQHandler /*SWI5 */
119 .long 0 /*Reserved */
120 .long 0 /*Reserved */
121 .long 0 /*Reserved */
122 .long 0 /*Reserved */
123 .long 0 /*Reserved */
124 .long 0 /*Reserved */
125
126
127 .size __Vectors, . - __Vectors
128
129 /* Reset Handler */
130
131 .equ NRF_POWER_RAMON_ADDRESS, 0x40000524
132 .equ NRF_POWER_RAMON_RAMxON_ONMODE_Msk, 0x3
133
134 .text
135 .thumb
136 .thumb_func
137 .align 1
138 .globl Reset_Handler
139 .type Reset_Handler, %function
140 Reset_Handler:
141 .fnstart
142
143 /* Make sure ALL RAM banks are powered on */
144 LDR R0, =NRF_POWER_RAMON_ADDRESS
145 LDR R2, [R0]
146 MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
147 ORRS R2, R1
148 STR R2, [R0]
149
150 /* Loop to copy data from read only memory to RAM. The ranges
151 * of copy from/to are specified by following symbols evaluated in
152 * linker script.
153 * __etext: End of code section, i.e., begin of data sections to copy from.
154 * __data_start__/__data_end__: RAM address range that data should be
155 * copied to. Both must be aligned to 4 bytes boundary. */
156
157 ldr r1, =__etext
158 ldr r2, =__data_start__
159 ldr r3, =__data_end__
160
161 subs r3, r2
162 ble .LC0
163
164 .LC1:
165 subs r3, 4
166 ldr r0, [r1,r3]
167 str r0, [r2,r3]
168 bgt .LC1
169 .LC0:
170
171 LDR R0, =SystemInit
172 BLX R0
173 LDR R0, =_start
174 BX R0
175
176 .pool
177 .cantunwind
178 .fnend
179 .size Reset_Handler,.-Reset_Handler
180
181 .section ".text"
182
183
184 /* Dummy Exception Handlers (infinite loops which can be modified) */
185
186 .weak NMI_Handler
187 .type NMI_Handler, %function
188 NMI_Handler:
189 B .
190 .size NMI_Handler, . - NMI_Handler
191
192
193 .weak HardFault_Handler
194 .type HardFault_Handler, %function
195 HardFault_Handler:
196 B .
197 .size HardFault_Handler, . - HardFault_Handler
198
199
200 .weak SVC_Handler
201 .type SVC_Handler, %function
202 SVC_Handler:
203 B .
204 .size SVC_Handler, . - SVC_Handler
205
206
207 .weak PendSV_Handler
208 .type PendSV_Handler, %function
209 PendSV_Handler:
210 B .
211 .size PendSV_Handler, . - PendSV_Handler
212
213
214 .weak SysTick_Handler
215 .type SysTick_Handler, %function
216 SysTick_Handler:
217 B .
218 .size SysTick_Handler, . - SysTick_Handler
219
220
221 /* IRQ Handlers */
222
223 .globl Default_Handler
224 .type Default_Handler, %function
225 Default_Handler:
226 B .
227 .size Default_Handler, . - Default_Handler
228
229 .macro IRQ handler
230 .weak \handler
231 .set \handler, Default_Handler
232 .endm
233
234 IRQ POWER_CLOCK_IRQHandler
235 IRQ RADIO_IRQHandler
236 IRQ UART0_IRQHandler
237 IRQ SPI0_TWI0_IRQHandler
238 IRQ SPI1_TWI1_IRQHandler
239 IRQ GPIOTE_IRQHandler
240 IRQ ADC_IRQHandler
241 IRQ TIMER0_IRQHandler
242 IRQ TIMER1_IRQHandler
243 IRQ TIMER2_IRQHandler
244 IRQ RTC0_IRQHandler
245 IRQ TEMP_IRQHandler
246 IRQ RNG_IRQHandler
247 IRQ ECB_IRQHandler
248 IRQ CCM_AAR_IRQHandler
249 IRQ WDT_IRQHandler
250 IRQ RTC1_IRQHandler
251 IRQ QDEC_IRQHandler
252 IRQ LPCOMP_IRQHandler
253 IRQ SWI0_IRQHandler
254 IRQ SWI1_IRQHandler
255 IRQ SWI2_IRQHandler
256 IRQ SWI3_IRQHandler
257 IRQ SWI4_IRQHandler
258 IRQ SWI5_IRQHandler
259
260
261 .end
262
Imprint / Impressum