You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

308 lines
10 KiB

  1. /**
  2. ******************************************************************************
  3. * @file startup_stm32f070x6.s
  4. * @author MCD Application Team
  5. * @brief STM32F070x4/STM32F070x6 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. *
  16. * Redistribution and use in source and binary forms, with or without modification,
  17. * are permitted provided that the following conditions are met:
  18. * 1. Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  24. * may be used to endorse or promote products derived from this software
  25. * without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  31. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  33. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  34. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  35. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. ******************************************************************************
  39. */
  40. .syntax unified
  41. .cpu cortex-m0
  42. .fpu softvfp
  43. .thumb
  44. .global g_pfnVectors
  45. .global Default_Handler
  46. /* start address for the initialization values of the .data section.
  47. defined in linker script */
  48. .word _sidata
  49. /* start address for the .data section. defined in linker script */
  50. .word _sdata
  51. /* end address for the .data section. defined in linker script */
  52. .word _edata
  53. /* start address for the .bss section. defined in linker script */
  54. .word _sbss
  55. /* end address for the .bss section. defined in linker script */
  56. .word _ebss
  57. /**
  58. * @brief This is the code that gets called when the processor first
  59. * starts execution following a reset event. Only the absolutely
  60. * necessary set is performed, after which the application
  61. * supplied main() routine is called.
  62. * @param None
  63. * @retval : None
  64. */
  65. .section .text.Reset_Handler
  66. .weak Reset_Handler
  67. .type Reset_Handler, %function
  68. Reset_Handler:
  69. ldr r0, =_estack
  70. mov sp, r0 /* set stack pointer */
  71. /*Check if boot space corresponds to test memory*/
  72. LDR R0,=0x00000004
  73. LDR R1, [R0]
  74. LSRS R1, R1, #24
  75. LDR R2,=0x1F
  76. CMP R1, R2
  77. BNE ApplicationStart
  78. /*SYSCFG clock enable*/
  79. LDR R0,=0x40021018
  80. LDR R1,=0x00000001
  81. STR R1, [R0]
  82. /*Set CFGR1 register with flash memory remap at address 0*/
  83. LDR R0,=0x40010000
  84. LDR R1,=0x00000000
  85. STR R1, [R0]
  86. ApplicationStart:
  87. /* Copy the data segment initializers from flash to SRAM */
  88. ldr r0, =_sdata
  89. ldr r1, =_edata
  90. ldr r2, =_sidata
  91. movs r3, #0
  92. b LoopCopyDataInit
  93. CopyDataInit:
  94. ldr r4, [r2, r3]
  95. str r4, [r0, r3]
  96. adds r3, r3, #4
  97. LoopCopyDataInit:
  98. adds r4, r0, r3
  99. cmp r4, r1
  100. bcc CopyDataInit
  101. /* Zero fill the bss segment. */
  102. ldr r2, =_sbss
  103. ldr r4, =_ebss
  104. movs r3, #0
  105. b LoopFillZerobss
  106. FillZerobss:
  107. str r3, [r2]
  108. adds r2, r2, #4
  109. LoopFillZerobss:
  110. cmp r2, r4
  111. bcc FillZerobss
  112. /* Call the clock system intitialization function.*/
  113. bl SystemInit
  114. /* Call static constructors */
  115. bl __libc_init_array
  116. /* Call the application's entry point.*/
  117. bl main
  118. LoopForever:
  119. b LoopForever
  120. .size Reset_Handler, .-Reset_Handler
  121. /**
  122. * @brief This is the code that gets called when the processor receives an
  123. * unexpected interrupt. This simply enters an infinite loop, preserving
  124. * the system state for examination by a debugger.
  125. *
  126. * @param None
  127. * @retval : None
  128. */
  129. .section .text.Default_Handler,"ax",%progbits
  130. Default_Handler:
  131. Infinite_Loop:
  132. b Infinite_Loop
  133. .size Default_Handler, .-Default_Handler
  134. /******************************************************************************
  135. *
  136. * The minimal vector table for a Cortex M0. Note that the proper constructs
  137. * must be placed on this to ensure that it ends up at physical address
  138. * 0x0000.0000.
  139. *
  140. ******************************************************************************/
  141. .section .isr_vector,"a",%progbits
  142. .type g_pfnVectors, %object
  143. .size g_pfnVectors, .-g_pfnVectors
  144. g_pfnVectors:
  145. .word _estack
  146. .word Reset_Handler
  147. .word NMI_Handler
  148. .word HardFault_Handler
  149. .word 0
  150. .word 0
  151. .word 0
  152. .word 0
  153. .word 0
  154. .word 0
  155. .word 0
  156. .word SVC_Handler
  157. .word 0
  158. .word 0
  159. .word PendSV_Handler
  160. .word SysTick_Handler
  161. .word WWDG_IRQHandler /* Window WatchDog */
  162. .word 0 /* Reserved */
  163. .word RTC_IRQHandler /* RTC through the EXTI line */
  164. .word FLASH_IRQHandler /* FLASH */
  165. .word RCC_IRQHandler /* RCC */
  166. .word EXTI0_1_IRQHandler /* EXTI Line 0 and 1 */
  167. .word EXTI2_3_IRQHandler /* EXTI Line 2 and 3 */
  168. .word EXTI4_15_IRQHandler /* EXTI Line 4 to 15 */
  169. .word 0 /* Reserved */
  170. .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */
  171. .word DMA1_Channel2_3_IRQHandler /* DMA1 Channel 2 and Channel 3 */
  172. .word DMA1_Channel4_5_IRQHandler /* DMA1 Channel 4 and Channel 5 */
  173. .word ADC1_IRQHandler /* ADC1 */
  174. .word TIM1_BRK_UP_TRG_COM_IRQHandler /* TIM1 Break, Update, Trigger and Commutation */
  175. .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
  176. .word 0 /* Reserved */
  177. .word TIM3_IRQHandler /* TIM3 */
  178. .word 0 /* Reserved */
  179. .word 0 /* Reserved */
  180. .word TIM14_IRQHandler /* TIM14 */
  181. .word 0 /* Reserved */
  182. .word TIM16_IRQHandler /* TIM16 */
  183. .word TIM17_IRQHandler /* TIM17 */
  184. .word I2C1_IRQHandler /* I2C1 */
  185. .word 0 /* Reserved */
  186. .word SPI1_IRQHandler /* SPI1 */
  187. .word 0 /* Reserved */
  188. .word USART1_IRQHandler /* USART1 */
  189. .word USART2_IRQHandler /* USART2 */
  190. .word 0 /* Reserved */
  191. .word 0 /* Reserved */
  192. .word USB_IRQHandler /* USB */
  193. /*******************************************************************************
  194. *
  195. * Provide weak aliases for each Exception handler to the Default_Handler.
  196. * As they are weak aliases, any function with the same name will override
  197. * this definition.
  198. *
  199. *******************************************************************************/
  200. .weak NMI_Handler
  201. .thumb_set NMI_Handler,Default_Handler
  202. .weak HardFault_Handler
  203. .thumb_set HardFault_Handler,Default_Handler
  204. .weak SVC_Handler
  205. .thumb_set SVC_Handler,Default_Handler
  206. .weak PendSV_Handler
  207. .thumb_set PendSV_Handler,Default_Handler
  208. .weak SysTick_Handler
  209. .thumb_set SysTick_Handler,Default_Handler
  210. .weak WWDG_IRQHandler
  211. .thumb_set WWDG_IRQHandler,Default_Handler
  212. .weak RTC_IRQHandler
  213. .thumb_set RTC_IRQHandler,Default_Handler
  214. .weak FLASH_IRQHandler
  215. .thumb_set FLASH_IRQHandler,Default_Handler
  216. .weak RCC_IRQHandler
  217. .thumb_set RCC_IRQHandler,Default_Handler
  218. .weak EXTI0_1_IRQHandler
  219. .thumb_set EXTI0_1_IRQHandler,Default_Handler
  220. .weak EXTI2_3_IRQHandler
  221. .thumb_set EXTI2_3_IRQHandler,Default_Handler
  222. .weak EXTI4_15_IRQHandler
  223. .thumb_set EXTI4_15_IRQHandler,Default_Handler
  224. .weak DMA1_Channel1_IRQHandler
  225. .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
  226. .weak DMA1_Channel2_3_IRQHandler
  227. .thumb_set DMA1_Channel2_3_IRQHandler,Default_Handler
  228. .weak DMA1_Channel4_5_IRQHandler
  229. .thumb_set DMA1_Channel4_5_IRQHandler,Default_Handler
  230. .weak ADC1_IRQHandler
  231. .thumb_set ADC1_IRQHandler,Default_Handler
  232. .weak TIM1_BRK_UP_TRG_COM_IRQHandler
  233. .thumb_set TIM1_BRK_UP_TRG_COM_IRQHandler,Default_Handler
  234. .weak TIM1_CC_IRQHandler
  235. .thumb_set TIM1_CC_IRQHandler,Default_Handler
  236. .weak TIM3_IRQHandler
  237. .thumb_set TIM3_IRQHandler,Default_Handler
  238. .weak TIM14_IRQHandler
  239. .thumb_set TIM14_IRQHandler,Default_Handler
  240. .weak TIM16_IRQHandler
  241. .thumb_set TIM16_IRQHandler,Default_Handler
  242. .weak TIM17_IRQHandler
  243. .thumb_set TIM17_IRQHandler,Default_Handler
  244. .weak I2C1_IRQHandler
  245. .thumb_set I2C1_IRQHandler,Default_Handler
  246. .weak SPI1_IRQHandler
  247. .thumb_set SPI1_IRQHandler,Default_Handler
  248. .weak USART1_IRQHandler
  249. .thumb_set USART1_IRQHandler,Default_Handler
  250. .weak USART2_IRQHandler
  251. .thumb_set USART2_IRQHandler,Default_Handler
  252. .weak USB_IRQHandler
  253. .thumb_set USB_IRQHandler,Default_Handler
  254. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/