You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

267 lines
10 KiB

  1. ;******************** (C) COPYRIGHT 2018 STMicroelectronics ********************
  2. ;* File Name : startup_stm32l010x4.s
  3. ;* Author : MCD Application Team
  4. ;* Description : STM32l010x4 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. ;* - Branches to __main in the C library (which eventually
  10. ;* calls main()).
  11. ;* After Reset the Cortex-M0+ processor is in Thread mode,
  12. ;* priority is Privileged, and the Stack is set to Main.
  13. ;*******************************************************************************
  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. ;* 1. Redistributions of source code must retain the above copyright notice,
  18. ;* this list of conditions and the following disclaimer.
  19. ;* 2. Redistributions in binary form must reproduce the above copyright notice,
  20. ;* this list of conditions and the following disclaimer in the documentation
  21. ;* and/or other materials provided with the distribution.
  22. ;* 3. Neither the name of STMicroelectronics nor the names of its contributors
  23. ;* may be used to endorse or promote products derived from this software
  24. ;* without specific prior written permission.
  25. ;*
  26. ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. ;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. ;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  29. ;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  30. ;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. ;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  32. ;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  33. ;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  34. ;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. ;*
  37. ;*******************************************************************************
  38. ;
  39. ; Amount of memory (in bytes) allocated for Stack
  40. ; Tailor this value to your application needs
  41. ; <h> Stack Configuration
  42. ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
  43. ; </h>
  44. Stack_Size EQU 0x400
  45. AREA STACK, NOINIT, READWRITE, ALIGN=3
  46. Stack_Mem SPACE Stack_Size
  47. __initial_sp
  48. ; <h> Heap Configuration
  49. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  50. ; </h>
  51. Heap_Size EQU 0x200
  52. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  53. __heap_base
  54. Heap_Mem SPACE Heap_Size
  55. __heap_limit
  56. PRESERVE8
  57. THUMB
  58. ; Vector Table Mapped to Address 0 at Reset
  59. AREA RESET, DATA, READONLY
  60. EXPORT __Vectors
  61. EXPORT __Vectors_End
  62. EXPORT __Vectors_Size
  63. __Vectors DCD __initial_sp ; Top of Stack
  64. DCD Reset_Handler ; Reset Handler
  65. DCD NMI_Handler ; NMI Handler
  66. DCD HardFault_Handler ; Hard Fault Handler
  67. DCD 0 ; Reserved
  68. DCD 0 ; Reserved
  69. DCD 0 ; Reserved
  70. DCD 0 ; Reserved
  71. DCD 0 ; Reserved
  72. DCD 0 ; Reserved
  73. DCD 0 ; Reserved
  74. DCD SVC_Handler ; SVCall Handler
  75. DCD 0 ; Reserved
  76. DCD 0 ; Reserved
  77. DCD PendSV_Handler ; PendSV Handler
  78. DCD SysTick_Handler ; SysTick Handler
  79. ; External Interrupts
  80. DCD WWDG_IRQHandler ; Window Watchdog
  81. DCD 0 ; Reserved
  82. DCD RTC_IRQHandler ; RTC through EXTI Line
  83. DCD FLASH_IRQHandler ; FLASH
  84. DCD RCC_IRQHandler ; RCC
  85. DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1
  86. DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3
  87. DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15
  88. DCD 0 ; Reserved
  89. DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
  90. DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3
  91. DCD DMA1_Channel4_5_IRQHandler ; DMA1 Channel 4 and Channel 5
  92. DCD ADC1_IRQHandler ; ADC1
  93. DCD LPTIM1_IRQHandler ; LPTIM1
  94. DCD 0 ; Reserved
  95. DCD TIM2_IRQHandler ; TIM2
  96. DCD 0 ; Reserved
  97. DCD 0 ; Reserved
  98. DCD 0 ; Reserved
  99. DCD 0 ; Reserved
  100. DCD TIM21_IRQHandler ; TIM21
  101. DCD 0 ; Reserved
  102. DCD 0 ; Reserved
  103. DCD I2C1_IRQHandler ; I2C1
  104. DCD 0 ; Reserved
  105. DCD SPI1_IRQHandler ; SPI1
  106. DCD 0 ; Reserved
  107. DCD 0 ; Reserved
  108. DCD USART2_IRQHandler ; USART2
  109. DCD LPUART1_IRQHandler ; LPUART1
  110. DCD 0 ; Reserved
  111. DCD 0 ; Reserved
  112. __Vectors_End
  113. __Vectors_Size EQU __Vectors_End - __Vectors
  114. AREA |.text|, CODE, READONLY
  115. ; Reset handler routine
  116. Reset_Handler PROC
  117. EXPORT Reset_Handler [WEAK]
  118. IMPORT __main
  119. IMPORT SystemInit
  120. LDR R0, =__initial_sp ; set stack pointer
  121. MSR MSP, R0
  122. ;;Check if boot space corresponds to system memory
  123. LDR R0,=0x00000004
  124. LDR R1, [R0]
  125. LSRS R1, R1, #24
  126. LDR R2,=0x1F
  127. CMP R1, R2
  128. BNE ApplicationStart
  129. ;; SYSCFG clock enable
  130. LDR R0,=0x40021034
  131. LDR R1,=0x00000001
  132. STR R1, [R0]
  133. ;; Set CFGR1 register with flash memory remap at address 0
  134. LDR R0,=0x40010000
  135. LDR R1,=0x00000000
  136. STR R1, [R0]
  137. ApplicationStart
  138. LDR R0, =SystemInit
  139. BLX R0
  140. LDR R0, =__main
  141. BX R0
  142. ENDP
  143. ; Dummy Exception Handlers (infinite loops which can be modified)
  144. NMI_Handler PROC
  145. EXPORT NMI_Handler [WEAK]
  146. B .
  147. ENDP
  148. HardFault_Handler\
  149. PROC
  150. EXPORT HardFault_Handler [WEAK]
  151. B .
  152. ENDP
  153. SVC_Handler PROC
  154. EXPORT SVC_Handler [WEAK]
  155. B .
  156. ENDP
  157. PendSV_Handler PROC
  158. EXPORT PendSV_Handler [WEAK]
  159. B .
  160. ENDP
  161. SysTick_Handler PROC
  162. EXPORT SysTick_Handler [WEAK]
  163. B .
  164. ENDP
  165. Default_Handler PROC
  166. EXPORT WWDG_IRQHandler [WEAK]
  167. EXPORT RTC_IRQHandler [WEAK]
  168. EXPORT FLASH_IRQHandler [WEAK]
  169. EXPORT RCC_IRQHandler [WEAK]
  170. EXPORT EXTI0_1_IRQHandler [WEAK]
  171. EXPORT EXTI2_3_IRQHandler [WEAK]
  172. EXPORT EXTI4_15_IRQHandler [WEAK]
  173. EXPORT DMA1_Channel1_IRQHandler [WEAK]
  174. EXPORT DMA1_Channel2_3_IRQHandler [WEAK]
  175. EXPORT DMA1_Channel4_5_IRQHandler [WEAK]
  176. EXPORT ADC1_IRQHandler [WEAK]
  177. EXPORT LPTIM1_IRQHandler [WEAK]
  178. EXPORT TIM2_IRQHandler [WEAK]
  179. EXPORT TIM21_IRQHandler [WEAK]
  180. EXPORT I2C1_IRQHandler [WEAK]
  181. EXPORT SPI1_IRQHandler [WEAK]
  182. EXPORT USART2_IRQHandler [WEAK]
  183. EXPORT LPUART1_IRQHandler [WEAK]
  184. WWDG_IRQHandler
  185. RTC_IRQHandler
  186. FLASH_IRQHandler
  187. RCC_IRQHandler
  188. EXTI0_1_IRQHandler
  189. EXTI2_3_IRQHandler
  190. EXTI4_15_IRQHandler
  191. DMA1_Channel1_IRQHandler
  192. DMA1_Channel2_3_IRQHandler
  193. DMA1_Channel4_5_IRQHandler
  194. ADC1_IRQHandler
  195. LPTIM1_IRQHandler
  196. TIM2_IRQHandler
  197. TIM21_IRQHandler
  198. I2C1_IRQHandler
  199. SPI1_IRQHandler
  200. USART2_IRQHandler
  201. LPUART1_IRQHandler
  202. B .
  203. ENDP
  204. ALIGN
  205. ;*******************************************************************************
  206. ; User Stack and Heap initialization
  207. ;*******************************************************************************
  208. IF :DEF:__MICROLIB
  209. EXPORT __initial_sp
  210. EXPORT __heap_base
  211. EXPORT __heap_limit
  212. ELSE
  213. IMPORT __use_two_region_memory
  214. EXPORT __user_initial_stackheap
  215. __user_initial_stackheap
  216. LDR R0, = Heap_Mem
  217. LDR R1, =(Stack_Mem + Stack_Size)
  218. LDR R2, = (Heap_Mem + Heap_Size)
  219. LDR R3, = Stack_Mem
  220. BX LR
  221. ALIGN
  222. ENDIF
  223. END
  224. ;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****