cmsis_armclang.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /**************************************************************************//**
  2. * @file cmsis_armclang.h
  3. * @brief CMSIS compiler specific macros, functions, instructions
  4. * @version V1.2.1
  5. * @date 05. May 2021
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2021 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. /* CMSIS compiler specific defines */
  28. #ifndef __ASM
  29. #define __ASM __asm
  30. #endif
  31. #ifndef __INLINE
  32. #define __INLINE __inline
  33. #endif
  34. #ifndef __FORCEINLINE
  35. #define __FORCEINLINE __attribute__((always_inline))
  36. #endif
  37. #ifndef __STATIC_INLINE
  38. #define __STATIC_INLINE static __inline
  39. #endif
  40. #ifndef __STATIC_FORCEINLINE
  41. #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline
  42. #endif
  43. #ifndef __NO_RETURN
  44. #define __NO_RETURN __attribute__((__noreturn__))
  45. #endif
  46. #ifndef CMSIS_DEPRECATED
  47. #define CMSIS_DEPRECATED __attribute__((deprecated))
  48. #endif
  49. #ifndef __USED
  50. #define __USED __attribute__((used))
  51. #endif
  52. #ifndef __WEAK
  53. #define __WEAK __attribute__((weak))
  54. #endif
  55. #ifndef __PACKED
  56. #define __PACKED __attribute__((packed, aligned(1)))
  57. #endif
  58. #ifndef __PACKED_STRUCT
  59. #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
  60. #endif
  61. #ifndef __UNALIGNED_UINT16_WRITE
  62. #pragma clang diagnostic push
  63. #pragma clang diagnostic ignored "-Wpacked"
  64. /*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */
  65. __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
  66. #pragma clang diagnostic pop
  67. #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
  68. #endif
  69. #ifndef __UNALIGNED_UINT16_READ
  70. #pragma clang diagnostic push
  71. #pragma clang diagnostic ignored "-Wpacked"
  72. /*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */
  73. __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
  74. #pragma clang diagnostic pop
  75. #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
  76. #endif
  77. #ifndef __UNALIGNED_UINT32_WRITE
  78. #pragma clang diagnostic push
  79. #pragma clang diagnostic ignored "-Wpacked"
  80. /*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */
  81. __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
  82. #pragma clang diagnostic pop
  83. #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
  84. #endif
  85. #ifndef __UNALIGNED_UINT32_READ
  86. #pragma clang diagnostic push
  87. #pragma clang diagnostic ignored "-Wpacked"
  88. __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
  89. #pragma clang diagnostic pop
  90. #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
  91. #endif
  92. #ifndef __ALIGNED
  93. #define __ALIGNED(x) __attribute__((aligned(x)))
  94. #endif
  95. #ifndef __PACKED
  96. #define __PACKED __attribute__((packed))
  97. #endif
  98. #ifndef __COMPILER_BARRIER
  99. #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
  100. #endif
  101. /* ########################## Core Instruction Access ######################### */
  102. /**
  103. \brief No Operation
  104. */
  105. #define __NOP __builtin_arm_nop
  106. /**
  107. \brief Wait For Interrupt
  108. */
  109. #define __WFI __builtin_arm_wfi
  110. /**
  111. \brief Wait For Event
  112. */
  113. #define __WFE __builtin_arm_wfe
  114. /**
  115. \brief Send Event
  116. */
  117. #define __SEV __builtin_arm_sev
  118. /**
  119. \brief Instruction Synchronization Barrier
  120. */
  121. #define __ISB() __builtin_arm_isb(0xF)
  122. /**
  123. \brief Data Synchronization Barrier
  124. */
  125. #define __DSB() __builtin_arm_dsb(0xF)
  126. /**
  127. \brief Data Memory Barrier
  128. */
  129. #define __DMB() __builtin_arm_dmb(0xF)
  130. /**
  131. \brief Reverse byte order (32 bit)
  132. \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
  133. \param [in] value Value to reverse
  134. \return Reversed value
  135. */
  136. #define __REV(value) __builtin_bswap32(value)
  137. /**
  138. \brief Reverse byte order (16 bit)
  139. \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
  140. \param [in] value Value to reverse
  141. \return Reversed value
  142. */
  143. #define __REV16(value) __ROR(__REV(value), 16)
  144. /**
  145. \brief Reverse byte order (16 bit)
  146. \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
  147. \param [in] value Value to reverse
  148. \return Reversed value
  149. */
  150. #define __REVSH(value) (int16_t)__builtin_bswap16(value)
  151. /**
  152. \brief Rotate Right in unsigned value (32 bit)
  153. \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
  154. \param [in] op1 Value to rotate
  155. \param [in] op2 Number of Bits to rotate
  156. \return Rotated value
  157. */
  158. __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
  159. {
  160. op2 %= 32U;
  161. if (op2 == 0U)
  162. {
  163. return op1;
  164. }
  165. return (op1 >> op2) | (op1 << (32U - op2));
  166. }
  167. /**
  168. \brief Breakpoint
  169. \param [in] value is ignored by the processor.
  170. If required, a debugger can use it to store additional information about the breakpoint.
  171. */
  172. #define __BKPT(value) __ASM volatile ("bkpt "#value)
  173. /**
  174. \brief Reverse bit order of value
  175. \param [in] value Value to reverse
  176. \return Reversed value
  177. */
  178. #define __RBIT __builtin_arm_rbit
  179. /**
  180. \brief Count leading zeros
  181. \param [in] value Value to count the leading zeros
  182. \return number of leading zeros in value
  183. */
  184. __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
  185. {
  186. /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
  187. __builtin_clz(0) is undefined behaviour, so handle this case specially.
  188. This guarantees ARM-compatible results if happening to compile on a non-ARM
  189. target, and ensures the compiler doesn't decide to activate any
  190. optimisations using the logic "value was passed to __builtin_clz, so it
  191. is non-zero".
  192. ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
  193. single CLZ instruction.
  194. */
  195. if (value == 0U)
  196. {
  197. return 32U;
  198. }
  199. return __builtin_clz(value);
  200. }
  201. /**
  202. \brief LDR Exclusive (8 bit)
  203. \details Executes a exclusive LDR instruction for 8 bit value.
  204. \param [in] ptr Pointer to data
  205. \return value of type uint8_t at (*ptr)
  206. */
  207. #define __LDREXB (uint8_t)__builtin_arm_ldrex
  208. /**
  209. \brief LDR Exclusive (16 bit)
  210. \details Executes a exclusive LDR instruction for 16 bit values.
  211. \param [in] ptr Pointer to data
  212. \return value of type uint16_t at (*ptr)
  213. */
  214. #define __LDREXH (uint16_t)__builtin_arm_ldrex
  215. /**
  216. \brief LDR Exclusive (32 bit)
  217. \details Executes a exclusive LDR instruction for 32 bit values.
  218. \param [in] ptr Pointer to data
  219. \return value of type uint32_t at (*ptr)
  220. */
  221. #define __LDREXW (uint32_t)__builtin_arm_ldrex
  222. /**
  223. \brief STR Exclusive (8 bit)
  224. \details Executes a exclusive STR instruction for 8 bit values.
  225. \param [in] value Value to store
  226. \param [in] ptr Pointer to location
  227. \return 0 Function succeeded
  228. \return 1 Function failed
  229. */
  230. #define __STREXB (uint32_t)__builtin_arm_strex
  231. /**
  232. \brief STR Exclusive (16 bit)
  233. \details Executes a exclusive STR instruction for 16 bit values.
  234. \param [in] value Value to store
  235. \param [in] ptr Pointer to location
  236. \return 0 Function succeeded
  237. \return 1 Function failed
  238. */
  239. #define __STREXH (uint32_t)__builtin_arm_strex
  240. /**
  241. \brief STR Exclusive (32 bit)
  242. \details Executes a exclusive STR instruction for 32 bit values.
  243. \param [in] value Value to store
  244. \param [in] ptr Pointer to location
  245. \return 0 Function succeeded
  246. \return 1 Function failed
  247. */
  248. #define __STREXW (uint32_t)__builtin_arm_strex
  249. /**
  250. \brief Remove the exclusive lock
  251. \details Removes the exclusive lock which is created by LDREX.
  252. */
  253. #define __CLREX __builtin_arm_clrex
  254. /**
  255. \brief Signed Saturate
  256. \details Saturates a signed value.
  257. \param [in] value Value to be saturated
  258. \param [in] sat Bit position to saturate to (1..32)
  259. \return Saturated value
  260. */
  261. #define __SSAT __builtin_arm_ssat
  262. /**
  263. \brief Unsigned Saturate
  264. \details Saturates an unsigned value.
  265. \param [in] value Value to be saturated
  266. \param [in] sat Bit position to saturate to (0..31)
  267. \return Saturated value
  268. */
  269. #define __USAT __builtin_arm_usat
  270. /* ################### Compiler specific Intrinsics ########################### */
  271. /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
  272. Access to dedicated SIMD instructions
  273. @{
  274. */
  275. #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
  276. #define __SADD8 __builtin_arm_sadd8
  277. #define __SADD16 __builtin_arm_sadd16
  278. #define __QADD8 __builtin_arm_qadd8
  279. #define __QSUB8 __builtin_arm_qsub8
  280. #define __QADD16 __builtin_arm_qadd16
  281. #define __SHADD16 __builtin_arm_shadd16
  282. #define __QSUB16 __builtin_arm_qsub16
  283. #define __SHSUB16 __builtin_arm_shsub16
  284. #define __QASX __builtin_arm_qasx
  285. #define __SHASX __builtin_arm_shasx
  286. #define __QSAX __builtin_arm_qsax
  287. #define __SHSAX __builtin_arm_shsax
  288. #define __SXTB16 __builtin_arm_sxtb16
  289. #define __SMUAD __builtin_arm_smuad
  290. #define __SMUADX __builtin_arm_smuadx
  291. #define __SMLAD __builtin_arm_smlad
  292. #define __SMLADX __builtin_arm_smladx
  293. #define __SMLALD __builtin_arm_smlald
  294. #define __SMLALDX __builtin_arm_smlaldx
  295. #define __SMUSD __builtin_arm_smusd
  296. #define __SMUSDX __builtin_arm_smusdx
  297. #define __SMLSDX __builtin_arm_smlsdx
  298. #define __USAT16 __builtin_arm_usat16
  299. #define __SSUB8 __builtin_arm_ssub8
  300. #define __SXTB16 __builtin_arm_sxtb16
  301. #define __SXTAB16 __builtin_arm_sxtab16
  302. __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2)
  303. {
  304. int32_t result;
  305. __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  306. return(result);
  307. }
  308. __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2)
  309. {
  310. int32_t result;
  311. __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
  312. return(result);
  313. }
  314. #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
  315. ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
  316. #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
  317. ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
  318. __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
  319. {
  320. int32_t result;
  321. __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
  322. return(result);
  323. }
  324. #endif /* (__ARM_FEATURE_DSP == 1) */
  325. /* ########################### Core Function Access ########################### */
  326. /**
  327. \brief Enable IRQ Interrupts
  328. \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
  329. Can only be executed in Privileged modes.
  330. */
  331. __STATIC_FORCEINLINE void __enable_irq(void)
  332. {
  333. __ASM volatile ("cpsie i" : : : "memory");
  334. }
  335. /**
  336. \brief Disable IRQ Interrupts
  337. \details Disables IRQ interrupts by setting the I-bit in the CPSR.
  338. Can only be executed in Privileged modes.
  339. */
  340. __STATIC_FORCEINLINE void __disable_irq(void)
  341. {
  342. __ASM volatile ("cpsid i" : : : "memory");
  343. }
  344. /**
  345. \brief Enable FIQ
  346. \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
  347. Can only be executed in Privileged modes.
  348. */
  349. __STATIC_FORCEINLINE void __enable_fault_irq(void)
  350. {
  351. __ASM volatile ("cpsie f" : : : "memory");
  352. }
  353. /**
  354. \brief Disable FIQ
  355. \details Disables FIQ interrupts by setting the F-bit in the CPSR.
  356. Can only be executed in Privileged modes.
  357. */
  358. __STATIC_FORCEINLINE void __disable_fault_irq(void)
  359. {
  360. __ASM volatile ("cpsid f" : : : "memory");
  361. }
  362. /**
  363. \brief Get FPSCR
  364. \details Returns the current value of the Floating Point Status/Control register.
  365. \return Floating Point Status/Control register value
  366. */
  367. #define __get_FPSCR __builtin_arm_get_fpscr
  368. /**
  369. \brief Set FPSCR
  370. \details Assigns the given value to the Floating Point Status/Control register.
  371. \param [in] fpscr Floating Point Status/Control value to set
  372. */
  373. #define __set_FPSCR __builtin_arm_set_fpscr
  374. /** \brief Get CPSR Register
  375. \return CPSR Register value
  376. */
  377. __STATIC_FORCEINLINE uint32_t __get_CPSR(void)
  378. {
  379. uint32_t result;
  380. __ASM volatile("MRS %0, cpsr" : "=r" (result) );
  381. return(result);
  382. }
  383. /** \brief Set CPSR Register
  384. \param [in] cpsr CPSR value to set
  385. */
  386. __STATIC_FORCEINLINE void __set_CPSR(uint32_t cpsr)
  387. {
  388. __ASM volatile ("MSR cpsr, %0" : : "r" (cpsr) : "cc", "memory");
  389. }
  390. /** \brief Get Mode
  391. \return Processor Mode
  392. */
  393. __STATIC_FORCEINLINE uint32_t __get_mode(void)
  394. {
  395. return (__get_CPSR() & 0x1FU);
  396. }
  397. /** \brief Set Mode
  398. \param [in] mode Mode value to set
  399. */
  400. __STATIC_FORCEINLINE void __set_mode(uint32_t mode)
  401. {
  402. __ASM volatile("MSR cpsr_c, %0" : : "r" (mode) : "memory");
  403. }
  404. /** \brief Get Stack Pointer
  405. \return Stack Pointer value
  406. */
  407. __STATIC_FORCEINLINE uint32_t __get_SP(void)
  408. {
  409. uint32_t result;
  410. __ASM volatile("MOV %0, sp" : "=r" (result) : : "memory");
  411. return result;
  412. }
  413. /** \brief Set Stack Pointer
  414. \param [in] stack Stack Pointer value to set
  415. */
  416. __STATIC_FORCEINLINE void __set_SP(uint32_t stack)
  417. {
  418. __ASM volatile("MOV sp, %0" : : "r" (stack) : "memory");
  419. }
  420. /** \brief Get USR/SYS Stack Pointer
  421. \return USR/SYS Stack Pointer value
  422. */
  423. __STATIC_FORCEINLINE uint32_t __get_SP_usr(void)
  424. {
  425. uint32_t cpsr;
  426. uint32_t result;
  427. __ASM volatile(
  428. "MRS %0, cpsr \n"
  429. "CPS #0x1F \n" // no effect in USR mode
  430. "MOV %1, sp \n"
  431. "MSR cpsr_c, %0 \n" // no effect in USR mode
  432. "ISB" : "=r"(cpsr), "=r"(result) : : "memory"
  433. );
  434. return result;
  435. }
  436. /** \brief Set USR/SYS Stack Pointer
  437. \param [in] topOfProcStack USR/SYS Stack Pointer value to set
  438. */
  439. __STATIC_FORCEINLINE void __set_SP_usr(uint32_t topOfProcStack)
  440. {
  441. uint32_t cpsr;
  442. __ASM volatile(
  443. "MRS %0, cpsr \n"
  444. "CPS #0x1F \n" // no effect in USR mode
  445. "MOV sp, %1 \n"
  446. "MSR cpsr_c, %0 \n" // no effect in USR mode
  447. "ISB" : "=r"(cpsr) : "r" (topOfProcStack) : "memory"
  448. );
  449. }
  450. /** \brief Get FPEXC
  451. \return Floating Point Exception Control register value
  452. */
  453. __STATIC_FORCEINLINE uint32_t __get_FPEXC(void)
  454. {
  455. #if (__FPU_PRESENT == 1)
  456. uint32_t result;
  457. __ASM volatile("VMRS %0, fpexc" : "=r" (result) : : "memory");
  458. return(result);
  459. #else
  460. return(0);
  461. #endif
  462. }
  463. /** \brief Set FPEXC
  464. \param [in] fpexc Floating Point Exception Control value to set
  465. */
  466. __STATIC_FORCEINLINE void __set_FPEXC(uint32_t fpexc)
  467. {
  468. #if (__FPU_PRESENT == 1)
  469. __ASM volatile ("VMSR fpexc, %0" : : "r" (fpexc) : "memory");
  470. #endif
  471. }
  472. /*
  473. * Include common core functions to access Coprocessor 15 registers
  474. */
  475. #define __get_CP(cp, op1, Rt, CRn, CRm, op2) __ASM volatile("MRC p" # cp ", " # op1 ", %0, c" # CRn ", c" # CRm ", " # op2 : "=r" (Rt) : : "memory" )
  476. #define __set_CP(cp, op1, Rt, CRn, CRm, op2) __ASM volatile("MCR p" # cp ", " # op1 ", %0, c" # CRn ", c" # CRm ", " # op2 : : "r" (Rt) : "memory" )
  477. #define __get_CP64(cp, op1, Rt, CRm) __ASM volatile("MRRC p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : "=r" (Rt) : : "memory" )
  478. #define __set_CP64(cp, op1, Rt, CRm) __ASM volatile("MCRR p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : : "r" (Rt) : "memory" )
  479. #include "cmsis_cp15.h"
  480. /** \brief Enable Floating Point Unit
  481. Critical section, called from undef handler, so systick is disabled
  482. */
  483. __STATIC_INLINE void __FPU_Enable(void)
  484. {
  485. __ASM volatile(
  486. //Permit access to VFP/NEON, registers by modifying CPACR
  487. " MRC p15,0,R1,c1,c0,2 \n"
  488. " ORR R1,R1,#0x00F00000 \n"
  489. " MCR p15,0,R1,c1,c0,2 \n"
  490. //Ensure that subsequent instructions occur in the context of VFP/NEON access permitted
  491. " ISB \n"
  492. //Enable VFP/NEON
  493. " VMRS R1,FPEXC \n"
  494. " ORR R1,R1,#0x40000000 \n"
  495. " VMSR FPEXC,R1 \n"
  496. //Initialise VFP/NEON registers to 0
  497. " MOV R2,#0 \n"
  498. //Initialise D16 registers to 0
  499. " VMOV D0, R2,R2 \n"
  500. " VMOV D1, R2,R2 \n"
  501. " VMOV D2, R2,R2 \n"
  502. " VMOV D3, R2,R2 \n"
  503. " VMOV D4, R2,R2 \n"
  504. " VMOV D5, R2,R2 \n"
  505. " VMOV D6, R2,R2 \n"
  506. " VMOV D7, R2,R2 \n"
  507. " VMOV D8, R2,R2 \n"
  508. " VMOV D9, R2,R2 \n"
  509. " VMOV D10,R2,R2 \n"
  510. " VMOV D11,R2,R2 \n"
  511. " VMOV D12,R2,R2 \n"
  512. " VMOV D13,R2,R2 \n"
  513. " VMOV D14,R2,R2 \n"
  514. " VMOV D15,R2,R2 \n"
  515. #if (defined(__ARM_NEON) && (__ARM_NEON == 1))
  516. //Initialise D32 registers to 0
  517. " VMOV D16,R2,R2 \n"
  518. " VMOV D17,R2,R2 \n"
  519. " VMOV D18,R2,R2 \n"
  520. " VMOV D19,R2,R2 \n"
  521. " VMOV D20,R2,R2 \n"
  522. " VMOV D21,R2,R2 \n"
  523. " VMOV D22,R2,R2 \n"
  524. " VMOV D23,R2,R2 \n"
  525. " VMOV D24,R2,R2 \n"
  526. " VMOV D25,R2,R2 \n"
  527. " VMOV D26,R2,R2 \n"
  528. " VMOV D27,R2,R2 \n"
  529. " VMOV D28,R2,R2 \n"
  530. " VMOV D29,R2,R2 \n"
  531. " VMOV D30,R2,R2 \n"
  532. " VMOV D31,R2,R2 \n"
  533. #endif
  534. //Initialise FPSCR to a known state
  535. " VMRS R1,FPSCR \n"
  536. " LDR R2,=0x00086060 \n" //Mask off all bits that do not have to be preserved. Non-preserved bits can/should be zero.
  537. " AND R1,R1,R2 \n"
  538. " VMSR FPSCR,R1 "
  539. : : : "cc", "r1", "r2"
  540. );
  541. }
  542. #endif /* __CMSIS_ARMCLANG_H */