cmsis_armclang.h 20 KB

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