训练营PLSR题目
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

291 строка
12 KiB

  1. @********************************************************************************************************
  2. @ uC/CPU
  3. @ CPU CONFIGURATION & PORT LAYER
  4. @
  5. @ (c) Copyright 2004-2013; Micrium, Inc.; Weston, FL
  6. @
  7. @ All rights reserved. Protected by international copyright laws.
  8. @
  9. @ uC/CPU is provided in source form to registered licensees ONLY. It is
  10. @ illegal to distribute this source code to any third party unless you receive
  11. @ written permission by an authorized Micrium representative. Knowledge of
  12. @ the source code may NOT be used to develop a similar product.
  13. @
  14. @ Please help us continue to provide the Embedded community with the finest
  15. @ software available. Your honesty is greatly appreciated.
  16. @
  17. @ You can find our product's user manual, API reference, release notes and
  18. @ more information at https://doc.micrium.com.
  19. @ You can contact us at www.micrium.com.
  20. @********************************************************************************************************
  21. @********************************************************************************************************
  22. @
  23. @ CPU PORT FILE
  24. @
  25. @ ARM-Cortex-M4
  26. @ GNU C Compiler
  27. @
  28. @ Filename : cpu_a.asm
  29. @ Version : V1.30.01.00
  30. @ Programmer(s) : JJL
  31. @********************************************************************************************************
  32. @********************************************************************************************************
  33. @ PUBLIC FUNCTIONS
  34. @********************************************************************************************************
  35. .global CPU_IntDis
  36. .global CPU_IntEn
  37. .global CPU_SR_Save
  38. .global CPU_SR_Restore
  39. .global CPU_WaitForInt
  40. .global CPU_WaitForExcept
  41. .global CPU_CntLeadZeros
  42. .global CPU_CntTrailZeros
  43. .global CPU_RevBits
  44. @********************************************************************************************************
  45. @ CODE GENERATION DIRECTIVES
  46. @********************************************************************************************************
  47. .text
  48. .align 2
  49. .syntax unified
  50. @********************************************************************************************************
  51. @ DISABLE and ENABLE INTERRUPTS
  52. @
  53. @ Description: Disable/Enable interrupts.
  54. @
  55. @ Prototypes : void CPU_IntDis(void);
  56. @ void CPU_IntEn (void);
  57. @********************************************************************************************************
  58. .thumb_func
  59. CPU_IntDis:
  60. CPSID I
  61. BX LR
  62. .thumb_func
  63. CPU_IntEn:
  64. CPSIE I
  65. BX LR
  66. @********************************************************************************************************
  67. @ CRITICAL SECTION FUNCTIONS
  68. @
  69. @ Description : Disable/Enable interrupts by preserving the state of interrupts. Generally speaking, the
  70. @ state of the interrupt disable flag is stored in the local variable 'cpu_sr' & interrupts
  71. @ are then disabled ('cpu_sr' is allocated in all functions that need to disable interrupts).
  72. @ The previous interrupt state is restored by copying 'cpu_sr' into the CPU's status register.
  73. @
  74. @ Prototypes : CPU_SR CPU_SR_Save (void);
  75. @ void CPU_SR_Restore(CPU_SR cpu_sr);
  76. @
  77. @ Note(s) : (1) These functions are used in general like this :
  78. @
  79. @ void Task (void *p_arg)
  80. @ {
  81. @ CPU_SR_ALLOC(); /* Allocate storage for CPU status register */
  82. @ :
  83. @ :
  84. @ CPU_CRITICAL_ENTER(); /* cpu_sr = CPU_SR_Save(); */
  85. @ :
  86. @ :
  87. @ CPU_CRITICAL_EXIT(); /* CPU_SR_Restore(cpu_sr); */
  88. @ :
  89. @ }
  90. @********************************************************************************************************
  91. .thumb_func
  92. CPU_SR_Save:
  93. MRS R0, PRIMASK @ Set prio int mask to mask all (except faults)
  94. CPSID I
  95. BX LR
  96. .thumb_func
  97. CPU_SR_Restore: @ See Note #2.
  98. MSR PRIMASK, R0
  99. BX LR
  100. @********************************************************************************************************
  101. @ WAIT FOR INTERRUPT
  102. @
  103. @ Description : Enters sleep state, which will be exited when an interrupt is received.
  104. @
  105. @ Prototypes : void CPU_WaitForInt (void)
  106. @
  107. @ Argument(s) : none.
  108. @********************************************************************************************************
  109. .thumb_func
  110. CPU_WaitForInt:
  111. WFI @ Wait for interrupt
  112. BX LR
  113. @********************************************************************************************************
  114. @ WAIT FOR EXCEPTION
  115. @
  116. @ Description : Enters sleep state, which will be exited when an exception is received.
  117. @
  118. @ Prototypes : void CPU_WaitForExcept (void)
  119. @
  120. @ Argument(s) : none.
  121. @********************************************************************************************************
  122. .thumb_func
  123. CPU_WaitForExcept:
  124. WFE @ Wait for exception
  125. BX LR
  126. @********************************************************************************************************
  127. @ CPU_CntLeadZeros()
  128. @ COUNT LEADING ZEROS
  129. @
  130. @ Description : Counts the number of contiguous, most-significant, leading zero bits before the
  131. @ first binary one bit in a data value.
  132. @
  133. @ Prototype : CPU_DATA CPU_CntLeadZeros(CPU_DATA val);
  134. @
  135. @ Argument(s) : val Data value to count leading zero bits.
  136. @
  137. @ Return(s) : Number of contiguous, most-significant, leading zero bits in 'val'.
  138. @
  139. @ Caller(s) : Application.
  140. @
  141. @ This function is an INTERNAL CPU module function but MAY be called by application
  142. @ function(s).
  143. @
  144. @ Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
  145. @ CPU WORD CONFIGURATION Note #1').
  146. @
  147. @ (b) For 32-bit values :
  148. @
  149. @ b31 b30 b29 ... b04 b03 b02 b01 b00 # Leading Zeros
  150. @ --- --- --- --- --- --- --- --- ---------------
  151. @ 1 x x x x x x x 0
  152. @ 0 1 x x x x x x 1
  153. @ 0 0 1 x x x x x 2
  154. @ : : : : : : : : :
  155. @ : : : : : : : : :
  156. @ 0 0 0 1 x x x x 27
  157. @ 0 0 0 0 1 x x x 28
  158. @ 0 0 0 0 0 1 x x 29
  159. @ 0 0 0 0 0 0 1 x 30
  160. @ 0 0 0 0 0 0 0 1 31
  161. @ 0 0 0 0 0 0 0 0 32
  162. @
  163. @
  164. @ (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_LEAD_ZEROS_ASM_PRESENT is
  165. @ #define'd in 'cpu_cfg.h' or 'cpu.h'.
  166. @********************************************************************************************************
  167. .thumb_func
  168. CPU_CntLeadZeros:
  169. CLZ R0, R0 @ Count leading zeros
  170. BX LR
  171. @********************************************************************************************************
  172. @ CPU_CntTrailZeros()
  173. @ COUNT TRAILING ZEROS
  174. @
  175. @ Description : Counts the number of contiguous, least-significant, trailing zero bits before the
  176. @ first binary one bit in a data value.
  177. @
  178. @ Prototype : CPU_DATA CPU_CntTrailZeros(CPU_DATA val);
  179. @
  180. @ Argument(s) : val Data value to count trailing zero bits.
  181. @
  182. @ Return(s) : Number of contiguous, least-significant, trailing zero bits in 'val'.
  183. @
  184. @ Caller(s) : Application.
  185. @
  186. @ This function is an INTERNAL CPU module function but MAY be called by application
  187. @ function(s).
  188. @
  189. @ Note(s) : (1) (a) Supports 32-bit data value size as configured by 'CPU_DATA' (see 'cpu.h
  190. @ CPU WORD CONFIGURATION Note #1').
  191. @
  192. @ (b) For 32-bit values :
  193. @
  194. @ b31 b30 b29 b28 b27 ... b02 b01 b00 # Trailing Zeros
  195. @ --- --- --- --- --- --- --- --- ----------------
  196. @ x x x x x x x 1 0
  197. @ x x x x x x 1 0 1
  198. @ x x x x x 1 0 0 2
  199. @ : : : : : : : : :
  200. @ : : : : : : : : :
  201. @ x x x x 1 0 0 0 27
  202. @ x x x 1 0 0 0 0 28
  203. @ x x 1 0 0 0 0 0 29
  204. @ x 1 0 0 0 0 0 0 30
  205. @ 1 0 0 0 0 0 0 0 31
  206. @ 0 0 0 0 0 0 0 0 32
  207. @
  208. @
  209. @ (2) MUST be defined in 'cpu_a.asm' (or 'cpu_c.c') if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT is
  210. @ #define'd in 'cpu_cfg.h' or 'cpu.h'.
  211. @********************************************************************************************************
  212. .thumb_func
  213. CPU_CntTrailZeros:
  214. RBIT R0, R0 @ Reverse bits
  215. CLZ R0, R0 @ Count trailing zeros
  216. BX LR
  217. @********************************************************************************************************
  218. @ CPU_RevBits()
  219. @ REVERSE BITS
  220. @
  221. @ Description : Reverses the bits in a data value.
  222. @
  223. @ Prototypes : CPU_DATA CPU_RevBits(CPU_DATA val);
  224. @
  225. @ Argument(s) : val Data value to reverse bits.
  226. @
  227. @ Return(s) : Value with all bits in 'val' reversed (see Note #1).
  228. @
  229. @ Caller(s) : Application.
  230. @
  231. @ This function is an INTERNAL CPU module function but MAY be called by application function(s).
  232. @
  233. @ Note(s) : (1) The final, reversed data value for 'val' is such that :
  234. @
  235. @ 'val's final bit 0 = 'val's original bit N
  236. @ 'val's final bit 1 = 'val's original bit (N - 1)
  237. @ 'val's final bit 2 = 'val's original bit (N - 2)
  238. @
  239. @ ... ...
  240. @
  241. @ 'val's final bit (N - 2) = 'val's original bit 2
  242. @ 'val's final bit (N - 1) = 'val's original bit 1
  243. @ 'val's final bit N = 'val's original bit 0
  244. @********************************************************************************************************
  245. .thumb_func
  246. CPU_RevBits:
  247. RBIT R0, R0 @ Reverse bits
  248. BX LR
  249. @********************************************************************************************************
  250. @ CPU ASSEMBLY PORT FILE END
  251. @********************************************************************************************************
  252. .end