cmsis_armcc.h 25 KB

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