startup_stm32f030.s 10 KB

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