startup_gd32f10x_cl.s 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. ;/*!
  2. ; \file startup_gd32f10x_cl.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 0x00000400
  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 0x00000200
  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 CAN0_TX_IRQHandler ; 35:CAN0 TX
  97. DCD CAN0_RX0_IRQHandler ; 36: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_IRQHandler ; 40:TIMER0 Break
  102. DCD TIMER0_UP_IRQHandler ; 41:TIMER0 Update
  103. DCD TIMER0_TRG_CMT_IRQHandler ; 42:TIMER0 Trigger and Commutation
  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 USBFS_WKUP_IRQHandler ; 58:USBFS WakeUp from suspend through EXTI Line
  120. DCD TIMER7_BRK_IRQHandler ; 59:TIMER7 Break Interrupt
  121. DCD TIMER7_UP_IRQHandler ; 60:TIMER7 Update Interrupt
  122. DCD TIMER7_TRG_CMT_IRQHandler ; 61:TIMER7 Trigger
  123. DCD TIMER7_Channel_IRQHandler ; 62:TIMER7 Channel Capture Compare
  124. DCD 0 ; Reserved
  125. DCD EXMC_IRQHandler ; 64:EXMC
  126. DCD 0 ; Reserved
  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_IRQHandler ; 75:DMA1 Channel3
  137. DCD DMA1_Channel4_IRQHandler ; 76:DMA1 Channel4
  138. DCD ENET_IRQHandler ; 77:Ethernet
  139. DCD ENET_WKUP_IRQHandler ; 78:Ethernet Wakeup through EXTI line
  140. DCD CAN1_TX_IRQHandler ; 79:CAN1 TX
  141. DCD CAN1_RX0_IRQHandler ; 80:CAN1 RX0
  142. DCD CAN1_RX1_IRQHandler ; 81:CAN1 RX1
  143. DCD CAN1_EWMC_IRQHandler ; 82:CAN1 EWMC
  144. DCD USBFS_IRQHandler ; 83:USBFS
  145. __Vectors_End
  146. __Vectors_Size EQU __Vectors_End - __Vectors
  147. AREA |.text|, CODE, READONLY
  148. ;/* reset Handler */
  149. Reset_Handler PROC
  150. EXPORT Reset_Handler [WEAK]
  151. IMPORT __main
  152. IMPORT SystemInit
  153. LDR R0, =SystemInit
  154. BLX R0
  155. LDR R0, =__main
  156. BX R0
  157. ENDP
  158. ;/* dummy Exception Handlers */
  159. NMI_Handler PROC
  160. EXPORT NMI_Handler [WEAK]
  161. B .
  162. ENDP
  163. HardFault_Handler PROC
  164. EXPORT HardFault_Handler [WEAK]
  165. B .
  166. ENDP
  167. MemManage_Handler PROC
  168. EXPORT MemManage_Handler [WEAK]
  169. B .
  170. ENDP
  171. BusFault_Handler PROC
  172. EXPORT BusFault_Handler [WEAK]
  173. B .
  174. ENDP
  175. UsageFault_Handler PROC
  176. EXPORT UsageFault_Handler [WEAK]
  177. B .
  178. ENDP
  179. SVC_Handler PROC
  180. EXPORT SVC_Handler [WEAK]
  181. B .
  182. ENDP
  183. DebugMon_Handler PROC
  184. EXPORT DebugMon_Handler [WEAK]
  185. B .
  186. ENDP
  187. PendSV_Handler PROC
  188. EXPORT PendSV_Handler [WEAK]
  189. B .
  190. ENDP
  191. SysTick_Handler PROC
  192. EXPORT SysTick_Handler [WEAK]
  193. B .
  194. ENDP
  195. Default_Handler PROC
  196. ; /* external interrupts handler */
  197. EXPORT WWDGT_IRQHandler [WEAK]
  198. EXPORT LVD_IRQHandler [WEAK]
  199. EXPORT TAMPER_IRQHandler [WEAK]
  200. EXPORT RTC_IRQHandler [WEAK]
  201. EXPORT FMC_IRQHandler [WEAK]
  202. EXPORT RCU_IRQHandler [WEAK]
  203. EXPORT EXTI0_IRQHandler [WEAK]
  204. EXPORT EXTI1_IRQHandler [WEAK]
  205. EXPORT EXTI2_IRQHandler [WEAK]
  206. EXPORT EXTI3_IRQHandler [WEAK]
  207. EXPORT EXTI4_IRQHandler [WEAK]
  208. EXPORT DMA0_Channel0_IRQHandler [WEAK]
  209. EXPORT DMA0_Channel1_IRQHandler [WEAK]
  210. EXPORT DMA0_Channel2_IRQHandler [WEAK]
  211. EXPORT DMA0_Channel3_IRQHandler [WEAK]
  212. EXPORT DMA0_Channel4_IRQHandler [WEAK]
  213. EXPORT DMA0_Channel5_IRQHandler [WEAK]
  214. EXPORT DMA0_Channel6_IRQHandler [WEAK]
  215. EXPORT ADC0_1_IRQHandler [WEAK]
  216. EXPORT CAN0_TX_IRQHandler [WEAK]
  217. EXPORT CAN0_RX0_IRQHandler [WEAK]
  218. EXPORT CAN0_RX1_IRQHandler [WEAK]
  219. EXPORT CAN0_EWMC_IRQHandler [WEAK]
  220. EXPORT EXTI5_9_IRQHandler [WEAK]
  221. EXPORT TIMER0_BRK_IRQHandler [WEAK]
  222. EXPORT TIMER0_UP_IRQHandler [WEAK]
  223. EXPORT TIMER0_TRG_CMT_IRQHandler [WEAK]
  224. EXPORT TIMER0_Channel_IRQHandler [WEAK]
  225. EXPORT TIMER1_IRQHandler [WEAK]
  226. EXPORT TIMER2_IRQHandler [WEAK]
  227. EXPORT TIMER3_IRQHandler [WEAK]
  228. EXPORT I2C0_EV_IRQHandler [WEAK]
  229. EXPORT I2C0_ER_IRQHandler [WEAK]
  230. EXPORT I2C1_EV_IRQHandler [WEAK]
  231. EXPORT I2C1_ER_IRQHandler [WEAK]
  232. EXPORT SPI0_IRQHandler [WEAK]
  233. EXPORT SPI1_IRQHandler [WEAK]
  234. EXPORT USART0_IRQHandler [WEAK]
  235. EXPORT USART1_IRQHandler [WEAK]
  236. EXPORT USART2_IRQHandler [WEAK]
  237. EXPORT EXTI10_15_IRQHandler [WEAK]
  238. EXPORT RTC_Alarm_IRQHandler [WEAK]
  239. EXPORT USBFS_WKUP_IRQHandler [WEAK]
  240. EXPORT TIMER7_BRK_IRQHandler [WEAK]
  241. EXPORT TIMER7_UP_IRQHandler [WEAK]
  242. EXPORT TIMER7_TRG_CMT_IRQHandler [WEAK]
  243. EXPORT TIMER7_Channel_IRQHandler [WEAK]
  244. EXPORT EXMC_IRQHandler [WEAK]
  245. EXPORT TIMER4_IRQHandler [WEAK]
  246. EXPORT SPI2_IRQHandler [WEAK]
  247. EXPORT UART3_IRQHandler [WEAK]
  248. EXPORT UART4_IRQHandler [WEAK]
  249. EXPORT TIMER5_IRQHandler [WEAK]
  250. EXPORT TIMER6_IRQHandler [WEAK]
  251. EXPORT DMA1_Channel0_IRQHandler [WEAK]
  252. EXPORT DMA1_Channel1_IRQHandler [WEAK]
  253. EXPORT DMA1_Channel2_IRQHandler [WEAK]
  254. EXPORT DMA1_Channel3_IRQHandler [WEAK]
  255. EXPORT DMA1_Channel4_IRQHandler [WEAK]
  256. EXPORT ENET_IRQHandler [WEAK]
  257. EXPORT ENET_WKUP_IRQHandler [WEAK]
  258. EXPORT CAN1_TX_IRQHandler [WEAK]
  259. EXPORT CAN1_RX0_IRQHandler [WEAK]
  260. EXPORT CAN1_RX1_IRQHandler [WEAK]
  261. EXPORT CAN1_EWMC_IRQHandler [WEAK]
  262. EXPORT USBFS_IRQHandler [WEAK]
  263. ;/* external interrupts handler */
  264. WWDGT_IRQHandler
  265. LVD_IRQHandler
  266. TAMPER_IRQHandler
  267. RTC_IRQHandler
  268. FMC_IRQHandler
  269. RCU_IRQHandler
  270. EXTI0_IRQHandler
  271. EXTI1_IRQHandler
  272. EXTI2_IRQHandler
  273. EXTI3_IRQHandler
  274. EXTI4_IRQHandler
  275. DMA0_Channel0_IRQHandler
  276. DMA0_Channel1_IRQHandler
  277. DMA0_Channel2_IRQHandler
  278. DMA0_Channel3_IRQHandler
  279. DMA0_Channel4_IRQHandler
  280. DMA0_Channel5_IRQHandler
  281. DMA0_Channel6_IRQHandler
  282. ADC0_1_IRQHandler
  283. CAN0_TX_IRQHandler
  284. CAN0_RX0_IRQHandler
  285. CAN0_RX1_IRQHandler
  286. CAN0_EWMC_IRQHandler
  287. EXTI5_9_IRQHandler
  288. TIMER0_BRK_IRQHandler
  289. TIMER0_UP_IRQHandler
  290. TIMER0_TRG_CMT_IRQHandler
  291. TIMER0_Channel_IRQHandler
  292. TIMER1_IRQHandler
  293. TIMER2_IRQHandler
  294. TIMER3_IRQHandler
  295. I2C0_EV_IRQHandler
  296. I2C0_ER_IRQHandler
  297. I2C1_EV_IRQHandler
  298. I2C1_ER_IRQHandler
  299. SPI0_IRQHandler
  300. SPI1_IRQHandler
  301. USART0_IRQHandler
  302. USART1_IRQHandler
  303. USART2_IRQHandler
  304. EXTI10_15_IRQHandler
  305. RTC_Alarm_IRQHandler
  306. USBFS_WKUP_IRQHandler
  307. TIMER7_BRK_IRQHandler
  308. TIMER7_UP_IRQHandler
  309. TIMER7_TRG_CMT_IRQHandler
  310. TIMER7_Channel_IRQHandler
  311. EXMC_IRQHandler
  312. TIMER4_IRQHandler
  313. SPI2_IRQHandler
  314. UART3_IRQHandler
  315. UART4_IRQHandler
  316. TIMER5_IRQHandler
  317. TIMER6_IRQHandler
  318. DMA1_Channel0_IRQHandler
  319. DMA1_Channel1_IRQHandler
  320. DMA1_Channel2_IRQHandler
  321. DMA1_Channel3_IRQHandler
  322. DMA1_Channel4_IRQHandler
  323. ENET_IRQHandler
  324. ENET_WKUP_IRQHandler
  325. CAN1_TX_IRQHandler
  326. CAN1_RX0_IRQHandler
  327. CAN1_RX1_IRQHandler
  328. CAN1_EWMC_IRQHandler
  329. USBFS_IRQHandler
  330. B .
  331. ENDP
  332. ALIGN
  333. ; user Initial Stack & Heap
  334. IF :DEF:__MICROLIB
  335. EXPORT __initial_sp
  336. EXPORT __heap_base
  337. EXPORT __heap_limit
  338. ELSE
  339. IMPORT __use_two_region_memory
  340. EXPORT __user_initial_stackheap
  341. __user_initial_stackheap PROC
  342. LDR R0, = Heap_Mem
  343. LDR R1, =(Stack_Mem + Stack_Size)
  344. LDR R2, = (Heap_Mem + Heap_Size)
  345. LDR R3, = Stack_Mem
  346. BX LR
  347. ENDP
  348. ALIGN
  349. ENDIF
  350. END