startup_gd32f10x_xd.s 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. ;/*!
  2. ; \file startup_gd32f10x_xd.s
  3. ; \brief start up file
  4. ;
  5. ; \version 2014-12-26, V1.0.0, firmware for GD32F10x
  6. ; \version 2017-06-20, V2.0.0, firmware for GD32F10x
  7. ; \version 2018-07-31, V2.1.0, firmware for GD32F10x
  8. ;*/
  9. ;
  10. ;/*
  11. ; Copyright (c) 2018, GigaDevice Semiconductor Inc.
  12. ;
  13. ; All rights reserved.
  14. ;
  15. ; Redistribution and use in source and binary forms, with or without modification,
  16. ;are permitted provided that the following conditions are met:
  17. ;
  18. ; 1. Redistributions of source code must retain the above copyright notice, this
  19. ; 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 the copyright holder nor the names of its contributors
  24. ; may be used to endorse or promote products derived from this software without
  25. ; 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 IMPLIED
  29. ;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  30. ;IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  31. ;INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  32. ;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  33. ;PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  34. ;WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. ;ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  36. ;OF SUCH DAMAGE.
  37. ;*/
  38. ; <h> Stack Configuration
  39. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  40. ; </h>
  41. Stack_Size EQU 0x0002000
  42. AREA STACK, NOINIT, READWRITE, ALIGN = 3
  43. Stack_Mem SPACE Stack_Size
  44. __initial_sp
  45. ; <h> Heap Configuration
  46. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  47. ; </h>
  48. Heap_Size EQU 0x0000C000
  49. AREA HEAP, NOINIT, READWRITE, ALIGN = 3
  50. __heap_base
  51. Heap_Mem SPACE Heap_Size
  52. __heap_limit
  53. PRESERVE8
  54. THUMB
  55. ; /* reset Vector Mapped to at Address 0 */
  56. AREA RESET, DATA, READONLY
  57. EXPORT __Vectors
  58. EXPORT __Vectors_End
  59. EXPORT __Vectors_Size
  60. __Vectors DCD __initial_sp ; Top of Stack
  61. DCD Reset_Handler ; Reset Handler
  62. DCD NMI_Handler ; NMI Handler
  63. DCD HardFault_Handler ; Hard Fault Handler
  64. DCD MemManage_Handler ; MPU Fault Handler
  65. DCD BusFault_Handler ; Bus Fault Handler
  66. DCD UsageFault_Handler ; Usage Fault Handler
  67. DCD 0 ; Reserved
  68. DCD 0 ; Reserved
  69. DCD 0 ; Reserved
  70. DCD 0 ; Reserved
  71. DCD SVC_Handler ; SVCall Handler
  72. DCD DebugMon_Handler ; Debug Monitor Handler
  73. DCD 0 ; Reserved
  74. DCD PendSV_Handler ; PendSV Handler
  75. DCD SysTick_Handler ; SysTick Handler
  76. ; /* external interrupts handler */
  77. DCD WWDGT_IRQHandler ; 16:Window Watchdog Timer
  78. DCD LVD_IRQHandler ; 17:LVD through EXTI Line detect
  79. DCD TAMPER_IRQHandler ; 18:Tamper Interrupt
  80. DCD RTC_IRQHandler ; 19:RTC through EXTI Line
  81. DCD FMC_IRQHandler ; 20:FMC
  82. DCD RCU_IRQHandler ; 21:RCU
  83. DCD EXTI0_IRQHandler ; 22:EXTI Line 0
  84. DCD EXTI1_IRQHandler ; 23:EXTI Line 1
  85. DCD EXTI2_IRQHandler ; 24:EXTI Line 2
  86. DCD EXTI3_IRQHandler ; 25:EXTI Line 3
  87. DCD EXTI4_IRQHandler ; 26:EXTI Line 4
  88. DCD DMA0_Channel0_IRQHandler ; 27:DMA0 Channel 0
  89. DCD DMA0_Channel1_IRQHandler ; 28:DMA0 Channel 1
  90. DCD DMA0_Channel2_IRQHandler ; 29:DMA0 Channel 2
  91. DCD DMA0_Channel3_IRQHandler ; 30:DMA0 Channel 3
  92. DCD DMA0_Channel4_IRQHandler ; 31:DMA0 Channel 4
  93. DCD DMA0_Channel5_IRQHandler ; 32:DMA0 Channel 5
  94. DCD DMA0_Channel6_IRQHandler ; 33:DMA0 Channel 6
  95. DCD ADC0_1_IRQHandler ; 34:ADC0 and ADC1
  96. DCD USBD_HP_CAN0_TX_IRQHandler ; 35:USBD and CAN0 TX
  97. DCD USBD_LP_CAN0_RX0_IRQHandler ; 36:USBD and CAN0 RX0
  98. DCD CAN0_RX1_IRQHandler ; 37:CAN0 RX1
  99. DCD CAN0_EWMC_IRQHandler ; 38:CAN0 EWMC
  100. DCD EXTI5_9_IRQHandler ; 39:EXTI Line 5 to EXTI Line 9
  101. DCD TIMER0_BRK_TIMER8_IRQHandler ; 40:TIMER0 Break and TIMER8 global
  102. DCD TIMER0_UP_TIMER9_IRQHandler ; 41:TIMER0 Update and TIMER9 global
  103. DCD TIMER0_TRG_CMT_TIMER10_IRQHandler ; 42:TIMER0 Trigger and Commutation and TIMER10 global
  104. DCD TIMER0_Channel_IRQHandler ; 43:TIMER0 Channel Capture Compare
  105. DCD TIMER1_IRQHandler ; 44:TIMER1
  106. DCD TIMER2_IRQHandler ; 45:TIMER2
  107. DCD TIMER3_IRQHandler ; 46:TIMER3
  108. DCD I2C0_EV_IRQHandler ; 47:I2C0 Event
  109. DCD I2C0_ER_IRQHandler ; 48:I2C0 Error
  110. DCD I2C1_EV_IRQHandler ; 49:I2C1 Event
  111. DCD I2C1_ER_IRQHandler ; 50:I2C1 Error
  112. DCD SPI0_IRQHandler ; 51:SPI0
  113. DCD SPI1_IRQHandler ; 52:SPI1
  114. DCD USART0_IRQHandler ; 53:USART0
  115. DCD USART1_IRQHandler ; 54:USART1
  116. DCD USART2_IRQHandler ; 55:USART2
  117. DCD EXTI10_15_IRQHandler ; 56:EXTI Line 10 to EXTI Line 15
  118. DCD RTC_Alarm_IRQHandler ; 57:RTC Alarm through EXTI Line
  119. DCD USBD_WKUP_IRQHandler ; 58:USBD WakeUp from suspend through EXTI Line
  120. DCD TIMER7_BRK_TIMER11_IRQHandler ; 59:TIMER7 Break Interrupt and TIMER11 global
  121. DCD TIMER7_UP_TIMER12_IRQHandler ; 60:TIMER7 Update Interrupt and TIMER12 global
  122. DCD TIMER7_TRG_CMT_TIMER13_IRQHandler ; 61:TIMER7 Trigger and Commutation Interrupt and TIMER13 global
  123. DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Channel Capture Compare
  124. DCD ADC2_IRQHandler ; 63:ADC2
  125. DCD EXMC_IRQHandler ; 64:EXMC
  126. DCD SDIO_IRQHandler ; 65:SDIO
  127. DCD TIMER4_IRQHandler ; 66:TIMER4
  128. DCD SPI2_IRQHandler ; 67:SPI2
  129. DCD UART3_IRQHandler ; 68:UART3
  130. DCD UART4_IRQHandler ; 69:UART4
  131. DCD TIMER5_IRQHandler ; 70:TIMER5
  132. DCD TIMER6_IRQHandler ; 71:TIMER6
  133. DCD DMA1_Channel0_IRQHandler ; 72:DMA1 Channel0
  134. DCD DMA1_Channel1_IRQHandler ; 73:DMA1 Channel1
  135. DCD DMA1_Channel2_IRQHandler ; 74:DMA1 Channel2
  136. DCD DMA1_Channel3_4_IRQHandler ; 75:DMA1 Channel3 and Channel4
  137. __Vectors_End
  138. __Vectors_Size EQU __Vectors_End - __Vectors
  139. AREA |.text|, CODE, READONLY
  140. ;/* reset Handler */
  141. Reset_Handler PROC
  142. EXPORT Reset_Handler [WEAK]
  143. IMPORT __main
  144. IMPORT SystemInit
  145. LDR R0, =SystemInit
  146. BLX R0
  147. LDR R0, =__main
  148. BX R0
  149. ENDP
  150. ;/* dummy Exception Handlers */
  151. NMI_Handler PROC
  152. EXPORT NMI_Handler [WEAK]
  153. B .
  154. ENDP
  155. HardFault_Handler PROC
  156. EXPORT HardFault_Handler [WEAK]
  157. B .
  158. ENDP
  159. MemManage_Handler PROC
  160. EXPORT MemManage_Handler [WEAK]
  161. B .
  162. ENDP
  163. BusFault_Handler PROC
  164. EXPORT BusFault_Handler [WEAK]
  165. B .
  166. ENDP
  167. UsageFault_Handler PROC
  168. EXPORT UsageFault_Handler [WEAK]
  169. B .
  170. ENDP
  171. SVC_Handler PROC
  172. EXPORT SVC_Handler [WEAK]
  173. B .
  174. ENDP
  175. DebugMon_Handler PROC
  176. EXPORT DebugMon_Handler [WEAK]
  177. B .
  178. ENDP
  179. PendSV_Handler PROC
  180. EXPORT PendSV_Handler [WEAK]
  181. B .
  182. ENDP
  183. SysTick_Handler PROC
  184. EXPORT SysTick_Handler [WEAK]
  185. B .
  186. ENDP
  187. Default_Handler PROC
  188. ; /* external interrupts handler */
  189. EXPORT WWDGT_IRQHandler [WEAK]
  190. EXPORT LVD_IRQHandler [WEAK]
  191. EXPORT TAMPER_IRQHandler [WEAK]
  192. EXPORT RTC_IRQHandler [WEAK]
  193. EXPORT FMC_IRQHandler [WEAK]
  194. EXPORT RCU_IRQHandler [WEAK]
  195. EXPORT EXTI0_IRQHandler [WEAK]
  196. EXPORT EXTI1_IRQHandler [WEAK]
  197. EXPORT EXTI2_IRQHandler [WEAK]
  198. EXPORT EXTI3_IRQHandler [WEAK]
  199. EXPORT EXTI4_IRQHandler [WEAK]
  200. EXPORT DMA0_Channel0_IRQHandler [WEAK]
  201. EXPORT DMA0_Channel1_IRQHandler [WEAK]
  202. EXPORT DMA0_Channel2_IRQHandler [WEAK]
  203. EXPORT DMA0_Channel3_IRQHandler [WEAK]
  204. EXPORT DMA0_Channel4_IRQHandler [WEAK]
  205. EXPORT DMA0_Channel5_IRQHandler [WEAK]
  206. EXPORT DMA0_Channel6_IRQHandler [WEAK]
  207. EXPORT ADC0_1_IRQHandler [WEAK]
  208. EXPORT USBD_HP_CAN0_TX_IRQHandler [WEAK]
  209. EXPORT USBD_LP_CAN0_RX0_IRQHandler [WEAK]
  210. EXPORT CAN0_RX1_IRQHandler [WEAK]
  211. EXPORT CAN0_EWMC_IRQHandler [WEAK]
  212. EXPORT EXTI5_9_IRQHandler [WEAK]
  213. EXPORT TIMER0_BRK_TIMER8_IRQHandler [WEAK]
  214. EXPORT TIMER0_UP_TIMER9_IRQHandler [WEAK]
  215. EXPORT TIMER0_TRG_CMT_TIMER10_IRQHandler [WEAK]
  216. EXPORT TIMER0_Channel_IRQHandler [WEAK]
  217. EXPORT TIMER1_IRQHandler [WEAK]
  218. EXPORT TIMER2_IRQHandler [WEAK]
  219. EXPORT TIMER3_IRQHandler [WEAK]
  220. EXPORT I2C0_EV_IRQHandler [WEAK]
  221. EXPORT I2C0_ER_IRQHandler [WEAK]
  222. EXPORT I2C1_EV_IRQHandler [WEAK]
  223. EXPORT I2C1_ER_IRQHandler [WEAK]
  224. EXPORT SPI0_IRQHandler [WEAK]
  225. EXPORT SPI1_IRQHandler [WEAK]
  226. EXPORT USART0_IRQHandler [WEAK]
  227. EXPORT USART1_IRQHandler [WEAK]
  228. EXPORT USART2_IRQHandler [WEAK]
  229. EXPORT EXTI10_15_IRQHandler [WEAK]
  230. EXPORT RTC_Alarm_IRQHandler [WEAK]
  231. EXPORT USBD_WKUP_IRQHandler [WEAK]
  232. EXPORT TIMER7_BRK_TIMER11_IRQHandler [WEAK]
  233. EXPORT TIMER7_UP_TIMER12_IRQHandler [WEAK]
  234. EXPORT TIMER7_TRG_CMT_TIMER13_IRQHandler [WEAK]
  235. EXPORT TIMER7_Channel_IRQHandler [WEAK]
  236. EXPORT ADC2_IRQHandler [WEAK]
  237. EXPORT EXMC_IRQHandler [WEAK]
  238. EXPORT SDIO_IRQHandler [WEAK]
  239. EXPORT TIMER4_IRQHandler [WEAK]
  240. EXPORT SPI2_IRQHandler [WEAK]
  241. EXPORT UART3_IRQHandler [WEAK]
  242. EXPORT UART4_IRQHandler [WEAK]
  243. EXPORT TIMER5_IRQHandler [WEAK]
  244. EXPORT TIMER6_IRQHandler [WEAK]
  245. EXPORT DMA1_Channel0_IRQHandler [WEAK]
  246. EXPORT DMA1_Channel1_IRQHandler [WEAK]
  247. EXPORT DMA1_Channel2_IRQHandler [WEAK]
  248. EXPORT DMA1_Channel3_4_IRQHandler [WEAK]
  249. ;/* external interrupts handler */
  250. WWDGT_IRQHandler
  251. LVD_IRQHandler
  252. TAMPER_IRQHandler
  253. RTC_IRQHandler
  254. FMC_IRQHandler
  255. RCU_IRQHandler
  256. EXTI0_IRQHandler
  257. EXTI1_IRQHandler
  258. EXTI2_IRQHandler
  259. EXTI3_IRQHandler
  260. EXTI4_IRQHandler
  261. DMA0_Channel0_IRQHandler
  262. DMA0_Channel1_IRQHandler
  263. DMA0_Channel2_IRQHandler
  264. DMA0_Channel3_IRQHandler
  265. DMA0_Channel4_IRQHandler
  266. DMA0_Channel5_IRQHandler
  267. DMA0_Channel6_IRQHandler
  268. ADC0_1_IRQHandler
  269. USBD_HP_CAN0_TX_IRQHandler
  270. USBD_LP_CAN0_RX0_IRQHandler
  271. CAN0_RX1_IRQHandler
  272. CAN0_EWMC_IRQHandler
  273. EXTI5_9_IRQHandler
  274. TIMER0_BRK_TIMER8_IRQHandler
  275. TIMER0_UP_TIMER9_IRQHandler
  276. TIMER0_TRG_CMT_TIMER10_IRQHandler
  277. TIMER0_Channel_IRQHandler
  278. TIMER1_IRQHandler
  279. TIMER2_IRQHandler
  280. TIMER3_IRQHandler
  281. I2C0_EV_IRQHandler
  282. I2C0_ER_IRQHandler
  283. I2C1_EV_IRQHandler
  284. I2C1_ER_IRQHandler
  285. SPI0_IRQHandler
  286. SPI1_IRQHandler
  287. USART0_IRQHandler
  288. USART1_IRQHandler
  289. USART2_IRQHandler
  290. EXTI10_15_IRQHandler
  291. RTC_Alarm_IRQHandler
  292. USBD_WKUP_IRQHandler
  293. TIMER7_BRK_TIMER11_IRQHandler
  294. TIMER7_UP_TIMER12_IRQHandler
  295. TIMER7_TRG_CMT_TIMER13_IRQHandler
  296. TIMER7_Channel_IRQHandler
  297. ADC2_IRQHandler
  298. EXMC_IRQHandler
  299. SDIO_IRQHandler
  300. TIMER4_IRQHandler
  301. SPI2_IRQHandler
  302. UART3_IRQHandler
  303. UART4_IRQHandler
  304. TIMER5_IRQHandler
  305. TIMER6_IRQHandler
  306. DMA1_Channel0_IRQHandler
  307. DMA1_Channel1_IRQHandler
  308. DMA1_Channel2_IRQHandler
  309. DMA1_Channel3_4_IRQHandler
  310. B .
  311. ENDP
  312. ALIGN
  313. ; user Initial Stack & Heap
  314. IF :DEF:__MICROLIB
  315. EXPORT __initial_sp
  316. EXPORT __heap_base
  317. EXPORT __heap_limit
  318. ELSE
  319. IMPORT __use_two_region_memory
  320. EXPORT __user_initial_stackheap
  321. __user_initial_stackheap PROC
  322. LDR R0, = Heap_Mem
  323. LDR R1, =(Stack_Mem + Stack_Size)
  324. LDR R2, = (Heap_Mem + Heap_Size)
  325. LDR R3, = Stack_Mem
  326. BX LR
  327. ENDP
  328. ALIGN
  329. ENDIF
  330. END