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:
AnnaBridge
Date:
Fri Feb 16 16:16:41 2018 +0000
Revision:
161:aa5281ff4a02
Child:
169:a7c7b631e539
mbed library. Release version 159.

Who changed what in which revision?

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