startup_gd32f30x_cl.s 18 KB

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