xref: /btstack/port/stm32-l073rz-nucleo-em9304/startup_stm32l073xx.s (revision e838079242074edcbcbb400962776e15fe6ca6cb)
1*e8380792SMatthias Ringwald/**
2*e8380792SMatthias Ringwald  ******************************************************************************
3*e8380792SMatthias Ringwald  * @file      startup_stm32l073xx.s
4*e8380792SMatthias Ringwald  * @author    MCD Application Team
5*e8380792SMatthias Ringwald  * @brief     STM32L073xx Devices vector table for GCC toolchain.
6*e8380792SMatthias Ringwald  *            This module performs:
7*e8380792SMatthias Ringwald  *                - Set the initial SP
8*e8380792SMatthias Ringwald  *                - Set the initial PC == Reset_Handler,
9*e8380792SMatthias Ringwald  *                - Set the vector table entries with the exceptions ISR address
10*e8380792SMatthias Ringwald  *                - Branches to main in the C library (which eventually
11*e8380792SMatthias Ringwald  *                  calls main()).
12*e8380792SMatthias Ringwald  *            After Reset the Cortex-M0+ processor is in Thread mode,
13*e8380792SMatthias Ringwald  *            priority is Privileged, and the Stack is set to Main.
14*e8380792SMatthias Ringwald  ******************************************************************************
15*e8380792SMatthias Ringwald  *
16*e8380792SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without modification,
17*e8380792SMatthias Ringwald  * are permitted provided that the following conditions are met:
18*e8380792SMatthias Ringwald  *   1. Redistributions of source code must retain the above copyright notice,
19*e8380792SMatthias Ringwald  *      this list of conditions and the following disclaimer.
20*e8380792SMatthias Ringwald  *   2. Redistributions in binary form must reproduce the above copyright notice,
21*e8380792SMatthias Ringwald  *      this list of conditions and the following disclaimer in the documentation
22*e8380792SMatthias Ringwald  *      and/or other materials provided with the distribution.
23*e8380792SMatthias Ringwald  *   3. Neither the name of STMicroelectronics nor the names of its contributors
24*e8380792SMatthias Ringwald  *      may be used to endorse or promote products derived from this software
25*e8380792SMatthias Ringwald  *      without specific prior written permission.
26*e8380792SMatthias Ringwald  *
27*e8380792SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28*e8380792SMatthias Ringwald  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29*e8380792SMatthias Ringwald  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30*e8380792SMatthias Ringwald  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31*e8380792SMatthias Ringwald  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32*e8380792SMatthias Ringwald  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33*e8380792SMatthias Ringwald  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34*e8380792SMatthias Ringwald  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35*e8380792SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36*e8380792SMatthias Ringwald  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37*e8380792SMatthias Ringwald  *
38*e8380792SMatthias Ringwald  ******************************************************************************
39*e8380792SMatthias Ringwald  */
40*e8380792SMatthias Ringwald
41*e8380792SMatthias Ringwald  .syntax unified
42*e8380792SMatthias Ringwald  .cpu cortex-m0plus
43*e8380792SMatthias Ringwald  .fpu softvfp
44*e8380792SMatthias Ringwald  .thumb
45*e8380792SMatthias Ringwald
46*e8380792SMatthias Ringwald.global  g_pfnVectors
47*e8380792SMatthias Ringwald.global  Default_Handler
48*e8380792SMatthias Ringwald
49*e8380792SMatthias Ringwald/* start address for the initialization values of the .data section.
50*e8380792SMatthias Ringwalddefined in linker script */
51*e8380792SMatthias Ringwald.word  _sidata
52*e8380792SMatthias Ringwald/* start address for the .data section. defined in linker script */
53*e8380792SMatthias Ringwald.word  _sdata
54*e8380792SMatthias Ringwald/* end address for the .data section. defined in linker script */
55*e8380792SMatthias Ringwald.word  _edata
56*e8380792SMatthias Ringwald/* start address for the .bss section. defined in linker script */
57*e8380792SMatthias Ringwald.word  _sbss
58*e8380792SMatthias Ringwald/* end address for the .bss section. defined in linker script */
59*e8380792SMatthias Ringwald.word  _ebss
60*e8380792SMatthias Ringwald
61*e8380792SMatthias Ringwald    .section  .text.Reset_Handler
62*e8380792SMatthias Ringwald  .weak  Reset_Handler
63*e8380792SMatthias Ringwald  .type  Reset_Handler, %function
64*e8380792SMatthias RingwaldReset_Handler:
65*e8380792SMatthias Ringwald   ldr   r0, =_estack
66*e8380792SMatthias Ringwald   mov   sp, r0          /* set stack pointer */
67*e8380792SMatthias Ringwald
68*e8380792SMatthias Ringwald/* Copy the data segment initializers from flash to SRAM */
69*e8380792SMatthias Ringwald  movs  r1, #0
70*e8380792SMatthias Ringwald  b  LoopCopyDataInit
71*e8380792SMatthias Ringwald
72*e8380792SMatthias RingwaldCopyDataInit:
73*e8380792SMatthias Ringwald  ldr  r3, =_sidata
74*e8380792SMatthias Ringwald  ldr  r3, [r3, r1]
75*e8380792SMatthias Ringwald  str  r3, [r0, r1]
76*e8380792SMatthias Ringwald  adds  r1, r1, #4
77*e8380792SMatthias Ringwald
78*e8380792SMatthias RingwaldLoopCopyDataInit:
79*e8380792SMatthias Ringwald  ldr  r0, =_sdata
80*e8380792SMatthias Ringwald  ldr  r3, =_edata
81*e8380792SMatthias Ringwald  adds  r2, r0, r1
82*e8380792SMatthias Ringwald  cmp  r2, r3
83*e8380792SMatthias Ringwald  bcc  CopyDataInit
84*e8380792SMatthias Ringwald  ldr  r2, =_sbss
85*e8380792SMatthias Ringwald  b  LoopFillZerobss
86*e8380792SMatthias Ringwald/* Zero fill the bss segment. */
87*e8380792SMatthias RingwaldFillZerobss:
88*e8380792SMatthias Ringwald  movs  r3, #0
89*e8380792SMatthias Ringwald  str  r3, [r2]
90*e8380792SMatthias Ringwald  adds r2, r2, #4
91*e8380792SMatthias Ringwald
92*e8380792SMatthias Ringwald
93*e8380792SMatthias RingwaldLoopFillZerobss:
94*e8380792SMatthias Ringwald  ldr  r3, = _ebss
95*e8380792SMatthias Ringwald  cmp  r2, r3
96*e8380792SMatthias Ringwald  bcc  FillZerobss
97*e8380792SMatthias Ringwald
98*e8380792SMatthias Ringwald/* Call the clock system intitialization function.*/
99*e8380792SMatthias Ringwald  bl  SystemInit
100*e8380792SMatthias Ringwald/* Call static constructors */
101*e8380792SMatthias Ringwald    bl __libc_init_array
102*e8380792SMatthias Ringwald/* Call the application's entry point.*/
103*e8380792SMatthias Ringwald  bl  main
104*e8380792SMatthias Ringwald
105*e8380792SMatthias RingwaldLoopForever:
106*e8380792SMatthias Ringwald    b LoopForever
107*e8380792SMatthias Ringwald
108*e8380792SMatthias Ringwald
109*e8380792SMatthias Ringwald.size  Reset_Handler, .-Reset_Handler
110*e8380792SMatthias Ringwald
111*e8380792SMatthias Ringwald/**
112*e8380792SMatthias Ringwald * @brief  This is the code that gets called when the processor receives an
113*e8380792SMatthias Ringwald *         unexpected interrupt.  This simply enters an infinite loop, preserving
114*e8380792SMatthias Ringwald *         the system state for examination by a debugger.
115*e8380792SMatthias Ringwald *
116*e8380792SMatthias Ringwald * @param  None
117*e8380792SMatthias Ringwald * @retval : None
118*e8380792SMatthias Ringwald*/
119*e8380792SMatthias Ringwald    .section  .text.Default_Handler,"ax",%progbits
120*e8380792SMatthias RingwaldDefault_Handler:
121*e8380792SMatthias RingwaldInfinite_Loop:
122*e8380792SMatthias Ringwald  b  Infinite_Loop
123*e8380792SMatthias Ringwald  .size  Default_Handler, .-Default_Handler
124*e8380792SMatthias Ringwald/******************************************************************************
125*e8380792SMatthias Ringwald*
126*e8380792SMatthias Ringwald* The minimal vector table for a Cortex M0.  Note that the proper constructs
127*e8380792SMatthias Ringwald* must be placed on this to ensure that it ends up at physical address
128*e8380792SMatthias Ringwald* 0x0000.0000.
129*e8380792SMatthias Ringwald*
130*e8380792SMatthias Ringwald******************************************************************************/
131*e8380792SMatthias Ringwald   .section  .isr_vector,"a",%progbits
132*e8380792SMatthias Ringwald  .type  g_pfnVectors, %object
133*e8380792SMatthias Ringwald  .size  g_pfnVectors, .-g_pfnVectors
134*e8380792SMatthias Ringwald
135*e8380792SMatthias Ringwald
136*e8380792SMatthias Ringwaldg_pfnVectors:
137*e8380792SMatthias Ringwald  .word  _estack
138*e8380792SMatthias Ringwald  .word  Reset_Handler
139*e8380792SMatthias Ringwald  .word  NMI_Handler
140*e8380792SMatthias Ringwald  .word  HardFault_Handler
141*e8380792SMatthias Ringwald  .word  0
142*e8380792SMatthias Ringwald  .word  0
143*e8380792SMatthias Ringwald  .word  0
144*e8380792SMatthias Ringwald  .word  0
145*e8380792SMatthias Ringwald  .word  0
146*e8380792SMatthias Ringwald  .word  0
147*e8380792SMatthias Ringwald  .word  0
148*e8380792SMatthias Ringwald  .word  SVC_Handler
149*e8380792SMatthias Ringwald  .word  0
150*e8380792SMatthias Ringwald  .word  0
151*e8380792SMatthias Ringwald  .word  PendSV_Handler
152*e8380792SMatthias Ringwald  .word  SysTick_Handler
153*e8380792SMatthias Ringwald  .word     WWDG_IRQHandler                   /* Window WatchDog              */
154*e8380792SMatthias Ringwald  .word     PVD_IRQHandler                    /* PVD through EXTI Line detection */
155*e8380792SMatthias Ringwald  .word     RTC_IRQHandler                    /* RTC through the EXTI line     */
156*e8380792SMatthias Ringwald  .word     FLASH_IRQHandler                  /* FLASH                        */
157*e8380792SMatthias Ringwald  .word     RCC_CRS_IRQHandler                /* RCC and CRS                  */
158*e8380792SMatthias Ringwald  .word     EXTI0_1_IRQHandler                /* EXTI Line 0 and 1            */
159*e8380792SMatthias Ringwald  .word     EXTI2_3_IRQHandler                /* EXTI Line 2 and 3            */
160*e8380792SMatthias Ringwald  .word     EXTI4_15_IRQHandler               /* EXTI Line 4 to 15            */
161*e8380792SMatthias Ringwald  .word     TSC_IRQHandler                     /* TSC                           */
162*e8380792SMatthias Ringwald  .word     DMA1_Channel1_IRQHandler          /* DMA1 Channel 1               */
163*e8380792SMatthias Ringwald  .word     DMA1_Channel2_3_IRQHandler        /* DMA1 Channel 2 and Channel 3 */
164*e8380792SMatthias Ringwald  .word     DMA1_Channel4_5_6_7_IRQHandler    /* DMA1 Channel 4, Channel 5, Channel 6 and Channel 7*/
165*e8380792SMatthias Ringwald  .word     ADC1_COMP_IRQHandler              /* ADC1, COMP1 and COMP2        */
166*e8380792SMatthias Ringwald  .word     LPTIM1_IRQHandler                 /* LPTIM1                       */
167*e8380792SMatthias Ringwald  .word     USART4_5_IRQHandler               /* USART4 and USART 5           */
168*e8380792SMatthias Ringwald  .word     TIM2_IRQHandler                   /* TIM2                         */
169*e8380792SMatthias Ringwald  .word     TIM3_IRQHandler                   /* TIM3                         */
170*e8380792SMatthias Ringwald  .word     TIM6_DAC_IRQHandler               /* TIM6 and DAC                 */
171*e8380792SMatthias Ringwald  .word     TIM7_IRQHandler 				          /* TIM7                         */
172*e8380792SMatthias Ringwald  .word     0              					          /* Reserved                     */
173*e8380792SMatthias Ringwald  .word     TIM21_IRQHandler                  /* TIM21                        */
174*e8380792SMatthias Ringwald  .word     I2C3_IRQHandler                   /* I2C3                         */
175*e8380792SMatthias Ringwald  .word     TIM22_IRQHandler                  /* TIM22                        */
176*e8380792SMatthias Ringwald  .word     I2C1_IRQHandler                   /* I2C1                         */
177*e8380792SMatthias Ringwald  .word     I2C2_IRQHandler                   /* I2C2                         */
178*e8380792SMatthias Ringwald  .word     SPI1_IRQHandler                   /* SPI1                         */
179*e8380792SMatthias Ringwald  .word     SPI2_IRQHandler                   /* SPI2                         */
180*e8380792SMatthias Ringwald  .word     USART1_IRQHandler                 /* USART1                       */
181*e8380792SMatthias Ringwald  .word     USART2_IRQHandler                 /* USART2                       */
182*e8380792SMatthias Ringwald  .word     RNG_LPUART1_IRQHandler            /* RNG and LPUART1              */
183*e8380792SMatthias Ringwald  .word     LCD_IRQHandler                    /* LCD                          */
184*e8380792SMatthias Ringwald  .word     USB_IRQHandler                    /* USB                          */
185*e8380792SMatthias Ringwald
186*e8380792SMatthias Ringwald/*******************************************************************************
187*e8380792SMatthias Ringwald*
188*e8380792SMatthias Ringwald* Provide weak aliases for each Exception handler to the Default_Handler.
189*e8380792SMatthias Ringwald* As they are weak aliases, any function with the same name will override
190*e8380792SMatthias Ringwald* this definition.
191*e8380792SMatthias Ringwald*
192*e8380792SMatthias Ringwald*******************************************************************************/
193*e8380792SMatthias Ringwald
194*e8380792SMatthias Ringwald   .weak      NMI_Handler
195*e8380792SMatthias Ringwald   .thumb_set NMI_Handler,Default_Handler
196*e8380792SMatthias Ringwald
197*e8380792SMatthias Ringwald   .weak      HardFault_Handler
198*e8380792SMatthias Ringwald   .thumb_set HardFault_Handler,Default_Handler
199*e8380792SMatthias Ringwald
200*e8380792SMatthias Ringwald   .weak      SVC_Handler
201*e8380792SMatthias Ringwald   .thumb_set SVC_Handler,Default_Handler
202*e8380792SMatthias Ringwald
203*e8380792SMatthias Ringwald   .weak      PendSV_Handler
204*e8380792SMatthias Ringwald   .thumb_set PendSV_Handler,Default_Handler
205*e8380792SMatthias Ringwald
206*e8380792SMatthias Ringwald   .weak      SysTick_Handler
207*e8380792SMatthias Ringwald   .thumb_set SysTick_Handler,Default_Handler
208*e8380792SMatthias Ringwald
209*e8380792SMatthias Ringwald   .weak      WWDG_IRQHandler
210*e8380792SMatthias Ringwald   .thumb_set WWDG_IRQHandler,Default_Handler
211*e8380792SMatthias Ringwald
212*e8380792SMatthias Ringwald   .weak      PVD_IRQHandler
213*e8380792SMatthias Ringwald   .thumb_set PVD_IRQHandler,Default_Handler
214*e8380792SMatthias Ringwald
215*e8380792SMatthias Ringwald   .weak      RTC_IRQHandler
216*e8380792SMatthias Ringwald   .thumb_set RTC_IRQHandler,Default_Handler
217*e8380792SMatthias Ringwald
218*e8380792SMatthias Ringwald   .weak      FLASH_IRQHandler
219*e8380792SMatthias Ringwald   .thumb_set FLASH_IRQHandler,Default_Handler
220*e8380792SMatthias Ringwald
221*e8380792SMatthias Ringwald   .weak      RCC_CRS_IRQHandler
222*e8380792SMatthias Ringwald   .thumb_set RCC_CRS_IRQHandler,Default_Handler
223*e8380792SMatthias Ringwald
224*e8380792SMatthias Ringwald   .weak      EXTI0_1_IRQHandler
225*e8380792SMatthias Ringwald   .thumb_set EXTI0_1_IRQHandler,Default_Handler
226*e8380792SMatthias Ringwald
227*e8380792SMatthias Ringwald   .weak      EXTI2_3_IRQHandler
228*e8380792SMatthias Ringwald   .thumb_set EXTI2_3_IRQHandler,Default_Handler
229*e8380792SMatthias Ringwald
230*e8380792SMatthias Ringwald   .weak      EXTI4_15_IRQHandler
231*e8380792SMatthias Ringwald   .thumb_set EXTI4_15_IRQHandler,Default_Handler
232*e8380792SMatthias Ringwald
233*e8380792SMatthias Ringwald   .weak      TSC_IRQHandler
234*e8380792SMatthias Ringwald   .thumb_set TSC_IRQHandler,Default_Handler
235*e8380792SMatthias Ringwald
236*e8380792SMatthias Ringwald   .weak      DMA1_Channel1_IRQHandler
237*e8380792SMatthias Ringwald   .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
238*e8380792SMatthias Ringwald
239*e8380792SMatthias Ringwald   .weak      DMA1_Channel2_3_IRQHandler
240*e8380792SMatthias Ringwald   .thumb_set DMA1_Channel2_3_IRQHandler,Default_Handler
241*e8380792SMatthias Ringwald
242*e8380792SMatthias Ringwald   .weak      DMA1_Channel4_5_6_7_IRQHandler
243*e8380792SMatthias Ringwald   .thumb_set DMA1_Channel4_5_6_7_IRQHandler,Default_Handler
244*e8380792SMatthias Ringwald
245*e8380792SMatthias Ringwald   .weak      ADC1_COMP_IRQHandler
246*e8380792SMatthias Ringwald   .thumb_set ADC1_COMP_IRQHandler,Default_Handler
247*e8380792SMatthias Ringwald
248*e8380792SMatthias Ringwald   .weak      LPTIM1_IRQHandler
249*e8380792SMatthias Ringwald   .thumb_set LPTIM1_IRQHandler,Default_Handler
250*e8380792SMatthias Ringwald
251*e8380792SMatthias Ringwald   .weak      USART4_5_IRQHandler
252*e8380792SMatthias Ringwald   .thumb_set USART4_5_IRQHandler,Default_Handler
253*e8380792SMatthias Ringwald
254*e8380792SMatthias Ringwald   .weak      TIM2_IRQHandler
255*e8380792SMatthias Ringwald   .thumb_set TIM2_IRQHandler,Default_Handler
256*e8380792SMatthias Ringwald
257*e8380792SMatthias Ringwald   .weak      TIM3_IRQHandler
258*e8380792SMatthias Ringwald   .thumb_set TIM3_IRQHandler,Default_Handler
259*e8380792SMatthias Ringwald
260*e8380792SMatthias Ringwald   .weak      TIM6_DAC_IRQHandler
261*e8380792SMatthias Ringwald   .thumb_set TIM6_DAC_IRQHandler,Default_Handler
262*e8380792SMatthias Ringwald
263*e8380792SMatthias Ringwald   .weak      TIM7_IRQHandler
264*e8380792SMatthias Ringwald   .thumb_set TIM7_IRQHandler,Default_Handler
265*e8380792SMatthias Ringwald
266*e8380792SMatthias Ringwald   .weak      TIM21_IRQHandler
267*e8380792SMatthias Ringwald   .thumb_set TIM21_IRQHandler,Default_Handler
268*e8380792SMatthias Ringwald
269*e8380792SMatthias Ringwald   .weak      I2C3_IRQHandler
270*e8380792SMatthias Ringwald   .thumb_set I2C3_IRQHandler,Default_Handler
271*e8380792SMatthias Ringwald
272*e8380792SMatthias Ringwald   .weak      TIM22_IRQHandler
273*e8380792SMatthias Ringwald   .thumb_set TIM22_IRQHandler,Default_Handler
274*e8380792SMatthias Ringwald
275*e8380792SMatthias Ringwald   .weak      I2C1_IRQHandler
276*e8380792SMatthias Ringwald   .thumb_set I2C1_IRQHandler,Default_Handler
277*e8380792SMatthias Ringwald
278*e8380792SMatthias Ringwald   .weak      I2C2_IRQHandler
279*e8380792SMatthias Ringwald   .thumb_set I2C2_IRQHandler,Default_Handler
280*e8380792SMatthias Ringwald
281*e8380792SMatthias Ringwald   .weak      SPI1_IRQHandler
282*e8380792SMatthias Ringwald   .thumb_set SPI1_IRQHandler,Default_Handler
283*e8380792SMatthias Ringwald
284*e8380792SMatthias Ringwald   .weak      SPI2_IRQHandler
285*e8380792SMatthias Ringwald   .thumb_set SPI2_IRQHandler,Default_Handler
286*e8380792SMatthias Ringwald
287*e8380792SMatthias Ringwald   .weak      USART1_IRQHandler
288*e8380792SMatthias Ringwald   .thumb_set USART1_IRQHandler,Default_Handler
289*e8380792SMatthias Ringwald
290*e8380792SMatthias Ringwald   .weak      USART2_IRQHandler
291*e8380792SMatthias Ringwald   .thumb_set USART2_IRQHandler,Default_Handler
292*e8380792SMatthias Ringwald
293*e8380792SMatthias Ringwald   .weak      RNG_LPUART1_IRQHandler
294*e8380792SMatthias Ringwald   .thumb_set RNG_LPUART1_IRQHandler,Default_Handler
295*e8380792SMatthias Ringwald
296*e8380792SMatthias Ringwald   .weak      LCD_IRQHandler
297*e8380792SMatthias Ringwald   .thumb_set LCD_IRQHandler,Default_Handler
298*e8380792SMatthias Ringwald
299*e8380792SMatthias Ringwald   .weak      USB_IRQHandler
300*e8380792SMatthias Ringwald   .thumb_set USB_IRQHandler,Default_Handler
301*e8380792SMatthias Ringwald
302*e8380792SMatthias Ringwald
303*e8380792SMatthias Ringwald
304*e8380792SMatthias Ringwald/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
305*e8380792SMatthias Ringwald
306