startup_stm32f030k6tx.s 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /**
  2. ******************************************************************************
  3. * @file startup_stm32f030x6.s
  4. * @author MCD Application Team
  5. * @brief STM32F030x4/STM32F030x6 devices vector table for GCC toolchain.
  6. * This module performs:
  7. * - Set the initial SP
  8. * - Set the initial PC == Reset_Handler,
  9. * - Set the vector table entries with the exceptions ISR address
  10. * - Branches to main in the C library (which eventually
  11. * calls main()).
  12. * After Reset the Cortex-M0 processor is in Thread mode,
  13. * priority is Privileged, and the Stack is set to Main.
  14. ******************************************************************************
  15. * @attention
  16. *
  17. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  18. * All rights reserved.</center></h2>
  19. *
  20. * This software component is licensed by ST under BSD 3-Clause license,
  21. * the "License"; You may not use this file except in compliance with the
  22. * License. You may obtain a copy of the License at:
  23. * opensource.org/licenses/BSD-3-Clause
  24. *
  25. ******************************************************************************
  26. */
  27. .syntax unified
  28. .cpu cortex-m0
  29. .fpu softvfp
  30. .thumb
  31. .global g_pfnVectors
  32. .global Default_Handler
  33. /* start address for the initialization values of the .data section.
  34. defined in linker script */
  35. .word _sidata
  36. /* start address for the .data section. defined in linker script */
  37. .word _sdata
  38. /* end address for the .data section. defined in linker script */
  39. .word _edata
  40. /* start address for the .bss section. defined in linker script */
  41. .word _sbss
  42. /* end address for the .bss section. defined in linker script */
  43. .word _ebss
  44. .section .text.Reset_Handler
  45. .weak Reset_Handler
  46. .type Reset_Handler, %function
  47. Reset_Handler:
  48. ldr r0, =_estack
  49. mov sp, r0 /* set stack pointer */
  50. /* Copy the data segment initializers from flash to SRAM */
  51. ldr r0, =_sdata
  52. ldr r1, =_edata
  53. ldr r2, =_sidata
  54. movs r3, #0
  55. b LoopCopyDataInit
  56. CopyDataInit:
  57. ldr r4, [r2, r3]
  58. str r4, [r0, r3]
  59. adds r3, r3, #4
  60. LoopCopyDataInit:
  61. adds r4, r0, r3
  62. cmp r4, r1
  63. bcc CopyDataInit
  64. /* Zero fill the bss segment. */
  65. ldr r2, =_sbss
  66. ldr r4, =_ebss
  67. movs r3, #0
  68. b LoopFillZerobss
  69. FillZerobss:
  70. str r3, [r2]
  71. adds r2, r2, #4
  72. LoopFillZerobss:
  73. cmp r2, r4
  74. bcc FillZerobss
  75. /* Call the clock system intitialization function.*/
  76. bl SystemInit
  77. /* Call static constructors */
  78. bl __libc_init_array
  79. /* Call the application's entry point.*/
  80. bl main
  81. LoopForever:
  82. b LoopForever
  83. .size Reset_Handler, .-Reset_Handler
  84. /**
  85. * @brief This is the code that gets called when the processor receives an
  86. * unexpected interrupt. This simply enters an infinite loop, preserving
  87. * the system state for examination by a debugger.
  88. *
  89. * @param None
  90. * @retval : None
  91. */
  92. .section .text.Default_Handler,"ax",%progbits
  93. Default_Handler:
  94. Infinite_Loop:
  95. b Infinite_Loop
  96. .size Default_Handler, .-Default_Handler
  97. /******************************************************************************
  98. *
  99. * The minimal vector table for a Cortex M0. Note that the proper constructs
  100. * must be placed on this to ensure that it ends up at physical address
  101. * 0x0000.0000.
  102. *
  103. ******************************************************************************/
  104. .section .isr_vector,"a",%progbits
  105. .type g_pfnVectors, %object
  106. .size g_pfnVectors, .-g_pfnVectors
  107. g_pfnVectors:
  108. .word _estack
  109. .word Reset_Handler
  110. .word NMI_Handler
  111. .word HardFault_Handler
  112. .word 0
  113. .word 0
  114. .word 0
  115. .word 0
  116. .word 0
  117. .word 0
  118. .word 0
  119. .word SVC_Handler
  120. .word 0
  121. .word 0
  122. .word PendSV_Handler
  123. .word SysTick_Handler
  124. .word WWDG_IRQHandler /* Window WatchDog */
  125. .word 0 /* Reserved */
  126. .word RTC_IRQHandler /* RTC through the EXTI line */
  127. .word FLASH_IRQHandler /* FLASH */
  128. .word RCC_IRQHandler /* RCC */
  129. .word EXTI0_1_IRQHandler /* EXTI Line 0 and 1 */
  130. .word EXTI2_3_IRQHandler /* EXTI Line 2 and 3 */
  131. .word EXTI4_15_IRQHandler /* EXTI Line 4 to 15 */
  132. .word 0 /* Reserved */
  133. .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */
  134. .word DMA1_Channel2_3_IRQHandler /* DMA1 Channel 2 and Channel 3 */
  135. .word DMA1_Channel4_5_IRQHandler /* DMA1 Channel 4 and Channel 5 */
  136. .word ADC1_IRQHandler /* ADC1 */
  137. .word TIM1_BRK_UP_TRG_COM_IRQHandler /* TIM1 Break, Update, Trigger and Commutation */
  138. .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
  139. .word 0 /* Reserved */
  140. .word TIM3_IRQHandler /* TIM3 */
  141. .word 0 /* Reserved */
  142. .word 0 /* Reserved */
  143. .word TIM14_IRQHandler /* TIM14 */
  144. .word 0 /* Reserved */
  145. .word TIM16_IRQHandler /* TIM16 */
  146. .word TIM17_IRQHandler /* TIM17 */
  147. .word I2C1_IRQHandler /* I2C1 */
  148. .word 0 /* Reserved */
  149. .word SPI1_IRQHandler /* SPI1 */
  150. .word 0 /* Reserved */
  151. .word USART1_IRQHandler /* USART1 */
  152. .word 0 /* Reserved */
  153. .word 0 /* Reserved */
  154. .word 0 /* Reserved */
  155. .word 0 /* Reserved */
  156. /*******************************************************************************
  157. *
  158. * Provide weak aliases for each Exception handler to the Default_Handler.
  159. * As they are weak aliases, any function with the same name will override
  160. * this definition.
  161. *
  162. *******************************************************************************/
  163. .weak NMI_Handler
  164. .thumb_set NMI_Handler,Default_Handler
  165. .weak HardFault_Handler
  166. .thumb_set HardFault_Handler,Default_Handler
  167. .weak SVC_Handler
  168. .thumb_set SVC_Handler,Default_Handler
  169. .weak PendSV_Handler
  170. .thumb_set PendSV_Handler,Default_Handler
  171. .weak SysTick_Handler
  172. .thumb_set SysTick_Handler,Default_Handler
  173. .weak WWDG_IRQHandler
  174. .thumb_set WWDG_IRQHandler,Default_Handler
  175. .weak RTC_IRQHandler
  176. .thumb_set RTC_IRQHandler,Default_Handler
  177. .weak FLASH_IRQHandler
  178. .thumb_set FLASH_IRQHandler,Default_Handler
  179. .weak RCC_IRQHandler
  180. .thumb_set RCC_IRQHandler,Default_Handler
  181. .weak EXTI0_1_IRQHandler
  182. .thumb_set EXTI0_1_IRQHandler,Default_Handler
  183. .weak EXTI2_3_IRQHandler
  184. .thumb_set EXTI2_3_IRQHandler,Default_Handler
  185. .weak EXTI4_15_IRQHandler
  186. .thumb_set EXTI4_15_IRQHandler,Default_Handler
  187. .weak DMA1_Channel1_IRQHandler
  188. .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
  189. .weak DMA1_Channel2_3_IRQHandler
  190. .thumb_set DMA1_Channel2_3_IRQHandler,Default_Handler
  191. .weak DMA1_Channel4_5_IRQHandler
  192. .thumb_set DMA1_Channel4_5_IRQHandler,Default_Handler
  193. .weak ADC1_IRQHandler
  194. .thumb_set ADC1_IRQHandler,Default_Handler
  195. .weak TIM1_BRK_UP_TRG_COM_IRQHandler
  196. .thumb_set TIM1_BRK_UP_TRG_COM_IRQHandler,Default_Handler
  197. .weak TIM1_CC_IRQHandler
  198. .thumb_set TIM1_CC_IRQHandler,Default_Handler
  199. .weak TIM3_IRQHandler
  200. .thumb_set TIM3_IRQHandler,Default_Handler
  201. .weak TIM14_IRQHandler
  202. .thumb_set TIM14_IRQHandler,Default_Handler
  203. .weak TIM16_IRQHandler
  204. .thumb_set TIM16_IRQHandler,Default_Handler
  205. .weak TIM17_IRQHandler
  206. .thumb_set TIM17_IRQHandler,Default_Handler
  207. .weak I2C1_IRQHandler
  208. .thumb_set I2C1_IRQHandler,Default_Handler
  209. .weak SPI1_IRQHandler
  210. .thumb_set SPI1_IRQHandler,Default_Handler
  211. .weak USART1_IRQHandler
  212. .thumb_set USART1_IRQHandler,Default_Handler
  213. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/