cmsis_clang.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. /**************************************************************************//**
  2. * @file cmsis_clang.h
  3. * @brief CMSIS compiler LLVM/Clang header file
  4. * @version V6.0.0
  5. * @date 27. July 2024
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2023 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_CLANG_H
  25. #define __CMSIS_CLANG_H
  26. #pragma clang system_header /* treat file as system include file */
  27. #if (__ARM_ACLE >= 200)
  28. #include <arm_acle.h>
  29. #else
  30. #error Compiler must support ACLE V2.0
  31. #endif /* (__ARM_ACLE >= 200) */
  32. /* Fallback for __has_builtin */
  33. #ifndef __has_builtin
  34. #define __has_builtin(x) (0)
  35. #endif
  36. /* CMSIS compiler specific defines */
  37. #ifndef __ASM
  38. #define __ASM __asm
  39. #endif
  40. #ifndef __INLINE
  41. #define __INLINE inline
  42. #endif
  43. #ifndef __STATIC_INLINE
  44. #define __STATIC_INLINE static inline
  45. #endif
  46. #ifndef __STATIC_FORCEINLINE
  47. #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
  48. #endif
  49. #ifndef __NO_RETURN
  50. #define __NO_RETURN __attribute__((__noreturn__))
  51. #endif
  52. #ifndef CMSIS_DEPRECATED
  53. #define CMSIS_DEPRECATED __attribute__((deprecated))
  54. #endif
  55. #ifndef __USED
  56. #define __USED __attribute__((used))
  57. #endif
  58. #ifndef __WEAK
  59. #define __WEAK __attribute__((weak))
  60. #endif
  61. #ifndef __PACKED
  62. #define __PACKED __attribute__((packed, aligned(1)))
  63. #endif
  64. #ifndef __PACKED_STRUCT
  65. #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
  66. #endif
  67. #ifndef __PACKED_UNION
  68. #define __PACKED_UNION union __attribute__((packed, aligned(1)))
  69. #endif
  70. #ifndef __UNALIGNED_UINT16_WRITE
  71. #pragma clang diagnostic push
  72. #pragma clang diagnostic ignored "-Wpacked"
  73. __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
  74. #pragma clang diagnostic pop
  75. #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
  76. #endif
  77. #ifndef __UNALIGNED_UINT16_READ
  78. #pragma clang diagnostic push
  79. #pragma clang diagnostic ignored "-Wpacked"
  80. __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
  81. #pragma clang diagnostic pop
  82. #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
  83. #endif
  84. #ifndef __UNALIGNED_UINT32_WRITE
  85. #pragma clang diagnostic push
  86. #pragma clang diagnostic ignored "-Wpacked"
  87. __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
  88. #pragma clang diagnostic pop
  89. #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
  90. #endif
  91. #ifndef __UNALIGNED_UINT32_READ
  92. #pragma clang diagnostic push
  93. #pragma clang diagnostic ignored "-Wpacked"
  94. __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
  95. #pragma clang diagnostic pop
  96. #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
  97. #endif
  98. #ifndef __ALIGNED
  99. #define __ALIGNED(x) __attribute__((aligned(x)))
  100. #endif
  101. #ifndef __RESTRICT
  102. #define __RESTRICT __restrict
  103. #endif
  104. #ifndef __COMPILER_BARRIER
  105. #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
  106. #endif
  107. #ifndef __NO_INIT
  108. #define __NO_INIT __attribute__ ((section (".noinit")))
  109. #endif
  110. #ifndef __ALIAS
  111. #define __ALIAS(x) __attribute__ ((alias(x)))
  112. #endif
  113. /* ########################## Core Instruction Access ######################### */
  114. /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
  115. Access to dedicated instructions
  116. @{
  117. */
  118. /* Define macros for porting to both thumb1 and thumb2.
  119. * For thumb1, use low register (r0-r7), specified by constraint "l"
  120. * Otherwise, use general registers, specified by constraint "r" */
  121. #if defined (__thumb__) && !defined (__thumb2__)
  122. #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
  123. #define __CMSIS_GCC_RW_REG(r) "+l" (r)
  124. #define __CMSIS_GCC_USE_REG(r) "l" (r)
  125. #else
  126. #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
  127. #define __CMSIS_GCC_RW_REG(r) "+r" (r)
  128. #define __CMSIS_GCC_USE_REG(r) "r" (r)
  129. #endif
  130. /**
  131. \brief No Operation
  132. \details No Operation does nothing. This instruction can be used for code alignment purposes.
  133. */
  134. #define __NOP() __nop()
  135. /**
  136. \brief Wait For Interrupt
  137. \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
  138. */
  139. #define __WFI() __wfi()
  140. /**
  141. \brief Wait For Event
  142. \details Wait For Event is a hint instruction that permits the processor to enter
  143. a low-power state until one of a number of events occurs.
  144. */
  145. #define __WFE() __wfe()
  146. /**
  147. \brief Send Event
  148. \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
  149. */
  150. #define __SEV() __sev()
  151. /**
  152. \brief Instruction Synchronization Barrier
  153. \details Instruction Synchronization Barrier flushes the pipeline in the processor,
  154. so that all instructions following the ISB are fetched from cache or memory,
  155. after the instruction has been completed.
  156. */
  157. #define __ISB() __isb(0xF)
  158. /**
  159. \brief Data Synchronization Barrier
  160. \details Acts as a special kind of Data Memory Barrier.
  161. It completes when all explicit memory accesses before this instruction complete.
  162. */
  163. #define __DSB() __dsb(0xF)
  164. /**
  165. \brief Data Memory Barrier
  166. \details Ensures the apparent order of the explicit memory operations before
  167. and after the instruction, without ensuring their completion.
  168. */
  169. #define __DMB() __dmb(0xF)
  170. /**
  171. \brief Reverse byte order (32 bit)
  172. \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
  173. \param [in] value Value to reverse
  174. \return Reversed value
  175. */
  176. #define __REV(value) __rev(value)
  177. /**
  178. \brief Reverse byte order (16 bit)
  179. \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
  180. \param [in] value Value to reverse
  181. \return Reversed value
  182. */
  183. #define __REV16(value) __rev16(value)
  184. /**
  185. \brief Reverse byte order (16 bit)
  186. \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
  187. \param [in] value Value to reverse
  188. \return Reversed value
  189. */
  190. #define __REVSH(value) __revsh(value)
  191. /**
  192. \brief Rotate Right in unsigned value (32 bit)
  193. \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
  194. \param [in] op1 Value to rotate
  195. \param [in] op2 Number of Bits to rotate
  196. \return Rotated value
  197. */
  198. #define __ROR(op1, op2) __ror(op1, op2)
  199. /**
  200. \brief Breakpoint
  201. \details Causes the processor to enter Debug state.
  202. Debug tools can use this to investigate system state when the instruction at a particular address is reached.
  203. \param [in] value is ignored by the processor.
  204. If required, a debugger can use it to store additional information about the breakpoint.
  205. */
  206. #define __BKPT(value) __ASM volatile ("bkpt "#value)
  207. /**
  208. \brief Reverse bit order of value
  209. \details Reverses the bit order of the given value.
  210. \param [in] value Value to reverse
  211. \return Reversed value
  212. */
  213. #define __RBIT(value) __rbit(value)
  214. /**
  215. \brief Count leading zeros
  216. \details Counts the number of leading zeros of a data value.
  217. \param [in] value Value to count the leading zeros
  218. \return number of leading zeros in value
  219. */
  220. #define __CLZ(value) __clz(value)
  221. #if ((__ARM_FEATURE_SAT >= 1) && \
  222. (__ARM_ARCH_ISA_THUMB >= 2) )
  223. /* __ARM_FEATURE_SAT is wrong for Armv8-M Baseline devices */
  224. /**
  225. \brief Signed Saturate
  226. \details Saturates a signed value.
  227. \param [in] value Value to be saturated
  228. \param [in] sat Bit position to saturate to (1..32)
  229. \return Saturated value
  230. */
  231. #define __SSAT(value, sat) __ssat(value, sat)
  232. /**
  233. \brief Unsigned Saturate
  234. \details Saturates an unsigned value.
  235. \param [in] value Value to be saturated
  236. \param [in] sat Bit position to saturate to (0..31)
  237. \return Saturated value
  238. */
  239. #define __USAT(value, sat) __usat(value, sat)
  240. #else /* (__ARM_FEATURE_SAT >= 1) */
  241. /**
  242. \brief Signed Saturate
  243. \details Saturates a signed value.
  244. \param [in] value Value to be saturated
  245. \param [in] sat Bit position to saturate to (1..32)
  246. \return Saturated value
  247. */
  248. __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
  249. {
  250. if ((sat >= 1U) && (sat <= 32U))
  251. {
  252. const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
  253. const int32_t min = -1 - max ;
  254. if (val > max)
  255. {
  256. return (max);
  257. }
  258. else if (val < min)
  259. {
  260. return (min);
  261. }
  262. }
  263. return (val);
  264. }
  265. /**
  266. \brief Unsigned Saturate
  267. \details Saturates an unsigned value.
  268. \param [in] value Value to be saturated
  269. \param [in] sat Bit position to saturate to (0..31)
  270. \return Saturated value
  271. */
  272. __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
  273. {
  274. if (sat <= 31U)
  275. {
  276. const uint32_t max = ((1U << sat) - 1U);
  277. if (val > (int32_t)max)
  278. {
  279. return (max);
  280. }
  281. else if (val < 0)
  282. {
  283. return (0U);
  284. }
  285. }
  286. return ((uint32_t)val);
  287. }
  288. #endif /* (__ARM_FEATURE_SAT >= 1) */
  289. #if (__ARM_FEATURE_LDREX >= 1)
  290. /**
  291. \brief Remove the exclusive lock
  292. \details Removes the exclusive lock which is created by LDREX.
  293. */
  294. #define __CLREX __builtin_arm_clrex
  295. /**
  296. \brief LDR Exclusive (8 bit)
  297. \details Executes a exclusive LDR instruction for 8 bit value.
  298. \param [in] ptr Pointer to data
  299. \return value of type uint8_t at (*ptr)
  300. */
  301. #define __LDREXB (uint8_t)__builtin_arm_ldrex
  302. /**
  303. \brief STR Exclusive (8 bit)
  304. \details Executes a exclusive STR instruction for 8 bit values.
  305. \param [in] value Value to store
  306. \param [in] ptr Pointer to location
  307. \return 0 Function succeeded
  308. \return 1 Function failed
  309. */
  310. #define __STREXB (uint32_t)__builtin_arm_strex
  311. #endif /* (__ARM_FEATURE_LDREX >= 1) */
  312. #if (__ARM_FEATURE_LDREX >= 2)
  313. /**
  314. \brief LDR Exclusive (16 bit)
  315. \details Executes a exclusive LDR instruction for 16 bit values.
  316. \param [in] ptr Pointer to data
  317. \return value of type uint16_t at (*ptr)
  318. */
  319. #define __LDREXH (uint16_t)__builtin_arm_ldrex
  320. /**
  321. \brief STR Exclusive (16 bit)
  322. \details Executes a exclusive STR instruction for 16 bit values.
  323. \param [in] value Value to store
  324. \param [in] ptr Pointer to location
  325. \return 0 Function succeeded
  326. \return 1 Function failed
  327. */
  328. #define __STREXH (uint32_t)__builtin_arm_strex
  329. #endif /* (__ARM_FEATURE_LDREX >= 2) */
  330. #if (__ARM_FEATURE_LDREX >= 4)
  331. /**
  332. \brief LDR Exclusive (32 bit)
  333. \details Executes a exclusive LDR instruction for 32 bit values.
  334. \param [in] ptr Pointer to data
  335. \return value of type uint32_t at (*ptr)
  336. */
  337. #define __LDREXW (uint32_t)__builtin_arm_ldrex
  338. /**
  339. \brief STR Exclusive (32 bit)
  340. \details Executes a exclusive STR instruction for 32 bit values.
  341. \param [in] value Value to store
  342. \param [in] ptr Pointer to location
  343. \return 0 Function succeeded
  344. \return 1 Function failed
  345. */
  346. #define __STREXW (uint32_t)__builtin_arm_strex
  347. #endif /* (__ARM_FEATURE_LDREX >= 4) */
  348. #if (__ARM_ARCH_ISA_THUMB >= 2)
  349. /**
  350. \brief Rotate Right with Extend (32 bit)
  351. \details Moves each bit of a bitstring right by one bit.
  352. The carry input is shifted in at the left end of the bitstring.
  353. \param [in] value Value to rotate
  354. \return Rotated value
  355. */
  356. __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
  357. {
  358. uint32_t result;
  359. __ASM volatile ("rrx %0, %1" : "=r" (result) : "r" (value));
  360. return (result);
  361. }
  362. /**
  363. \brief LDRT Unprivileged (8 bit)
  364. \details Executes a Unprivileged LDRT instruction for 8 bit value.
  365. \param [in] ptr Pointer to data
  366. \return value of type uint8_t at (*ptr)
  367. */
  368. __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
  369. {
  370. uint32_t result;
  371. __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
  372. return ((uint8_t)result); /* Add explicit type cast here */
  373. }
  374. /**
  375. \brief LDRT Unprivileged (16 bit)
  376. \details Executes a Unprivileged LDRT instruction for 16 bit values.
  377. \param [in] ptr Pointer to data
  378. \return value of type uint16_t at (*ptr)
  379. */
  380. __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
  381. {
  382. uint32_t result;
  383. __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
  384. return ((uint16_t)result); /* Add explicit type cast here */
  385. }
  386. /**
  387. \brief LDRT Unprivileged (32 bit)
  388. \details Executes a Unprivileged LDRT instruction for 32 bit values.
  389. \param [in] ptr Pointer to data
  390. \return value of type uint32_t at (*ptr)
  391. */
  392. __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
  393. {
  394. uint32_t result;
  395. __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
  396. return (result);
  397. }
  398. #endif /* (__ARM_ARCH_ISA_THUMB >= 2) */
  399. #if (__ARM_ARCH >= 8)
  400. /**
  401. \brief Load-Acquire (8 bit)
  402. \details Executes a LDAB instruction for 8 bit value.
  403. \param [in] ptr Pointer to data
  404. \return value of type uint8_t at (*ptr)
  405. */
  406. __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
  407. {
  408. uint32_t result;
  409. __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
  410. return ((uint8_t)result); /* Add explicit type cast here */
  411. }
  412. /**
  413. \brief Load-Acquire (16 bit)
  414. \details Executes a LDAH instruction for 16 bit values.
  415. \param [in] ptr Pointer to data
  416. \return value of type uint16_t at (*ptr)
  417. */
  418. __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
  419. {
  420. uint32_t result;
  421. __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
  422. return ((uint16_t)result); /* Add explicit type cast here */
  423. }
  424. /**
  425. \brief Load-Acquire (32 bit)
  426. \details Executes a LDA instruction for 32 bit values.
  427. \param [in] ptr Pointer to data
  428. \return value of type uint32_t at (*ptr)
  429. */
  430. __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
  431. {
  432. uint32_t result;
  433. __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
  434. return (result);
  435. }
  436. /**
  437. \brief Store-Release (8 bit)
  438. \details Executes a STLB instruction for 8 bit values.
  439. \param [in] value Value to store
  440. \param [in] ptr Pointer to location
  441. */
  442. __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
  443. {
  444. __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
  445. }
  446. /**
  447. \brief Store-Release (16 bit)
  448. \details Executes a STLH instruction for 16 bit values.
  449. \param [in] value Value to store
  450. \param [in] ptr Pointer to location
  451. */
  452. __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
  453. {
  454. __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
  455. }
  456. /**
  457. \brief Store-Release (32 bit)
  458. \details Executes a STL instruction for 32 bit values.
  459. \param [in] value Value to store
  460. \param [in] ptr Pointer to location
  461. */
  462. __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
  463. {
  464. __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
  465. }
  466. /**
  467. \brief Load-Acquire Exclusive (8 bit)
  468. \details Executes a LDAB exclusive instruction for 8 bit value.
  469. \param [in] ptr Pointer to data
  470. \return value of type uint8_t at (*ptr)
  471. */
  472. #define __LDAEXB (uint8_t)__builtin_arm_ldaex
  473. /**
  474. \brief Load-Acquire Exclusive (16 bit)
  475. \details Executes a LDAH exclusive instruction for 16 bit values.
  476. \param [in] ptr Pointer to data
  477. \return value of type uint16_t at (*ptr)
  478. */
  479. #define __LDAEXH (uint16_t)__builtin_arm_ldaex
  480. /**
  481. \brief Load-Acquire Exclusive (32 bit)
  482. \details Executes a LDA exclusive instruction for 32 bit values.
  483. \param [in] ptr Pointer to data
  484. \return value of type uint32_t at (*ptr)
  485. */
  486. #define __LDAEX (uint32_t)__builtin_arm_ldaex
  487. /**
  488. \brief Store-Release Exclusive (8 bit)
  489. \details Executes a STLB exclusive instruction for 8 bit values.
  490. \param [in] value Value to store
  491. \param [in] ptr Pointer to location
  492. \return 0 Function succeeded
  493. \return 1 Function failed
  494. */
  495. #define __STLEXB (uint32_t)__builtin_arm_stlex
  496. /**
  497. \brief Store-Release Exclusive (16 bit)
  498. \details Executes a STLH exclusive instruction for 16 bit values.
  499. \param [in] value Value to store
  500. \param [in] ptr Pointer to location
  501. \return 0 Function succeeded
  502. \return 1 Function failed
  503. */
  504. #define __STLEXH (uint32_t)__builtin_arm_stlex
  505. /**
  506. \brief Store-Release Exclusive (32 bit)
  507. \details Executes a STL exclusive instruction for 32 bit values.
  508. \param [in] value Value to store
  509. \param [in] ptr Pointer to location
  510. \return 0 Function succeeded
  511. \return 1 Function failed
  512. */
  513. #define __STLEX (uint32_t)__builtin_arm_stlex
  514. #endif /* (__ARM_ARCH >= 8) */
  515. /** @}*/ /* end of group CMSIS_Core_InstructionInterface */
  516. /* ########################### Core Function Access ########################### */
  517. /** \ingroup CMSIS_Core_FunctionInterface
  518. \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
  519. @{
  520. */
  521. /**
  522. \brief Enable IRQ Interrupts
  523. \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
  524. Can only be executed in Privileged modes.
  525. */
  526. __STATIC_FORCEINLINE void __enable_irq(void)
  527. {
  528. __ASM volatile ("cpsie i" : : : "memory");
  529. }
  530. /**
  531. \brief Disable IRQ Interrupts
  532. \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
  533. Can only be executed in Privileged modes.
  534. */
  535. __STATIC_FORCEINLINE void __disable_irq(void)
  536. {
  537. __ASM volatile ("cpsid i" : : : "memory");
  538. }
  539. #if (__ARM_ARCH_ISA_THUMB >= 2)
  540. /**
  541. \brief Enable FIQ
  542. \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
  543. Can only be executed in Privileged modes.
  544. */
  545. __STATIC_FORCEINLINE void __enable_fault_irq(void)
  546. {
  547. __ASM volatile ("cpsie f" : : : "memory");
  548. }
  549. /**
  550. \brief Disable FIQ
  551. \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
  552. Can only be executed in Privileged modes.
  553. */
  554. __STATIC_FORCEINLINE void __disable_fault_irq(void)
  555. {
  556. __ASM volatile ("cpsid f" : : : "memory");
  557. }
  558. #endif
  559. /**
  560. \brief Get FPSCR
  561. \details Returns the current value of the Floating Point Status/Control register.
  562. \return Floating Point Status/Control register value
  563. */
  564. __STATIC_FORCEINLINE uint32_t __get_FPSCR(void)
  565. {
  566. #if (defined(__ARM_FP) && (__ARM_FP >= 1))
  567. return (__builtin_arm_get_fpscr());
  568. #else
  569. return (0U);
  570. #endif
  571. }
  572. /**
  573. \brief Set FPSCR
  574. \details Assigns the given value to the Floating Point Status/Control register.
  575. \param [in] fpscr Floating Point Status/Control value to set
  576. */
  577. __STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr)
  578. {
  579. #if (defined(__ARM_FP) && (__ARM_FP >= 1))
  580. __builtin_arm_set_fpscr(fpscr);
  581. #else
  582. (void)fpscr;
  583. #endif
  584. }
  585. /** @} end of CMSIS_Core_RegAccFunctions */
  586. // Include the profile specific settings:
  587. #if __ARM_ARCH_PROFILE == 'A'
  588. #include "./a-profile/cmsis_clang_a.h"
  589. #elif __ARM_ARCH_PROFILE == 'R'
  590. #include "./r-profile/cmsis_clang_r.h"
  591. #elif __ARM_ARCH_PROFILE == 'M'
  592. #include "./m-profile/cmsis_clang_m.h"
  593. #else
  594. #error "Unknown Arm architecture profile"
  595. #endif
  596. #endif /* __CMSIS_CLANG_H */