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:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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