startup.s 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. Stack_Size EQU 0x004000
  2. AREA STACK, NOINIT, READWRITE, ALIGN=4
  3. Stack_Mem SPACE Stack_Size
  4. __initial_sp EQU 0x10014000
  5. ; <h> Heap Configuration
  6. ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
  7. ; </h>
  8. Heap_Size EQU 0x00000400
  9. AREA HEAP, NOINIT, READWRITE, ALIGN=4
  10. __heap_base
  11. Heap_Mem SPACE Heap_Size
  12. __heap_limit
  13. PRESERVE8
  14. THUMB
  15. ; Vector Table Mapped to Address 0 at Reset
  16. AREA RESET, DATA, READONLY
  17. IMPORT NMI_Handler
  18. IMPORT HardFault_Handler
  19. IMPORT SVC_Handler
  20. IMPORT PendSV_Handler
  21. EXPORT __Vectors
  22. EXPORT __Vectors_End
  23. EXPORT __Vectors_Size
  24. __Vectors DCD __initial_sp ; Top of Stack
  25. DCD Reset_Handler ; Reset Handler
  26. DCD NMI_Handler
  27. DCD HardFault_Handler ; Hard Fault Handler
  28. DCD 0 ;
  29. DCD 0 ;
  30. DCD 0 ;
  31. DCD 0 ;
  32. DCD 0 ;
  33. DCD 0 ;
  34. DCD 0 ;
  35. DCD SVC_Handler ;
  36. DCD 0 ;
  37. DCD 0 ;
  38. DCD PendSV_Handler ;
  39. DCD SYStick_handle ;
  40. DCD USB_IRQHandler ;
  41. DCD IIC_IRQHandler ;
  42. DCD QSPI_IRQHandler ;
  43. DCD SPI_IRQHandler ;
  44. DCD UART_IRQHandler ;
  45. DCD UARTB_IRQHandler ;
  46. DCD ADC_IRQHandler ;
  47. DCD IIS_IRQHandler ;
  48. DCD BT_IRQHandler ;
  49. DCD GPIO0_IRQHandler ;
  50. DCD GPIO1_IRQHandler ;
  51. DCD 0 ;
  52. DCD 0 ;
  53. DCD 0 ;
  54. DCD 0 ;
  55. DCD 0 ;
  56. DCD 0 ;
  57. DCD GPIO8_IRQHandler ;
  58. DCD GPIO9_IRQHandler ;
  59. DCD GPIO10_IRQHandler ;
  60. DCD GPIO11_IRQHandler ;
  61. DCD GPIO12_IRQHandler ;
  62. DCD GPIO13_IRQHandler ;
  63. DCD GPIO14_IRQHandler ;
  64. DCD GPIO15_IRQHandler ;
  65. DCD GPIO16_IRQHandler ;
  66. DCD GPIO17_IRQHandler ;
  67. DCD GPIO18_IRQHandler ;
  68. DCD GPIO19_IRQHandler ;
  69. DCD GPIO20_IRQHandler ;
  70. DCD GPIO21_IRQHandler ;
  71. DCD GPIO22_IRQHandler ;
  72. __Vectors_End
  73. __Vectors_Size EQU __Vectors_End - __Vectors
  74. AREA |.text|, CODE, READONLY ,ALIGN=4
  75. ; Reset Handler
  76. Reset_Handler PROC
  77. EXPORT Reset_Handler [WEAK]
  78. IMPORT __main
  79. LDR R0,= LOADRAMFLAG
  80. LDR R0,[R0]
  81. LDRB R0,[R0]
  82. CMP R0,#0
  83. BEQ RUN_TO_MAIN
  84. LDR R0, =__main
  85. BX R0
  86. ENDP
  87. RUN_TO_MAIN PROC
  88. IMPORT main
  89. LDR R0, = main
  90. BX R0
  91. ENDP
  92. align 4
  93. ; mem_wake_flag
  94. LOADRAMFLAG DCD 0x10004704
  95. Default_Handler PROC
  96. ; ToDo: Add here the export definition for the device specific external interrupts handler
  97. EXPORT SYStick_handle [WEAK]
  98. EXPORT USB_IRQHandler [WEAK]
  99. EXPORT IIC_IRQHandler [WEAK]
  100. EXPORT QSPI_IRQHandler [WEAK]
  101. EXPORT SPI_IRQHandler [WEAK]
  102. EXPORT UART_IRQHandler [WEAK]
  103. EXPORT UARTB_IRQHandler [WEAK]
  104. EXPORT ADC_IRQHandler [WEAK]
  105. EXPORT IIS_IRQHandler [WEAK]
  106. EXPORT BT_IRQHandler [WEAK]
  107. EXPORT GPIO0_IRQHandler [WEAK]
  108. EXPORT GPIO1_IRQHandler [WEAK]
  109. EXPORT GPIO8_IRQHandler [WEAK]
  110. EXPORT GPIO9_IRQHandler [WEAK]
  111. EXPORT GPIO10_IRQHandler [WEAK]
  112. EXPORT GPIO11_IRQHandler [WEAK]
  113. EXPORT GPIO12_IRQHandler [WEAK]
  114. EXPORT GPIO13_IRQHandler [WEAK]
  115. EXPORT GPIO14_IRQHandler [WEAK]
  116. EXPORT GPIO15_IRQHandler [WEAK]
  117. EXPORT GPIO16_IRQHandler [WEAK]
  118. EXPORT GPIO17_IRQHandler [WEAK]
  119. EXPORT GPIO18_IRQHandler [WEAK]
  120. EXPORT GPIO19_IRQHandler [WEAK]
  121. EXPORT GPIO20_IRQHandler [WEAK]
  122. EXPORT GPIO21_IRQHandler [WEAK]
  123. EXPORT GPIO22_IRQHandler [WEAK]
  124. ; ToDo: Add here the names for the device specific external interrupts handler
  125. SYStick_handle
  126. USB_IRQHandler
  127. IIC_IRQHandler
  128. QSPI_IRQHandler
  129. SPI_IRQHandler
  130. UART_IRQHandler
  131. UARTB_IRQHandler
  132. ADC_IRQHandler
  133. IIS_IRQHandler
  134. BT_IRQHandler
  135. GPIO0_IRQHandler
  136. GPIO1_IRQHandler
  137. GPIO8_IRQHandler
  138. GPIO9_IRQHandler
  139. GPIO10_IRQHandler
  140. GPIO11_IRQHandler
  141. GPIO12_IRQHandler
  142. GPIO13_IRQHandler
  143. GPIO14_IRQHandler
  144. GPIO15_IRQHandler
  145. GPIO16_IRQHandler
  146. GPIO17_IRQHandler
  147. GPIO18_IRQHandler
  148. GPIO19_IRQHandler
  149. GPIO20_IRQHandler
  150. GPIO21_IRQHandler
  151. GPIO22_IRQHandler
  152. B .
  153. ENDP
  154. ALIGN
  155. ; User Initial Stack & Heap
  156. IF :DEF:__MICROLIB
  157. EXPORT __initial_sp
  158. EXPORT __heap_base
  159. EXPORT __heap_limit
  160. ELSE
  161. IMPORT __use_two_region_memory
  162. EXPORT __user_initial_stackheap
  163. __user_initial_stackheap PROC
  164. LDR R0, = Heap_Mem
  165. LDR R1, =(Stack_Mem + Stack_Size)
  166. LDR R2, = (Heap_Mem + Heap_Size)
  167. LDR R3, = Stack_Mem
  168. BX LR
  169. ENDP
  170. ALIGN
  171. ENDIF
  172. END