cmsis_armcc.h 23 KB

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