Merge pull request #11297 from SteveCEvans/baro_state
[betaflight.git] / src / main / startup / startup_stm32f30x_md_gcc.S
blobe1387cbc0e6d2d46b145d275285f4c5af0b59906
1 /**
2   ******************************************************************************
3   * @file      startup_stm32f30x.s
4   * @author    MCD Application Team
5   * @version   V1.0.0
6   * @date      04-Spetember-2012
7   * @brief     STM32F30x Devices vector table for RIDE7 toolchain.
8   *            This module performs:
9   *                - Set the initial SP
10   *                - Set the initial PC == Reset_Handler,
11   *                - Set the vector table entries with the exceptions ISR address
12   *                - Configure the clock system and the external SRAM mounted on
13   *                  STM3230C-EVAL board to be used as data memory (optional,
14   *                  to be enabled by user)
15   *                - Branches to main in the C library (which eventually
16   *                  calls main()).
17   *            After Reset the Cortex-M4 processor is in Thread mode,
18   *            priority is Privileged, and the Stack is set to Main.
19   ******************************************************************************
20   * @attention
21   *
22   * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
23   *
24   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
25   * You may not use this file except in compliance with the License.
26   * You may obtain a copy of the License at:
27   *
28   *        http://www.st.com/software_license_agreement_liberty_v2
29   *
30   * Unless required by applicable law or agreed to in writing, software
31   * distributed under the License is distributed on an "AS IS" BASIS,
32   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33   * See the License for the specific language governing permissions and
34   * limitations under the License.
35   *
36   ******************************************************************************
37   */
39   .syntax unified
40   .cpu cortex-m4
41   .fpu softvfp
42   .thumb
44 .global  g_pfnVectors
45 .global  Default_Handler
47 /* start address for the initialization values of the .data section.
48 defined in linker script */
49 .word  _sidata
50 /* start address for the .data section. defined in linker script */
51 .word  _sdata
52 /* end address for the .data section. defined in linker script */
53 .word  _edata
54 /* start address for the .bss section. defined in linker script */
55 .word  _sbss
56 /* end address for the .bss section. defined in linker script */
57 .word  _ebss
58 /* stack used for SystemInit_ExtMemCtl; always internal RAM used */
60 /**
61  * @brief  This is the code that gets called when the processor first
62  *          starts execution following a reset event. Only the absolutely
63  *          necessary set is performed, after which the application
64  *          supplied main() routine is called.
65  * @param  None
66  * @retval : None
69     .section  .text.Reset_Handler
70   .weak  Reset_Handler
71   .type  Reset_Handler, %function
72 Reset_Handler:
73   ldr r0, =0x20009FFC         // HJI 11/9/2012
74   ldr r1, =0xDEADBEEF         // HJI 11/9/2012
75   ldr r2, [r0, #0]            // HJI 11/9/2012
76   str r0, [r0, #0]            // HJI 11/9/2012
77   cmp r2, r1                  // HJI 11/9/2012
78   beq Reboot_Loader           // HJI 11/9/2012
80 /* Copy the data segment initializers from flash to SRAM */
81   movs  r1, #0
82   b  LoopCopyDataInit
84 CopyDataInit:
85   ldr  r3, =_sidata
86   ldr  r3, [r3, r1]
87   str  r3, [r0, r1]
88   adds  r1, r1, #4
90 LoopCopyDataInit:
91   ldr  r0, =_sdata
92   ldr  r3, =_edata
93   adds  r2, r0, r1
94   cmp  r2, r3
95   bcc  CopyDataInit
96   ldr  r2, =_sbss
97   b  LoopFillZerobss
98 /* Zero fill the bss segment. */
99 FillZerobss:
100   movs  r3, #0
101   str  r3, [r2], #4
103 LoopFillZerobss:
104   ldr  r3, = _ebss
105   cmp  r2, r3
106   bcc  FillZerobss
108 /* Call the clock system intitialization function.*/
109   bl  SystemInit
110 /* Call the application's entry point.*/
111   bl  main
112   bx  lr
114 LoopForever:
115   b LoopForever
117 Reboot_Loader:                // HJI 11/9/2012
119   // Reboot to ROM            // HJI 11/9/2012
120   ldr     r0, =0x1FFFD800     // HJI 4/26/2013
121   ldr     sp,[r0, #0]         // HJI 11/9/2012
122   ldr     r0,[r0, #4]         // HJI 11/9/2012
123   bx      r0                  // HJI 11/9/2012
125 .size  Reset_Handler, .-Reset_Handler
128  * @brief  This is the code that gets called when the processor receives an
129  *         unexpected interrupt.  This simply enters an infinite loop, preserving
130  *         the system state for examination by a debugger.
131  * @param  None
132  * @retval None
134     .section  .text.Default_Handler,"ax",%progbits
135 Default_Handler:
136 Infinite_Loop:
137   b  Infinite_Loop
138   .size  Default_Handler, .-Default_Handler
139 /******************************************************************************
141 * The minimal vector table for a Cortex M4. Note that the proper constructs
142 * must be placed on this to ensure that it ends up at physical address
143 * 0x0000.0000.
145 *******************************************************************************/
146    .section  .isr_vector,"a",%progbits
147   .type  g_pfnVectors, %object
148   .size  g_pfnVectors, .-g_pfnVectors
151 g_pfnVectors:
152         .word   _estack
153         .word   Reset_Handler
154         .word   NMI_Handler
155         .word   HardFault_Handler
156         .word   MemManage_Handler
157         .word   BusFault_Handler
158         .word   UsageFault_Handler
159         .word   0
160         .word   0
161         .word   0
162         .word   0
163         .word   SVC_Handler
164         .word   DebugMon_Handler
165         .word   0
166         .word   PendSV_Handler
167         .word   SysTick_Handler
168         .word   WWDG_IRQHandler
169         .word   PVD_IRQHandler
170         .word   TAMPER_STAMP_IRQHandler
171         .word   RTC_WKUP_IRQHandler
172         .word   FLASH_IRQHandler
173         .word   RCC_IRQHandler
174         .word   EXTI0_IRQHandler
175         .word   EXTI1_IRQHandler
176         .word   EXTI2_TS_IRQHandler
177         .word   EXTI3_IRQHandler
178         .word   EXTI4_IRQHandler
179         .word   DMA1_Channel1_IRQHandler
180         .word   DMA1_Channel2_IRQHandler
181         .word   DMA1_Channel3_IRQHandler
182         .word   DMA1_Channel4_IRQHandler
183         .word   DMA1_Channel5_IRQHandler
184         .word   DMA1_Channel6_IRQHandler
185         .word   DMA1_Channel7_IRQHandler
186         .word   ADC1_2_IRQHandler
187         .word   USB_HP_CAN1_TX_IRQHandler
188         .word   USB_LP_CAN1_RX0_IRQHandler
189         .word   CAN1_RX1_IRQHandler
190         .word   CAN1_SCE_IRQHandler
191         .word   EXTI9_5_IRQHandler
192         .word   TIM1_BRK_TIM15_IRQHandler
193         .word   TIM1_UP_TIM16_IRQHandler
194         .word   TIM1_TRG_COM_TIM17_IRQHandler
195         .word   TIM1_CC_IRQHandler
196         .word   TIM2_IRQHandler
197         .word   TIM3_IRQHandler
198         .word   TIM4_IRQHandler
199         .word   I2C1_EV_IRQHandler
200         .word   I2C1_ER_IRQHandler
201         .word   I2C2_EV_IRQHandler
202         .word   I2C2_ER_IRQHandler
203         .word   SPI1_IRQHandler
204         .word   SPI2_IRQHandler
205         .word   USART1_IRQHandler
206         .word   USART2_IRQHandler
207         .word   USART3_IRQHandler
208         .word   EXTI15_10_IRQHandler
209         .word   RTC_Alarm_IRQHandler
210         .word   USBWakeUp_IRQHandler
211         .word   TIM8_BRK_IRQHandler
212         .word   TIM8_UP_IRQHandler
213         .word   TIM8_TRG_COM_IRQHandler
214         .word   TIM8_CC_IRQHandler
215         .word   ADC3_IRQHandler
216         .word   0
217         .word   0
218         .word   0
219         .word   SPI3_IRQHandler
220         .word   UART4_IRQHandler
221         .word   UART5_IRQHandler
222         .word   TIM6_DAC_IRQHandler
223         .word   TIM7_IRQHandler
224         .word   DMA2_Channel1_IRQHandler
225         .word   DMA2_Channel2_IRQHandler
226         .word   DMA2_Channel3_IRQHandler
227         .word   DMA2_Channel4_IRQHandler
228         .word   DMA2_Channel5_IRQHandler
229         .word   ADC4_IRQHandler
230         .word   0
231         .word   0
232         .word   COMP1_2_3_IRQHandler
233         .word   COMP4_5_6_IRQHandler
234         .word   COMP7_IRQHandler
235         .word   0
236         .word   0
237         .word   0
238         .word   0
239         .word   0
240         .word   0
241         .word   0
242         .word   USB_HP_IRQHandler
243         .word   USB_LP_IRQHandler
244         .word   USBWakeUp_RMP_IRQHandler
245         .word   0
246         .word   0
247         .word   0
248         .word   0
249         .word   FPU_IRQHandler
251 /*******************************************************************************
253 * Provide weak aliases for each Exception handler to the Default_Handler.
254 * As they are weak aliases, any function with the same name will override
255 * this definition.
257 *******************************************************************************/
259   .weak NMI_Handler
260         .thumb_set NMI_Handler,Default_Handler
262   .weak HardFault_Handler
263         .thumb_set HardFault_Handler,Default_Handler
265   .weak MemManage_Handler
266         .thumb_set MemManage_Handler,Default_Handler
268   .weak BusFault_Handler
269         .thumb_set BusFault_Handler,Default_Handler
271         .weak   UsageFault_Handler
272         .thumb_set UsageFault_Handler,Default_Handler
274         .weak   SVC_Handler
275         .thumb_set SVC_Handler,Default_Handler
277         .weak   DebugMon_Handler
278         .thumb_set DebugMon_Handler,Default_Handler
280         .weak   PendSV_Handler
281         .thumb_set PendSV_Handler,Default_Handler
283         .weak   SysTick_Handler
284         .thumb_set SysTick_Handler,Default_Handler
286         .weak   WWDG_IRQHandler
287         .thumb_set WWDG_IRQHandler,Default_Handler
289         .weak   PVD_IRQHandler
290         .thumb_set PVD_IRQHandler,Default_Handler
292         .weak   TAMPER_STAMP_IRQHandler
293         .thumb_set TAMPER_STAMP_IRQHandler,Default_Handler
295         .weak   RTC_WKUP_IRQHandler
296         .thumb_set RTC_WKUP_IRQHandler,Default_Handler
298         .weak   FLASH_IRQHandler
299         .thumb_set FLASH_IRQHandler,Default_Handler
301         .weak   RCC_IRQHandler
302         .thumb_set RCC_IRQHandler,Default_Handler
304         .weak   EXTI0_IRQHandler
305         .thumb_set EXTI0_IRQHandler,Default_Handler
307         .weak   EXTI1_IRQHandler
308         .thumb_set EXTI1_IRQHandler,Default_Handler
310         .weak   EXTI2_TS_IRQHandler
311         .thumb_set EXTI2_TS_IRQHandler,Default_Handler
313         .weak   EXTI3_IRQHandler
314         .thumb_set EXTI3_IRQHandler,Default_Handler
316         .weak   EXTI4_IRQHandler
317         .thumb_set EXTI4_IRQHandler,Default_Handler
319         .weak   DMA1_Channel1_IRQHandler
320         .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
322         .weak   DMA1_Channel2_IRQHandler
323         .thumb_set DMA1_Channel2_IRQHandler,Default_Handler
325         .weak   DMA1_Channel3_IRQHandler
326         .thumb_set DMA1_Channel3_IRQHandler,Default_Handler
328         .weak   DMA1_Channel4_IRQHandler
329         .thumb_set DMA1_Channel4_IRQHandler,Default_Handler
331         .weak   DMA1_Channel5_IRQHandler
332         .thumb_set DMA1_Channel5_IRQHandler,Default_Handler
334         .weak   DMA1_Channel6_IRQHandler
335         .thumb_set DMA1_Channel6_IRQHandler,Default_Handler
337         .weak   DMA1_Channel7_IRQHandler
338         .thumb_set DMA1_Channel7_IRQHandler,Default_Handler
340         .weak   ADC1_2_IRQHandler
341         .thumb_set ADC1_2_IRQHandler,Default_Handler
343         .weak   USB_HP_CAN1_TX_IRQHandler
344         .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
346         .weak   USB_LP_CAN1_RX0_IRQHandler
347         .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
349         .weak   CAN1_RX1_IRQHandler
350         .thumb_set CAN1_RX1_IRQHandler,Default_Handler
352         .weak   CAN1_SCE_IRQHandler
353         .thumb_set CAN1_SCE_IRQHandler,Default_Handler
355         .weak   EXTI9_5_IRQHandler
356         .thumb_set EXTI9_5_IRQHandler,Default_Handler
358         .weak   TIM1_BRK_TIM15_IRQHandler
359         .thumb_set TIM1_BRK_TIM15_IRQHandler,Default_Handler
361         .weak   TIM1_UP_TIM16_IRQHandler
362         .thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler
364         .weak   TIM1_TRG_COM_TIM17_IRQHandler
365         .thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler
367         .weak   TIM1_CC_IRQHandler
368         .thumb_set TIM1_CC_IRQHandler,Default_Handler
370         .weak   TIM2_IRQHandler
371         .thumb_set TIM2_IRQHandler,Default_Handler
373         .weak   TIM3_IRQHandler
374         .thumb_set TIM3_IRQHandler,Default_Handler
376         .weak   TIM4_IRQHandler
377         .thumb_set TIM4_IRQHandler,Default_Handler
379         .weak   I2C1_EV_IRQHandler
380         .thumb_set I2C1_EV_IRQHandler,Default_Handler
382         .weak   I2C1_ER_IRQHandler
383         .thumb_set I2C1_ER_IRQHandler,Default_Handler
385         .weak   I2C2_EV_IRQHandler
386         .thumb_set I2C2_EV_IRQHandler,Default_Handler
388         .weak   I2C2_ER_IRQHandler
389         .thumb_set I2C2_ER_IRQHandler,Default_Handler
391         .weak   SPI1_IRQHandler
392         .thumb_set SPI1_IRQHandler,Default_Handler
394         .weak   SPI2_IRQHandler
395         .thumb_set SPI2_IRQHandler,Default_Handler
397         .weak   USART1_IRQHandler
398         .thumb_set USART1_IRQHandler,Default_Handler
400         .weak   USART2_IRQHandler
401         .thumb_set USART2_IRQHandler,Default_Handler
403         .weak   USART3_IRQHandler
404         .thumb_set USART3_IRQHandler,Default_Handler
406         .weak   EXTI15_10_IRQHandler
407         .thumb_set EXTI15_10_IRQHandler,Default_Handler
409         .weak   RTC_Alarm_IRQHandler
410         .thumb_set RTC_Alarm_IRQHandler,Default_Handler
412         .weak   USBWakeUp_IRQHandler
413         .thumb_set USBWakeUp_IRQHandler,Default_Handler
415         .weak   TIM8_BRK_IRQHandler
416         .thumb_set TIM8_BRK_IRQHandler,Default_Handler
418         .weak   TIM8_UP_IRQHandler
419         .thumb_set TIM8_UP_IRQHandler,Default_Handler
421         .weak   TIM8_TRG_COM_IRQHandler
422         .thumb_set TIM8_TRG_COM_IRQHandler,Default_Handler
424         .weak   TIM8_CC_IRQHandler
425         .thumb_set TIM8_CC_IRQHandler,Default_Handler
427         .weak   ADC3_IRQHandler
428         .thumb_set ADC3_IRQHandler,Default_Handler
430         .weak   SPI3_IRQHandler
431         .thumb_set SPI3_IRQHandler,Default_Handler
433         .weak   UART4_IRQHandler
434         .thumb_set UART4_IRQHandler,Default_Handler
436         .weak   UART5_IRQHandler
437         .thumb_set UART5_IRQHandler,Default_Handler
439         .weak   TIM6_DAC_IRQHandler
440         .thumb_set TIM6_DAC_IRQHandler,Default_Handler
442         .weak   TIM7_IRQHandler
443         .thumb_set TIM7_IRQHandler,Default_Handler
445         .weak   DMA2_Channel1_IRQHandler
446         .thumb_set DMA2_Channel1_IRQHandler,Default_Handler
448         .weak   DMA2_Channel2_IRQHandler
449         .thumb_set DMA2_Channel2_IRQHandler,Default_Handler
451         .weak   DMA2_Channel3_IRQHandler
452         .thumb_set DMA2_Channel3_IRQHandler,Default_Handler
454         .weak   DMA2_Channel4_IRQHandler
455         .thumb_set DMA2_Channel4_IRQHandler,Default_Handler
457         .weak   DMA2_Channel5_IRQHandler
458         .thumb_set DMA2_Channel5_IRQHandler,Default_Handler
460         .weak   ADC4_IRQHandler
461         .thumb_set ADC4_IRQHandler,Default_Handler
463         .weak   COMP1_2_3_IRQHandler
464         .thumb_set COMP1_2_3_IRQHandler,Default_Handler
466         .weak   COMP4_5_6_IRQHandler
467         .thumb_set COMP4_5_6_IRQHandler,Default_Handler
469         .weak   COMP7_IRQHandler
470         .thumb_set COMP7_IRQHandler,Default_Handler
472         .weak   USB_HP_IRQHandler
473         .thumb_set USB_HP_IRQHandler,Default_Handler
475         .weak   USB_LP_IRQHandler
476         .thumb_set USB_LP_IRQHandler,Default_Handler
478         .weak   USBWakeUp_RMP_IRQHandler
479         .thumb_set USBWakeUp_RMP_IRQHandler,Default_Handler
481         .weak   FPU_IRQHandler
482         .thumb_set FPU_IRQHandler,Default_Handler
483 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/