2 ******************************************************************************
3 * @file startup_stm32f10x_md.s
4 * @author MCD Application Team / Angus Peart
7 * @brief STM32F10x Medium Density Devices vector table for RIDE7 toolchain.
8 * This module performs:
10 * - Set the initial PC == Reset_Handler,
11 * - Set the vector table entries with the exceptions ISR address
12 * - Branches to main in the C library (which eventually
14 * After Reset the Cortex-M3 processor is in Thread mode,
15 * priority is Privileged, and the Stack is set to Main.
16 *******************************************************************************
19 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
20 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
21 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
22 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
23 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
24 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
26 * <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
35 .global Default_Handler
36 .global xPortIncreaseHeapSize
39 /* start address for the initialization values of the .data section.
40 defined in linker script */
42 /* start address for the .data section. defined in linker script */
44 /* end address for the .data section. defined in linker script */
46 /* start address for the .bss section. defined in linker script */
48 /* end address for the .bss section. defined in linker script */
51 .equ BootRAM, 0xF108F85F
53 * @brief This is the code that gets called when the processor first
54 * starts execution following a reset event. Only the absolutely
55 * necessary set is performed, after which the application
56 * supplied main() routine is called.
61 .section .text.Reset_Handler
63 .type Reset_Handler, %function
67 * From COrtex-M3 reference manual:
68 * - Handler IRQ always use SP_main
69 * - Process use SP_main or SP_process
70 * Here, we will use beginning of SRAM for IRQ (SP_main)
71 * and end of heap for initialization (SP_process).
72 * Once the schedule starts, all threads will use their own stack
73 * from heap and NOBOBY should use SP_process again.
75 /* Do set/reset the stack pointers */
76 LDR r0, =_irq_stack_top
78 LDR r2, =_init_stack_top
80 /* check if irq and init stack are the same */
81 /* if they are, we don't do stack swap */
82 /* and lets bypass the monitoring as well for now */
86 * - stay in thread process mode
87 * - stay in privilege level
93 /* Fill IRQ stack for watermark monitoring */
94 ldr r2, =_irq_stack_end
102 ldr r3, = _irq_stack_top
107 /* Copy the data segment initializers from flash to SRAM */
125 /* Zero fill the bss segment. */
134 /* Call the application's entry point.*/
136 /* will never return here */
138 .size Reset_Handler, .-Reset_Handler
141 * @brief This is the code that swaps stack (from end of heap to irq_stack).
142 * Also reclaim the heap that was used as a stack.
146 .section .text.Stack_Change
148 .type Stack_Change, %function
151 /* Switches stack back momentarily to MSP */
155 /* add heap_post_rtos to the heap (if the capability/function exist) */
156 /* Also claim the unused memory (between end of heap to end of memory */
157 /* CAREFULL: the heap section must be the last section in RAM in order this to work */
158 ldr r0, = _init_stack_size
159 ldr r1, = _eheap_post_rtos
163 bl xPortIncreaseHeapSize
165 .size Stack_Change, .-Stack_Change
169 * @brief This is the code that gets called when the processor receives an
170 * unexpected interrupt. This simply enters an infinite loop, preserving
171 * the system state for examination by a debugger.
176 .section .text.Default_Handler,"ax",%progbits
180 .size Default_Handler, .-Default_Handler
181 /******************************************************************************
183 * The minimal vector table for a Cortex M3. Note that the proper constructs
184 * must be placed on this to ensure that it ends up at physical address
187 ******************************************************************************/
188 .section .isr_vector,"a",%progbits
189 .type g_pfnVectors, %object
190 .size g_pfnVectors, .-g_pfnVectors
197 .word HardFault_Handler
198 .word MemManage_Handler
199 .word BusFault_Handler
200 .word UsageFault_Handler
205 .word vPortSVCHandler
206 .word DebugMon_Handler
208 .word xPortPendSVHandler
209 .word xPortSysTickHandler
210 .word WWDG_IRQHandler
212 .word TAMPER_IRQHandler
214 .word FLASH_IRQHandler
216 .word EXTI0_IRQHandler
217 .word EXTI1_IRQHandler
218 .word EXTI2_IRQHandler
219 .word EXTI3_IRQHandler
220 .word EXTI4_IRQHandler
221 .word DMA1_Channel1_IRQHandler
222 .word DMA1_Channel2_IRQHandler
223 .word DMA1_Channel3_IRQHandler
224 .word DMA1_Channel4_IRQHandler
225 .word DMA1_Channel5_IRQHandler
226 .word DMA1_Channel6_IRQHandler
227 .word DMA1_Channel7_IRQHandler
228 .word ADC1_2_IRQHandler
229 .word USB_HP_CAN1_TX_IRQHandler
230 .word USB_LP_CAN1_RX0_IRQHandler
231 .word CAN1_RX1_IRQHandler
232 .word CAN1_SCE_IRQHandler
233 .word EXTI9_5_IRQHandler
234 .word TIM1_BRK_IRQHandler
235 .word TIM1_UP_IRQHandler
236 .word TIM1_TRG_COM_IRQHandler
237 .word TIM1_CC_IRQHandler
238 .word TIM2_IRQHandler
239 .word TIM3_IRQHandler
240 .word TIM4_IRQHandler
241 .word I2C1_EV_IRQHandler
242 .word I2C1_ER_IRQHandler
243 .word I2C2_EV_IRQHandler
244 .word I2C2_ER_IRQHandler
245 .word SPI1_IRQHandler
246 .word SPI2_IRQHandler
247 .word USART1_IRQHandler
248 .word USART2_IRQHandler
249 .word USART3_IRQHandler
250 .word EXTI15_10_IRQHandler
251 .word RTCAlarm_IRQHandler
252 .word USBWakeUp_IRQHandler
260 .word BootRAM /* @0x108. This is for boot in RAM mode for
261 STM32F10x Medium Density devices. */
263 /*******************************************************************************
265 * Provide weak aliases for each Exception handler to the Default_Handler.
266 * As they are weak aliases, any function with the same name will override
269 *******************************************************************************/
272 .thumb_set NMI_Handler,Default_Handler
274 .weak HardFault_Handler
275 .thumb_set HardFault_Handler,Default_Handler
277 .weak MemManage_Handler
278 .thumb_set MemManage_Handler,Default_Handler
280 .weak BusFault_Handler
281 .thumb_set BusFault_Handler,Default_Handler
283 .weak UsageFault_Handler
284 .thumb_set UsageFault_Handler,Default_Handler
287 .thumb_set SVC_Handler,Default_Handler
289 .weak DebugMon_Handler
290 .thumb_set DebugMon_Handler,Default_Handler
293 .thumb_set PendSV_Handler,Default_Handler
295 .weak SysTick_Handler
296 .thumb_set SysTick_Handler,Default_Handler
298 .weak WWDG_IRQHandler
299 .thumb_set WWDG_IRQHandler,Default_Handler
302 .thumb_set PVD_IRQHandler,Default_Handler
304 .weak TAMPER_IRQHandler
305 .thumb_set TAMPER_IRQHandler,Default_Handler
308 .thumb_set RTC_IRQHandler,Default_Handler
310 .weak FLASH_IRQHandler
311 .thumb_set FLASH_IRQHandler,Default_Handler
314 .thumb_set RCC_IRQHandler,Default_Handler
316 .weak EXTI0_IRQHandler
317 .thumb_set EXTI0_IRQHandler,Default_Handler
319 .weak EXTI1_IRQHandler
320 .thumb_set EXTI1_IRQHandler,Default_Handler
322 .weak EXTI2_IRQHandler
323 .thumb_set EXTI2_IRQHandler,Default_Handler
325 .weak EXTI3_IRQHandler
326 .thumb_set EXTI3_IRQHandler,Default_Handler
328 .weak EXTI4_IRQHandler
329 .thumb_set EXTI4_IRQHandler,Default_Handler
331 .weak DMA1_Channel1_IRQHandler
332 .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
334 .weak DMA1_Channel2_IRQHandler
335 .thumb_set DMA1_Channel2_IRQHandler,Default_Handler
337 .weak DMA1_Channel3_IRQHandler
338 .thumb_set DMA1_Channel3_IRQHandler,Default_Handler
340 .weak DMA1_Channel4_IRQHandler
341 .thumb_set DMA1_Channel4_IRQHandler,Default_Handler
343 .weak DMA1_Channel5_IRQHandler
344 .thumb_set DMA1_Channel5_IRQHandler,Default_Handler
346 .weak DMA1_Channel6_IRQHandler
347 .thumb_set DMA1_Channel6_IRQHandler,Default_Handler
349 .weak DMA1_Channel7_IRQHandler
350 .thumb_set DMA1_Channel7_IRQHandler,Default_Handler
352 .weak ADC1_2_IRQHandler
353 .thumb_set ADC1_2_IRQHandler,Default_Handler
355 .weak USB_HP_CAN1_TX_IRQHandler
356 .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
358 .weak USB_LP_CAN1_RX0_IRQHandler
359 .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
361 .weak CAN1_RX1_IRQHandler
362 .thumb_set CAN1_RX1_IRQHandler,Default_Handler
364 .weak CAN1_SCE_IRQHandler
365 .thumb_set CAN1_SCE_IRQHandler,Default_Handler
367 .weak EXTI9_5_IRQHandler
368 .thumb_set EXTI9_5_IRQHandler,Default_Handler
370 .weak TIM1_BRK_IRQHandler
371 .thumb_set TIM1_BRK_IRQHandler,Default_Handler
373 .weak TIM1_UP_IRQHandler
374 .thumb_set TIM1_UP_IRQHandler,Default_Handler
376 .weak TIM1_TRG_COM_IRQHandler
377 .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
379 .weak TIM1_CC_IRQHandler
380 .thumb_set TIM1_CC_IRQHandler,Default_Handler
382 .weak TIM2_IRQHandler
383 .thumb_set TIM2_IRQHandler,Default_Handler
385 .weak TIM3_IRQHandler
386 .thumb_set TIM3_IRQHandler,Default_Handler
388 .weak TIM4_IRQHandler
389 .thumb_set TIM4_IRQHandler,Default_Handler
391 .weak I2C1_EV_IRQHandler
392 .thumb_set I2C1_EV_IRQHandler,Default_Handler
394 .weak I2C1_ER_IRQHandler
395 .thumb_set I2C1_ER_IRQHandler,Default_Handler
397 .weak I2C2_EV_IRQHandler
398 .thumb_set I2C2_EV_IRQHandler,Default_Handler
400 .weak I2C2_ER_IRQHandler
401 .thumb_set I2C2_ER_IRQHandler,Default_Handler
403 .weak SPI1_IRQHandler
404 .thumb_set SPI1_IRQHandler,Default_Handler
406 .weak SPI2_IRQHandler
407 .thumb_set SPI2_IRQHandler,Default_Handler
409 .weak USART1_IRQHandler
410 .thumb_set USART1_IRQHandler,Default_Handler
412 .weak USART2_IRQHandler
413 .thumb_set USART2_IRQHandler,Default_Handler
415 .weak USART3_IRQHandler
416 .thumb_set USART3_IRQHandler,Default_Handler
418 .weak EXTI15_10_IRQHandler
419 .thumb_set EXTI15_10_IRQHandler,Default_Handler
421 .weak RTCAlarm_IRQHandler
422 .thumb_set RTCAlarm_IRQHandler,Default_Handler
424 .weak USBWakeUp_IRQHandler
425 .thumb_set USBWakeUp_IRQHandler,Default_Handler