arm_startup_nrf51.s 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. ; Copyright (c) 2013, Nordic Semiconductor ASA
  2. ; All rights reserved.
  3. ;
  4. ; Redistribution and use in source and binary forms, with or without
  5. ; modification, are permitted provided that the following conditions are met:
  6. ;
  7. ; * Redistributions of source code must retain the above copyright notice, this
  8. ; list of conditions and the following disclaimer.
  9. ;
  10. ; * Redistributions in binary form must reproduce the above copyright notice,
  11. ; this list of conditions and the following disclaimer in the documentation
  12. ; and/or other materials provided with the distribution.
  13. ;
  14. ; * Neither the name of Nordic Semiconductor ASA nor the names of its
  15. ; contributors may be used to endorse or promote products derived from
  16. ; this software without specific prior written permission.
  17. ;
  18. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  22. ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. ; NOTE: Template files (including this one) are application specific and therefore
  29. ; expected to be copied into the application project folder prior to its use!
  30. ; Description message
  31. Stack_Size EQU 2048
  32. AREA STACK, NOINIT, READWRITE, ALIGN=3
  33. Stack_Mem SPACE Stack_Size
  34. __initial_sp
  35. Heap_Size EQU 2048
  36. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  37. __heap_base
  38. Heap_Mem SPACE Heap_Size
  39. __heap_limit
  40. PRESERVE8
  41. THUMB
  42. ; Vector Table Mapped to Address 0 at Reset
  43. AREA RESET, DATA, READONLY
  44. EXPORT __Vectors
  45. EXPORT __Vectors_End
  46. EXPORT __Vectors_Size
  47. __Vectors DCD __initial_sp ; Top of Stack
  48. DCD Reset_Handler ; Reset Handler
  49. DCD NMI_Handler ; NMI Handler
  50. DCD HardFault_Handler ; Hard Fault Handler
  51. DCD 0 ; Reserved
  52. DCD 0 ; Reserved
  53. DCD 0 ; Reserved
  54. DCD 0 ; Reserved
  55. DCD 0 ; Reserved
  56. DCD 0 ; Reserved
  57. DCD 0 ; Reserved
  58. DCD SVC_Handler ; SVCall Handler
  59. DCD 0 ; Reserved
  60. DCD 0 ; Reserved
  61. DCD PendSV_Handler ; PendSV Handler
  62. DCD SysTick_Handler ; SysTick Handler
  63. ; External Interrupts
  64. DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
  65. DCD RADIO_IRQHandler ;RADIO
  66. DCD UART0_IRQHandler ;UART0
  67. DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
  68. DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
  69. DCD 0 ;Reserved
  70. DCD GPIOTE_IRQHandler ;GPIOTE
  71. DCD ADC_IRQHandler ;ADC
  72. DCD TIMER0_IRQHandler ;TIMER0
  73. DCD TIMER1_IRQHandler ;TIMER1
  74. DCD TIMER2_IRQHandler ;TIMER2
  75. DCD RTC0_IRQHandler ;RTC0
  76. DCD TEMP_IRQHandler ;TEMP
  77. DCD RNG_IRQHandler ;RNG
  78. DCD ECB_IRQHandler ;ECB
  79. DCD CCM_AAR_IRQHandler ;CCM_AAR
  80. DCD WDT_IRQHandler ;WDT
  81. DCD RTC1_IRQHandler ;RTC1
  82. DCD QDEC_IRQHandler ;QDEC
  83. DCD LPCOMP_IRQHandler ;LPCOMP
  84. DCD SWI0_IRQHandler ;SWI0
  85. DCD SWI1_IRQHandler ;SWI1
  86. DCD SWI2_IRQHandler ;SWI2
  87. DCD SWI3_IRQHandler ;SWI3
  88. DCD SWI4_IRQHandler ;SWI4
  89. DCD SWI5_IRQHandler ;SWI5
  90. DCD 0 ;Reserved
  91. DCD 0 ;Reserved
  92. DCD 0 ;Reserved
  93. DCD 0 ;Reserved
  94. DCD 0 ;Reserved
  95. DCD 0 ;Reserved
  96. __Vectors_End
  97. __Vectors_Size EQU __Vectors_End - __Vectors
  98. AREA |.text|, CODE, READONLY
  99. ; Reset Handler
  100. NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address
  101. NRF_POWER_RAMON_RAMxON_ONMODE_Msk EQU 0x3 ; All RAM blocks on in onmode bit mask
  102. Reset_Handler PROC
  103. EXPORT Reset_Handler [WEAK]
  104. IMPORT SystemInit
  105. IMPORT __main
  106. LDR R0, =NRF_POWER_RAMON_ADDRESS
  107. LDR R2, [R0]
  108. MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
  109. ORRS R2, R2, R1
  110. STR R2, [R0]
  111. LDR R0, =SystemInit
  112. BLX R0
  113. LDR R0, =__main
  114. BX R0
  115. ENDP
  116. ; Dummy Exception Handlers (infinite loops which can be modified)
  117. NMI_Handler PROC
  118. EXPORT NMI_Handler [WEAK]
  119. B .
  120. ENDP
  121. HardFault_Handler\
  122. PROC
  123. EXPORT HardFault_Handler [WEAK]
  124. B .
  125. ENDP
  126. SVC_Handler PROC
  127. EXPORT SVC_Handler [WEAK]
  128. B .
  129. ENDP
  130. PendSV_Handler PROC
  131. EXPORT PendSV_Handler [WEAK]
  132. B .
  133. ENDP
  134. SysTick_Handler PROC
  135. EXPORT SysTick_Handler [WEAK]
  136. B .
  137. ENDP
  138. Default_Handler PROC
  139. EXPORT POWER_CLOCK_IRQHandler [WEAK]
  140. EXPORT RADIO_IRQHandler [WEAK]
  141. EXPORT UART0_IRQHandler [WEAK]
  142. EXPORT SPI0_TWI0_IRQHandler [WEAK]
  143. EXPORT SPI1_TWI1_IRQHandler [WEAK]
  144. EXPORT GPIOTE_IRQHandler [WEAK]
  145. EXPORT ADC_IRQHandler [WEAK]
  146. EXPORT TIMER0_IRQHandler [WEAK]
  147. EXPORT TIMER1_IRQHandler [WEAK]
  148. EXPORT TIMER2_IRQHandler [WEAK]
  149. EXPORT RTC0_IRQHandler [WEAK]
  150. EXPORT TEMP_IRQHandler [WEAK]
  151. EXPORT RNG_IRQHandler [WEAK]
  152. EXPORT ECB_IRQHandler [WEAK]
  153. EXPORT CCM_AAR_IRQHandler [WEAK]
  154. EXPORT WDT_IRQHandler [WEAK]
  155. EXPORT RTC1_IRQHandler [WEAK]
  156. EXPORT QDEC_IRQHandler [WEAK]
  157. EXPORT LPCOMP_IRQHandler [WEAK]
  158. EXPORT SWI0_IRQHandler [WEAK]
  159. EXPORT SWI1_IRQHandler [WEAK]
  160. EXPORT SWI2_IRQHandler [WEAK]
  161. EXPORT SWI3_IRQHandler [WEAK]
  162. EXPORT SWI4_IRQHandler [WEAK]
  163. EXPORT SWI5_IRQHandler [WEAK]
  164. POWER_CLOCK_IRQHandler
  165. RADIO_IRQHandler
  166. UART0_IRQHandler
  167. SPI0_TWI0_IRQHandler
  168. SPI1_TWI1_IRQHandler
  169. GPIOTE_IRQHandler
  170. ADC_IRQHandler
  171. TIMER0_IRQHandler
  172. TIMER1_IRQHandler
  173. TIMER2_IRQHandler
  174. RTC0_IRQHandler
  175. TEMP_IRQHandler
  176. RNG_IRQHandler
  177. ECB_IRQHandler
  178. CCM_AAR_IRQHandler
  179. WDT_IRQHandler
  180. RTC1_IRQHandler
  181. QDEC_IRQHandler
  182. LPCOMP_IRQHandler
  183. SWI0_IRQHandler
  184. SWI1_IRQHandler
  185. SWI2_IRQHandler
  186. SWI3_IRQHandler
  187. SWI4_IRQHandler
  188. SWI5_IRQHandler
  189. B .
  190. ENDP
  191. ALIGN
  192. ; User Initial Stack & Heap
  193. IF :DEF:__MICROLIB
  194. EXPORT __initial_sp
  195. EXPORT __heap_base
  196. EXPORT __heap_limit
  197. ELSE
  198. IMPORT __use_two_region_memory
  199. EXPORT __user_initial_stackheap
  200. __user_initial_stackheap
  201. LDR R0, = Heap_Mem
  202. LDR R1, = (Stack_Mem + Stack_Size)
  203. LDR R2, = (Heap_Mem + Heap_Size)
  204. LDR R3, = Stack_Mem
  205. BX LR
  206. ALIGN
  207. ENDIF
  208. END