cmsis_armcc.h 25 KB

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