startup_at32f413.s 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. /**
  2. ******************************************************************************
  3. * @file startup_at32f413.s
  4. * @brief at32f413xx devices vector table for gcc toolchain.
  5. * this module performs:
  6. * - set the initial sp
  7. * - set the initial pc == reset_handler,
  8. * - set the vector table entries with the exceptions isr address
  9. * - configure the clock system and the external sram to
  10. * be used as data memory (optional, to be enabled by user)
  11. * - branches to main in the c library (which eventually
  12. * calls main()).
  13. * after reset the cortex-m4 processor is in thread mode,
  14. * priority is privileged, and the stack is set to main.
  15. ******************************************************************************
  16. */
  17. .syntax unified
  18. .cpu cortex-m4
  19. .fpu softvfp
  20. .thumb
  21. .global g_pfnVectors
  22. .global Default_Handler
  23. /* start address for the initialization values of the .data section.
  24. defined in linker script */
  25. .word _sidata
  26. /* start address for the .data section. defined in linker script */
  27. .word _sdata
  28. /* end address for the .data section. defined in linker script */
  29. .word _edata
  30. /* start address for the .bss section. defined in linker script */
  31. .word _sbss
  32. /* end address for the .bss section. defined in linker script */
  33. .word _ebss
  34. /* stack used for SystemInit_ExtMemCtl; always internal RAM used */
  35. /**
  36. * @brief This is the code that gets called when the processor first
  37. * starts execution following a reset event. Only the absolutely
  38. * necessary set is performed, after which the application
  39. * supplied main() routine is called.
  40. * @param None
  41. * @retval None
  42. */
  43. .section .text.Reset_Handler
  44. .weak Reset_Handler
  45. .type Reset_Handler, %function
  46. Reset_Handler:
  47. /* Copy the data segment initializers from flash to SRAM */
  48. movs r1, #0
  49. b LoopCopyDataInit
  50. CopyDataInit:
  51. ldr r3, =_sidata
  52. ldr r3, [r3, r1]
  53. str r3, [r0, r1]
  54. adds r1, r1, #4
  55. LoopCopyDataInit:
  56. ldr r0, =_sdata
  57. ldr r3, =_edata
  58. adds r2, r0, r1
  59. cmp r2, r3
  60. bcc CopyDataInit
  61. ldr r2, =_sbss
  62. b LoopFillZerobss
  63. /* Zero fill the bss segment. */
  64. FillZerobss:
  65. movs r3, #0
  66. str r3, [r2], #4
  67. LoopFillZerobss:
  68. ldr r3, = _ebss
  69. cmp r2, r3
  70. bcc FillZerobss
  71. /* Call the clock system intitialization function.*/
  72. bl SystemInit
  73. /* Call static constructors */
  74. bl __libc_init_array
  75. /* Call the application's entry point.*/
  76. bl main
  77. bx lr
  78. .size Reset_Handler, .-Reset_Handler
  79. /**
  80. * @brief This is the code that gets called when the processor receives an
  81. * unexpected interrupt. This simply enters an infinite loop, preserving
  82. * the system state for examination by a debugger.
  83. * @param None
  84. * @retval None
  85. */
  86. .section .text.Default_Handler,"ax",%progbits
  87. Default_Handler:
  88. Infinite_Loop:
  89. b Infinite_Loop
  90. .size Default_Handler, .-Default_Handler
  91. /******************************************************************************
  92. *
  93. * The minimal vector table for a Cortex M3. Note that the proper constructs
  94. * must be placed on this to ensure that it ends up at physical address
  95. * 0x0000.0000.
  96. *
  97. *******************************************************************************/
  98. .section .isr_vector,"a",%progbits
  99. .type g_pfnVectors, %object
  100. .size g_pfnVectors, .-g_pfnVectors
  101. g_pfnVectors:
  102. .word _estack
  103. .word Reset_Handler
  104. .word NMI_Handler
  105. .word HardFault_Handler
  106. .word MemManage_Handler
  107. .word BusFault_Handler
  108. .word UsageFault_Handler
  109. .word 0
  110. .word 0
  111. .word 0
  112. .word 0
  113. .word SVC_Handler
  114. .word DebugMon_Handler
  115. .word 0
  116. .word PendSV_Handler
  117. .word SysTick_Handler
  118. /* External Interrupts */
  119. .word WWDT_IRQHandler /* Window Watchdog Timer */
  120. .word PVM_IRQHandler /* PVM through EXINT Line detect */
  121. .word TAMPER_IRQHandler /* Tamper */
  122. .word RTC_IRQHandler /* RTC */
  123. .word FLASH_IRQHandler /* Flash */
  124. .word CRM_IRQHandler /* CRM */
  125. .word EXINT0_IRQHandler /* EXINT Line 0 */
  126. .word EXINT1_IRQHandler /* EXINT Line 1 */
  127. .word EXINT2_IRQHandler /* EXINT Line 2 */
  128. .word EXINT3_IRQHandler /* EXINT Line 3 */
  129. .word EXINT4_IRQHandler /* EXINT Line 4 */
  130. .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */
  131. .word DMA1_Channel2_IRQHandler /* DMA1 Channel 2 */
  132. .word DMA1_Channel3_IRQHandler /* DMA1 Channel 3 */
  133. .word DMA1_Channel4_IRQHandler /* DMA1 Channel 4 */
  134. .word DMA1_Channel5_IRQHandler /* DMA1 Channel 5 */
  135. .word DMA1_Channel6_IRQHandler /* DMA1 Channel 6 */
  136. .word DMA1_Channel7_IRQHandler /* DMA1 Channel 7 */
  137. .word ADC1_2_IRQHandler /* ADC1 & ADC2 */
  138. .word USBFS_H_CAN1_TX_IRQHandler /* USB High Priority or CAN1 TX */
  139. .word USBFS_L_CAN1_RX0_IRQHandler /* USB Low Priority or CAN1 RX0 */
  140. .word CAN1_RX1_IRQHandler /* CAN1 RX1 */
  141. .word CAN1_SE_IRQHandler /* CAN1 SE */
  142. .word EXINT9_5_IRQHandler /* EXINT Line [9:5] */
  143. .word TMR1_BRK_TMR9_IRQHandler /* TMR1 Brake and TMR9 */
  144. .word TMR1_OVF_TMR10_IRQHandler /* TMR1 Overflow and TMR10 */
  145. .word TMR1_TRG_HALL_TMR11_IRQHandler /* TMR1 Trigger and hall and TMR11 */
  146. .word TMR1_CH_IRQHandler /* TMR1 Channel */
  147. .word TMR2_GLOBAL_IRQHandler /* TMR2 */
  148. .word TMR3_GLOBAL_IRQHandler /* TMR3 */
  149. .word TMR4_GLOBAL_IRQHandler /* TMR4 */
  150. .word I2C1_EVT_IRQHandler /* I2C1 Event */
  151. .word I2C1_ERR_IRQHandler /* I2C1 Error */
  152. .word I2C2_EVT_IRQHandler /* I2C2 Event */
  153. .word I2C2_ERR_IRQHandler /* I2C2 Error */
  154. .word SPI1_IRQHandler /* SPI1 */
  155. .word SPI2_IRQHandler /* Reserved */
  156. .word USART1_IRQHandler /* USART1 */
  157. .word USART2_IRQHandler /* USART2 */
  158. .word USART3_IRQHandler /* USART3 */
  159. .word EXINT15_10_IRQHandler /* EXINT Line [15:10] */
  160. .word RTCAlarm_IRQHandler /* RTC Alarm through EXINT Line */
  161. .word USBFSWakeUp_IRQHandler /* USB Wakeup from suspend */
  162. .word TMR8_BRK_IRQHandler /* TMR8 Brake */
  163. .word TMR8_OVF_IRQHandler /* TMR8 Overflow */
  164. .word TMR8_TRG_HALL_IRQHandler /* TMR8 Trigger and hall */
  165. .word TMR8_CH_IRQHandler /* TMR8 Channel */
  166. .word 0 /* Reserved */
  167. .word 0 /* Reserved */
  168. .word SDIO1_IRQHandler /* SDIO1 */
  169. .word TMR5_GLOBAL_IRQHandler /* TMR5 */
  170. .word 0 /* Reserved */
  171. .word UART4_IRQHandler /* UART4 */
  172. .word UART5_IRQHandler /* UART5 */
  173. .word 0 /* Reserved */
  174. .word 0 /* Reserved */
  175. .word DMA2_Channel1_IRQHandler /* DMA2 Channel1 */
  176. .word DMA2_Channel2_IRQHandler /* DMA2 Channel2 */
  177. .word DMA2_Channel3_IRQHandler /* DMA2 Channel3 */
  178. .word DMA2_Channel4_5_IRQHandler /* DMA2 Channel4 & Channel5 */
  179. .word 0 /* Reserved */
  180. .word 0 /* Reserved */
  181. .word 0 /* Reserved */
  182. .word 0 /* Reserved */
  183. .word 0 /* Reserved */
  184. .word 0 /* Reserved */
  185. .word 0 /* Reserved */
  186. .word 0 /* Reserved */
  187. .word CAN2_TX_IRQHandler /* CAN2 TX */
  188. .word CAN2_RX0_IRQHandler /* CAN2 RX0 */
  189. .word CAN2_RX1_IRQHandler /* CAN2 RX1 */
  190. .word CAN2_SE_IRQHandler /* CAN2 SE */
  191. .word ACC_IRQHandler /* ACC */
  192. .word USBFS_MAPH_IRQHandler /* USB Map HP */
  193. .word USBFS_MAPL_IRQHandler /* USB Map LP */
  194. .word DMA2_Channel6_7_IRQHandler /* DMA2 Channel6 & Channel7 */
  195. /*******************************************************************************
  196. *
  197. * Provide weak aliases for each Exception handler to the Default_Handler.
  198. * As they are weak aliases, any function with the same name will override
  199. * this definition.
  200. *
  201. *******************************************************************************/
  202. .weak NMI_Handler
  203. .thumb_set NMI_Handler,Default_Handler
  204. .weak HardFault_Handler
  205. .thumb_set HardFault_Handler,Default_Handler
  206. .weak MemManage_Handler
  207. .thumb_set MemManage_Handler,Default_Handler
  208. .weak BusFault_Handler
  209. .thumb_set BusFault_Handler,Default_Handler
  210. .weak UsageFault_Handler
  211. .thumb_set UsageFault_Handler,Default_Handler
  212. .weak SVC_Handler
  213. .thumb_set SVC_Handler,Default_Handler
  214. .weak DebugMon_Handler
  215. .thumb_set DebugMon_Handler,Default_Handler
  216. .weak PendSV_Handler
  217. .thumb_set PendSV_Handler,Default_Handler
  218. .weak SysTick_Handler
  219. .thumb_set SysTick_Handler,Default_Handler
  220. .weak WWDT_IRQHandler
  221. .thumb_set WWDT_IRQHandler,Default_Handler
  222. .weak PVM_IRQHandler
  223. .thumb_set PVM_IRQHandler,Default_Handler
  224. .weak TAMPER_IRQHandler
  225. .thumb_set TAMPER_IRQHandler,Default_Handler
  226. .weak RTC_IRQHandler
  227. .thumb_set RTC_IRQHandler,Default_Handler
  228. .weak FLASH_IRQHandler
  229. .thumb_set FLASH_IRQHandler,Default_Handler
  230. .weak CRM_IRQHandler
  231. .thumb_set CRM_IRQHandler,Default_Handler
  232. .weak EXINT0_IRQHandler
  233. .thumb_set EXINT0_IRQHandler,Default_Handler
  234. .weak EXINT1_IRQHandler
  235. .thumb_set EXINT1_IRQHandler,Default_Handler
  236. .weak EXINT2_IRQHandler
  237. .thumb_set EXINT2_IRQHandler,Default_Handler
  238. .weak EXINT3_IRQHandler
  239. .thumb_set EXINT3_IRQHandler,Default_Handler
  240. .weak EXINT4_IRQHandler
  241. .thumb_set EXINT4_IRQHandler,Default_Handler
  242. .weak DMA1_Channel1_IRQHandler
  243. .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
  244. .weak DMA1_Channel2_IRQHandler
  245. .thumb_set DMA1_Channel2_IRQHandler,Default_Handler
  246. .weak DMA1_Channel3_IRQHandler
  247. .thumb_set DMA1_Channel3_IRQHandler,Default_Handler
  248. .weak DMA1_Channel4_IRQHandler
  249. .thumb_set DMA1_Channel4_IRQHandler,Default_Handler
  250. .weak DMA1_Channel5_IRQHandler
  251. .thumb_set DMA1_Channel5_IRQHandler,Default_Handler
  252. .weak DMA1_Channel6_IRQHandler
  253. .thumb_set DMA1_Channel6_IRQHandler,Default_Handler
  254. .weak DMA1_Channel7_IRQHandler
  255. .thumb_set DMA1_Channel7_IRQHandler,Default_Handler
  256. .weak ADC1_2_IRQHandler
  257. .thumb_set ADC1_2_IRQHandler,Default_Handler
  258. .weak USBFS_H_CAN1_TX_IRQHandler
  259. .thumb_set USBFS_H_CAN1_TX_IRQHandler,Default_Handler
  260. .weak USBFS_L_CAN1_RX0_IRQHandler
  261. .thumb_set USBFS_L_CAN1_RX0_IRQHandler,Default_Handler
  262. .weak CAN1_RX1_IRQHandler
  263. .thumb_set CAN1_RX1_IRQHandler,Default_Handler
  264. .weak CAN1_SE_IRQHandler
  265. .thumb_set CAN1_SE_IRQHandler,Default_Handler
  266. .weak EXINT9_5_IRQHandler
  267. .thumb_set EXINT9_5_IRQHandler,Default_Handler
  268. .weak TMR1_BRK_TMR9_IRQHandler
  269. .thumb_set TMR1_BRK_TMR9_IRQHandler,Default_Handler
  270. .weak TMR1_OVF_TMR10_IRQHandler
  271. .thumb_set TMR1_OVF_TMR10_IRQHandler,Default_Handler
  272. .weak TMR1_TRG_HALL_TMR11_IRQHandler
  273. .thumb_set TMR1_TRG_HALL_TMR11_IRQHandler,Default_Handler
  274. .weak TMR1_CH_IRQHandler
  275. .thumb_set TMR1_CH_IRQHandler,Default_Handler
  276. .weak TMR2_GLOBAL_IRQHandler
  277. .thumb_set TMR2_GLOBAL_IRQHandler,Default_Handler
  278. .weak TMR3_GLOBAL_IRQHandler
  279. .thumb_set TMR3_GLOBAL_IRQHandler,Default_Handler
  280. .weak TMR4_GLOBAL_IRQHandler
  281. .thumb_set TMR4_GLOBAL_IRQHandler,Default_Handler
  282. .weak I2C1_EVT_IRQHandler
  283. .thumb_set I2C1_EVT_IRQHandler,Default_Handler
  284. .weak I2C1_ERR_IRQHandler
  285. .thumb_set I2C1_ERR_IRQHandler,Default_Handler
  286. .weak I2C2_EVT_IRQHandler
  287. .thumb_set I2C2_EVT_IRQHandler,Default_Handler
  288. .weak I2C2_ERR_IRQHandler
  289. .thumb_set I2C2_ERR_IRQHandler,Default_Handler
  290. .weak SPI1_IRQHandler
  291. .thumb_set SPI1_IRQHandler,Default_Handler
  292. .weak SPI2_IRQHandler
  293. .thumb_set SPI2_IRQHandler,Default_Handler
  294. .weak USART1_IRQHandler
  295. .thumb_set USART1_IRQHandler,Default_Handler
  296. .weak USART2_IRQHandler
  297. .thumb_set USART2_IRQHandler,Default_Handler
  298. .weak USART3_IRQHandler
  299. .thumb_set USART3_IRQHandler,Default_Handler
  300. .weak EXINT15_10_IRQHandler
  301. .thumb_set EXINT15_10_IRQHandler,Default_Handler
  302. .weak RTCAlarm_IRQHandler
  303. .thumb_set RTCAlarm_IRQHandler,Default_Handler
  304. .weak USBFSWakeUp_IRQHandler
  305. .thumb_set USBFSWakeUp_IRQHandler,Default_Handler
  306. .weak TMR8_BRK_IRQHandler
  307. .thumb_set TMR8_BRK_IRQHandler,Default_Handler
  308. .weak TMR8_OVF_IRQHandler
  309. .thumb_set TMR8_OVF_IRQHandler,Default_Handler
  310. .weak TMR8_TRG_HALL_IRQHandler
  311. .thumb_set TMR8_TRG_HALL_IRQHandler,Default_Handler
  312. .weak TMR8_CH_IRQHandler
  313. .thumb_set TMR8_CH_IRQHandler,Default_Handler
  314. .weak SDIO1_IRQHandler
  315. .thumb_set SDIO1_IRQHandler,Default_Handler
  316. .weak TMR5_GLOBAL_IRQHandler
  317. .thumb_set TMR5_GLOBAL_IRQHandler,Default_Handler
  318. .weak UART4_IRQHandler
  319. .thumb_set UART4_IRQHandler,Default_Handler
  320. .weak UART5_IRQHandler
  321. .thumb_set UART5_IRQHandler,Default_Handler
  322. .weak DMA2_Channel1_IRQHandler
  323. .thumb_set DMA2_Channel1_IRQHandler,Default_Handler
  324. .weak DMA2_Channel2_IRQHandler
  325. .thumb_set DMA2_Channel2_IRQHandler,Default_Handler
  326. .weak DMA2_Channel3_IRQHandler
  327. .thumb_set DMA2_Channel3_IRQHandler,Default_Handler
  328. .weak DMA2_Channel4_5_IRQHandler
  329. .thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler
  330. .weak CAN2_TX_IRQHandler
  331. .thumb_set CAN2_TX_IRQHandler,Default_Handler
  332. .weak CAN2_RX0_IRQHandler
  333. .thumb_set CAN2_RX0_IRQHandler ,Default_Handler
  334. .weak CAN2_RX1_IRQHandler
  335. .thumb_set CAN2_RX1_IRQHandler ,Default_Handler
  336. .weak CAN2_SE_IRQHandler
  337. .thumb_set CAN2_SE_IRQHandler,Default_Handler
  338. .weak ACC_IRQHandler
  339. .thumb_set ACC_IRQHandler,Default_Handler
  340. .weak USBFS_MAPH_IRQHandler
  341. .thumb_set USBFS_MAPH_IRQHandler,Default_Handler
  342. .weak USBFS_MAPL_IRQHandler
  343. .thumb_set USBFS_MAPL_IRQHandler,Default_Handler
  344. .weak DMA2_Channel6_7_IRQHandler
  345. .thumb_set DMA2_Channel6_7_IRQHandler,Default_Handler