startup_stm32f072.s 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. ;******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
  2. ;* File Name : startup_stm32f072.s
  3. ;* Author : MCD Application Team
  4. ;* Version : V1.5.0
  5. ;* Date : 05-December-2014
  6. ;* Description : STM32F072 Devices vector table for
  7. ;* for MDK-ARM toolchain.
  8. ;* This module performs:
  9. ;* - Set the initial SP
  10. ;* - Set the initial PC == Reset_Handler
  11. ;* - Set the vector table entries with the exceptions ISR address
  12. ;* - Configure the system clock
  13. ;* - Branches to __main in the C library (which eventually
  14. ;* calls main()).
  15. ;* After Reset the CortexM0 processor is in Thread mode,
  16. ;* priority is Privileged, and the Stack is set to Main.
  17. ;* <<< Use Configuration Wizard in Context Menu >>>
  18. ;*******************************************************************************
  19. ; @attention
  20. ;
  21. ; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  22. ; You may not use this file except in compliance with the License.
  23. ; You may obtain a copy of the License at:
  24. ;
  25. ; http://www.st.com/software_license_agreement_liberty_v2
  26. ;
  27. ; Unless required by applicable law or agreed to in writing, software
  28. ; distributed under the License is distributed on an "AS IS" BASIS,
  29. ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  30. ; See the License for the specific language governing permissions and
  31. ; limitations under the License.
  32. ;
  33. ;*******************************************************************************
  34. ;
  35. ; Amount of memory (in bytes) allocated for Stack
  36. ; Tailor this value to your application needs
  37. ; <h> Stack Configuration
  38. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  39. ; </h>
  40. Stack_Size EQU 0x00000400
  41. AREA STACK, NOINIT, READWRITE, ALIGN=3
  42. Stack_Mem SPACE Stack_Size
  43. __initial_sp
  44. ; <h> Heap Configuration
  45. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  46. ; </h>
  47. Heap_Size EQU 0x00000200
  48. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  49. __heap_base
  50. Heap_Mem SPACE Heap_Size
  51. __heap_limit
  52. PRESERVE8
  53. THUMB
  54. ; Vector Table Mapped to Address 0 at Reset
  55. AREA RESET, DATA, READONLY
  56. EXPORT __Vectors
  57. EXPORT __Vectors_End
  58. EXPORT __Vectors_Size
  59. __Vectors DCD __initial_sp ; Top of Stack
  60. DCD Reset_Handler ; Reset Handler
  61. DCD NMI_Handler ; NMI Handler
  62. DCD HardFault_Handler ; Hard Fault Handler
  63. DCD 0 ; Reserved
  64. DCD 0 ; Reserved
  65. DCD 0 ; Reserved
  66. DCD 0 ; Reserved
  67. DCD 0 ; Reserved
  68. DCD 0 ; Reserved
  69. DCD 0 ; Reserved
  70. DCD SVC_Handler ; SVCall Handler
  71. DCD 0 ; Reserved
  72. DCD 0 ; Reserved
  73. DCD PendSV_Handler ; PendSV Handler
  74. DCD SysTick_Handler ; SysTick Handler
  75. ; External Interrupts
  76. DCD WWDG_IRQHandler ; Window Watchdog
  77. DCD PVD_VDDIO2_IRQHandler ; PVD and VDDIO2 through EXTI Line detect
  78. DCD RTC_IRQHandler ; RTC through EXTI Line
  79. DCD FLASH_IRQHandler ; FLASH
  80. DCD RCC_CRS_IRQHandler ; RCC and CRS
  81. DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1
  82. DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3
  83. DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15
  84. DCD TSC_IRQHandler ; TS
  85. DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
  86. DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3
  87. DCD DMA1_Channel4_5_6_7_IRQHandler ; DMA1 Channel 4, Channel 5, Channel 6 and Channel 7
  88. DCD ADC1_COMP_IRQHandler ; ADC1, COMP1 and COMP2
  89. DCD TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation
  90. DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
  91. DCD TIM2_IRQHandler ; TIM2
  92. DCD TIM3_IRQHandler ; TIM3
  93. DCD TIM6_DAC_IRQHandler ; TIM6 and DAC
  94. DCD TIM7_IRQHandler ; TIM7
  95. DCD TIM14_IRQHandler ; TIM14
  96. DCD TIM15_IRQHandler ; TIM15
  97. DCD TIM16_IRQHandler ; TIM16
  98. DCD TIM17_IRQHandler ; TIM17
  99. DCD I2C1_IRQHandler ; I2C1
  100. DCD I2C2_IRQHandler ; I2C2
  101. DCD SPI1_IRQHandler ; SPI1
  102. DCD SPI2_IRQHandler ; SPI2
  103. DCD USART1_IRQHandler ; USART1
  104. DCD USART2_IRQHandler ; USART2
  105. DCD USART3_4_IRQHandler ; USART3 and USART4
  106. DCD CEC_CAN_IRQHandler ; CEC and CAN
  107. DCD USB_IRQHandler ; USB
  108. __Vectors_End
  109. __Vectors_Size EQU __Vectors_End - __Vectors
  110. AREA |.text|, CODE, READONLY
  111. ; Reset handler routine
  112. Reset_Handler PROC
  113. EXPORT Reset_Handler [WEAK]
  114. IMPORT __main
  115. IMPORT SystemInit
  116. LDR R0, =__initial_sp ; set stack pointer
  117. MSR MSP, R0
  118. ;;Check if boot space corresponds to test memory
  119. LDR R0,=0x00000004
  120. LDR R1, [R0]
  121. LSRS R1, R1, #24
  122. LDR R2,=0x1F
  123. CMP R1, R2
  124. BNE ApplicationStart
  125. ;; SYSCFG clock enable
  126. LDR R0,=0x40021018
  127. LDR R1,=0x00000001
  128. STR R1, [R0]
  129. ;; Set CFGR1 register with flash memory remap at address 0
  130. LDR R0,=0x40010000
  131. LDR R1,=0x00000000
  132. STR R1, [R0]
  133. ApplicationStart
  134. LDR R0, =SystemInit
  135. BLX R0
  136. LDR R0, =__main
  137. BX R0
  138. ENDP
  139. ; Dummy Exception Handlers (infinite loops which can be modified)
  140. NMI_Handler PROC
  141. EXPORT NMI_Handler [WEAK]
  142. B .
  143. ENDP
  144. HardFault_Handler\
  145. PROC
  146. EXPORT HardFault_Handler [WEAK]
  147. B .
  148. ENDP
  149. SVC_Handler PROC
  150. EXPORT SVC_Handler [WEAK]
  151. B .
  152. ENDP
  153. PendSV_Handler PROC
  154. EXPORT PendSV_Handler [WEAK]
  155. B .
  156. ENDP
  157. SysTick_Handler PROC
  158. EXPORT SysTick_Handler [WEAK]
  159. B .
  160. ENDP
  161. Default_Handler PROC
  162. EXPORT WWDG_IRQHandler [WEAK]
  163. EXPORT PVD_VDDIO2_IRQHandler [WEAK]
  164. EXPORT RTC_IRQHandler [WEAK]
  165. EXPORT FLASH_IRQHandler [WEAK]
  166. EXPORT RCC_CRS_IRQHandler [WEAK]
  167. EXPORT EXTI0_1_IRQHandler [WEAK]
  168. EXPORT EXTI2_3_IRQHandler [WEAK]
  169. EXPORT EXTI4_15_IRQHandler [WEAK]
  170. EXPORT TSC_IRQHandler [WEAK]
  171. EXPORT DMA1_Channel1_IRQHandler [WEAK]
  172. EXPORT DMA1_Channel2_3_IRQHandler [WEAK]
  173. EXPORT DMA1_Channel4_5_6_7_IRQHandler [WEAK]
  174. EXPORT ADC1_COMP_IRQHandler [WEAK]
  175. EXPORT TIM1_BRK_UP_TRG_COM_IRQHandler [WEAK]
  176. EXPORT TIM1_CC_IRQHandler [WEAK]
  177. EXPORT TIM2_IRQHandler [WEAK]
  178. EXPORT TIM3_IRQHandler [WEAK]
  179. EXPORT TIM6_DAC_IRQHandler [WEAK]
  180. EXPORT TIM7_IRQHandler [WEAK]
  181. EXPORT TIM14_IRQHandler [WEAK]
  182. EXPORT TIM15_IRQHandler [WEAK]
  183. EXPORT TIM16_IRQHandler [WEAK]
  184. EXPORT TIM17_IRQHandler [WEAK]
  185. EXPORT I2C1_IRQHandler [WEAK]
  186. EXPORT I2C2_IRQHandler [WEAK]
  187. EXPORT SPI1_IRQHandler [WEAK]
  188. EXPORT SPI2_IRQHandler [WEAK]
  189. EXPORT USART1_IRQHandler [WEAK]
  190. EXPORT USART2_IRQHandler [WEAK]
  191. EXPORT USART3_4_IRQHandler [WEAK]
  192. EXPORT CEC_CAN_IRQHandler [WEAK]
  193. EXPORT USB_IRQHandler [WEAK]
  194. WWDG_IRQHandler
  195. PVD_VDDIO2_IRQHandler
  196. RTC_IRQHandler
  197. FLASH_IRQHandler
  198. RCC_CRS_IRQHandler
  199. EXTI0_1_IRQHandler
  200. EXTI2_3_IRQHandler
  201. EXTI4_15_IRQHandler
  202. TSC_IRQHandler
  203. DMA1_Channel1_IRQHandler
  204. DMA1_Channel2_3_IRQHandler
  205. DMA1_Channel4_5_6_7_IRQHandler
  206. ADC1_COMP_IRQHandler
  207. TIM1_BRK_UP_TRG_COM_IRQHandler
  208. TIM1_CC_IRQHandler
  209. TIM2_IRQHandler
  210. TIM3_IRQHandler
  211. TIM6_DAC_IRQHandler
  212. TIM7_IRQHandler
  213. TIM14_IRQHandler
  214. TIM15_IRQHandler
  215. TIM16_IRQHandler
  216. TIM17_IRQHandler
  217. I2C1_IRQHandler
  218. I2C2_IRQHandler
  219. SPI1_IRQHandler
  220. SPI2_IRQHandler
  221. USART1_IRQHandler
  222. USART2_IRQHandler
  223. USART3_4_IRQHandler
  224. CEC_CAN_IRQHandler
  225. USB_IRQHandler
  226. B .
  227. ENDP
  228. ALIGN
  229. ;*******************************************************************************
  230. ; User Stack and Heap initialization
  231. ;*******************************************************************************
  232. IF :DEF:__MICROLIB
  233. EXPORT __initial_sp
  234. EXPORT __heap_base
  235. EXPORT __heap_limit
  236. ELSE
  237. IMPORT __use_two_region_memory
  238. EXPORT __user_initial_stackheap
  239. __user_initial_stackheap
  240. LDR R0, = Heap_Mem
  241. LDR R1, =(Stack_Mem + Stack_Size)
  242. LDR R2, = (Heap_Mem + Heap_Size)
  243. LDR R3, = Stack_Mem
  244. BX LR
  245. ALIGN
  246. ENDIF
  247. END
  248. ;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****