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:
Fri Jun 22 15:38:59 2018 +0100
Revision:
169:a7c7b631e539
Parent:
160:5571c4ff569f
mbed library. Release version 162

Who changed what in which revision?

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