startup_stm32g030xx.s 8.8 KB

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