cmsis_armclang.h 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. /**************************************************************************//**
  2. * @file cmsis_armclang.h
  3. * @brief CMSIS compiler ARMCLANG (ARM compiler V6) header file
  4. * @version V5.0.1
  5. * @date 02. 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_ARMCLANG_H
  25. #define __CMSIS_ARMCLANG_H
  26. #ifndef __ARM_COMPAT_H
  27. #include <arm_compat.h> /* Compatibility header for ARM Compiler 5 intrinsics */
  28. #endif
  29. /* CMSIS compiler specific defines */
  30. #ifndef __ASM
  31. #define __ASM __asm
  32. #endif
  33. #ifndef __INLINE
  34. #define __INLINE __inline
  35. #endif
  36. #ifndef __STATIC_INLINE
  37. #define __STATIC_INLINE static __inline
  38. #endif
  39. #ifndef __NO_RETURN
  40. #define __NO_RETURN __attribute__((noreturn))
  41. #endif
  42. #ifndef __USED
  43. #define __USED __attribute__((used))
  44. #endif
  45. #ifndef __WEAK
  46. #define __WEAK __attribute__((weak))
  47. #endif
  48. #ifndef __UNALIGNED_UINT32
  49. #pragma clang diagnostic push
  50. #pragma clang diagnostic ignored "-Wpacked"
  51. struct __attribute__((packed)) T_UINT32 { uint32_t v; };
  52. #pragma clang diagnostic pop
  53. #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
  54. #endif
  55. #ifndef __ALIGNED
  56. #define __ALIGNED(x) __attribute__((aligned(x)))
  57. #endif
  58. #ifndef __PACKED
  59. #define __PACKED __attribute__((packed, aligned(1)))
  60. #endif
  61. #ifndef __PACKED_STRUCT
  62. #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
  63. #endif
  64. /* ########################### Core Function Access ########################### */
  65. /** \ingroup CMSIS_Core_FunctionInterface
  66. \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
  67. @{
  68. */
  69. /**
  70. \brief Enable IRQ Interrupts
  71. \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
  72. Can only be executed in Privileged modes.
  73. */
  74. /* intrinsic void __enable_irq(); see arm_compat.h */
  75. /**
  76. \brief Disable IRQ Interrupts
  77. \details Disables IRQ interrupts by setting the I-bit in the CPSR.
  78. Can only be executed in Privileged modes.
  79. */
  80. /* intrinsic void __disable_irq(); see arm_compat.h */
  81. /**
  82. \brief Get Control Register
  83. \details Returns the content of the Control Register.
  84. \return Control Register value
  85. */
  86. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
  87. {
  88. uint32_t result;
  89. __ASM volatile ("MRS %0, control" : "=r" (result) );
  90. return(result);
  91. }
  92. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  93. /**
  94. \brief Get Control Register (non-secure)
  95. \details Returns the content of the non-secure Control Register when in secure mode.
  96. \return non-secure Control Register value
  97. */
  98. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
  99. {
  100. uint32_t result;
  101. __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
  102. return(result);
  103. }
  104. #endif
  105. /**
  106. \brief Set Control Register
  107. \details Writes the given value to the Control Register.
  108. \param [in] control Control Register value to set
  109. */
  110. __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
  111. {
  112. __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
  113. }
  114. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  115. /**
  116. \brief Set Control Register (non-secure)
  117. \details Writes the given value to the non-secure Control Register when in secure state.
  118. \param [in] control Control Register value to set
  119. */
  120. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
  121. {
  122. __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
  123. }
  124. #endif
  125. /**
  126. \brief Get IPSR Register
  127. \details Returns the content of the IPSR Register.
  128. \return IPSR Register value
  129. */
  130. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
  131. {
  132. uint32_t result;
  133. __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
  134. return(result);
  135. }
  136. /**
  137. \brief Get APSR Register
  138. \details Returns the content of the APSR Register.
  139. \return APSR Register value
  140. */
  141. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
  142. {
  143. uint32_t result;
  144. __ASM volatile ("MRS %0, apsr" : "=r" (result) );
  145. return(result);
  146. }
  147. /**
  148. \brief Get xPSR Register
  149. \details Returns the content of the xPSR Register.
  150. \return xPSR Register value
  151. */
  152. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
  153. {
  154. uint32_t result;
  155. __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
  156. return(result);
  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. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
  164. {
  165. register uint32_t result;
  166. __ASM volatile ("MRS %0, psp" : "=r" (result) );
  167. return(result);
  168. }
  169. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  170. /**
  171. \brief Get Process Stack Pointer (non-secure)
  172. \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
  173. \return PSP Register value
  174. */
  175. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
  176. {
  177. register uint32_t result;
  178. __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
  179. return(result);
  180. }
  181. #endif
  182. /**
  183. \brief Set Process Stack Pointer
  184. \details Assigns the given value to the Process Stack Pointer (PSP).
  185. \param [in] topOfProcStack Process Stack Pointer value to set
  186. */
  187. __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
  188. {
  189. __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
  190. }
  191. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  192. /**
  193. \brief Set Process Stack Pointer (non-secure)
  194. \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
  195. \param [in] topOfProcStack Process Stack Pointer value to set
  196. */
  197. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
  198. {
  199. __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
  200. }
  201. #endif
  202. /**
  203. \brief Get Main Stack Pointer
  204. \details Returns the current value of the Main Stack Pointer (MSP).
  205. \return MSP Register value
  206. */
  207. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
  208. {
  209. register uint32_t result;
  210. __ASM volatile ("MRS %0, msp" : "=r" (result) );
  211. return(result);
  212. }
  213. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  214. /**
  215. \brief Get Main Stack Pointer (non-secure)
  216. \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
  217. \return MSP Register value
  218. */
  219. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
  220. {
  221. register uint32_t result;
  222. __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
  223. return(result);
  224. }
  225. #endif
  226. /**
  227. \brief Set Main Stack Pointer
  228. \details Assigns the given value to the Main Stack Pointer (MSP).
  229. \param [in] topOfMainStack Main Stack Pointer value to set
  230. */
  231. __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
  232. {
  233. __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
  234. }
  235. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  236. /**
  237. \brief Set Main Stack Pointer (non-secure)
  238. \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
  239. \param [in] topOfMainStack Main Stack Pointer value to set
  240. */
  241. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
  242. {
  243. __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
  244. }
  245. #endif
  246. /**
  247. \brief Get Priority Mask
  248. \details Returns the current state of the priority mask bit from the Priority Mask Register.
  249. \return Priority Mask value
  250. */
  251. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
  252. {
  253. uint32_t result;
  254. __ASM volatile ("MRS %0, primask" : "=r" (result) );
  255. return(result);
  256. }
  257. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  258. /**
  259. \brief Get Priority Mask (non-secure)
  260. \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
  261. \return Priority Mask value
  262. */
  263. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
  264. {
  265. uint32_t result;
  266. __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
  267. return(result);
  268. }
  269. #endif
  270. /**
  271. \brief Set Priority Mask
  272. \details Assigns the given value to the Priority Mask Register.
  273. \param [in] priMask Priority Mask
  274. */
  275. __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
  276. {
  277. __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
  278. }
  279. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  280. /**
  281. \brief Set Priority Mask (non-secure)
  282. \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
  283. \param [in] priMask Priority Mask
  284. */
  285. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
  286. {
  287. __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
  288. }
  289. #endif
  290. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  291. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  292. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  293. /**
  294. \brief Enable FIQ
  295. \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
  296. Can only be executed in Privileged modes.
  297. */
  298. #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
  299. /**
  300. \brief Disable FIQ
  301. \details Disables FIQ interrupts by setting the F-bit in the CPSR.
  302. Can only be executed in Privileged modes.
  303. */
  304. #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
  305. /**
  306. \brief Get Base Priority
  307. \details Returns the current value of the Base Priority register.
  308. \return Base Priority register value
  309. */
  310. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
  311. {
  312. uint32_t result;
  313. __ASM volatile ("MRS %0, basepri" : "=r" (result) );
  314. return(result);
  315. }
  316. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  317. /**
  318. \brief Get Base Priority (non-secure)
  319. \details Returns the current value of the non-secure Base Priority register when in secure state.
  320. \return Base Priority register value
  321. */
  322. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
  323. {
  324. uint32_t result;
  325. __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
  326. return(result);
  327. }
  328. #endif
  329. /**
  330. \brief Set Base Priority
  331. \details Assigns the given value to the Base Priority register.
  332. \param [in] basePri Base Priority value to set
  333. */
  334. __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
  335. {
  336. __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
  337. }
  338. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  339. /**
  340. \brief Set Base Priority (non-secure)
  341. \details Assigns the given value to the non-secure Base Priority register when in secure state.
  342. \param [in] basePri Base Priority value to set
  343. */
  344. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
  345. {
  346. __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
  347. }
  348. #endif
  349. /**
  350. \brief Set Base Priority with condition
  351. \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
  352. or the new value increases the BASEPRI priority level.
  353. \param [in] basePri Base Priority value to set
  354. */
  355. __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
  356. {
  357. __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
  358. }
  359. /**
  360. \brief Get Fault Mask
  361. \details Returns the current value of the Fault Mask register.
  362. \return Fault Mask register value
  363. */
  364. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
  365. {
  366. uint32_t result;
  367. __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
  368. return(result);
  369. }
  370. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  371. /**
  372. \brief Get Fault Mask (non-secure)
  373. \details Returns the current value of the non-secure Fault Mask register when in secure state.
  374. \return Fault Mask register value
  375. */
  376. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
  377. {
  378. uint32_t result;
  379. __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
  380. return(result);
  381. }
  382. #endif
  383. /**
  384. \brief Set Fault Mask
  385. \details Assigns the given value to the Fault Mask register.
  386. \param [in] faultMask Fault Mask value to set
  387. */
  388. __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
  389. {
  390. __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
  391. }
  392. #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
  393. /**
  394. \brief Set Fault Mask (non-secure)
  395. \details Assigns the given value to the non-secure Fault Mask register when in secure state.
  396. \param [in] faultMask Fault Mask value to set
  397. */
  398. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
  399. {
  400. __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
  401. }
  402. #endif
  403. #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  404. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  405. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
  406. #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
  407. (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
  408. /**
  409. \brief Get Process Stack Pointer Limit
  410. \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
  411. \return PSPLIM Register value
  412. */
  413. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
  414. {
  415. register uint32_t result;
  416. __ASM volatile ("MRS %0, psplim" : "=r" (result) );
  417. return(result);
  418. }
  419. #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
  420. (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  421. /**
  422. \brief Get Process Stack Pointer Limit (non-secure)
  423. \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
  424. \return PSPLIM Register value
  425. */
  426. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
  427. {
  428. register uint32_t result;
  429. __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
  430. return(result);
  431. }
  432. #endif
  433. /**
  434. \brief Set Process Stack Pointer Limit
  435. \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
  436. \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
  437. */
  438. __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
  439. {
  440. __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
  441. }
  442. #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
  443. (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  444. /**
  445. \brief Set Process Stack Pointer (non-secure)
  446. \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
  447. \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
  448. */
  449. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
  450. {
  451. __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
  452. }
  453. #endif
  454. /**
  455. \brief Get Main Stack Pointer Limit
  456. \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
  457. \return MSPLIM Register value
  458. */
  459. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
  460. {
  461. register uint32_t result;
  462. __ASM volatile ("MRS %0, msplim" : "=r" (result) );
  463. return(result);
  464. }
  465. #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
  466. (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  467. /**
  468. \brief Get Main Stack Pointer Limit (non-secure)
  469. \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
  470. \return MSPLIM Register value
  471. */
  472. __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
  473. {
  474. register uint32_t result;
  475. __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
  476. return(result);
  477. }
  478. #endif
  479. /**
  480. \brief Set Main Stack Pointer Limit
  481. \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
  482. \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
  483. */
  484. __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
  485. {
  486. __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
  487. }
  488. #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
  489. (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  490. /**
  491. \brief Set Main Stack Pointer Limit (non-secure)
  492. \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
  493. \param [in] MainStackPtrLimit Main Stack Pointer value to set
  494. */
  495. __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
  496. {
  497. __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
  498. }
  499. #endif
  500. #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
  501. (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
  502. #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  503. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  504. /**
  505. \brief Get FPSCR
  506. \details Returns the current value of the Floating Point Status/Control register.
  507. \return Floating Point Status/Control register value
  508. */
  509. /* #define __get_FPSCR __builtin_arm_get_fpscr */
  510. __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
  511. {
  512. #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
  513. (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
  514. uint32_t result;
  515. __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
  516. return(result);
  517. #else
  518. return(0U);
  519. #endif
  520. }
  521. /**
  522. \brief Set FPSCR
  523. \details Assigns the given value to the Floating Point Status/Control register.
  524. \param [in] fpscr Floating Point Status/Control value to set
  525. */
  526. /* #define __set_FPSCR __builtin_arm_set_fpscr */
  527. __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
  528. {
  529. #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
  530. (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
  531. __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
  532. #else
  533. (void)fpscr;
  534. #endif
  535. }
  536. #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  537. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
  538. /*@} end of CMSIS_Core_RegAccFunctions */
  539. /* ########################## Core Instruction Access ######################### */
  540. /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
  541. Access to dedicated instructions
  542. @{
  543. */
  544. /* Define macros for porting to both thumb1 and thumb2.
  545. * For thumb1, use low register (r0-r7), specified by constraint "l"
  546. * Otherwise, use general registers, specified by constraint "r" */
  547. #if defined (__thumb__) && !defined (__thumb2__)
  548. #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
  549. #define __CMSIS_GCC_USE_REG(r) "l" (r)
  550. #else
  551. #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
  552. #define __CMSIS_GCC_USE_REG(r) "r" (r)
  553. #endif
  554. /**
  555. \brief No Operation
  556. \details No Operation does nothing. This instruction can be used for code alignment purposes.
  557. */
  558. #define __NOP __builtin_arm_nop
  559. /**
  560. \brief Wait For Interrupt
  561. \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
  562. */
  563. #define __WFI __builtin_arm_wfi
  564. /**
  565. \brief Wait For Event
  566. \details Wait For Event is a hint instruction that permits the processor to enter
  567. a low-power state until one of a number of events occurs.
  568. */
  569. #define __WFE __builtin_arm_wfe
  570. /**
  571. \brief Send Event
  572. \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
  573. */
  574. #define __SEV __builtin_arm_sev
  575. /**
  576. \brief Instruction Synchronization Barrier
  577. \details Instruction Synchronization Barrier flushes the pipeline in the processor,
  578. so that all instructions following the ISB are fetched from cache or memory,
  579. after the instruction has been completed.
  580. */
  581. #define __ISB() __builtin_arm_isb(0xF);
  582. /**
  583. \brief Data Synchronization Barrier
  584. \details Acts as a special kind of Data Memory Barrier.
  585. It completes when all explicit memory accesses before this instruction complete.
  586. */
  587. #define __DSB() __builtin_arm_dsb(0xF);
  588. /**
  589. \brief Data Memory Barrier
  590. \details Ensures the apparent order of the explicit memory operations before
  591. and after the instruction, without ensuring their completion.
  592. */
  593. #define __DMB() __builtin_arm_dmb(0xF);
  594. /**
  595. \brief Reverse byte order (32 bit)
  596. \details Reverses the byte order in integer value.
  597. \param [in] value Value to reverse
  598. \return Reversed value
  599. */
  600. #define __REV __builtin_bswap32
  601. /**
  602. \brief Reverse byte order (16 bit)
  603. \details Reverses the byte order in two unsigned short values.
  604. \param [in] value Value to reverse
  605. \return Reversed value
  606. */
  607. #define __REV16 __builtin_bswap16 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
  608. #if 0
  609. __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
  610. {
  611. uint32_t result;
  612. __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
  613. return(result);
  614. }
  615. #endif
  616. /**
  617. \brief Reverse byte order in signed short value
  618. \details Reverses the byte order in a signed short value with sign extension to integer.
  619. \param [in] value Value to reverse
  620. \return Reversed value
  621. */
  622. /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
  623. __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
  624. {
  625. int32_t result;
  626. __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
  627. return(result);
  628. }
  629. /**
  630. \brief Rotate Right in unsigned value (32 bit)
  631. \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
  632. \param [in] op1 Value to rotate
  633. \param [in] op2 Number of Bits to rotate
  634. \return Rotated value
  635. */
  636. __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
  637. {
  638. return (op1 >> op2) | (op1 << (32U - op2));
  639. }
  640. /**
  641. \brief Breakpoint
  642. \details Causes the processor to enter Debug state.
  643. Debug tools can use this to investigate system state when the instruction at a particular address is reached.
  644. \param [in] value is ignored by the processor.
  645. If required, a debugger can use it to store additional information about the breakpoint.
  646. */
  647. #define __BKPT(value) __ASM volatile ("bkpt "#value)
  648. /**
  649. \brief Reverse bit order of value
  650. \details Reverses the bit order of the given value.
  651. \param [in] value Value to reverse
  652. \return Reversed value
  653. */
  654. /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
  655. __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
  656. {
  657. uint32_t result;
  658. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  659. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  660. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  661. __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
  662. #else
  663. int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
  664. result = value; /* r will be reversed bits of v; first get LSB of v */
  665. for (value >>= 1U; value; value >>= 1U)
  666. {
  667. result <<= 1U;
  668. result |= value & 1U;
  669. s--;
  670. }
  671. result <<= s; /* shift when v's highest bits are zero */
  672. #endif
  673. return(result);
  674. }
  675. /**
  676. \brief Count leading zeros
  677. \details Counts the number of leading zeros of a data value.
  678. \param [in] value Value to count the leading zeros
  679. \return number of leading zeros in value
  680. */
  681. #define __CLZ __builtin_clz
  682. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  683. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  684. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
  685. (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
  686. /**
  687. \brief LDR Exclusive (8 bit)
  688. \details Executes a exclusive LDR instruction for 8 bit value.
  689. \param [in] ptr Pointer to data
  690. \return value of type uint8_t at (*ptr)
  691. */
  692. #define __LDREXB (uint8_t)__builtin_arm_ldrex
  693. /**
  694. \brief LDR Exclusive (16 bit)
  695. \details Executes a exclusive LDR instruction for 16 bit values.
  696. \param [in] ptr Pointer to data
  697. \return value of type uint16_t at (*ptr)
  698. */
  699. #define __LDREXH (uint16_t)__builtin_arm_ldrex
  700. /**
  701. \brief LDR Exclusive (32 bit)
  702. \details Executes a exclusive LDR instruction for 32 bit values.
  703. \param [in] ptr Pointer to data
  704. \return value of type uint32_t at (*ptr)
  705. */
  706. #define __LDREXW (uint32_t)__builtin_arm_ldrex
  707. /**
  708. \brief STR Exclusive (8 bit)
  709. \details Executes a exclusive STR instruction for 8 bit values.
  710. \param [in] value Value to store
  711. \param [in] ptr Pointer to location
  712. \return 0 Function succeeded
  713. \return 1 Function failed
  714. */
  715. #define __STREXB (uint32_t)__builtin_arm_strex
  716. /**
  717. \brief STR Exclusive (16 bit)
  718. \details Executes a exclusive STR instruction for 16 bit values.
  719. \param [in] value Value to store
  720. \param [in] ptr Pointer to location
  721. \return 0 Function succeeded
  722. \return 1 Function failed
  723. */
  724. #define __STREXH (uint32_t)__builtin_arm_strex
  725. /**
  726. \brief STR Exclusive (32 bit)
  727. \details Executes a exclusive STR instruction for 32 bit values.
  728. \param [in] value Value to store
  729. \param [in] ptr Pointer to location
  730. \return 0 Function succeeded
  731. \return 1 Function failed
  732. */
  733. #define __STREXW (uint32_t)__builtin_arm_strex
  734. /**
  735. \brief Remove the exclusive lock
  736. \details Removes the exclusive lock which is created by LDREX.
  737. */
  738. #define __CLREX __builtin_arm_clrex
  739. #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  740. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  741. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
  742. (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
  743. #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  744. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  745. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
  746. /**
  747. \brief Signed Saturate
  748. \details Saturates a signed value.
  749. \param [in] value Value to be saturated
  750. \param [in] sat Bit position to saturate to (1..32)
  751. \return Saturated value
  752. */
  753. #define __SSAT __builtin_arm_ssat
  754. /**
  755. \brief Unsigned Saturate
  756. \details Saturates an unsigned value.
  757. \param [in] value Value to be saturated
  758. \param [in] sat Bit position to saturate to (0..31)
  759. \return Saturated value
  760. */
  761. #define __USAT __builtin_arm_usat
  762. /**
  763. \brief Rotate Right with Extend (32 bit)
  764. \details Moves each bit of a bitstring right by one bit.
  765. The carry input is shifted in at the left end of the bitstring.
  766. \param [in] value Value to rotate
  767. \return Rotated value
  768. */
  769. __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
  770. {
  771. uint32_t result;
  772. __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
  773. return(result);
  774. }
  775. /**
  776. \brief LDRT Unprivileged (8 bit)
  777. \details Executes a Unprivileged LDRT instruction for 8 bit value.
  778. \param [in] ptr Pointer to data
  779. \return value of type uint8_t at (*ptr)
  780. */
  781. __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
  782. {
  783. uint32_t result;
  784. __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
  785. return ((uint8_t) result); /* Add explicit type cast here */
  786. }
  787. /**
  788. \brief LDRT Unprivileged (16 bit)
  789. \details Executes a Unprivileged LDRT instruction for 16 bit values.
  790. \param [in] ptr Pointer to data
  791. \return value of type uint16_t at (*ptr)
  792. */
  793. __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
  794. {
  795. uint32_t result;
  796. __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
  797. return ((uint16_t) result); /* Add explicit type cast here */
  798. }
  799. /**
  800. \brief LDRT Unprivileged (32 bit)
  801. \details Executes a Unprivileged LDRT instruction for 32 bit values.
  802. \param [in] ptr Pointer to data
  803. \return value of type uint32_t at (*ptr)
  804. */
  805. __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
  806. {
  807. uint32_t result;
  808. __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
  809. return(result);
  810. }
  811. /**
  812. \brief STRT Unprivileged (8 bit)
  813. \details Executes a Unprivileged STRT instruction for 8 bit values.
  814. \param [in] value Value to store
  815. \param [in] ptr Pointer to location
  816. */
  817. __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
  818. {
  819. __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
  820. }
  821. /**
  822. \brief STRT Unprivileged (16 bit)
  823. \details Executes a Unprivileged STRT instruction for 16 bit values.
  824. \param [in] value Value to store
  825. \param [in] ptr Pointer to location
  826. */
  827. __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
  828. {
  829. __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
  830. }
  831. /**
  832. \brief STRT Unprivileged (32 bit)
  833. \details Executes a Unprivileged STRT instruction for 32 bit values.
  834. \param [in] value Value to store
  835. \param [in] ptr Pointer to location
  836. */
  837. __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
  838. {
  839. __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
  840. }
  841. #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
  842. (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
  843. (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
  844. #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
  845. (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
  846. /**
  847. \brief Load-Acquire (8 bit)
  848. \details Executes a LDAB instruction for 8 bit value.
  849. \param [in] ptr Pointer to data
  850. \return value of type uint8_t at (*ptr)
  851. */
  852. __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
  853. {
  854. uint32_t result;
  855. __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
  856. return ((uint8_t) result);
  857. }
  858. /**
  859. \brief Load-Acquire (16 bit)
  860. \details Executes a LDAH instruction for 16 bit values.
  861. \param [in] ptr Pointer to data
  862. \return value of type uint16_t at (*ptr)
  863. */
  864. __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
  865. {
  866. uint32_t result;
  867. __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
  868. return ((uint16_t) result);
  869. }
  870. /**
  871. \brief Load-Acquire (32 bit)
  872. \details Executes a LDA instruction for 32 bit values.
  873. \param [in] ptr Pointer to data
  874. \return value of type uint32_t at (*ptr)
  875. */
  876. __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
  877. {
  878. uint32_t result;
  879. __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
  880. return(result);
  881. }
  882. /**
  883. \brief Store-Release (8 bit)
  884. \details Executes a STLB instruction for 8 bit values.
  885. \param [in] value Value to store
  886. \param [in] ptr Pointer to location
  887. */
  888. __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
  889. {
  890. __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
  891. }
  892. /**
  893. \brief Store-Release (16 bit)
  894. \details Executes a STLH instruction for 16 bit values.
  895. \param [in] value Value to store
  896. \param [in] ptr Pointer to location
  897. */
  898. __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
  899. {
  900. __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
  901. }
  902. /**
  903. \brief Store-Release (32 bit)
  904. \details Executes a STL instruction for 32 bit values.
  905. \param [in] value Value to store
  906. \param [in] ptr Pointer to location
  907. */
  908. __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
  909. {
  910. __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
  911. }
  912. /**
  913. \brief Load-Acquire Exclusive (8 bit)
  914. \details Executes a LDAB exclusive instruction for 8 bit value.
  915. \param [in] ptr Pointer to data
  916. \return value of type uint8_t at (*ptr)
  917. */
  918. #define __LDAEXB (uint8_t)__builtin_arm_ldaex
  919. /**
  920. \brief Load-Acquire Exclusive (16 bit)
  921. \details Executes a LDAH exclusive instruction for 16 bit values.
  922. \param [in] ptr Pointer to data
  923. \return value of type uint16_t at (*ptr)
  924. */
  925. #define __LDAEXH (uint16_t)__builtin_arm_ldaex
  926. /**
  927. \brief Load-Acquire Exclusive (32 bit)
  928. \details Executes a LDA exclusive instruction for 32 bit values.
  929. \param [in] ptr Pointer to data
  930. \return value of type uint32_t at (*ptr)
  931. */
  932. #define __LDAEX (uint32_t)__builtin_arm_ldaex
  933. /**
  934. \brief Store-Release Exclusive (8 bit)
  935. \details Executes a STLB exclusive instruction for 8 bit values.
  936. \param [in] value Value to store
  937. \param [in] ptr Pointer to location
  938. \return 0 Function succeeded
  939. \return 1 Function failed
  940. */
  941. #define __STLEXB (uint32_t)__builtin_arm_stlex
  942. /**
  943. \brief Store-Release Exclusive (16 bit)
  944. \details Executes a STLH exclusive instruction for 16 bit values.
  945. \param [in] value Value to store
  946. \param [in] ptr Pointer to location
  947. \return 0 Function succeeded
  948. \return 1 Function failed
  949. */
  950. #define __STLEXH (uint32_t)__builtin_arm_stlex
  951. /**
  952. \brief Store-Release Exclusive (32 bit)
  953. \details Executes a STL exclusive instruction for 32 bit values.
  954. \param [in] value Value to store
  955. \param [in] ptr Pointer to location
  956. \return 0 Function succeeded
  957. \return 1 Function failed
  958. */
  959. #define __STLEX (uint32_t)__builtin_arm_stlex
  960. #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
  961. (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
  962. /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
  963. /* ################### Compiler specific Intrinsics ########################### */
  964. /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
  965. Access to dedicated SIMD instructions
  966. @{
  967. */
  968. #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
  969. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
  970. {
  971. uint32_t result;
  972. __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  973. return(result);
  974. }
  975. __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
  976. {
  977. uint32_t result;
  978. __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  979. return(result);
  980. }
  981. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
  982. {
  983. uint32_t result;
  984. __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  985. return(result);
  986. }
  987. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
  988. {
  989. uint32_t result;
  990. __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  991. return(result);
  992. }
  993. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
  994. {
  995. uint32_t result;
  996. __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  997. return(result);
  998. }
  999. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
  1000. {
  1001. uint32_t result;
  1002. __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1003. return(result);
  1004. }
  1005. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
  1006. {
  1007. uint32_t result;
  1008. __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1009. return(result);
  1010. }
  1011. __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
  1012. {
  1013. uint32_t result;
  1014. __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1015. return(result);
  1016. }
  1017. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
  1018. {
  1019. uint32_t result;
  1020. __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1021. return(result);
  1022. }
  1023. __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
  1024. {
  1025. uint32_t result;
  1026. __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1027. return(result);
  1028. }
  1029. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
  1030. {
  1031. uint32_t result;
  1032. __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1033. return(result);
  1034. }
  1035. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
  1036. {
  1037. uint32_t result;
  1038. __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1039. return(result);
  1040. }
  1041. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
  1042. {
  1043. uint32_t result;
  1044. __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1045. return(result);
  1046. }
  1047. __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
  1048. {
  1049. uint32_t result;
  1050. __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1051. return(result);
  1052. }
  1053. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
  1054. {
  1055. uint32_t result;
  1056. __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1057. return(result);
  1058. }
  1059. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
  1060. {
  1061. uint32_t result;
  1062. __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1063. return(result);
  1064. }
  1065. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
  1066. {
  1067. uint32_t result;
  1068. __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1069. return(result);
  1070. }
  1071. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
  1072. {
  1073. uint32_t result;
  1074. __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1075. return(result);
  1076. }
  1077. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
  1078. {
  1079. uint32_t result;
  1080. __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1081. return(result);
  1082. }
  1083. __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
  1084. {
  1085. uint32_t result;
  1086. __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1087. return(result);
  1088. }
  1089. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
  1090. {
  1091. uint32_t result;
  1092. __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1093. return(result);
  1094. }
  1095. __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
  1096. {
  1097. uint32_t result;
  1098. __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1099. return(result);
  1100. }
  1101. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
  1102. {
  1103. uint32_t result;
  1104. __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1105. return(result);
  1106. }
  1107. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
  1108. {
  1109. uint32_t result;
  1110. __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1111. return(result);
  1112. }
  1113. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
  1114. {
  1115. uint32_t result;
  1116. __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1117. return(result);
  1118. }
  1119. __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
  1120. {
  1121. uint32_t result;
  1122. __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1123. return(result);
  1124. }
  1125. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
  1126. {
  1127. uint32_t result;
  1128. __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1129. return(result);
  1130. }
  1131. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
  1132. {
  1133. uint32_t result;
  1134. __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1135. return(result);
  1136. }
  1137. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
  1138. {
  1139. uint32_t result;
  1140. __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1141. return(result);
  1142. }
  1143. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
  1144. {
  1145. uint32_t result;
  1146. __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1147. return(result);
  1148. }
  1149. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
  1150. {
  1151. uint32_t result;
  1152. __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1153. return(result);
  1154. }
  1155. __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
  1156. {
  1157. uint32_t result;
  1158. __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1159. return(result);
  1160. }
  1161. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
  1162. {
  1163. uint32_t result;
  1164. __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1165. return(result);
  1166. }
  1167. __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
  1168. {
  1169. uint32_t result;
  1170. __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1171. return(result);
  1172. }
  1173. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
  1174. {
  1175. uint32_t result;
  1176. __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1177. return(result);
  1178. }
  1179. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
  1180. {
  1181. uint32_t result;
  1182. __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1183. return(result);
  1184. }
  1185. __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
  1186. {
  1187. uint32_t result;
  1188. __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1189. return(result);
  1190. }
  1191. __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
  1192. {
  1193. uint32_t result;
  1194. __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
  1195. return(result);
  1196. }
  1197. #define __SSAT16(ARG1,ARG2) \
  1198. ({ \
  1199. int32_t __RES, __ARG1 = (ARG1); \
  1200. __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
  1201. __RES; \
  1202. })
  1203. #define __USAT16(ARG1,ARG2) \
  1204. ({ \
  1205. uint32_t __RES, __ARG1 = (ARG1); \
  1206. __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
  1207. __RES; \
  1208. })
  1209. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
  1210. {
  1211. uint32_t result;
  1212. __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
  1213. return(result);
  1214. }
  1215. __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
  1216. {
  1217. uint32_t result;
  1218. __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1219. return(result);
  1220. }
  1221. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
  1222. {
  1223. uint32_t result;
  1224. __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
  1225. return(result);
  1226. }
  1227. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
  1228. {
  1229. uint32_t result;
  1230. __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1231. return(result);
  1232. }
  1233. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
  1234. {
  1235. uint32_t result;
  1236. __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1237. return(result);
  1238. }
  1239. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
  1240. {
  1241. uint32_t result;
  1242. __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1243. return(result);
  1244. }
  1245. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
  1246. {
  1247. uint32_t result;
  1248. __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
  1249. return(result);
  1250. }
  1251. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
  1252. {
  1253. uint32_t result;
  1254. __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
  1255. return(result);
  1256. }
  1257. __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
  1258. {
  1259. union llreg_u{
  1260. uint32_t w32[2];
  1261. uint64_t w64;
  1262. } llr;
  1263. llr.w64 = acc;
  1264. #ifndef __ARMEB__ /* Little endian */
  1265. __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
  1266. #else /* Big endian */
  1267. __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
  1268. #endif
  1269. return(llr.w64);
  1270. }
  1271. __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
  1272. {
  1273. union llreg_u{
  1274. uint32_t w32[2];
  1275. uint64_t w64;
  1276. } llr;
  1277. llr.w64 = acc;
  1278. #ifndef __ARMEB__ /* Little endian */
  1279. __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
  1280. #else /* Big endian */
  1281. __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
  1282. #endif
  1283. return(llr.w64);
  1284. }
  1285. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
  1286. {
  1287. uint32_t result;
  1288. __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1289. return(result);
  1290. }
  1291. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
  1292. {
  1293. uint32_t result;
  1294. __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1295. return(result);
  1296. }
  1297. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
  1298. {
  1299. uint32_t result;
  1300. __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
  1301. return(result);
  1302. }
  1303. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
  1304. {
  1305. uint32_t result;
  1306. __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
  1307. return(result);
  1308. }
  1309. __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
  1310. {
  1311. union llreg_u{
  1312. uint32_t w32[2];
  1313. uint64_t w64;
  1314. } llr;
  1315. llr.w64 = acc;
  1316. #ifndef __ARMEB__ /* Little endian */
  1317. __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
  1318. #else /* Big endian */
  1319. __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
  1320. #endif
  1321. return(llr.w64);
  1322. }
  1323. __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
  1324. {
  1325. union llreg_u{
  1326. uint32_t w32[2];
  1327. uint64_t w64;
  1328. } llr;
  1329. llr.w64 = acc;
  1330. #ifndef __ARMEB__ /* Little endian */
  1331. __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
  1332. #else /* Big endian */
  1333. __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
  1334. #endif
  1335. return(llr.w64);
  1336. }
  1337. __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
  1338. {
  1339. uint32_t result;
  1340. __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1341. return(result);
  1342. }
  1343. __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
  1344. {
  1345. int32_t result;
  1346. __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1347. return(result);
  1348. }
  1349. __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
  1350. {
  1351. int32_t result;
  1352. __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  1353. return(result);
  1354. }
  1355. #if 0
  1356. #define __PKHBT(ARG1,ARG2,ARG3) \
  1357. ({ \
  1358. uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
  1359. __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
  1360. __RES; \
  1361. })
  1362. #define __PKHTB(ARG1,ARG2,ARG3) \
  1363. ({ \
  1364. uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
  1365. if (ARG3 == 0) \
  1366. __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
  1367. else \
  1368. __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
  1369. __RES; \
  1370. })
  1371. #endif
  1372. #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
  1373. ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
  1374. #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
  1375. ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
  1376. __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
  1377. {
  1378. int32_t result;
  1379. __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
  1380. return(result);
  1381. }
  1382. #endif /* (__ARM_FEATURE_DSP == 1) */
  1383. /*@} end of group CMSIS_SIMD_intrinsics */
  1384. #endif /* __CMSIS_ARMCLANG_H */