cmsis_armcc.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /**************************************************************************//**
  2. * @file cmsis_armcc.h
  3. * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
  4. * @version V5.3.2
  5. * @date 27. May 2021
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #ifndef __CMSIS_ARMCC_H
  25. #define __CMSIS_ARMCC_H
  26. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
  27. #error "Please use Arm Compiler Toolchain V4.0.677 or later!"
  28. #endif
  29. /* CMSIS compiler control architecture macros */
  30. #if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
  31. (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
  32. #define __ARM_ARCH_6M__ 1
  33. #endif
  34. #if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
  35. #define __ARM_ARCH_7M__ 1
  36. #endif
  37. #if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
  38. #define __ARM_ARCH_7EM__ 1
  39. #endif
  40. /* __ARM_ARCH_8M_BASE__ not applicable */
  41. /* __ARM_ARCH_8M_MAIN__ not applicable */
  42. /* __ARM_ARCH_8_1M_MAIN__ not applicable */
  43. /* CMSIS compiler control DSP macros */
  44. #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
  45. #define __ARM_FEATURE_DSP 1
  46. #endif
  47. /* CMSIS compiler specific defines */
  48. #ifndef __ASM
  49. #define __ASM __asm
  50. #endif
  51. #ifndef __INLINE
  52. #define __INLINE __inline
  53. #endif
  54. #ifndef __STATIC_INLINE
  55. #define __STATIC_INLINE static __inline
  56. #endif
  57. #ifndef __STATIC_FORCEINLINE
  58. #define __STATIC_FORCEINLINE static __forceinline
  59. #endif
  60. #ifndef __NO_RETURN
  61. #define __NO_RETURN __declspec(noreturn)
  62. #endif
  63. #ifndef __USED
  64. #define __USED __attribute__((used))
  65. #endif
  66. #ifndef __WEAK
  67. #define __WEAK __attribute__((weak))
  68. #endif
  69. #ifndef __PACKED
  70. #define __PACKED __attribute__((packed))
  71. #endif
  72. #ifndef __PACKED_STRUCT
  73. #define __PACKED_STRUCT __packed struct
  74. #endif
  75. #ifndef __PACKED_UNION
  76. #define __PACKED_UNION __packed union
  77. #endif
  78. #ifndef __UNALIGNED_UINT32 /* deprecated */
  79. #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
  80. #endif
  81. #ifndef __UNALIGNED_UINT16_WRITE
  82. #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
  83. #endif
  84. #ifndef __UNALIGNED_UINT16_READ
  85. #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
  86. #endif
  87. #ifndef __UNALIGNED_UINT32_WRITE
  88. #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
  89. #endif
  90. #ifndef __UNALIGNED_UINT32_READ
  91. #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
  92. #endif
  93. #ifndef __ALIGNED
  94. #define __ALIGNED(x) __attribute__((aligned(x)))
  95. #endif
  96. #ifndef __RESTRICT
  97. #define __RESTRICT __restrict
  98. #endif
  99. #ifndef __COMPILER_BARRIER
  100. #define __COMPILER_BARRIER() __memory_changed()
  101. #endif
  102. /* ######################### Startup and Lowlevel Init ######################## */
  103. #ifndef __PROGRAM_START
  104. #define __PROGRAM_START __main
  105. #endif
  106. #ifndef __INITIAL_SP
  107. #define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
  108. #endif
  109. #ifndef __STACK_LIMIT
  110. #define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
  111. #endif
  112. #ifndef __VECTOR_TABLE
  113. #define __VECTOR_TABLE __Vectors
  114. #endif
  115. #ifndef __VECTOR_TABLE_ATTRIBUTE
  116. #define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
  117. #endif
  118. /* ########################## Core Instruction Access ######################### */
  119. /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
  120. Access to dedicated instructions
  121. @{
  122. */
  123. /**
  124. \brief No Operation
  125. \details No Operation does nothing. This instruction can be used for code alignment purposes.
  126. */
  127. #define __NOP __nop
  128. /**
  129. \brief Wait For Interrupt
  130. \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
  131. */
  132. #define __WFI __wfi
  133. /**
  134. \brief Wait For Event
  135. \details Wait For Event is a hint instruction that permits the processor to enter
  136. a low-power state until one of a number of events occurs.
  137. */
  138. #define __WFE __wfe
  139. /**
  140. \brief Send Event
  141. \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
  142. */
  143. #define __SEV __sev
  144. /**
  145. \brief Instruction Synchronization Barrier
  146. \details Instruction Synchronization Barrier flushes the pipeline in the processor,
  147. so that all instructions following the ISB are fetched from cache or memory,
  148. after the instruction has been completed.
  149. */
  150. #define __ISB() __isb(0xF)
  151. /**
  152. \brief Data Synchronization Barrier
  153. \details Acts as a special kind of Data Memory Barrier.
  154. It completes when all explicit memory accesses before this instruction complete.
  155. */
  156. #define __DSB() __dsb(0xF)
  157. /**
  158. \brief Data Memory Barrier
  159. \details Ensures the apparent order of the explicit memory operations before
  160. and after the instruction, without ensuring their completion.
  161. */
  162. #define __DMB() __dmb(0xF)
  163. /**
  164. \brief Reverse byte order (32 bit)
  165. \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
  166. \param [in] value Value to reverse
  167. \return Reversed value
  168. */
  169. #define __REV __rev
  170. /**
  171. \brief Reverse byte order (16 bit)
  172. \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
  173. \param [in] value Value to reverse
  174. \return Reversed value
  175. */
  176. #ifndef __NO_EMBEDDED_ASM
  177. __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
  178. {
  179. rev16 r0, r0
  180. bx lr
  181. }
  182. #endif
  183. /**
  184. \brief Reverse byte order (16 bit)
  185. \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
  186. \param [in] value Value to reverse
  187. \return Reversed value
  188. */
  189. #ifndef __NO_EMBEDDED_ASM
  190. __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
  191. {
  192. revsh r0, r0
  193. bx lr
  194. }
  195. #endif
  196. /**
  197. \brief Rotate Right in unsigned value (32 bit)
  198. \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
  199. \param [in] op1 Value to rotate
  200. \param [in] op2 Number of Bits to rotate
  201. \return Rotated value
  202. */
  203. #define __ROR __ror
  204. /**
  205. \brief Breakpoint
  206. \details Causes the processor to enter Debug state.
  207. Debug tools can use this to investigate system state when the instruction at a particular address is reached.
  208. \param [in] value is ignored by the processor.
  209. If required, a debugger can use it to store additional information about the breakpoint.
  210. */
  211. #define __BKPT(value) __breakpoint(value)
  212. /**
  213. \brief Reverse bit order of value
  214. \details Reverses the bit order of the given value.
  215. \param [in] value Value to reverse
  216. \return Reversed value
  217. */
  218. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  219. (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
  220. #define __RBIT __rbit
  221. #else
  222. __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
  223. {
  224. uint32_t result;
  225. uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
  226. result = value; /* r will be reversed bits of v; first get LSB of v */
  227. for (value >>= 1U; value != 0U; value >>= 1U)
  228. {
  229. result <<= 1U;
  230. result |= value & 1U;
  231. s--;
  232. }
  233. result <<= s; /* shift when v's highest bits are zero */
  234. return result;
  235. }
  236. #endif
  237. /**
  238. \brief Count leading zeros
  239. \details Counts the number of leading zeros of a data value.
  240. \param [in] value Value to count the leading zeros
  241. \return number of leading zeros in value
  242. */
  243. #define __CLZ __clz
  244. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  245. (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
  246. /**
  247. \brief LDR Exclusive (8 bit)
  248. \details Executes a exclusive LDR instruction for 8 bit value.
  249. \param [in] ptr Pointer to data
  250. \return value of type uint8_t at (*ptr)
  251. */
  252. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
  253. #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
  254. #else
  255. #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
  256. #endif
  257. /**
  258. \brief LDR Exclusive (16 bit)
  259. \details Executes a exclusive LDR instruction for 16 bit values.
  260. \param [in] ptr Pointer to data
  261. \return value of type uint16_t at (*ptr)
  262. */
  263. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
  264. #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
  265. #else
  266. #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
  267. #endif
  268. /**
  269. \brief LDR Exclusive (32 bit)
  270. \details Executes a exclusive LDR instruction for 32 bit values.
  271. \param [in] ptr Pointer to data
  272. \return value of type uint32_t at (*ptr)
  273. */
  274. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
  275. #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
  276. #else
  277. #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
  278. #endif
  279. /**
  280. \brief STR Exclusive (8 bit)
  281. \details Executes a exclusive STR instruction for 8 bit values.
  282. \param [in] value Value to store
  283. \param [in] ptr Pointer to location
  284. \return 0 Function succeeded
  285. \return 1 Function failed
  286. */
  287. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
  288. #define __STREXB(value, ptr) __strex(value, ptr)
  289. #else
  290. #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
  291. #endif
  292. /**
  293. \brief STR Exclusive (16 bit)
  294. \details Executes a exclusive STR instruction for 16 bit values.
  295. \param [in] value Value to store
  296. \param [in] ptr Pointer to location
  297. \return 0 Function succeeded
  298. \return 1 Function failed
  299. */
  300. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
  301. #define __STREXH(value, ptr) __strex(value, ptr)
  302. #else
  303. #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
  304. #endif
  305. /**
  306. \brief STR Exclusive (32 bit)
  307. \details Executes a exclusive STR instruction for 32 bit values.
  308. \param [in] value Value to store
  309. \param [in] ptr Pointer to location
  310. \return 0 Function succeeded
  311. \return 1 Function failed
  312. */
  313. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
  314. #define __STREXW(value, ptr) __strex(value, ptr)
  315. #else
  316. #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
  317. #endif
  318. /**
  319. \brief Remove the exclusive lock
  320. \details Removes the exclusive lock which is created by LDREX.
  321. */
  322. #define __CLREX __clrex
  323. /**
  324. \brief Signed Saturate
  325. \details Saturates a signed value.
  326. \param [in] value Value to be saturated
  327. \param [in] sat Bit position to saturate to (1..32)
  328. \return Saturated value
  329. */
  330. #define __SSAT __ssat
  331. /**
  332. \brief Unsigned Saturate
  333. \details Saturates an unsigned value.
  334. \param [in] value Value to be saturated
  335. \param [in] sat Bit position to saturate to (0..31)
  336. \return Saturated value
  337. */
  338. #define __USAT __usat
  339. /**
  340. \brief Rotate Right with Extend (32 bit)
  341. \details Moves each bit of a bitstring right by one bit.
  342. The carry input is shifted in at the left end of the bitstring.
  343. \param [in] value Value to rotate
  344. \return Rotated value
  345. */
  346. #ifndef __NO_EMBEDDED_ASM
  347. __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
  348. {
  349. rrx r0, r0
  350. bx lr
  351. }
  352. #endif
  353. /**
  354. \brief LDRT Unprivileged (8 bit)
  355. \details Executes a Unprivileged LDRT instruction for 8 bit value.
  356. \param [in] ptr Pointer to data
  357. \return value of type uint8_t at (*ptr)
  358. */
  359. #define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
  360. /**
  361. \brief LDRT Unprivileged (16 bit)
  362. \details Executes a Unprivileged LDRT instruction for 16 bit values.
  363. \param [in] ptr Pointer to data
  364. \return value of type uint16_t at (*ptr)
  365. */
  366. #define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
  367. /**
  368. \brief LDRT Unprivileged (32 bit)
  369. \details Executes a Unprivileged LDRT instruction for 32 bit values.
  370. \param [in] ptr Pointer to data
  371. \return value of type uint32_t at (*ptr)
  372. */
  373. #define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
  374. /**
  375. \brief STRT Unprivileged (8 bit)
  376. \details Executes a Unprivileged STRT instruction for 8 bit values.
  377. \param [in] value Value to store
  378. \param [in] ptr Pointer to location
  379. */
  380. #define __STRBT(value, ptr) __strt(value, ptr)
  381. /**
  382. \brief STRT Unprivileged (16 bit)
  383. \details Executes a Unprivileged STRT instruction for 16 bit values.
  384. \param [in] value Value to store
  385. \param [in] ptr Pointer to location
  386. */
  387. #define __STRHT(value, ptr) __strt(value, ptr)
  388. /**
  389. \brief STRT Unprivileged (32 bit)
  390. \details Executes a Unprivileged STRT instruction for 32 bit values.
  391. \param [in] value Value to store
  392. \param [in] ptr Pointer to location
  393. */
  394. #define __STRT(value, ptr) __strt(value, ptr)
  395. #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  396. (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
  397. /**
  398. \brief Signed Saturate
  399. \details Saturates a signed value.
  400. \param [in] value Value to be saturated
  401. \param [in] sat Bit position to saturate to (1..32)
  402. \return Saturated value
  403. */
  404. __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
  405. {
  406. if ((sat >= 1U) && (sat <= 32U))
  407. {
  408. const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
  409. const int32_t min = -1 - max ;
  410. if (val > max)
  411. {
  412. return max;
  413. }
  414. else if (val < min)
  415. {
  416. return min;
  417. }
  418. }
  419. return val;
  420. }
  421. /**
  422. \brief Unsigned Saturate
  423. \details Saturates an unsigned value.
  424. \param [in] value Value to be saturated
  425. \param [in] sat Bit position to saturate to (0..31)
  426. \return Saturated value
  427. */
  428. __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
  429. {
  430. if (sat <= 31U)
  431. {
  432. const uint32_t max = ((1U << sat) - 1U);
  433. if (val > (int32_t)max)
  434. {
  435. return max;
  436. }
  437. else if (val < 0)
  438. {
  439. return 0U;
  440. }
  441. }
  442. return (uint32_t)val;
  443. }
  444. #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  445. (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
  446. /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
  447. /* ########################### Core Function Access ########################### */
  448. /** \ingroup CMSIS_Core_FunctionInterface
  449. \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
  450. @{
  451. */
  452. /**
  453. \brief Enable IRQ Interrupts
  454. \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
  455. Can only be executed in Privileged modes.
  456. */
  457. /* intrinsic void __enable_irq(); */
  458. /**
  459. \brief Disable IRQ Interrupts
  460. \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
  461. Can only be executed in Privileged modes.
  462. */
  463. /* intrinsic void __disable_irq(); */
  464. /**
  465. \brief Get Control Register
  466. \details Returns the content of the Control Register.
  467. \return Control Register value
  468. */
  469. __STATIC_INLINE uint32_t __get_CONTROL(void)
  470. {
  471. register uint32_t __regControl __ASM("control");
  472. return(__regControl);
  473. }
  474. /**
  475. \brief Set Control Register
  476. \details Writes the given value to the Control Register.
  477. \param [in] control Control Register value to set
  478. */
  479. __STATIC_INLINE void __set_CONTROL(uint32_t control)
  480. {
  481. register uint32_t __regControl __ASM("control");
  482. __regControl = control;
  483. __ISB();
  484. }
  485. /**
  486. \brief Get IPSR Register
  487. \details Returns the content of the IPSR Register.
  488. \return IPSR Register value
  489. */
  490. __STATIC_INLINE uint32_t __get_IPSR(void)
  491. {
  492. register uint32_t __regIPSR __ASM("ipsr");
  493. return(__regIPSR);
  494. }
  495. /**
  496. \brief Get APSR Register
  497. \details Returns the content of the APSR Register.
  498. \return APSR Register value
  499. */
  500. __STATIC_INLINE uint32_t __get_APSR(void)
  501. {
  502. register uint32_t __regAPSR __ASM("apsr");
  503. return(__regAPSR);
  504. }
  505. /**
  506. \brief Get xPSR Register
  507. \details Returns the content of the xPSR Register.
  508. \return xPSR Register value
  509. */
  510. __STATIC_INLINE uint32_t __get_xPSR(void)
  511. {
  512. register uint32_t __regXPSR __ASM("xpsr");
  513. return(__regXPSR);
  514. }
  515. /**
  516. \brief Get Process Stack Pointer
  517. \details Returns the current value of the Process Stack Pointer (PSP).
  518. \return PSP Register value
  519. */
  520. __STATIC_INLINE uint32_t __get_PSP(void)
  521. {
  522. register uint32_t __regProcessStackPointer __ASM("psp");
  523. return(__regProcessStackPointer);
  524. }
  525. /**
  526. \brief Set Process Stack Pointer
  527. \details Assigns the given value to the Process Stack Pointer (PSP).
  528. \param [in] topOfProcStack Process Stack Pointer value to set
  529. */
  530. __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
  531. {
  532. register uint32_t __regProcessStackPointer __ASM("psp");
  533. __regProcessStackPointer = topOfProcStack;
  534. }
  535. /**
  536. \brief Get Main Stack Pointer
  537. \details Returns the current value of the Main Stack Pointer (MSP).
  538. \return MSP Register value
  539. */
  540. __STATIC_INLINE uint32_t __get_MSP(void)
  541. {
  542. register uint32_t __regMainStackPointer __ASM("msp");
  543. return(__regMainStackPointer);
  544. }
  545. /**
  546. \brief Set Main Stack Pointer
  547. \details Assigns the given value to the Main Stack Pointer (MSP).
  548. \param [in] topOfMainStack Main Stack Pointer value to set
  549. */
  550. __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
  551. {
  552. register uint32_t __regMainStackPointer __ASM("msp");
  553. __regMainStackPointer = topOfMainStack;
  554. }
  555. /**
  556. \brief Get Priority Mask
  557. \details Returns the current state of the priority mask bit from the Priority Mask Register.
  558. \return Priority Mask value
  559. */
  560. __STATIC_INLINE uint32_t __get_PRIMASK(void)
  561. {
  562. register uint32_t __regPriMask __ASM("primask");
  563. return(__regPriMask);
  564. }
  565. /**
  566. \brief Set Priority Mask
  567. \details Assigns the given value to the Priority Mask Register.
  568. \param [in] priMask Priority Mask
  569. */
  570. __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
  571. {
  572. register uint32_t __regPriMask __ASM("primask");
  573. __regPriMask = (priMask);
  574. }
  575. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  576. (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
  577. /**
  578. \brief Enable FIQ
  579. \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
  580. Can only be executed in Privileged modes.
  581. */
  582. #define __enable_fault_irq __enable_fiq
  583. /**
  584. \brief Disable FIQ
  585. \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
  586. Can only be executed in Privileged modes.
  587. */
  588. #define __disable_fault_irq __disable_fiq
  589. /**
  590. \brief Get Base Priority
  591. \details Returns the current value of the Base Priority register.
  592. \return Base Priority register value
  593. */
  594. __STATIC_INLINE uint32_t __get_BASEPRI(void)
  595. {
  596. register uint32_t __regBasePri __ASM("basepri");
  597. return(__regBasePri);
  598. }
  599. /**
  600. \brief Set Base Priority
  601. \details Assigns the given value to the Base Priority register.
  602. \param [in] basePri Base Priority value to set
  603. */
  604. __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
  605. {
  606. register uint32_t __regBasePri __ASM("basepri");
  607. __regBasePri = (basePri & 0xFFU);
  608. }
  609. /**
  610. \brief Set Base Priority with condition
  611. \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
  612. or the new value increases the BASEPRI priority level.
  613. \param [in] basePri Base Priority value to set
  614. */
  615. __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
  616. {
  617. register uint32_t __regBasePriMax __ASM("basepri_max");
  618. __regBasePriMax = (basePri & 0xFFU);
  619. }
  620. /**
  621. \brief Get Fault Mask
  622. \details Returns the current value of the Fault Mask register.
  623. \return Fault Mask register value
  624. */
  625. __STATIC_INLINE uint32_t __get_FAULTMASK(void)
  626. {
  627. register uint32_t __regFaultMask __ASM("faultmask");
  628. return(__regFaultMask);
  629. }
  630. /**
  631. \brief Set Fault Mask
  632. \details Assigns the given value to the Fault Mask register.
  633. \param [in] faultMask Fault Mask value to set
  634. */
  635. __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
  636. {
  637. register uint32_t __regFaultMask __ASM("faultmask");
  638. __regFaultMask = (faultMask & (uint32_t)1U);
  639. }
  640. #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  641. (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
  642. /**
  643. \brief Get FPSCR
  644. \details Returns the current value of the Floating Point Status/Control register.
  645. \return Floating Point Status/Control register value
  646. */
  647. __STATIC_INLINE uint32_t __get_FPSCR(void)
  648. {
  649. #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
  650. (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
  651. register uint32_t __regfpscr __ASM("fpscr");
  652. return(__regfpscr);
  653. #else
  654. return(0U);
  655. #endif
  656. }
  657. /**
  658. \brief Set FPSCR
  659. \details Assigns the given value to the Floating Point Status/Control register.
  660. \param [in] fpscr Floating Point Status/Control value to set
  661. */
  662. __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
  663. {
  664. #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
  665. (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
  666. register uint32_t __regfpscr __ASM("fpscr");
  667. __regfpscr = (fpscr);
  668. #else
  669. (void)fpscr;
  670. #endif
  671. }
  672. /*@} end of CMSIS_Core_RegAccFunctions */
  673. /* ################### Compiler specific Intrinsics ########################### */
  674. /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
  675. Access to dedicated SIMD instructions
  676. @{
  677. */
  678. #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
  679. #define __SADD8 __sadd8
  680. #define __QADD8 __qadd8
  681. #define __SHADD8 __shadd8
  682. #define __UADD8 __uadd8
  683. #define __UQADD8 __uqadd8
  684. #define __UHADD8 __uhadd8
  685. #define __SSUB8 __ssub8
  686. #define __QSUB8 __qsub8
  687. #define __SHSUB8 __shsub8
  688. #define __USUB8 __usub8
  689. #define __UQSUB8 __uqsub8
  690. #define __UHSUB8 __uhsub8
  691. #define __SADD16 __sadd16
  692. #define __QADD16 __qadd16
  693. #define __SHADD16 __shadd16
  694. #define __UADD16 __uadd16
  695. #define __UQADD16 __uqadd16
  696. #define __UHADD16 __uhadd16
  697. #define __SSUB16 __ssub16
  698. #define __QSUB16 __qsub16
  699. #define __SHSUB16 __shsub16
  700. #define __USUB16 __usub16
  701. #define __UQSUB16 __uqsub16
  702. #define __UHSUB16 __uhsub16
  703. #define __SASX __sasx
  704. #define __QASX __qasx
  705. #define __SHASX __shasx
  706. #define __UASX __uasx
  707. #define __UQASX __uqasx
  708. #define __UHASX __uhasx
  709. #define __SSAX __ssax
  710. #define __QSAX __qsax
  711. #define __SHSAX __shsax
  712. #define __USAX __usax
  713. #define __UQSAX __uqsax
  714. #define __UHSAX __uhsax
  715. #define __USAD8 __usad8
  716. #define __USADA8 __usada8
  717. #define __SSAT16 __ssat16
  718. #define __USAT16 __usat16
  719. #define __UXTB16 __uxtb16
  720. #define __UXTAB16 __uxtab16
  721. #define __SXTB16 __sxtb16
  722. #define __SXTAB16 __sxtab16
  723. #define __SMUAD __smuad
  724. #define __SMUADX __smuadx
  725. #define __SMLAD __smlad
  726. #define __SMLADX __smladx
  727. #define __SMLALD __smlald
  728. #define __SMLALDX __smlaldx
  729. #define __SMUSD __smusd
  730. #define __SMUSDX __smusdx
  731. #define __SMLSD __smlsd
  732. #define __SMLSDX __smlsdx
  733. #define __SMLSLD __smlsld
  734. #define __SMLSLDX __smlsldx
  735. #define __SEL __sel
  736. #define __QADD __qadd
  737. #define __QSUB __qsub
  738. #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
  739. ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
  740. #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
  741. ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
  742. #define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
  743. ((int64_t)(ARG3) << 32U) ) >> 32U))
  744. #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
  745. #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
  746. #endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
  747. /*@} end of group CMSIS_SIMD_intrinsics */
  748. #endif /* __CMSIS_ARMCC_H */