The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Anna Bridge
Date:
Wed Jan 17 16:13:02 2018 +0000
Revision:
160:5571c4ff569f
Parent:
145:64910690c574
Child:
169:a7c7b631e539
mbed library. Release version 158

Who changed what in which revision?

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