mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
Anna Bridge
Date:
Wed Jan 17 15:23:54 2018 +0000
Revision:
180:96ed750bd169
Child:
186:707f6e361f3e
mbed-dev libray. Release version 158

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 180:96ed750bd169 1 /**************************************************************************//**
Anna Bridge 180:96ed750bd169 2 * @file cmsis_armcc.h
Anna Bridge 180:96ed750bd169 3 * @brief CMSIS compiler ARMCC (ARM compiler V5) header file
Anna Bridge 180:96ed750bd169 4 * @version V5.0.2
Anna Bridge 180:96ed750bd169 5 * @date 13. February 2017
Anna Bridge 180:96ed750bd169 6 ******************************************************************************/
Anna Bridge 180:96ed750bd169 7 /*
Anna Bridge 180:96ed750bd169 8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
Anna Bridge 180:96ed750bd169 9 *
Anna Bridge 180:96ed750bd169 10 * SPDX-License-Identifier: Apache-2.0
Anna Bridge 180:96ed750bd169 11 *
Anna Bridge 180:96ed750bd169 12 * Licensed under the Apache License, Version 2.0 (the License); you may
Anna Bridge 180:96ed750bd169 13 * not use this file except in compliance with the License.
Anna Bridge 180:96ed750bd169 14 * You may obtain a copy of the License at
Anna Bridge 180:96ed750bd169 15 *
Anna Bridge 180:96ed750bd169 16 * www.apache.org/licenses/LICENSE-2.0
Anna Bridge 180:96ed750bd169 17 *
Anna Bridge 180:96ed750bd169 18 * Unless required by applicable law or agreed to in writing, software
Anna Bridge 180:96ed750bd169 19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
Anna Bridge 180:96ed750bd169 20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Anna Bridge 180:96ed750bd169 21 * See the License for the specific language governing permissions and
Anna Bridge 180:96ed750bd169 22 * limitations under the License.
Anna Bridge 180:96ed750bd169 23 */
Anna Bridge 180:96ed750bd169 24
Anna Bridge 180:96ed750bd169 25 #ifndef __CMSIS_ARMCC_H
Anna Bridge 180:96ed750bd169 26 #define __CMSIS_ARMCC_H
Anna Bridge 180:96ed750bd169 27
Anna Bridge 180:96ed750bd169 28
Anna Bridge 180:96ed750bd169 29 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
Anna Bridge 180:96ed750bd169 30 #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
Anna Bridge 180:96ed750bd169 31 #endif
Anna Bridge 180:96ed750bd169 32
Anna Bridge 180:96ed750bd169 33 /* CMSIS compiler control architecture macros */
Anna Bridge 180:96ed750bd169 34 #if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
Anna Bridge 180:96ed750bd169 35 (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
Anna Bridge 180:96ed750bd169 36 #define __ARM_ARCH_6M__ 1
Anna Bridge 180:96ed750bd169 37 #endif
Anna Bridge 180:96ed750bd169 38
Anna Bridge 180:96ed750bd169 39 #if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
Anna Bridge 180:96ed750bd169 40 #define __ARM_ARCH_7M__ 1
Anna Bridge 180:96ed750bd169 41 #endif
Anna Bridge 180:96ed750bd169 42
Anna Bridge 180:96ed750bd169 43 #if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
Anna Bridge 180:96ed750bd169 44 #define __ARM_ARCH_7EM__ 1
Anna Bridge 180:96ed750bd169 45 #endif
Anna Bridge 180:96ed750bd169 46
Anna Bridge 180:96ed750bd169 47 /* __ARM_ARCH_8M_BASE__ not applicable */
Anna Bridge 180:96ed750bd169 48 /* __ARM_ARCH_8M_MAIN__ not applicable */
Anna Bridge 180:96ed750bd169 49
Anna Bridge 180:96ed750bd169 50
Anna Bridge 180:96ed750bd169 51 /* CMSIS compiler specific defines */
Anna Bridge 180:96ed750bd169 52 #ifndef __ASM
Anna Bridge 180:96ed750bd169 53 #define __ASM __asm
Anna Bridge 180:96ed750bd169 54 #endif
Anna Bridge 180:96ed750bd169 55 #ifndef __INLINE
Anna Bridge 180:96ed750bd169 56 #define __INLINE __inline
Anna Bridge 180:96ed750bd169 57 #endif
Anna Bridge 180:96ed750bd169 58 #ifndef __STATIC_INLINE
Anna Bridge 180:96ed750bd169 59 #define __STATIC_INLINE static __inline
Anna Bridge 180:96ed750bd169 60 #endif
Anna Bridge 180:96ed750bd169 61 #ifndef __NO_RETURN
Anna Bridge 180:96ed750bd169 62 #define __NO_RETURN __declspec(noreturn)
Anna Bridge 180:96ed750bd169 63 #endif
Anna Bridge 180:96ed750bd169 64 #ifndef __USED
Anna Bridge 180:96ed750bd169 65 #define __USED __attribute__((used))
Anna Bridge 180:96ed750bd169 66 #endif
Anna Bridge 180:96ed750bd169 67 #ifndef __WEAK
Anna Bridge 180:96ed750bd169 68 #define __WEAK __attribute__((weak))
Anna Bridge 180:96ed750bd169 69 #endif
Anna Bridge 180:96ed750bd169 70 #ifndef __PACKED
Anna Bridge 180:96ed750bd169 71 #define __PACKED __attribute__((packed))
Anna Bridge 180:96ed750bd169 72 #endif
Anna Bridge 180:96ed750bd169 73 #ifndef __PACKED_STRUCT
Anna Bridge 180:96ed750bd169 74 #define __PACKED_STRUCT __packed struct
Anna Bridge 180:96ed750bd169 75 #endif
Anna Bridge 180:96ed750bd169 76 #ifndef __PACKED_UNION
Anna Bridge 180:96ed750bd169 77 #define __PACKED_UNION __packed union
Anna Bridge 180:96ed750bd169 78 #endif
Anna Bridge 180:96ed750bd169 79 #ifndef __UNALIGNED_UINT32 /* deprecated */
Anna Bridge 180:96ed750bd169 80 #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
Anna Bridge 180:96ed750bd169 81 #endif
Anna Bridge 180:96ed750bd169 82 #ifndef __UNALIGNED_UINT16_WRITE
Anna Bridge 180:96ed750bd169 83 #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
Anna Bridge 180:96ed750bd169 84 #endif
Anna Bridge 180:96ed750bd169 85 #ifndef __UNALIGNED_UINT16_READ
Anna Bridge 180:96ed750bd169 86 #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
Anna Bridge 180:96ed750bd169 87 #endif
Anna Bridge 180:96ed750bd169 88 #ifndef __UNALIGNED_UINT32_WRITE
Anna Bridge 180:96ed750bd169 89 #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
Anna Bridge 180:96ed750bd169 90 #endif
Anna Bridge 180:96ed750bd169 91 #ifndef __UNALIGNED_UINT32_READ
Anna Bridge 180:96ed750bd169 92 #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
Anna Bridge 180:96ed750bd169 93 #endif
Anna Bridge 180:96ed750bd169 94 #ifndef __ALIGNED
Anna Bridge 180:96ed750bd169 95 #define __ALIGNED(x) __attribute__((aligned(x)))
Anna Bridge 180:96ed750bd169 96 #endif
Anna Bridge 180:96ed750bd169 97 #ifndef __RESTRICT
Anna Bridge 180:96ed750bd169 98 #define __RESTRICT __restrict
Anna Bridge 180:96ed750bd169 99 #endif
Anna Bridge 180:96ed750bd169 100
Anna Bridge 180:96ed750bd169 101 /* ########################### Core Function Access ########################### */
Anna Bridge 180:96ed750bd169 102 /** \ingroup CMSIS_Core_FunctionInterface
Anna Bridge 180:96ed750bd169 103 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
Anna Bridge 180:96ed750bd169 104 @{
Anna Bridge 180:96ed750bd169 105 */
Anna Bridge 180:96ed750bd169 106
Anna Bridge 180:96ed750bd169 107 /**
Anna Bridge 180:96ed750bd169 108 \brief Enable IRQ Interrupts
Anna Bridge 180:96ed750bd169 109 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
Anna Bridge 180:96ed750bd169 110 Can only be executed in Privileged modes.
Anna Bridge 180:96ed750bd169 111 */
Anna Bridge 180:96ed750bd169 112 /* intrinsic void __enable_irq(); */
Anna Bridge 180:96ed750bd169 113
Anna Bridge 180:96ed750bd169 114
Anna Bridge 180:96ed750bd169 115 /**
Anna Bridge 180:96ed750bd169 116 \brief Disable IRQ Interrupts
Anna Bridge 180:96ed750bd169 117 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
Anna Bridge 180:96ed750bd169 118 Can only be executed in Privileged modes.
Anna Bridge 180:96ed750bd169 119 */
Anna Bridge 180:96ed750bd169 120 /* intrinsic void __disable_irq(); */
Anna Bridge 180:96ed750bd169 121
Anna Bridge 180:96ed750bd169 122 /**
Anna Bridge 180:96ed750bd169 123 \brief Get Control Register
Anna Bridge 180:96ed750bd169 124 \details Returns the content of the Control Register.
Anna Bridge 180:96ed750bd169 125 \return Control Register value
Anna Bridge 180:96ed750bd169 126 */
Anna Bridge 180:96ed750bd169 127 __STATIC_INLINE uint32_t __get_CONTROL(void)
Anna Bridge 180:96ed750bd169 128 {
Anna Bridge 180:96ed750bd169 129 register uint32_t __regControl __ASM("control");
Anna Bridge 180:96ed750bd169 130 return(__regControl);
Anna Bridge 180:96ed750bd169 131 }
Anna Bridge 180:96ed750bd169 132
Anna Bridge 180:96ed750bd169 133
Anna Bridge 180:96ed750bd169 134 /**
Anna Bridge 180:96ed750bd169 135 \brief Set Control Register
Anna Bridge 180:96ed750bd169 136 \details Writes the given value to the Control Register.
Anna Bridge 180:96ed750bd169 137 \param [in] control Control Register value to set
Anna Bridge 180:96ed750bd169 138 */
Anna Bridge 180:96ed750bd169 139 __STATIC_INLINE void __set_CONTROL(uint32_t control)
Anna Bridge 180:96ed750bd169 140 {
Anna Bridge 180:96ed750bd169 141 register uint32_t __regControl __ASM("control");
Anna Bridge 180:96ed750bd169 142 __regControl = control;
Anna Bridge 180:96ed750bd169 143 }
Anna Bridge 180:96ed750bd169 144
Anna Bridge 180:96ed750bd169 145
Anna Bridge 180:96ed750bd169 146 /**
Anna Bridge 180:96ed750bd169 147 \brief Get IPSR Register
Anna Bridge 180:96ed750bd169 148 \details Returns the content of the IPSR Register.
Anna Bridge 180:96ed750bd169 149 \return IPSR Register value
Anna Bridge 180:96ed750bd169 150 */
Anna Bridge 180:96ed750bd169 151 __STATIC_INLINE uint32_t __get_IPSR(void)
Anna Bridge 180:96ed750bd169 152 {
Anna Bridge 180:96ed750bd169 153 register uint32_t __regIPSR __ASM("ipsr");
Anna Bridge 180:96ed750bd169 154 return(__regIPSR);
Anna Bridge 180:96ed750bd169 155 }
Anna Bridge 180:96ed750bd169 156
Anna Bridge 180:96ed750bd169 157
Anna Bridge 180:96ed750bd169 158 /**
Anna Bridge 180:96ed750bd169 159 \brief Get APSR Register
Anna Bridge 180:96ed750bd169 160 \details Returns the content of the APSR Register.
Anna Bridge 180:96ed750bd169 161 \return APSR Register value
Anna Bridge 180:96ed750bd169 162 */
Anna Bridge 180:96ed750bd169 163 __STATIC_INLINE uint32_t __get_APSR(void)
Anna Bridge 180:96ed750bd169 164 {
Anna Bridge 180:96ed750bd169 165 register uint32_t __regAPSR __ASM("apsr");
Anna Bridge 180:96ed750bd169 166 return(__regAPSR);
Anna Bridge 180:96ed750bd169 167 }
Anna Bridge 180:96ed750bd169 168
Anna Bridge 180:96ed750bd169 169
Anna Bridge 180:96ed750bd169 170 /**
Anna Bridge 180:96ed750bd169 171 \brief Get xPSR Register
Anna Bridge 180:96ed750bd169 172 \details Returns the content of the xPSR Register.
Anna Bridge 180:96ed750bd169 173 \return xPSR Register value
Anna Bridge 180:96ed750bd169 174 */
Anna Bridge 180:96ed750bd169 175 __STATIC_INLINE uint32_t __get_xPSR(void)
Anna Bridge 180:96ed750bd169 176 {
Anna Bridge 180:96ed750bd169 177 register uint32_t __regXPSR __ASM("xpsr");
Anna Bridge 180:96ed750bd169 178 return(__regXPSR);
Anna Bridge 180:96ed750bd169 179 }
Anna Bridge 180:96ed750bd169 180
Anna Bridge 180:96ed750bd169 181
Anna Bridge 180:96ed750bd169 182 /**
Anna Bridge 180:96ed750bd169 183 \brief Get Process Stack Pointer
Anna Bridge 180:96ed750bd169 184 \details Returns the current value of the Process Stack Pointer (PSP).
Anna Bridge 180:96ed750bd169 185 \return PSP Register value
Anna Bridge 180:96ed750bd169 186 */
Anna Bridge 180:96ed750bd169 187 __STATIC_INLINE uint32_t __get_PSP(void)
Anna Bridge 180:96ed750bd169 188 {
Anna Bridge 180:96ed750bd169 189 register uint32_t __regProcessStackPointer __ASM("psp");
Anna Bridge 180:96ed750bd169 190 return(__regProcessStackPointer);
Anna Bridge 180:96ed750bd169 191 }
Anna Bridge 180:96ed750bd169 192
Anna Bridge 180:96ed750bd169 193
Anna Bridge 180:96ed750bd169 194 /**
Anna Bridge 180:96ed750bd169 195 \brief Set Process Stack Pointer
Anna Bridge 180:96ed750bd169 196 \details Assigns the given value to the Process Stack Pointer (PSP).
Anna Bridge 180:96ed750bd169 197 \param [in] topOfProcStack Process Stack Pointer value to set
Anna Bridge 180:96ed750bd169 198 */
Anna Bridge 180:96ed750bd169 199 __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Anna Bridge 180:96ed750bd169 200 {
Anna Bridge 180:96ed750bd169 201 register uint32_t __regProcessStackPointer __ASM("psp");
Anna Bridge 180:96ed750bd169 202 __regProcessStackPointer = topOfProcStack;
Anna Bridge 180:96ed750bd169 203 }
Anna Bridge 180:96ed750bd169 204
Anna Bridge 180:96ed750bd169 205
Anna Bridge 180:96ed750bd169 206 /**
Anna Bridge 180:96ed750bd169 207 \brief Get Main Stack Pointer
Anna Bridge 180:96ed750bd169 208 \details Returns the current value of the Main Stack Pointer (MSP).
Anna Bridge 180:96ed750bd169 209 \return MSP Register value
Anna Bridge 180:96ed750bd169 210 */
Anna Bridge 180:96ed750bd169 211 __STATIC_INLINE uint32_t __get_MSP(void)
Anna Bridge 180:96ed750bd169 212 {
Anna Bridge 180:96ed750bd169 213 register uint32_t __regMainStackPointer __ASM("msp");
Anna Bridge 180:96ed750bd169 214 return(__regMainStackPointer);
Anna Bridge 180:96ed750bd169 215 }
Anna Bridge 180:96ed750bd169 216
Anna Bridge 180:96ed750bd169 217
Anna Bridge 180:96ed750bd169 218 /**
Anna Bridge 180:96ed750bd169 219 \brief Set Main Stack Pointer
Anna Bridge 180:96ed750bd169 220 \details Assigns the given value to the Main Stack Pointer (MSP).
Anna Bridge 180:96ed750bd169 221 \param [in] topOfMainStack Main Stack Pointer value to set
Anna Bridge 180:96ed750bd169 222 */
Anna Bridge 180:96ed750bd169 223 __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Anna Bridge 180:96ed750bd169 224 {
Anna Bridge 180:96ed750bd169 225 register uint32_t __regMainStackPointer __ASM("msp");
Anna Bridge 180:96ed750bd169 226 __regMainStackPointer = topOfMainStack;
Anna Bridge 180:96ed750bd169 227 }
Anna Bridge 180:96ed750bd169 228
Anna Bridge 180:96ed750bd169 229
Anna Bridge 180:96ed750bd169 230 /**
Anna Bridge 180:96ed750bd169 231 \brief Get Priority Mask
Anna Bridge 180:96ed750bd169 232 \details Returns the current state of the priority mask bit from the Priority Mask Register.
Anna Bridge 180:96ed750bd169 233 \return Priority Mask value
Anna Bridge 180:96ed750bd169 234 */
Anna Bridge 180:96ed750bd169 235 __STATIC_INLINE uint32_t __get_PRIMASK(void)
Anna Bridge 180:96ed750bd169 236 {
Anna Bridge 180:96ed750bd169 237 register uint32_t __regPriMask __ASM("primask");
Anna Bridge 180:96ed750bd169 238 return(__regPriMask);
Anna Bridge 180:96ed750bd169 239 }
Anna Bridge 180:96ed750bd169 240
Anna Bridge 180:96ed750bd169 241
Anna Bridge 180:96ed750bd169 242 /**
Anna Bridge 180:96ed750bd169 243 \brief Set Priority Mask
Anna Bridge 180:96ed750bd169 244 \details Assigns the given value to the Priority Mask Register.
Anna Bridge 180:96ed750bd169 245 \param [in] priMask Priority Mask
Anna Bridge 180:96ed750bd169 246 */
Anna Bridge 180:96ed750bd169 247 __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Anna Bridge 180:96ed750bd169 248 {
Anna Bridge 180:96ed750bd169 249 register uint32_t __regPriMask __ASM("primask");
Anna Bridge 180:96ed750bd169 250 __regPriMask = (priMask);
Anna Bridge 180:96ed750bd169 251 }
Anna Bridge 180:96ed750bd169 252
Anna Bridge 180:96ed750bd169 253
Anna Bridge 180:96ed750bd169 254 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
Anna Bridge 180:96ed750bd169 255 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
Anna Bridge 180:96ed750bd169 256
Anna Bridge 180:96ed750bd169 257 /**
Anna Bridge 180:96ed750bd169 258 \brief Enable FIQ
Anna Bridge 180:96ed750bd169 259 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
Anna Bridge 180:96ed750bd169 260 Can only be executed in Privileged modes.
Anna Bridge 180:96ed750bd169 261 */
Anna Bridge 180:96ed750bd169 262 #define __enable_fault_irq __enable_fiq
Anna Bridge 180:96ed750bd169 263
Anna Bridge 180:96ed750bd169 264
Anna Bridge 180:96ed750bd169 265 /**
Anna Bridge 180:96ed750bd169 266 \brief Disable FIQ
Anna Bridge 180:96ed750bd169 267 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
Anna Bridge 180:96ed750bd169 268 Can only be executed in Privileged modes.
Anna Bridge 180:96ed750bd169 269 */
Anna Bridge 180:96ed750bd169 270 #define __disable_fault_irq __disable_fiq
Anna Bridge 180:96ed750bd169 271
Anna Bridge 180:96ed750bd169 272
Anna Bridge 180:96ed750bd169 273 /**
Anna Bridge 180:96ed750bd169 274 \brief Get Base Priority
Anna Bridge 180:96ed750bd169 275 \details Returns the current value of the Base Priority register.
Anna Bridge 180:96ed750bd169 276 \return Base Priority register value
Anna Bridge 180:96ed750bd169 277 */
Anna Bridge 180:96ed750bd169 278 __STATIC_INLINE uint32_t __get_BASEPRI(void)
Anna Bridge 180:96ed750bd169 279 {
Anna Bridge 180:96ed750bd169 280 register uint32_t __regBasePri __ASM("basepri");
Anna Bridge 180:96ed750bd169 281 return(__regBasePri);
Anna Bridge 180:96ed750bd169 282 }
Anna Bridge 180:96ed750bd169 283
Anna Bridge 180:96ed750bd169 284
Anna Bridge 180:96ed750bd169 285 /**
Anna Bridge 180:96ed750bd169 286 \brief Set Base Priority
Anna Bridge 180:96ed750bd169 287 \details Assigns the given value to the Base Priority register.
Anna Bridge 180:96ed750bd169 288 \param [in] basePri Base Priority value to set
Anna Bridge 180:96ed750bd169 289 */
Anna Bridge 180:96ed750bd169 290 __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
Anna Bridge 180:96ed750bd169 291 {
Anna Bridge 180:96ed750bd169 292 register uint32_t __regBasePri __ASM("basepri");
Anna Bridge 180:96ed750bd169 293 __regBasePri = (basePri & 0xFFU);
Anna Bridge 180:96ed750bd169 294 }
Anna Bridge 180:96ed750bd169 295
Anna Bridge 180:96ed750bd169 296
Anna Bridge 180:96ed750bd169 297 /**
Anna Bridge 180:96ed750bd169 298 \brief Set Base Priority with condition
Anna Bridge 180:96ed750bd169 299 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
Anna Bridge 180:96ed750bd169 300 or the new value increases the BASEPRI priority level.
Anna Bridge 180:96ed750bd169 301 \param [in] basePri Base Priority value to set
Anna Bridge 180:96ed750bd169 302 */
Anna Bridge 180:96ed750bd169 303 __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
Anna Bridge 180:96ed750bd169 304 {
Anna Bridge 180:96ed750bd169 305 register uint32_t __regBasePriMax __ASM("basepri_max");
Anna Bridge 180:96ed750bd169 306 __regBasePriMax = (basePri & 0xFFU);
Anna Bridge 180:96ed750bd169 307 }
Anna Bridge 180:96ed750bd169 308
Anna Bridge 180:96ed750bd169 309
Anna Bridge 180:96ed750bd169 310 /**
Anna Bridge 180:96ed750bd169 311 \brief Get Fault Mask
Anna Bridge 180:96ed750bd169 312 \details Returns the current value of the Fault Mask register.
Anna Bridge 180:96ed750bd169 313 \return Fault Mask register value
Anna Bridge 180:96ed750bd169 314 */
Anna Bridge 180:96ed750bd169 315 __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Anna Bridge 180:96ed750bd169 316 {
Anna Bridge 180:96ed750bd169 317 register uint32_t __regFaultMask __ASM("faultmask");
Anna Bridge 180:96ed750bd169 318 return(__regFaultMask);
Anna Bridge 180:96ed750bd169 319 }
Anna Bridge 180:96ed750bd169 320
Anna Bridge 180:96ed750bd169 321
Anna Bridge 180:96ed750bd169 322 /**
Anna Bridge 180:96ed750bd169 323 \brief Set Fault Mask
Anna Bridge 180:96ed750bd169 324 \details Assigns the given value to the Fault Mask register.
Anna Bridge 180:96ed750bd169 325 \param [in] faultMask Fault Mask value to set
Anna Bridge 180:96ed750bd169 326 */
Anna Bridge 180:96ed750bd169 327 __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Anna Bridge 180:96ed750bd169 328 {
Anna Bridge 180:96ed750bd169 329 register uint32_t __regFaultMask __ASM("faultmask");
Anna Bridge 180:96ed750bd169 330 __regFaultMask = (faultMask & (uint32_t)1U);
Anna Bridge 180:96ed750bd169 331 }
Anna Bridge 180:96ed750bd169 332
Anna Bridge 180:96ed750bd169 333 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
Anna Bridge 180:96ed750bd169 334 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
Anna Bridge 180:96ed750bd169 335
Anna Bridge 180:96ed750bd169 336
Anna Bridge 180:96ed750bd169 337 #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
Anna Bridge 180:96ed750bd169 338
Anna Bridge 180:96ed750bd169 339 /**
Anna Bridge 180:96ed750bd169 340 \brief Get FPSCR
Anna Bridge 180:96ed750bd169 341 \details Returns the current value of the Floating Point Status/Control register.
Anna Bridge 180:96ed750bd169 342 \return Floating Point Status/Control register value
Anna Bridge 180:96ed750bd169 343 */
Anna Bridge 180:96ed750bd169 344 __STATIC_INLINE uint32_t __get_FPSCR(void)
Anna Bridge 180:96ed750bd169 345 {
Anna Bridge 180:96ed750bd169 346 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
Anna Bridge 180:96ed750bd169 347 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
Anna Bridge 180:96ed750bd169 348 register uint32_t __regfpscr __ASM("fpscr");
Anna Bridge 180:96ed750bd169 349 return(__regfpscr);
Anna Bridge 180:96ed750bd169 350 #else
Anna Bridge 180:96ed750bd169 351 return(0U);
Anna Bridge 180:96ed750bd169 352 #endif
Anna Bridge 180:96ed750bd169 353 }
Anna Bridge 180:96ed750bd169 354
Anna Bridge 180:96ed750bd169 355
Anna Bridge 180:96ed750bd169 356 /**
Anna Bridge 180:96ed750bd169 357 \brief Set FPSCR
Anna Bridge 180:96ed750bd169 358 \details Assigns the given value to the Floating Point Status/Control register.
Anna Bridge 180:96ed750bd169 359 \param [in] fpscr Floating Point Status/Control value to set
Anna Bridge 180:96ed750bd169 360 */
Anna Bridge 180:96ed750bd169 361 __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Anna Bridge 180:96ed750bd169 362 {
Anna Bridge 180:96ed750bd169 363 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
Anna Bridge 180:96ed750bd169 364 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
Anna Bridge 180:96ed750bd169 365 register uint32_t __regfpscr __ASM("fpscr");
Anna Bridge 180:96ed750bd169 366 __regfpscr = (fpscr);
Anna Bridge 180:96ed750bd169 367 #else
Anna Bridge 180:96ed750bd169 368 (void)fpscr;
Anna Bridge 180:96ed750bd169 369 #endif
Anna Bridge 180:96ed750bd169 370 }
Anna Bridge 180:96ed750bd169 371
Anna Bridge 180:96ed750bd169 372 #endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
Anna Bridge 180:96ed750bd169 373
Anna Bridge 180:96ed750bd169 374
Anna Bridge 180:96ed750bd169 375
Anna Bridge 180:96ed750bd169 376 /*@} end of CMSIS_Core_RegAccFunctions */
Anna Bridge 180:96ed750bd169 377
Anna Bridge 180:96ed750bd169 378
Anna Bridge 180:96ed750bd169 379 /* ########################## Core Instruction Access ######################### */
Anna Bridge 180:96ed750bd169 380 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
Anna Bridge 180:96ed750bd169 381 Access to dedicated instructions
Anna Bridge 180:96ed750bd169 382 @{
Anna Bridge 180:96ed750bd169 383 */
Anna Bridge 180:96ed750bd169 384
Anna Bridge 180:96ed750bd169 385 /**
Anna Bridge 180:96ed750bd169 386 \brief No Operation
Anna Bridge 180:96ed750bd169 387 \details No Operation does nothing. This instruction can be used for code alignment purposes.
Anna Bridge 180:96ed750bd169 388 */
Anna Bridge 180:96ed750bd169 389 #define __NOP __nop
Anna Bridge 180:96ed750bd169 390
Anna Bridge 180:96ed750bd169 391
Anna Bridge 180:96ed750bd169 392 /**
Anna Bridge 180:96ed750bd169 393 \brief Wait For Interrupt
Anna Bridge 180:96ed750bd169 394 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
Anna Bridge 180:96ed750bd169 395 */
Anna Bridge 180:96ed750bd169 396 #define __WFI __wfi
Anna Bridge 180:96ed750bd169 397
Anna Bridge 180:96ed750bd169 398
Anna Bridge 180:96ed750bd169 399 /**
Anna Bridge 180:96ed750bd169 400 \brief Wait For Event
Anna Bridge 180:96ed750bd169 401 \details Wait For Event is a hint instruction that permits the processor to enter
Anna Bridge 180:96ed750bd169 402 a low-power state until one of a number of events occurs.
Anna Bridge 180:96ed750bd169 403 */
Anna Bridge 180:96ed750bd169 404 #define __WFE __wfe
Anna Bridge 180:96ed750bd169 405
Anna Bridge 180:96ed750bd169 406
Anna Bridge 180:96ed750bd169 407 /**
Anna Bridge 180:96ed750bd169 408 \brief Send Event
Anna Bridge 180:96ed750bd169 409 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
Anna Bridge 180:96ed750bd169 410 */
Anna Bridge 180:96ed750bd169 411 #define __SEV __sev
Anna Bridge 180:96ed750bd169 412
Anna Bridge 180:96ed750bd169 413
Anna Bridge 180:96ed750bd169 414 /**
Anna Bridge 180:96ed750bd169 415 \brief Instruction Synchronization Barrier
Anna Bridge 180:96ed750bd169 416 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
Anna Bridge 180:96ed750bd169 417 so that all instructions following the ISB are fetched from cache or memory,
Anna Bridge 180:96ed750bd169 418 after the instruction has been completed.
Anna Bridge 180:96ed750bd169 419 */
Anna Bridge 180:96ed750bd169 420 #define __ISB() do {\
Anna Bridge 180:96ed750bd169 421 __schedule_barrier();\
Anna Bridge 180:96ed750bd169 422 __isb(0xF);\
Anna Bridge 180:96ed750bd169 423 __schedule_barrier();\
Anna Bridge 180:96ed750bd169 424 } while (0U)
Anna Bridge 180:96ed750bd169 425
Anna Bridge 180:96ed750bd169 426 /**
Anna Bridge 180:96ed750bd169 427 \brief Data Synchronization Barrier
Anna Bridge 180:96ed750bd169 428 \details Acts as a special kind of Data Memory Barrier.
Anna Bridge 180:96ed750bd169 429 It completes when all explicit memory accesses before this instruction complete.
Anna Bridge 180:96ed750bd169 430 */
Anna Bridge 180:96ed750bd169 431 #define __DSB() do {\
Anna Bridge 180:96ed750bd169 432 __schedule_barrier();\
Anna Bridge 180:96ed750bd169 433 __dsb(0xF);\
Anna Bridge 180:96ed750bd169 434 __schedule_barrier();\
Anna Bridge 180:96ed750bd169 435 } while (0U)
Anna Bridge 180:96ed750bd169 436
Anna Bridge 180:96ed750bd169 437 /**
Anna Bridge 180:96ed750bd169 438 \brief Data Memory Barrier
Anna Bridge 180:96ed750bd169 439 \details Ensures the apparent order of the explicit memory operations before
Anna Bridge 180:96ed750bd169 440 and after the instruction, without ensuring their completion.
Anna Bridge 180:96ed750bd169 441 */
Anna Bridge 180:96ed750bd169 442 #define __DMB() do {\
Anna Bridge 180:96ed750bd169 443 __schedule_barrier();\
Anna Bridge 180:96ed750bd169 444 __dmb(0xF);\
Anna Bridge 180:96ed750bd169 445 __schedule_barrier();\
Anna Bridge 180:96ed750bd169 446 } while (0U)
Anna Bridge 180:96ed750bd169 447
Anna Bridge 180:96ed750bd169 448 /**
Anna Bridge 180:96ed750bd169 449 \brief Reverse byte order (32 bit)
Anna Bridge 180:96ed750bd169 450 \details Reverses the byte order in integer value.
Anna Bridge 180:96ed750bd169 451 \param [in] value Value to reverse
Anna Bridge 180:96ed750bd169 452 \return Reversed value
Anna Bridge 180:96ed750bd169 453 */
Anna Bridge 180:96ed750bd169 454 #define __REV __rev
Anna Bridge 180:96ed750bd169 455
Anna Bridge 180:96ed750bd169 456
Anna Bridge 180:96ed750bd169 457 /**
Anna Bridge 180:96ed750bd169 458 \brief Reverse byte order (16 bit)
Anna Bridge 180:96ed750bd169 459 \details Reverses the byte order in two unsigned short values.
Anna Bridge 180:96ed750bd169 460 \param [in] value Value to reverse
Anna Bridge 180:96ed750bd169 461 \return Reversed value
Anna Bridge 180:96ed750bd169 462 */
Anna Bridge 180:96ed750bd169 463 #ifndef __NO_EMBEDDED_ASM
Anna Bridge 180:96ed750bd169 464 __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint16_t __REV16(uint16_t value)
Anna Bridge 180:96ed750bd169 465 {
Anna Bridge 180:96ed750bd169 466 rev16 r0, r0
Anna Bridge 180:96ed750bd169 467 bx lr
Anna Bridge 180:96ed750bd169 468 }
Anna Bridge 180:96ed750bd169 469 #endif
Anna Bridge 180:96ed750bd169 470
Anna Bridge 180:96ed750bd169 471
Anna Bridge 180:96ed750bd169 472 /**
Anna Bridge 180:96ed750bd169 473 \brief Reverse byte order in signed short value
Anna Bridge 180:96ed750bd169 474 \details Reverses the byte order in a signed short value with sign extension to integer.
Anna Bridge 180:96ed750bd169 475 \param [in] value Value to reverse
Anna Bridge 180:96ed750bd169 476 \return Reversed value
Anna Bridge 180:96ed750bd169 477 */
Anna Bridge 180:96ed750bd169 478 #ifndef __NO_EMBEDDED_ASM
Anna Bridge 180:96ed750bd169 479 __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
Anna Bridge 180:96ed750bd169 480 {
Anna Bridge 180:96ed750bd169 481 revsh r0, r0
Anna Bridge 180:96ed750bd169 482 bx lr
Anna Bridge 180:96ed750bd169 483 }
Anna Bridge 180:96ed750bd169 484 #endif
Anna Bridge 180:96ed750bd169 485
Anna Bridge 180:96ed750bd169 486
Anna Bridge 180:96ed750bd169 487 /**
Anna Bridge 180:96ed750bd169 488 \brief Rotate Right in unsigned value (32 bit)
Anna Bridge 180:96ed750bd169 489 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
Anna Bridge 180:96ed750bd169 490 \param [in] op1 Value to rotate
Anna Bridge 180:96ed750bd169 491 \param [in] op2 Number of Bits to rotate
Anna Bridge 180:96ed750bd169 492 \return Rotated value
Anna Bridge 180:96ed750bd169 493 */
Anna Bridge 180:96ed750bd169 494 #define __ROR __ror
Anna Bridge 180:96ed750bd169 495
Anna Bridge 180:96ed750bd169 496
Anna Bridge 180:96ed750bd169 497 /**
Anna Bridge 180:96ed750bd169 498 \brief Breakpoint
Anna Bridge 180:96ed750bd169 499 \details Causes the processor to enter Debug state.
Anna Bridge 180:96ed750bd169 500 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
Anna Bridge 180:96ed750bd169 501 \param [in] value is ignored by the processor.
Anna Bridge 180:96ed750bd169 502 If required, a debugger can use it to store additional information about the breakpoint.
Anna Bridge 180:96ed750bd169 503 */
Anna Bridge 180:96ed750bd169 504 #define __BKPT(value) __breakpoint(value)
Anna Bridge 180:96ed750bd169 505
Anna Bridge 180:96ed750bd169 506
Anna Bridge 180:96ed750bd169 507 /**
Anna Bridge 180:96ed750bd169 508 \brief Reverse bit order of value
Anna Bridge 180:96ed750bd169 509 \details Reverses the bit order of the given value.
Anna Bridge 180:96ed750bd169 510 \param [in] value Value to reverse
Anna Bridge 180:96ed750bd169 511 \return Reversed value
Anna Bridge 180:96ed750bd169 512 */
Anna Bridge 180:96ed750bd169 513 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
Anna Bridge 180:96ed750bd169 514 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
Anna Bridge 180:96ed750bd169 515 #define __RBIT __rbit
Anna Bridge 180:96ed750bd169 516 #else
Anna Bridge 180:96ed750bd169 517 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
Anna Bridge 180:96ed750bd169 518 {
Anna Bridge 180:96ed750bd169 519 uint32_t result;
Anna Bridge 180:96ed750bd169 520 uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
Anna Bridge 180:96ed750bd169 521
Anna Bridge 180:96ed750bd169 522 result = value; /* r will be reversed bits of v; first get LSB of v */
Anna Bridge 180:96ed750bd169 523 for (value >>= 1U; value != 0U; value >>= 1U)
Anna Bridge 180:96ed750bd169 524 {
Anna Bridge 180:96ed750bd169 525 result <<= 1U;
Anna Bridge 180:96ed750bd169 526 result |= value & 1U;
Anna Bridge 180:96ed750bd169 527 s--;
Anna Bridge 180:96ed750bd169 528 }
Anna Bridge 180:96ed750bd169 529 result <<= s; /* shift when v's highest bits are zero */
Anna Bridge 180:96ed750bd169 530 return result;
Anna Bridge 180:96ed750bd169 531 }
Anna Bridge 180:96ed750bd169 532 #endif
Anna Bridge 180:96ed750bd169 533
Anna Bridge 180:96ed750bd169 534
Anna Bridge 180:96ed750bd169 535 /**
Anna Bridge 180:96ed750bd169 536 \brief Count leading zeros
Anna Bridge 180:96ed750bd169 537 \details Counts the number of leading zeros of a data value.
Anna Bridge 180:96ed750bd169 538 \param [in] value Value to count the leading zeros
Anna Bridge 180:96ed750bd169 539 \return number of leading zeros in value
Anna Bridge 180:96ed750bd169 540 */
Anna Bridge 180:96ed750bd169 541 #define __CLZ __clz
Anna Bridge 180:96ed750bd169 542
Anna Bridge 180:96ed750bd169 543
Anna Bridge 180:96ed750bd169 544 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
Anna Bridge 180:96ed750bd169 545 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
Anna Bridge 180:96ed750bd169 546
Anna Bridge 180:96ed750bd169 547 /**
Anna Bridge 180:96ed750bd169 548 \brief LDR Exclusive (8 bit)
Anna Bridge 180:96ed750bd169 549 \details Executes a exclusive LDR instruction for 8 bit value.
Anna Bridge 180:96ed750bd169 550 \param [in] ptr Pointer to data
Anna Bridge 180:96ed750bd169 551 \return value of type uint8_t at (*ptr)
Anna Bridge 180:96ed750bd169 552 */
Anna Bridge 180:96ed750bd169 553 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
Anna Bridge 180:96ed750bd169 554 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
Anna Bridge 180:96ed750bd169 555 #else
Anna Bridge 180:96ed750bd169 556 #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
Anna Bridge 180:96ed750bd169 557 #endif
Anna Bridge 180:96ed750bd169 558
Anna Bridge 180:96ed750bd169 559
Anna Bridge 180:96ed750bd169 560 /**
Anna Bridge 180:96ed750bd169 561 \brief LDR Exclusive (16 bit)
Anna Bridge 180:96ed750bd169 562 \details Executes a exclusive LDR instruction for 16 bit values.
Anna Bridge 180:96ed750bd169 563 \param [in] ptr Pointer to data
Anna Bridge 180:96ed750bd169 564 \return value of type uint16_t at (*ptr)
Anna Bridge 180:96ed750bd169 565 */
Anna Bridge 180:96ed750bd169 566 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
Anna Bridge 180:96ed750bd169 567 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
Anna Bridge 180:96ed750bd169 568 #else
Anna Bridge 180:96ed750bd169 569 #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
Anna Bridge 180:96ed750bd169 570 #endif
Anna Bridge 180:96ed750bd169 571
Anna Bridge 180:96ed750bd169 572
Anna Bridge 180:96ed750bd169 573 /**
Anna Bridge 180:96ed750bd169 574 \brief LDR Exclusive (32 bit)
Anna Bridge 180:96ed750bd169 575 \details Executes a exclusive LDR instruction for 32 bit values.
Anna Bridge 180:96ed750bd169 576 \param [in] ptr Pointer to data
Anna Bridge 180:96ed750bd169 577 \return value of type uint32_t at (*ptr)
Anna Bridge 180:96ed750bd169 578 */
Anna Bridge 180:96ed750bd169 579 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
Anna Bridge 180:96ed750bd169 580 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
Anna Bridge 180:96ed750bd169 581 #else
Anna Bridge 180:96ed750bd169 582 #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
Anna Bridge 180:96ed750bd169 583 #endif
Anna Bridge 180:96ed750bd169 584
Anna Bridge 180:96ed750bd169 585
Anna Bridge 180:96ed750bd169 586 /**
Anna Bridge 180:96ed750bd169 587 \brief STR Exclusive (8 bit)
Anna Bridge 180:96ed750bd169 588 \details Executes a exclusive STR instruction for 8 bit values.
Anna Bridge 180:96ed750bd169 589 \param [in] value Value to store
Anna Bridge 180:96ed750bd169 590 \param [in] ptr Pointer to location
Anna Bridge 180:96ed750bd169 591 \return 0 Function succeeded
Anna Bridge 180:96ed750bd169 592 \return 1 Function failed
Anna Bridge 180:96ed750bd169 593 */
Anna Bridge 180:96ed750bd169 594 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
Anna Bridge 180:96ed750bd169 595 #define __STREXB(value, ptr) __strex(value, ptr)
Anna Bridge 180:96ed750bd169 596 #else
Anna Bridge 180:96ed750bd169 597 #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
Anna Bridge 180:96ed750bd169 598 #endif
Anna Bridge 180:96ed750bd169 599
Anna Bridge 180:96ed750bd169 600
Anna Bridge 180:96ed750bd169 601 /**
Anna Bridge 180:96ed750bd169 602 \brief STR Exclusive (16 bit)
Anna Bridge 180:96ed750bd169 603 \details Executes a exclusive STR instruction for 16 bit values.
Anna Bridge 180:96ed750bd169 604 \param [in] value Value to store
Anna Bridge 180:96ed750bd169 605 \param [in] ptr Pointer to location
Anna Bridge 180:96ed750bd169 606 \return 0 Function succeeded
Anna Bridge 180:96ed750bd169 607 \return 1 Function failed
Anna Bridge 180:96ed750bd169 608 */
Anna Bridge 180:96ed750bd169 609 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
Anna Bridge 180:96ed750bd169 610 #define __STREXH(value, ptr) __strex(value, ptr)
Anna Bridge 180:96ed750bd169 611 #else
Anna Bridge 180:96ed750bd169 612 #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
Anna Bridge 180:96ed750bd169 613 #endif
Anna Bridge 180:96ed750bd169 614
Anna Bridge 180:96ed750bd169 615
Anna Bridge 180:96ed750bd169 616 /**
Anna Bridge 180:96ed750bd169 617 \brief STR Exclusive (32 bit)
Anna Bridge 180:96ed750bd169 618 \details Executes a exclusive STR instruction for 32 bit values.
Anna Bridge 180:96ed750bd169 619 \param [in] value Value to store
Anna Bridge 180:96ed750bd169 620 \param [in] ptr Pointer to location
Anna Bridge 180:96ed750bd169 621 \return 0 Function succeeded
Anna Bridge 180:96ed750bd169 622 \return 1 Function failed
Anna Bridge 180:96ed750bd169 623 */
Anna Bridge 180:96ed750bd169 624 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
Anna Bridge 180:96ed750bd169 625 #define __STREXW(value, ptr) __strex(value, ptr)
Anna Bridge 180:96ed750bd169 626 #else
Anna Bridge 180:96ed750bd169 627 #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
Anna Bridge 180:96ed750bd169 628 #endif
Anna Bridge 180:96ed750bd169 629
Anna Bridge 180:96ed750bd169 630
Anna Bridge 180:96ed750bd169 631 /**
Anna Bridge 180:96ed750bd169 632 \brief Remove the exclusive lock
Anna Bridge 180:96ed750bd169 633 \details Removes the exclusive lock which is created by LDREX.
Anna Bridge 180:96ed750bd169 634 */
Anna Bridge 180:96ed750bd169 635 #define __CLREX __clrex
Anna Bridge 180:96ed750bd169 636
Anna Bridge 180:96ed750bd169 637
Anna Bridge 180:96ed750bd169 638 /**
Anna Bridge 180:96ed750bd169 639 \brief Signed Saturate
Anna Bridge 180:96ed750bd169 640 \details Saturates a signed value.
Anna Bridge 180:96ed750bd169 641 \param [in] value Value to be saturated
Anna Bridge 180:96ed750bd169 642 \param [in] sat Bit position to saturate to (1..32)
Anna Bridge 180:96ed750bd169 643 \return Saturated value
Anna Bridge 180:96ed750bd169 644 */
Anna Bridge 180:96ed750bd169 645 #define __SSAT __ssat
Anna Bridge 180:96ed750bd169 646
Anna Bridge 180:96ed750bd169 647
Anna Bridge 180:96ed750bd169 648 /**
Anna Bridge 180:96ed750bd169 649 \brief Unsigned Saturate
Anna Bridge 180:96ed750bd169 650 \details Saturates an unsigned value.
Anna Bridge 180:96ed750bd169 651 \param [in] value Value to be saturated
Anna Bridge 180:96ed750bd169 652 \param [in] sat Bit position to saturate to (0..31)
Anna Bridge 180:96ed750bd169 653 \return Saturated value
Anna Bridge 180:96ed750bd169 654 */
Anna Bridge 180:96ed750bd169 655 #define __USAT __usat
Anna Bridge 180:96ed750bd169 656
Anna Bridge 180:96ed750bd169 657
Anna Bridge 180:96ed750bd169 658 /**
Anna Bridge 180:96ed750bd169 659 \brief Rotate Right with Extend (32 bit)
Anna Bridge 180:96ed750bd169 660 \details Moves each bit of a bitstring right by one bit.
Anna Bridge 180:96ed750bd169 661 The carry input is shifted in at the left end of the bitstring.
Anna Bridge 180:96ed750bd169 662 \param [in] value Value to rotate
Anna Bridge 180:96ed750bd169 663 \return Rotated value
Anna Bridge 180:96ed750bd169 664 */
Anna Bridge 180:96ed750bd169 665 #ifndef __NO_EMBEDDED_ASM
Anna Bridge 180:96ed750bd169 666 __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
Anna Bridge 180:96ed750bd169 667 {
Anna Bridge 180:96ed750bd169 668 rrx r0, r0
Anna Bridge 180:96ed750bd169 669 bx lr
Anna Bridge 180:96ed750bd169 670 }
Anna Bridge 180:96ed750bd169 671 #endif
Anna Bridge 180:96ed750bd169 672
Anna Bridge 180:96ed750bd169 673
Anna Bridge 180:96ed750bd169 674 /**
Anna Bridge 180:96ed750bd169 675 \brief LDRT Unprivileged (8 bit)
Anna Bridge 180:96ed750bd169 676 \details Executes a Unprivileged LDRT instruction for 8 bit value.
Anna Bridge 180:96ed750bd169 677 \param [in] ptr Pointer to data
Anna Bridge 180:96ed750bd169 678 \return value of type uint8_t at (*ptr)
Anna Bridge 180:96ed750bd169 679 */
Anna Bridge 180:96ed750bd169 680 #define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
Anna Bridge 180:96ed750bd169 681
Anna Bridge 180:96ed750bd169 682
Anna Bridge 180:96ed750bd169 683 /**
Anna Bridge 180:96ed750bd169 684 \brief LDRT Unprivileged (16 bit)
Anna Bridge 180:96ed750bd169 685 \details Executes a Unprivileged LDRT instruction for 16 bit values.
Anna Bridge 180:96ed750bd169 686 \param [in] ptr Pointer to data
Anna Bridge 180:96ed750bd169 687 \return value of type uint16_t at (*ptr)
Anna Bridge 180:96ed750bd169 688 */
Anna Bridge 180:96ed750bd169 689 #define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
Anna Bridge 180:96ed750bd169 690
Anna Bridge 180:96ed750bd169 691
Anna Bridge 180:96ed750bd169 692 /**
Anna Bridge 180:96ed750bd169 693 \brief LDRT Unprivileged (32 bit)
Anna Bridge 180:96ed750bd169 694 \details Executes a Unprivileged LDRT instruction for 32 bit values.
Anna Bridge 180:96ed750bd169 695 \param [in] ptr Pointer to data
Anna Bridge 180:96ed750bd169 696 \return value of type uint32_t at (*ptr)
Anna Bridge 180:96ed750bd169 697 */
Anna Bridge 180:96ed750bd169 698 #define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
Anna Bridge 180:96ed750bd169 699
Anna Bridge 180:96ed750bd169 700
Anna Bridge 180:96ed750bd169 701 /**
Anna Bridge 180:96ed750bd169 702 \brief STRT Unprivileged (8 bit)
Anna Bridge 180:96ed750bd169 703 \details Executes a Unprivileged STRT instruction for 8 bit values.
Anna Bridge 180:96ed750bd169 704 \param [in] value Value to store
Anna Bridge 180:96ed750bd169 705 \param [in] ptr Pointer to location
Anna Bridge 180:96ed750bd169 706 */
Anna Bridge 180:96ed750bd169 707 #define __STRBT(value, ptr) __strt(value, ptr)
Anna Bridge 180:96ed750bd169 708
Anna Bridge 180:96ed750bd169 709
Anna Bridge 180:96ed750bd169 710 /**
Anna Bridge 180:96ed750bd169 711 \brief STRT Unprivileged (16 bit)
Anna Bridge 180:96ed750bd169 712 \details Executes a Unprivileged STRT instruction for 16 bit values.
Anna Bridge 180:96ed750bd169 713 \param [in] value Value to store
Anna Bridge 180:96ed750bd169 714 \param [in] ptr Pointer to location
Anna Bridge 180:96ed750bd169 715 */
Anna Bridge 180:96ed750bd169 716 #define __STRHT(value, ptr) __strt(value, ptr)
Anna Bridge 180:96ed750bd169 717
Anna Bridge 180:96ed750bd169 718
Anna Bridge 180:96ed750bd169 719 /**
Anna Bridge 180:96ed750bd169 720 \brief STRT Unprivileged (32 bit)
Anna Bridge 180:96ed750bd169 721 \details Executes a Unprivileged STRT instruction for 32 bit values.
Anna Bridge 180:96ed750bd169 722 \param [in] value Value to store
Anna Bridge 180:96ed750bd169 723 \param [in] ptr Pointer to location
Anna Bridge 180:96ed750bd169 724 */
Anna Bridge 180:96ed750bd169 725 #define __STRT(value, ptr) __strt(value, ptr)
Anna Bridge 180:96ed750bd169 726
Anna Bridge 180:96ed750bd169 727 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
Anna Bridge 180:96ed750bd169 728 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
Anna Bridge 180:96ed750bd169 729
Anna Bridge 180:96ed750bd169 730 /**
Anna Bridge 180:96ed750bd169 731 \brief Signed Saturate
Anna Bridge 180:96ed750bd169 732 \details Saturates a signed value.
Anna Bridge 180:96ed750bd169 733 \param [in] value Value to be saturated
Anna Bridge 180:96ed750bd169 734 \param [in] sat Bit position to saturate to (1..32)
Anna Bridge 180:96ed750bd169 735 \return Saturated value
Anna Bridge 180:96ed750bd169 736 */
Anna Bridge 180:96ed750bd169 737 __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
Anna Bridge 180:96ed750bd169 738 {
Anna Bridge 180:96ed750bd169 739 if ((sat >= 1U) && (sat <= 32U)) {
Anna Bridge 180:96ed750bd169 740 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
Anna Bridge 180:96ed750bd169 741 const int32_t min = -1 - max ;
Anna Bridge 180:96ed750bd169 742 if (val > max) {
Anna Bridge 180:96ed750bd169 743 return max;
Anna Bridge 180:96ed750bd169 744 } else if (val < min) {
Anna Bridge 180:96ed750bd169 745 return min;
Anna Bridge 180:96ed750bd169 746 }
Anna Bridge 180:96ed750bd169 747 }
Anna Bridge 180:96ed750bd169 748 return val;
Anna Bridge 180:96ed750bd169 749 }
Anna Bridge 180:96ed750bd169 750
Anna Bridge 180:96ed750bd169 751 /**
Anna Bridge 180:96ed750bd169 752 \brief Unsigned Saturate
Anna Bridge 180:96ed750bd169 753 \details Saturates an unsigned value.
Anna Bridge 180:96ed750bd169 754 \param [in] value Value to be saturated
Anna Bridge 180:96ed750bd169 755 \param [in] sat Bit position to saturate to (0..31)
Anna Bridge 180:96ed750bd169 756 \return Saturated value
Anna Bridge 180:96ed750bd169 757 */
Anna Bridge 180:96ed750bd169 758 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
Anna Bridge 180:96ed750bd169 759 {
Anna Bridge 180:96ed750bd169 760 if (sat <= 31U) {
Anna Bridge 180:96ed750bd169 761 const uint32_t max = ((1U << sat) - 1U);
Anna Bridge 180:96ed750bd169 762 if (val > (int32_t)max) {
Anna Bridge 180:96ed750bd169 763 return max;
Anna Bridge 180:96ed750bd169 764 } else if (val < 0) {
Anna Bridge 180:96ed750bd169 765 return 0U;
Anna Bridge 180:96ed750bd169 766 }
Anna Bridge 180:96ed750bd169 767 }
Anna Bridge 180:96ed750bd169 768 return (uint32_t)val;
Anna Bridge 180:96ed750bd169 769 }
Anna Bridge 180:96ed750bd169 770
Anna Bridge 180:96ed750bd169 771 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
Anna Bridge 180:96ed750bd169 772 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
Anna Bridge 180:96ed750bd169 773
Anna Bridge 180:96ed750bd169 774 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
Anna Bridge 180:96ed750bd169 775
Anna Bridge 180:96ed750bd169 776
Anna Bridge 180:96ed750bd169 777 /* ################### Compiler specific Intrinsics ########################### */
Anna Bridge 180:96ed750bd169 778 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
Anna Bridge 180:96ed750bd169 779 Access to dedicated SIMD instructions
Anna Bridge 180:96ed750bd169 780 @{
Anna Bridge 180:96ed750bd169 781 */
Anna Bridge 180:96ed750bd169 782
Anna Bridge 180:96ed750bd169 783 #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
Anna Bridge 180:96ed750bd169 784
Anna Bridge 180:96ed750bd169 785 #define __SADD8 __sadd8
Anna Bridge 180:96ed750bd169 786 #define __QADD8 __qadd8
Anna Bridge 180:96ed750bd169 787 #define __SHADD8 __shadd8
Anna Bridge 180:96ed750bd169 788 #define __UADD8 __uadd8
Anna Bridge 180:96ed750bd169 789 #define __UQADD8 __uqadd8
Anna Bridge 180:96ed750bd169 790 #define __UHADD8 __uhadd8
Anna Bridge 180:96ed750bd169 791 #define __SSUB8 __ssub8
Anna Bridge 180:96ed750bd169 792 #define __QSUB8 __qsub8
Anna Bridge 180:96ed750bd169 793 #define __SHSUB8 __shsub8
Anna Bridge 180:96ed750bd169 794 #define __USUB8 __usub8
Anna Bridge 180:96ed750bd169 795 #define __UQSUB8 __uqsub8
Anna Bridge 180:96ed750bd169 796 #define __UHSUB8 __uhsub8
Anna Bridge 180:96ed750bd169 797 #define __SADD16 __sadd16
Anna Bridge 180:96ed750bd169 798 #define __QADD16 __qadd16
Anna Bridge 180:96ed750bd169 799 #define __SHADD16 __shadd16
Anna Bridge 180:96ed750bd169 800 #define __UADD16 __uadd16
Anna Bridge 180:96ed750bd169 801 #define __UQADD16 __uqadd16
Anna Bridge 180:96ed750bd169 802 #define __UHADD16 __uhadd16
Anna Bridge 180:96ed750bd169 803 #define __SSUB16 __ssub16
Anna Bridge 180:96ed750bd169 804 #define __QSUB16 __qsub16
Anna Bridge 180:96ed750bd169 805 #define __SHSUB16 __shsub16
Anna Bridge 180:96ed750bd169 806 #define __USUB16 __usub16
Anna Bridge 180:96ed750bd169 807 #define __UQSUB16 __uqsub16
Anna Bridge 180:96ed750bd169 808 #define __UHSUB16 __uhsub16
Anna Bridge 180:96ed750bd169 809 #define __SASX __sasx
Anna Bridge 180:96ed750bd169 810 #define __QASX __qasx
Anna Bridge 180:96ed750bd169 811 #define __SHASX __shasx
Anna Bridge 180:96ed750bd169 812 #define __UASX __uasx
Anna Bridge 180:96ed750bd169 813 #define __UQASX __uqasx
Anna Bridge 180:96ed750bd169 814 #define __UHASX __uhasx
Anna Bridge 180:96ed750bd169 815 #define __SSAX __ssax
Anna Bridge 180:96ed750bd169 816 #define __QSAX __qsax
Anna Bridge 180:96ed750bd169 817 #define __SHSAX __shsax
Anna Bridge 180:96ed750bd169 818 #define __USAX __usax
Anna Bridge 180:96ed750bd169 819 #define __UQSAX __uqsax
Anna Bridge 180:96ed750bd169 820 #define __UHSAX __uhsax
Anna Bridge 180:96ed750bd169 821 #define __USAD8 __usad8
Anna Bridge 180:96ed750bd169 822 #define __USADA8 __usada8
Anna Bridge 180:96ed750bd169 823 #define __SSAT16 __ssat16
Anna Bridge 180:96ed750bd169 824 #define __USAT16 __usat16
Anna Bridge 180:96ed750bd169 825 #define __UXTB16 __uxtb16
Anna Bridge 180:96ed750bd169 826 #define __UXTAB16 __uxtab16
Anna Bridge 180:96ed750bd169 827 #define __SXTB16 __sxtb16
Anna Bridge 180:96ed750bd169 828 #define __SXTAB16 __sxtab16
Anna Bridge 180:96ed750bd169 829 #define __SMUAD __smuad
Anna Bridge 180:96ed750bd169 830 #define __SMUADX __smuadx
Anna Bridge 180:96ed750bd169 831 #define __SMLAD __smlad
Anna Bridge 180:96ed750bd169 832 #define __SMLADX __smladx
Anna Bridge 180:96ed750bd169 833 #define __SMLALD __smlald
Anna Bridge 180:96ed750bd169 834 #define __SMLALDX __smlaldx
Anna Bridge 180:96ed750bd169 835 #define __SMUSD __smusd
Anna Bridge 180:96ed750bd169 836 #define __SMUSDX __smusdx
Anna Bridge 180:96ed750bd169 837 #define __SMLSD __smlsd
Anna Bridge 180:96ed750bd169 838 #define __SMLSDX __smlsdx
Anna Bridge 180:96ed750bd169 839 #define __SMLSLD __smlsld
Anna Bridge 180:96ed750bd169 840 #define __SMLSLDX __smlsldx
Anna Bridge 180:96ed750bd169 841 #define __SEL __sel
Anna Bridge 180:96ed750bd169 842 #define __QADD __qadd
Anna Bridge 180:96ed750bd169 843 #define __QSUB __qsub
Anna Bridge 180:96ed750bd169 844
Anna Bridge 180:96ed750bd169 845 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
Anna Bridge 180:96ed750bd169 846 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
Anna Bridge 180:96ed750bd169 847
Anna Bridge 180:96ed750bd169 848 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
Anna Bridge 180:96ed750bd169 849 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
Anna Bridge 180:96ed750bd169 850
Anna Bridge 180:96ed750bd169 851 #define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
Anna Bridge 180:96ed750bd169 852 ((int64_t)(ARG3) << 32U) ) >> 32U))
Anna Bridge 180:96ed750bd169 853
Anna Bridge 180:96ed750bd169 854 #endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
Anna Bridge 180:96ed750bd169 855 /*@} end of group CMSIS_SIMD_intrinsics */
Anna Bridge 180:96ed750bd169 856
Anna Bridge 180:96ed750bd169 857
Anna Bridge 180:96ed750bd169 858 #endif /* __CMSIS_ARMCC_H */