startup_stm32f101xb.s 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. ;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
  2. ;* File Name : startup_stm32f101xb.s
  3. ;* Author : MCD Application Team
  4. ;* Description : STM32F101xB Devices vector table for MDK-ARM 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
  10. ;* - Branches to __main in the C library (which eventually
  11. ;* calls main()).
  12. ;* After Reset the Cortex-M3 processor is in Thread mode,
  13. ;* priority is Privileged, and the Stack is set to Main.
  14. ;******************************************************************************
  15. ;* @attention
  16. ;*
  17. ;* Copyright (c) 2017-2021 STMicroelectronics.
  18. ;* All rights reserved.
  19. ;*
  20. ;* This software is licensed under terms that can be found in the LICENSE file
  21. ;* in the root directory of this software component.
  22. ;* If no LICENSE file comes with this software, it is provided AS-IS.
  23. ;*
  24. ;******************************************************************************
  25. ; Amount of memory (in bytes) allocated for Stack
  26. ; Tailor this value to your application needs
  27. ; <h> Stack Configuration
  28. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  29. ; </h>
  30. Stack_Size EQU 0x00000400
  31. AREA STACK, NOINIT, READWRITE, ALIGN=3
  32. Stack_Mem SPACE Stack_Size
  33. __initial_sp
  34. ; <h> Heap Configuration
  35. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  36. ; </h>
  37. Heap_Size EQU 0x00000200
  38. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  39. __heap_base
  40. Heap_Mem SPACE Heap_Size
  41. __heap_limit
  42. PRESERVE8
  43. THUMB
  44. ; Vector Table Mapped to Address 0 at Reset
  45. AREA RESET, DATA, READONLY
  46. EXPORT __Vectors
  47. EXPORT __Vectors_End
  48. EXPORT __Vectors_Size
  49. __Vectors DCD __initial_sp ; Top of Stack
  50. DCD Reset_Handler ; Reset Handler
  51. DCD NMI_Handler ; NMI Handler
  52. DCD HardFault_Handler ; Hard Fault Handler
  53. DCD MemManage_Handler ; MPU Fault Handler
  54. DCD BusFault_Handler ; Bus Fault Handler
  55. DCD UsageFault_Handler ; Usage Fault Handler
  56. DCD 0 ; Reserved
  57. DCD 0 ; Reserved
  58. DCD 0 ; Reserved
  59. DCD 0 ; Reserved
  60. DCD SVC_Handler ; SVCall Handler
  61. DCD DebugMon_Handler ; Debug Monitor Handler
  62. DCD 0 ; Reserved
  63. DCD PendSV_Handler ; PendSV Handler
  64. DCD SysTick_Handler ; SysTick Handler
  65. ; External Interrupts
  66. DCD WWDG_IRQHandler ; Window Watchdog
  67. DCD PVD_IRQHandler ; PVD through EXTI Line detect
  68. DCD TAMPER_IRQHandler ; Tamper
  69. DCD RTC_IRQHandler ; RTC
  70. DCD FLASH_IRQHandler ; Flash
  71. DCD RCC_IRQHandler ; RCC
  72. DCD EXTI0_IRQHandler ; EXTI Line 0
  73. DCD EXTI1_IRQHandler ; EXTI Line 1
  74. DCD EXTI2_IRQHandler ; EXTI Line 2
  75. DCD EXTI3_IRQHandler ; EXTI Line 3
  76. DCD EXTI4_IRQHandler ; EXTI Line 4
  77. DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
  78. DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
  79. DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
  80. DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
  81. DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
  82. DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
  83. DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
  84. DCD ADC1_IRQHandler ; ADC1
  85. DCD 0 ; Reserved
  86. DCD 0 ; Reserved
  87. DCD 0 ; Reserved
  88. DCD 0 ; Reserved
  89. DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
  90. DCD 0 ; Reserved
  91. DCD 0 ; Reserved
  92. DCD 0 ; Reserved
  93. DCD 0 ; Reserved
  94. DCD TIM2_IRQHandler ; TIM2
  95. DCD TIM3_IRQHandler ; TIM3
  96. DCD TIM4_IRQHandler ; TIM4
  97. DCD I2C1_EV_IRQHandler ; I2C1 Event
  98. DCD I2C1_ER_IRQHandler ; I2C1 Error
  99. DCD I2C2_EV_IRQHandler ; I2C2 Event
  100. DCD I2C2_ER_IRQHandler ; I2C2 Error
  101. DCD SPI1_IRQHandler ; SPI1
  102. DCD SPI2_IRQHandler ; SPI2
  103. DCD USART1_IRQHandler ; USART1
  104. DCD USART2_IRQHandler ; USART2
  105. DCD USART3_IRQHandler ; USART3
  106. DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
  107. DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
  108. __Vectors_End
  109. __Vectors_Size EQU __Vectors_End - __Vectors
  110. AREA |.text|, CODE, READONLY
  111. ; Reset handler
  112. Reset_Handler PROC
  113. EXPORT Reset_Handler [WEAK]
  114. IMPORT __main
  115. IMPORT SystemInit
  116. LDR R0, =SystemInit
  117. BLX R0
  118. LDR R0, =__main
  119. BX R0
  120. ENDP
  121. ; Dummy Exception Handlers (infinite loops which can be modified)
  122. NMI_Handler PROC
  123. EXPORT NMI_Handler [WEAK]
  124. B .
  125. ENDP
  126. HardFault_Handler\
  127. PROC
  128. EXPORT HardFault_Handler [WEAK]
  129. B .
  130. ENDP
  131. MemManage_Handler\
  132. PROC
  133. EXPORT MemManage_Handler [WEAK]
  134. B .
  135. ENDP
  136. BusFault_Handler\
  137. PROC
  138. EXPORT BusFault_Handler [WEAK]
  139. B .
  140. ENDP
  141. UsageFault_Handler\
  142. PROC
  143. EXPORT UsageFault_Handler [WEAK]
  144. B .
  145. ENDP
  146. SVC_Handler PROC
  147. EXPORT SVC_Handler [WEAK]
  148. B .
  149. ENDP
  150. DebugMon_Handler\
  151. PROC
  152. EXPORT DebugMon_Handler [WEAK]
  153. B .
  154. ENDP
  155. PendSV_Handler PROC
  156. EXPORT PendSV_Handler [WEAK]
  157. B .
  158. ENDP
  159. SysTick_Handler PROC
  160. EXPORT SysTick_Handler [WEAK]
  161. B .
  162. ENDP
  163. Default_Handler PROC
  164. EXPORT WWDG_IRQHandler [WEAK]
  165. EXPORT PVD_IRQHandler [WEAK]
  166. EXPORT TAMPER_IRQHandler [WEAK]
  167. EXPORT RTC_IRQHandler [WEAK]
  168. EXPORT FLASH_IRQHandler [WEAK]
  169. EXPORT RCC_IRQHandler [WEAK]
  170. EXPORT EXTI0_IRQHandler [WEAK]
  171. EXPORT EXTI1_IRQHandler [WEAK]
  172. EXPORT EXTI2_IRQHandler [WEAK]
  173. EXPORT EXTI3_IRQHandler [WEAK]
  174. EXPORT EXTI4_IRQHandler [WEAK]
  175. EXPORT DMA1_Channel1_IRQHandler [WEAK]
  176. EXPORT DMA1_Channel2_IRQHandler [WEAK]
  177. EXPORT DMA1_Channel3_IRQHandler [WEAK]
  178. EXPORT DMA1_Channel4_IRQHandler [WEAK]
  179. EXPORT DMA1_Channel5_IRQHandler [WEAK]
  180. EXPORT DMA1_Channel6_IRQHandler [WEAK]
  181. EXPORT DMA1_Channel7_IRQHandler [WEAK]
  182. EXPORT ADC1_IRQHandler [WEAK]
  183. EXPORT EXTI9_5_IRQHandler [WEAK]
  184. EXPORT TIM2_IRQHandler [WEAK]
  185. EXPORT TIM3_IRQHandler [WEAK]
  186. EXPORT TIM4_IRQHandler [WEAK]
  187. EXPORT I2C1_EV_IRQHandler [WEAK]
  188. EXPORT I2C1_ER_IRQHandler [WEAK]
  189. EXPORT I2C2_EV_IRQHandler [WEAK]
  190. EXPORT I2C2_ER_IRQHandler [WEAK]
  191. EXPORT SPI1_IRQHandler [WEAK]
  192. EXPORT SPI2_IRQHandler [WEAK]
  193. EXPORT USART1_IRQHandler [WEAK]
  194. EXPORT USART2_IRQHandler [WEAK]
  195. EXPORT USART3_IRQHandler [WEAK]
  196. EXPORT EXTI15_10_IRQHandler [WEAK]
  197. EXPORT RTC_Alarm_IRQHandler [WEAK]
  198. WWDG_IRQHandler
  199. PVD_IRQHandler
  200. TAMPER_IRQHandler
  201. RTC_IRQHandler
  202. FLASH_IRQHandler
  203. RCC_IRQHandler
  204. EXTI0_IRQHandler
  205. EXTI1_IRQHandler
  206. EXTI2_IRQHandler
  207. EXTI3_IRQHandler
  208. EXTI4_IRQHandler
  209. DMA1_Channel1_IRQHandler
  210. DMA1_Channel2_IRQHandler
  211. DMA1_Channel3_IRQHandler
  212. DMA1_Channel4_IRQHandler
  213. DMA1_Channel5_IRQHandler
  214. DMA1_Channel6_IRQHandler
  215. DMA1_Channel7_IRQHandler
  216. ADC1_IRQHandler
  217. EXTI9_5_IRQHandler
  218. TIM2_IRQHandler
  219. TIM3_IRQHandler
  220. TIM4_IRQHandler
  221. I2C1_EV_IRQHandler
  222. I2C1_ER_IRQHandler
  223. I2C2_EV_IRQHandler
  224. I2C2_ER_IRQHandler
  225. SPI1_IRQHandler
  226. SPI2_IRQHandler
  227. USART1_IRQHandler
  228. USART2_IRQHandler
  229. USART3_IRQHandler
  230. EXTI15_10_IRQHandler
  231. RTC_Alarm_IRQHandler
  232. B .
  233. ENDP
  234. ALIGN
  235. ;*******************************************************************************
  236. ; User Stack and Heap initialization
  237. ;*******************************************************************************
  238. IF :DEF:__MICROLIB
  239. EXPORT __initial_sp
  240. EXPORT __heap_base
  241. EXPORT __heap_limit
  242. ELSE
  243. IMPORT __use_two_region_memory
  244. EXPORT __user_initial_stackheap
  245. __user_initial_stackheap
  246. LDR R0, = Heap_Mem
  247. LDR R1, =(Stack_Mem + Stack_Size)
  248. LDR R2, = (Heap_Mem + Heap_Size)
  249. LDR R3, = Stack_Mem
  250. BX LR
  251. ALIGN
  252. ENDIF
  253. END