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:
mbed_official
Date:
Thu Dec 21 18:20:02 2017 +0000
Revision:
159:7130f322cb7e
mbed library version 157

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 159:7130f322cb7e 1 /**************************************************************************//**
mbed_official 159:7130f322cb7e 2 * @file cmsis_armclang.h
mbed_official 159:7130f322cb7e 3 * @brief CMSIS compiler ARMCLANG (ARM compiler V6) header file
mbed_official 159:7130f322cb7e 4 * @version V5.0.3
mbed_official 159:7130f322cb7e 5 * @date 27. March 2017
mbed_official 159:7130f322cb7e 6 ******************************************************************************/
mbed_official 159:7130f322cb7e 7 /*
mbed_official 159:7130f322cb7e 8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
mbed_official 159:7130f322cb7e 9 *
mbed_official 159:7130f322cb7e 10 * SPDX-License-Identifier: Apache-2.0
mbed_official 159:7130f322cb7e 11 *
mbed_official 159:7130f322cb7e 12 * Licensed under the Apache License, Version 2.0 (the License); you may
mbed_official 159:7130f322cb7e 13 * not use this file except in compliance with the License.
mbed_official 159:7130f322cb7e 14 * You may obtain a copy of the License at
mbed_official 159:7130f322cb7e 15 *
mbed_official 159:7130f322cb7e 16 * www.apache.org/licenses/LICENSE-2.0
mbed_official 159:7130f322cb7e 17 *
mbed_official 159:7130f322cb7e 18 * Unless required by applicable law or agreed to in writing, software
mbed_official 159:7130f322cb7e 19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
mbed_official 159:7130f322cb7e 20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 159:7130f322cb7e 21 * See the License for the specific language governing permissions and
mbed_official 159:7130f322cb7e 22 * limitations under the License.
mbed_official 159:7130f322cb7e 23 */
mbed_official 159:7130f322cb7e 24
mbed_official 159:7130f322cb7e 25 //lint -esym(9058, IRQn) disable MISRA 2012 Rule 2.4 for IRQn
mbed_official 159:7130f322cb7e 26
mbed_official 159:7130f322cb7e 27 #ifndef __CMSIS_ARMCLANG_H
mbed_official 159:7130f322cb7e 28 #define __CMSIS_ARMCLANG_H
mbed_official 159:7130f322cb7e 29
mbed_official 159:7130f322cb7e 30 #ifndef __ARM_COMPAT_H
mbed_official 159:7130f322cb7e 31 #include <arm_compat.h> /* Compatibility header for ARM Compiler 5 intrinsics */
mbed_official 159:7130f322cb7e 32 #endif
mbed_official 159:7130f322cb7e 33
mbed_official 159:7130f322cb7e 34 /* CMSIS compiler specific defines */
mbed_official 159:7130f322cb7e 35 #ifndef __ASM
mbed_official 159:7130f322cb7e 36 #define __ASM __asm
mbed_official 159:7130f322cb7e 37 #endif
mbed_official 159:7130f322cb7e 38 #ifndef __INLINE
mbed_official 159:7130f322cb7e 39 #define __INLINE __inline
mbed_official 159:7130f322cb7e 40 #endif
mbed_official 159:7130f322cb7e 41 #ifndef __STATIC_INLINE
mbed_official 159:7130f322cb7e 42 #define __STATIC_INLINE static __inline
mbed_official 159:7130f322cb7e 43 #endif
mbed_official 159:7130f322cb7e 44 #ifndef __NO_RETURN
mbed_official 159:7130f322cb7e 45 #define __NO_RETURN __attribute__((noreturn))
mbed_official 159:7130f322cb7e 46 #endif
mbed_official 159:7130f322cb7e 47 #ifndef __USED
mbed_official 159:7130f322cb7e 48 #define __USED __attribute__((used))
mbed_official 159:7130f322cb7e 49 #endif
mbed_official 159:7130f322cb7e 50 #ifndef __WEAK
mbed_official 159:7130f322cb7e 51 #define __WEAK __attribute__((weak))
mbed_official 159:7130f322cb7e 52 #endif
mbed_official 159:7130f322cb7e 53 #ifndef __PACKED
mbed_official 159:7130f322cb7e 54 #define __PACKED __attribute__((packed, aligned(1)))
mbed_official 159:7130f322cb7e 55 #endif
mbed_official 159:7130f322cb7e 56 #ifndef __PACKED_STRUCT
mbed_official 159:7130f322cb7e 57 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
mbed_official 159:7130f322cb7e 58 #endif
mbed_official 159:7130f322cb7e 59 #ifndef __UNALIGNED_UINT32 /* deprecated */
mbed_official 159:7130f322cb7e 60 #pragma clang diagnostic push
mbed_official 159:7130f322cb7e 61 #pragma clang diagnostic ignored "-Wpacked"
mbed_official 159:7130f322cb7e 62 //lint -esym(9058, T_UINT32) disable MISRA 2012 Rule 2.4 for T_UINT32
mbed_official 159:7130f322cb7e 63 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
mbed_official 159:7130f322cb7e 64 #pragma clang diagnostic pop
mbed_official 159:7130f322cb7e 65 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
mbed_official 159:7130f322cb7e 66 #endif
mbed_official 159:7130f322cb7e 67 #ifndef __UNALIGNED_UINT16_WRITE
mbed_official 159:7130f322cb7e 68 #pragma clang diagnostic push
mbed_official 159:7130f322cb7e 69 #pragma clang diagnostic ignored "-Wpacked"
mbed_official 159:7130f322cb7e 70 //lint -esym(9058, T_UINT16_WRITE) disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE
mbed_official 159:7130f322cb7e 71 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
mbed_official 159:7130f322cb7e 72 #pragma clang diagnostic pop
mbed_official 159:7130f322cb7e 73 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
mbed_official 159:7130f322cb7e 74 #endif
mbed_official 159:7130f322cb7e 75 #ifndef __UNALIGNED_UINT16_READ
mbed_official 159:7130f322cb7e 76 #pragma clang diagnostic push
mbed_official 159:7130f322cb7e 77 #pragma clang diagnostic ignored "-Wpacked"
mbed_official 159:7130f322cb7e 78 //lint -esym(9058, T_UINT16_READ) disable MISRA 2012 Rule 2.4 for T_UINT16_READ
mbed_official 159:7130f322cb7e 79 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
mbed_official 159:7130f322cb7e 80 #pragma clang diagnostic pop
mbed_official 159:7130f322cb7e 81 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
mbed_official 159:7130f322cb7e 82 #endif
mbed_official 159:7130f322cb7e 83 #ifndef __UNALIGNED_UINT32_WRITE
mbed_official 159:7130f322cb7e 84 #pragma clang diagnostic push
mbed_official 159:7130f322cb7e 85 #pragma clang diagnostic ignored "-Wpacked"
mbed_official 159:7130f322cb7e 86 //lint -esym(9058, T_UINT32_WRITE) disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE
mbed_official 159:7130f322cb7e 87 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
mbed_official 159:7130f322cb7e 88 #pragma clang diagnostic pop
mbed_official 159:7130f322cb7e 89 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
mbed_official 159:7130f322cb7e 90 #endif
mbed_official 159:7130f322cb7e 91 #ifndef __UNALIGNED_UINT32_READ
mbed_official 159:7130f322cb7e 92 #pragma clang diagnostic push
mbed_official 159:7130f322cb7e 93 #pragma clang diagnostic ignored "-Wpacked"
mbed_official 159:7130f322cb7e 94 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
mbed_official 159:7130f322cb7e 95 #pragma clang diagnostic pop
mbed_official 159:7130f322cb7e 96 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
mbed_official 159:7130f322cb7e 97 #endif
mbed_official 159:7130f322cb7e 98 #ifndef __ALIGNED
mbed_official 159:7130f322cb7e 99 #define __ALIGNED(x) __attribute__((aligned(x)))
mbed_official 159:7130f322cb7e 100 #endif
mbed_official 159:7130f322cb7e 101
mbed_official 159:7130f322cb7e 102
mbed_official 159:7130f322cb7e 103 /* ########################### Core Function Access ########################### */
mbed_official 159:7130f322cb7e 104 /** \ingroup CMSIS_Core_FunctionInterface
mbed_official 159:7130f322cb7e 105 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
mbed_official 159:7130f322cb7e 106 @{
mbed_official 159:7130f322cb7e 107 */
mbed_official 159:7130f322cb7e 108
mbed_official 159:7130f322cb7e 109 /**
mbed_official 159:7130f322cb7e 110 \brief Enable IRQ Interrupts
mbed_official 159:7130f322cb7e 111 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
mbed_official 159:7130f322cb7e 112 Can only be executed in Privileged modes.
mbed_official 159:7130f322cb7e 113 */
mbed_official 159:7130f322cb7e 114 /* intrinsic void __enable_irq(); see arm_compat.h */
mbed_official 159:7130f322cb7e 115
mbed_official 159:7130f322cb7e 116
mbed_official 159:7130f322cb7e 117 /**
mbed_official 159:7130f322cb7e 118 \brief Disable IRQ Interrupts
mbed_official 159:7130f322cb7e 119 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
mbed_official 159:7130f322cb7e 120 Can only be executed in Privileged modes.
mbed_official 159:7130f322cb7e 121 */
mbed_official 159:7130f322cb7e 122 /* intrinsic void __disable_irq(); see arm_compat.h */
mbed_official 159:7130f322cb7e 123
mbed_official 159:7130f322cb7e 124
mbed_official 159:7130f322cb7e 125 /**
mbed_official 159:7130f322cb7e 126 \brief Get Control Register
mbed_official 159:7130f322cb7e 127 \details Returns the content of the Control Register.
mbed_official 159:7130f322cb7e 128 \return Control Register value
mbed_official 159:7130f322cb7e 129 */
mbed_official 159:7130f322cb7e 130 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
mbed_official 159:7130f322cb7e 131 {
mbed_official 159:7130f322cb7e 132 uint32_t result;
mbed_official 159:7130f322cb7e 133
mbed_official 159:7130f322cb7e 134 __ASM volatile ("MRS %0, control" : "=r" (result) );
mbed_official 159:7130f322cb7e 135 return(result);
mbed_official 159:7130f322cb7e 136 }
mbed_official 159:7130f322cb7e 137
mbed_official 159:7130f322cb7e 138
mbed_official 159:7130f322cb7e 139 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 140 /**
mbed_official 159:7130f322cb7e 141 \brief Get Control Register (non-secure)
mbed_official 159:7130f322cb7e 142 \details Returns the content of the non-secure Control Register when in secure mode.
mbed_official 159:7130f322cb7e 143 \return non-secure Control Register value
mbed_official 159:7130f322cb7e 144 */
mbed_official 159:7130f322cb7e 145 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
mbed_official 159:7130f322cb7e 146 {
mbed_official 159:7130f322cb7e 147 uint32_t result;
mbed_official 159:7130f322cb7e 148
mbed_official 159:7130f322cb7e 149 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 150 return(result);
mbed_official 159:7130f322cb7e 151 }
mbed_official 159:7130f322cb7e 152 #endif
mbed_official 159:7130f322cb7e 153
mbed_official 159:7130f322cb7e 154
mbed_official 159:7130f322cb7e 155 /**
mbed_official 159:7130f322cb7e 156 \brief Set Control Register
mbed_official 159:7130f322cb7e 157 \details Writes the given value to the Control Register.
mbed_official 159:7130f322cb7e 158 \param [in] control Control Register value to set
mbed_official 159:7130f322cb7e 159 */
mbed_official 159:7130f322cb7e 160 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
mbed_official 159:7130f322cb7e 161 {
mbed_official 159:7130f322cb7e 162 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
mbed_official 159:7130f322cb7e 163 }
mbed_official 159:7130f322cb7e 164
mbed_official 159:7130f322cb7e 165
mbed_official 159:7130f322cb7e 166 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 167 /**
mbed_official 159:7130f322cb7e 168 \brief Set Control Register (non-secure)
mbed_official 159:7130f322cb7e 169 \details Writes the given value to the non-secure Control Register when in secure state.
mbed_official 159:7130f322cb7e 170 \param [in] control Control Register value to set
mbed_official 159:7130f322cb7e 171 */
mbed_official 159:7130f322cb7e 172 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
mbed_official 159:7130f322cb7e 173 {
mbed_official 159:7130f322cb7e 174 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
mbed_official 159:7130f322cb7e 175 }
mbed_official 159:7130f322cb7e 176 #endif
mbed_official 159:7130f322cb7e 177
mbed_official 159:7130f322cb7e 178
mbed_official 159:7130f322cb7e 179 /**
mbed_official 159:7130f322cb7e 180 \brief Get IPSR Register
mbed_official 159:7130f322cb7e 181 \details Returns the content of the IPSR Register.
mbed_official 159:7130f322cb7e 182 \return IPSR Register value
mbed_official 159:7130f322cb7e 183 */
mbed_official 159:7130f322cb7e 184 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
mbed_official 159:7130f322cb7e 185 {
mbed_official 159:7130f322cb7e 186 uint32_t result;
mbed_official 159:7130f322cb7e 187
mbed_official 159:7130f322cb7e 188 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
mbed_official 159:7130f322cb7e 189 return(result);
mbed_official 159:7130f322cb7e 190 }
mbed_official 159:7130f322cb7e 191
mbed_official 159:7130f322cb7e 192
mbed_official 159:7130f322cb7e 193 /**
mbed_official 159:7130f322cb7e 194 \brief Get APSR Register
mbed_official 159:7130f322cb7e 195 \details Returns the content of the APSR Register.
mbed_official 159:7130f322cb7e 196 \return APSR Register value
mbed_official 159:7130f322cb7e 197 */
mbed_official 159:7130f322cb7e 198 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
mbed_official 159:7130f322cb7e 199 {
mbed_official 159:7130f322cb7e 200 uint32_t result;
mbed_official 159:7130f322cb7e 201
mbed_official 159:7130f322cb7e 202 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
mbed_official 159:7130f322cb7e 203 return(result);
mbed_official 159:7130f322cb7e 204 }
mbed_official 159:7130f322cb7e 205
mbed_official 159:7130f322cb7e 206
mbed_official 159:7130f322cb7e 207 /**
mbed_official 159:7130f322cb7e 208 \brief Get xPSR Register
mbed_official 159:7130f322cb7e 209 \details Returns the content of the xPSR Register.
mbed_official 159:7130f322cb7e 210 \return xPSR Register value
mbed_official 159:7130f322cb7e 211 */
mbed_official 159:7130f322cb7e 212 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
mbed_official 159:7130f322cb7e 213 {
mbed_official 159:7130f322cb7e 214 uint32_t result;
mbed_official 159:7130f322cb7e 215
mbed_official 159:7130f322cb7e 216 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
mbed_official 159:7130f322cb7e 217 return(result);
mbed_official 159:7130f322cb7e 218 }
mbed_official 159:7130f322cb7e 219
mbed_official 159:7130f322cb7e 220
mbed_official 159:7130f322cb7e 221 /**
mbed_official 159:7130f322cb7e 222 \brief Get Process Stack Pointer
mbed_official 159:7130f322cb7e 223 \details Returns the current value of the Process Stack Pointer (PSP).
mbed_official 159:7130f322cb7e 224 \return PSP Register value
mbed_official 159:7130f322cb7e 225 */
mbed_official 159:7130f322cb7e 226 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
mbed_official 159:7130f322cb7e 227 {
mbed_official 159:7130f322cb7e 228 register uint32_t result;
mbed_official 159:7130f322cb7e 229
mbed_official 159:7130f322cb7e 230 __ASM volatile ("MRS %0, psp" : "=r" (result) );
mbed_official 159:7130f322cb7e 231 return(result);
mbed_official 159:7130f322cb7e 232 }
mbed_official 159:7130f322cb7e 233
mbed_official 159:7130f322cb7e 234
mbed_official 159:7130f322cb7e 235 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 236 /**
mbed_official 159:7130f322cb7e 237 \brief Get Process Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 238 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
mbed_official 159:7130f322cb7e 239 \return PSP Register value
mbed_official 159:7130f322cb7e 240 */
mbed_official 159:7130f322cb7e 241 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
mbed_official 159:7130f322cb7e 242 {
mbed_official 159:7130f322cb7e 243 register uint32_t result;
mbed_official 159:7130f322cb7e 244
mbed_official 159:7130f322cb7e 245 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 246 return(result);
mbed_official 159:7130f322cb7e 247 }
mbed_official 159:7130f322cb7e 248 #endif
mbed_official 159:7130f322cb7e 249
mbed_official 159:7130f322cb7e 250
mbed_official 159:7130f322cb7e 251 /**
mbed_official 159:7130f322cb7e 252 \brief Set Process Stack Pointer
mbed_official 159:7130f322cb7e 253 \details Assigns the given value to the Process Stack Pointer (PSP).
mbed_official 159:7130f322cb7e 254 \param [in] topOfProcStack Process Stack Pointer value to set
mbed_official 159:7130f322cb7e 255 */
mbed_official 159:7130f322cb7e 256 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
mbed_official 159:7130f322cb7e 257 {
mbed_official 159:7130f322cb7e 258 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
mbed_official 159:7130f322cb7e 259 }
mbed_official 159:7130f322cb7e 260
mbed_official 159:7130f322cb7e 261
mbed_official 159:7130f322cb7e 262 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 263 /**
mbed_official 159:7130f322cb7e 264 \brief Set Process Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 265 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
mbed_official 159:7130f322cb7e 266 \param [in] topOfProcStack Process Stack Pointer value to set
mbed_official 159:7130f322cb7e 267 */
mbed_official 159:7130f322cb7e 268 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
mbed_official 159:7130f322cb7e 269 {
mbed_official 159:7130f322cb7e 270 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
mbed_official 159:7130f322cb7e 271 }
mbed_official 159:7130f322cb7e 272 #endif
mbed_official 159:7130f322cb7e 273
mbed_official 159:7130f322cb7e 274
mbed_official 159:7130f322cb7e 275 /**
mbed_official 159:7130f322cb7e 276 \brief Get Main Stack Pointer
mbed_official 159:7130f322cb7e 277 \details Returns the current value of the Main Stack Pointer (MSP).
mbed_official 159:7130f322cb7e 278 \return MSP Register value
mbed_official 159:7130f322cb7e 279 */
mbed_official 159:7130f322cb7e 280 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
mbed_official 159:7130f322cb7e 281 {
mbed_official 159:7130f322cb7e 282 register uint32_t result;
mbed_official 159:7130f322cb7e 283
mbed_official 159:7130f322cb7e 284 __ASM volatile ("MRS %0, msp" : "=r" (result) );
mbed_official 159:7130f322cb7e 285 return(result);
mbed_official 159:7130f322cb7e 286 }
mbed_official 159:7130f322cb7e 287
mbed_official 159:7130f322cb7e 288
mbed_official 159:7130f322cb7e 289 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 290 /**
mbed_official 159:7130f322cb7e 291 \brief Get Main Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 292 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
mbed_official 159:7130f322cb7e 293 \return MSP Register value
mbed_official 159:7130f322cb7e 294 */
mbed_official 159:7130f322cb7e 295 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
mbed_official 159:7130f322cb7e 296 {
mbed_official 159:7130f322cb7e 297 register uint32_t result;
mbed_official 159:7130f322cb7e 298
mbed_official 159:7130f322cb7e 299 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 300 return(result);
mbed_official 159:7130f322cb7e 301 }
mbed_official 159:7130f322cb7e 302 #endif
mbed_official 159:7130f322cb7e 303
mbed_official 159:7130f322cb7e 304
mbed_official 159:7130f322cb7e 305 /**
mbed_official 159:7130f322cb7e 306 \brief Set Main Stack Pointer
mbed_official 159:7130f322cb7e 307 \details Assigns the given value to the Main Stack Pointer (MSP).
mbed_official 159:7130f322cb7e 308 \param [in] topOfMainStack Main Stack Pointer value to set
mbed_official 159:7130f322cb7e 309 */
mbed_official 159:7130f322cb7e 310 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
mbed_official 159:7130f322cb7e 311 {
mbed_official 159:7130f322cb7e 312 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
mbed_official 159:7130f322cb7e 313 }
mbed_official 159:7130f322cb7e 314
mbed_official 159:7130f322cb7e 315
mbed_official 159:7130f322cb7e 316 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 317 /**
mbed_official 159:7130f322cb7e 318 \brief Set Main Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 319 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
mbed_official 159:7130f322cb7e 320 \param [in] topOfMainStack Main Stack Pointer value to set
mbed_official 159:7130f322cb7e 321 */
mbed_official 159:7130f322cb7e 322 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
mbed_official 159:7130f322cb7e 323 {
mbed_official 159:7130f322cb7e 324 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
mbed_official 159:7130f322cb7e 325 }
mbed_official 159:7130f322cb7e 326 #endif
mbed_official 159:7130f322cb7e 327
mbed_official 159:7130f322cb7e 328
mbed_official 159:7130f322cb7e 329 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 330 /**
mbed_official 159:7130f322cb7e 331 \brief Get Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 332 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
mbed_official 159:7130f322cb7e 333 \return SP Register value
mbed_official 159:7130f322cb7e 334 */
mbed_official 159:7130f322cb7e 335 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_SP_NS(void)
mbed_official 159:7130f322cb7e 336 {
mbed_official 159:7130f322cb7e 337 register uint32_t result;
mbed_official 159:7130f322cb7e 338
mbed_official 159:7130f322cb7e 339 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 340 return(result);
mbed_official 159:7130f322cb7e 341 }
mbed_official 159:7130f322cb7e 342
mbed_official 159:7130f322cb7e 343
mbed_official 159:7130f322cb7e 344 /**
mbed_official 159:7130f322cb7e 345 \brief Set Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 346 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
mbed_official 159:7130f322cb7e 347 \param [in] topOfStack Stack Pointer value to set
mbed_official 159:7130f322cb7e 348 */
mbed_official 159:7130f322cb7e 349 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_SP_NS(uint32_t topOfStack)
mbed_official 159:7130f322cb7e 350 {
mbed_official 159:7130f322cb7e 351 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
mbed_official 159:7130f322cb7e 352 }
mbed_official 159:7130f322cb7e 353 #endif
mbed_official 159:7130f322cb7e 354
mbed_official 159:7130f322cb7e 355
mbed_official 159:7130f322cb7e 356 /**
mbed_official 159:7130f322cb7e 357 \brief Get Priority Mask
mbed_official 159:7130f322cb7e 358 \details Returns the current state of the priority mask bit from the Priority Mask Register.
mbed_official 159:7130f322cb7e 359 \return Priority Mask value
mbed_official 159:7130f322cb7e 360 */
mbed_official 159:7130f322cb7e 361 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
mbed_official 159:7130f322cb7e 362 {
mbed_official 159:7130f322cb7e 363 uint32_t result;
mbed_official 159:7130f322cb7e 364
mbed_official 159:7130f322cb7e 365 __ASM volatile ("MRS %0, primask" : "=r" (result) );
mbed_official 159:7130f322cb7e 366 return(result);
mbed_official 159:7130f322cb7e 367 }
mbed_official 159:7130f322cb7e 368
mbed_official 159:7130f322cb7e 369
mbed_official 159:7130f322cb7e 370 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 371 /**
mbed_official 159:7130f322cb7e 372 \brief Get Priority Mask (non-secure)
mbed_official 159:7130f322cb7e 373 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
mbed_official 159:7130f322cb7e 374 \return Priority Mask value
mbed_official 159:7130f322cb7e 375 */
mbed_official 159:7130f322cb7e 376 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
mbed_official 159:7130f322cb7e 377 {
mbed_official 159:7130f322cb7e 378 uint32_t result;
mbed_official 159:7130f322cb7e 379
mbed_official 159:7130f322cb7e 380 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 381 return(result);
mbed_official 159:7130f322cb7e 382 }
mbed_official 159:7130f322cb7e 383 #endif
mbed_official 159:7130f322cb7e 384
mbed_official 159:7130f322cb7e 385
mbed_official 159:7130f322cb7e 386 /**
mbed_official 159:7130f322cb7e 387 \brief Set Priority Mask
mbed_official 159:7130f322cb7e 388 \details Assigns the given value to the Priority Mask Register.
mbed_official 159:7130f322cb7e 389 \param [in] priMask Priority Mask
mbed_official 159:7130f322cb7e 390 */
mbed_official 159:7130f322cb7e 391 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
mbed_official 159:7130f322cb7e 392 {
mbed_official 159:7130f322cb7e 393 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
mbed_official 159:7130f322cb7e 394 }
mbed_official 159:7130f322cb7e 395
mbed_official 159:7130f322cb7e 396
mbed_official 159:7130f322cb7e 397 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 398 /**
mbed_official 159:7130f322cb7e 399 \brief Set Priority Mask (non-secure)
mbed_official 159:7130f322cb7e 400 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
mbed_official 159:7130f322cb7e 401 \param [in] priMask Priority Mask
mbed_official 159:7130f322cb7e 402 */
mbed_official 159:7130f322cb7e 403 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
mbed_official 159:7130f322cb7e 404 {
mbed_official 159:7130f322cb7e 405 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
mbed_official 159:7130f322cb7e 406 }
mbed_official 159:7130f322cb7e 407 #endif
mbed_official 159:7130f322cb7e 408
mbed_official 159:7130f322cb7e 409
mbed_official 159:7130f322cb7e 410 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 411 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 412 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 413 /**
mbed_official 159:7130f322cb7e 414 \brief Enable FIQ
mbed_official 159:7130f322cb7e 415 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
mbed_official 159:7130f322cb7e 416 Can only be executed in Privileged modes.
mbed_official 159:7130f322cb7e 417 */
mbed_official 159:7130f322cb7e 418 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
mbed_official 159:7130f322cb7e 419
mbed_official 159:7130f322cb7e 420
mbed_official 159:7130f322cb7e 421 /**
mbed_official 159:7130f322cb7e 422 \brief Disable FIQ
mbed_official 159:7130f322cb7e 423 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
mbed_official 159:7130f322cb7e 424 Can only be executed in Privileged modes.
mbed_official 159:7130f322cb7e 425 */
mbed_official 159:7130f322cb7e 426 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
mbed_official 159:7130f322cb7e 427
mbed_official 159:7130f322cb7e 428
mbed_official 159:7130f322cb7e 429 /**
mbed_official 159:7130f322cb7e 430 \brief Get Base Priority
mbed_official 159:7130f322cb7e 431 \details Returns the current value of the Base Priority register.
mbed_official 159:7130f322cb7e 432 \return Base Priority register value
mbed_official 159:7130f322cb7e 433 */
mbed_official 159:7130f322cb7e 434 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
mbed_official 159:7130f322cb7e 435 {
mbed_official 159:7130f322cb7e 436 uint32_t result;
mbed_official 159:7130f322cb7e 437
mbed_official 159:7130f322cb7e 438 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
mbed_official 159:7130f322cb7e 439 return(result);
mbed_official 159:7130f322cb7e 440 }
mbed_official 159:7130f322cb7e 441
mbed_official 159:7130f322cb7e 442
mbed_official 159:7130f322cb7e 443 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 444 /**
mbed_official 159:7130f322cb7e 445 \brief Get Base Priority (non-secure)
mbed_official 159:7130f322cb7e 446 \details Returns the current value of the non-secure Base Priority register when in secure state.
mbed_official 159:7130f322cb7e 447 \return Base Priority register value
mbed_official 159:7130f322cb7e 448 */
mbed_official 159:7130f322cb7e 449 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
mbed_official 159:7130f322cb7e 450 {
mbed_official 159:7130f322cb7e 451 uint32_t result;
mbed_official 159:7130f322cb7e 452
mbed_official 159:7130f322cb7e 453 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 454 return(result);
mbed_official 159:7130f322cb7e 455 }
mbed_official 159:7130f322cb7e 456 #endif
mbed_official 159:7130f322cb7e 457
mbed_official 159:7130f322cb7e 458
mbed_official 159:7130f322cb7e 459 /**
mbed_official 159:7130f322cb7e 460 \brief Set Base Priority
mbed_official 159:7130f322cb7e 461 \details Assigns the given value to the Base Priority register.
mbed_official 159:7130f322cb7e 462 \param [in] basePri Base Priority value to set
mbed_official 159:7130f322cb7e 463 */
mbed_official 159:7130f322cb7e 464 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
mbed_official 159:7130f322cb7e 465 {
mbed_official 159:7130f322cb7e 466 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
mbed_official 159:7130f322cb7e 467 }
mbed_official 159:7130f322cb7e 468
mbed_official 159:7130f322cb7e 469
mbed_official 159:7130f322cb7e 470 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 471 /**
mbed_official 159:7130f322cb7e 472 \brief Set Base Priority (non-secure)
mbed_official 159:7130f322cb7e 473 \details Assigns the given value to the non-secure Base Priority register when in secure state.
mbed_official 159:7130f322cb7e 474 \param [in] basePri Base Priority value to set
mbed_official 159:7130f322cb7e 475 */
mbed_official 159:7130f322cb7e 476 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
mbed_official 159:7130f322cb7e 477 {
mbed_official 159:7130f322cb7e 478 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
mbed_official 159:7130f322cb7e 479 }
mbed_official 159:7130f322cb7e 480 #endif
mbed_official 159:7130f322cb7e 481
mbed_official 159:7130f322cb7e 482
mbed_official 159:7130f322cb7e 483 /**
mbed_official 159:7130f322cb7e 484 \brief Set Base Priority with condition
mbed_official 159:7130f322cb7e 485 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
mbed_official 159:7130f322cb7e 486 or the new value increases the BASEPRI priority level.
mbed_official 159:7130f322cb7e 487 \param [in] basePri Base Priority value to set
mbed_official 159:7130f322cb7e 488 */
mbed_official 159:7130f322cb7e 489 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
mbed_official 159:7130f322cb7e 490 {
mbed_official 159:7130f322cb7e 491 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
mbed_official 159:7130f322cb7e 492 }
mbed_official 159:7130f322cb7e 493
mbed_official 159:7130f322cb7e 494
mbed_official 159:7130f322cb7e 495 /**
mbed_official 159:7130f322cb7e 496 \brief Get Fault Mask
mbed_official 159:7130f322cb7e 497 \details Returns the current value of the Fault Mask register.
mbed_official 159:7130f322cb7e 498 \return Fault Mask register value
mbed_official 159:7130f322cb7e 499 */
mbed_official 159:7130f322cb7e 500 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
mbed_official 159:7130f322cb7e 501 {
mbed_official 159:7130f322cb7e 502 uint32_t result;
mbed_official 159:7130f322cb7e 503
mbed_official 159:7130f322cb7e 504 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
mbed_official 159:7130f322cb7e 505 return(result);
mbed_official 159:7130f322cb7e 506 }
mbed_official 159:7130f322cb7e 507
mbed_official 159:7130f322cb7e 508
mbed_official 159:7130f322cb7e 509 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 510 /**
mbed_official 159:7130f322cb7e 511 \brief Get Fault Mask (non-secure)
mbed_official 159:7130f322cb7e 512 \details Returns the current value of the non-secure Fault Mask register when in secure state.
mbed_official 159:7130f322cb7e 513 \return Fault Mask register value
mbed_official 159:7130f322cb7e 514 */
mbed_official 159:7130f322cb7e 515 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
mbed_official 159:7130f322cb7e 516 {
mbed_official 159:7130f322cb7e 517 uint32_t result;
mbed_official 159:7130f322cb7e 518
mbed_official 159:7130f322cb7e 519 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 520 return(result);
mbed_official 159:7130f322cb7e 521 }
mbed_official 159:7130f322cb7e 522 #endif
mbed_official 159:7130f322cb7e 523
mbed_official 159:7130f322cb7e 524
mbed_official 159:7130f322cb7e 525 /**
mbed_official 159:7130f322cb7e 526 \brief Set Fault Mask
mbed_official 159:7130f322cb7e 527 \details Assigns the given value to the Fault Mask register.
mbed_official 159:7130f322cb7e 528 \param [in] faultMask Fault Mask value to set
mbed_official 159:7130f322cb7e 529 */
mbed_official 159:7130f322cb7e 530 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
mbed_official 159:7130f322cb7e 531 {
mbed_official 159:7130f322cb7e 532 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
mbed_official 159:7130f322cb7e 533 }
mbed_official 159:7130f322cb7e 534
mbed_official 159:7130f322cb7e 535
mbed_official 159:7130f322cb7e 536 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
mbed_official 159:7130f322cb7e 537 /**
mbed_official 159:7130f322cb7e 538 \brief Set Fault Mask (non-secure)
mbed_official 159:7130f322cb7e 539 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
mbed_official 159:7130f322cb7e 540 \param [in] faultMask Fault Mask value to set
mbed_official 159:7130f322cb7e 541 */
mbed_official 159:7130f322cb7e 542 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
mbed_official 159:7130f322cb7e 543 {
mbed_official 159:7130f322cb7e 544 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
mbed_official 159:7130f322cb7e 545 }
mbed_official 159:7130f322cb7e 546 #endif
mbed_official 159:7130f322cb7e 547
mbed_official 159:7130f322cb7e 548 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 549 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 550 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
mbed_official 159:7130f322cb7e 551
mbed_official 159:7130f322cb7e 552
mbed_official 159:7130f322cb7e 553 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
mbed_official 159:7130f322cb7e 554 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
mbed_official 159:7130f322cb7e 555
mbed_official 159:7130f322cb7e 556 /**
mbed_official 159:7130f322cb7e 557 \brief Get Process Stack Pointer Limit
mbed_official 159:7130f322cb7e 558 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
mbed_official 159:7130f322cb7e 559 \return PSPLIM Register value
mbed_official 159:7130f322cb7e 560 */
mbed_official 159:7130f322cb7e 561 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
mbed_official 159:7130f322cb7e 562 {
mbed_official 159:7130f322cb7e 563 register uint32_t result;
mbed_official 159:7130f322cb7e 564
mbed_official 159:7130f322cb7e 565 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
mbed_official 159:7130f322cb7e 566 return(result);
mbed_official 159:7130f322cb7e 567 }
mbed_official 159:7130f322cb7e 568
mbed_official 159:7130f322cb7e 569
mbed_official 159:7130f322cb7e 570 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
mbed_official 159:7130f322cb7e 571 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 572 /**
mbed_official 159:7130f322cb7e 573 \brief Get Process Stack Pointer Limit (non-secure)
mbed_official 159:7130f322cb7e 574 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
mbed_official 159:7130f322cb7e 575 \return PSPLIM Register value
mbed_official 159:7130f322cb7e 576 */
mbed_official 159:7130f322cb7e 577 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
mbed_official 159:7130f322cb7e 578 {
mbed_official 159:7130f322cb7e 579 register uint32_t result;
mbed_official 159:7130f322cb7e 580
mbed_official 159:7130f322cb7e 581 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 582 return(result);
mbed_official 159:7130f322cb7e 583 }
mbed_official 159:7130f322cb7e 584 #endif
mbed_official 159:7130f322cb7e 585
mbed_official 159:7130f322cb7e 586
mbed_official 159:7130f322cb7e 587 /**
mbed_official 159:7130f322cb7e 588 \brief Set Process Stack Pointer Limit
mbed_official 159:7130f322cb7e 589 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
mbed_official 159:7130f322cb7e 590 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
mbed_official 159:7130f322cb7e 591 */
mbed_official 159:7130f322cb7e 592 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
mbed_official 159:7130f322cb7e 593 {
mbed_official 159:7130f322cb7e 594 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
mbed_official 159:7130f322cb7e 595 }
mbed_official 159:7130f322cb7e 596
mbed_official 159:7130f322cb7e 597
mbed_official 159:7130f322cb7e 598 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
mbed_official 159:7130f322cb7e 599 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 600 /**
mbed_official 159:7130f322cb7e 601 \brief Set Process Stack Pointer (non-secure)
mbed_official 159:7130f322cb7e 602 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
mbed_official 159:7130f322cb7e 603 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
mbed_official 159:7130f322cb7e 604 */
mbed_official 159:7130f322cb7e 605 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
mbed_official 159:7130f322cb7e 606 {
mbed_official 159:7130f322cb7e 607 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
mbed_official 159:7130f322cb7e 608 }
mbed_official 159:7130f322cb7e 609 #endif
mbed_official 159:7130f322cb7e 610
mbed_official 159:7130f322cb7e 611
mbed_official 159:7130f322cb7e 612 /**
mbed_official 159:7130f322cb7e 613 \brief Get Main Stack Pointer Limit
mbed_official 159:7130f322cb7e 614 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
mbed_official 159:7130f322cb7e 615 \return MSPLIM Register value
mbed_official 159:7130f322cb7e 616 */
mbed_official 159:7130f322cb7e 617 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
mbed_official 159:7130f322cb7e 618 {
mbed_official 159:7130f322cb7e 619 register uint32_t result;
mbed_official 159:7130f322cb7e 620
mbed_official 159:7130f322cb7e 621 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
mbed_official 159:7130f322cb7e 622
mbed_official 159:7130f322cb7e 623 return(result);
mbed_official 159:7130f322cb7e 624 }
mbed_official 159:7130f322cb7e 625
mbed_official 159:7130f322cb7e 626
mbed_official 159:7130f322cb7e 627 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
mbed_official 159:7130f322cb7e 628 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 629 /**
mbed_official 159:7130f322cb7e 630 \brief Get Main Stack Pointer Limit (non-secure)
mbed_official 159:7130f322cb7e 631 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
mbed_official 159:7130f322cb7e 632 \return MSPLIM Register value
mbed_official 159:7130f322cb7e 633 */
mbed_official 159:7130f322cb7e 634 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
mbed_official 159:7130f322cb7e 635 {
mbed_official 159:7130f322cb7e 636 register uint32_t result;
mbed_official 159:7130f322cb7e 637
mbed_official 159:7130f322cb7e 638 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
mbed_official 159:7130f322cb7e 639 return(result);
mbed_official 159:7130f322cb7e 640 }
mbed_official 159:7130f322cb7e 641 #endif
mbed_official 159:7130f322cb7e 642
mbed_official 159:7130f322cb7e 643
mbed_official 159:7130f322cb7e 644 /**
mbed_official 159:7130f322cb7e 645 \brief Set Main Stack Pointer Limit
mbed_official 159:7130f322cb7e 646 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
mbed_official 159:7130f322cb7e 647 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
mbed_official 159:7130f322cb7e 648 */
mbed_official 159:7130f322cb7e 649 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
mbed_official 159:7130f322cb7e 650 {
mbed_official 159:7130f322cb7e 651 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
mbed_official 159:7130f322cb7e 652 }
mbed_official 159:7130f322cb7e 653
mbed_official 159:7130f322cb7e 654
mbed_official 159:7130f322cb7e 655 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
mbed_official 159:7130f322cb7e 656 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 657 /**
mbed_official 159:7130f322cb7e 658 \brief Set Main Stack Pointer Limit (non-secure)
mbed_official 159:7130f322cb7e 659 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
mbed_official 159:7130f322cb7e 660 \param [in] MainStackPtrLimit Main Stack Pointer value to set
mbed_official 159:7130f322cb7e 661 */
mbed_official 159:7130f322cb7e 662 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
mbed_official 159:7130f322cb7e 663 {
mbed_official 159:7130f322cb7e 664 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
mbed_official 159:7130f322cb7e 665 }
mbed_official 159:7130f322cb7e 666 #endif
mbed_official 159:7130f322cb7e 667
mbed_official 159:7130f322cb7e 668 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
mbed_official 159:7130f322cb7e 669 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
mbed_official 159:7130f322cb7e 670
mbed_official 159:7130f322cb7e 671
mbed_official 159:7130f322cb7e 672 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 673 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 674
mbed_official 159:7130f322cb7e 675 /**
mbed_official 159:7130f322cb7e 676 \brief Get FPSCR
mbed_official 159:7130f322cb7e 677 \details Returns the current value of the Floating Point Status/Control register.
mbed_official 159:7130f322cb7e 678 \return Floating Point Status/Control register value
mbed_official 159:7130f322cb7e 679 */
mbed_official 159:7130f322cb7e 680 /* #define __get_FPSCR __builtin_arm_get_fpscr */
mbed_official 159:7130f322cb7e 681 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
mbed_official 159:7130f322cb7e 682 {
mbed_official 159:7130f322cb7e 683 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
mbed_official 159:7130f322cb7e 684 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
mbed_official 159:7130f322cb7e 685 uint32_t result;
mbed_official 159:7130f322cb7e 686
mbed_official 159:7130f322cb7e 687 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
mbed_official 159:7130f322cb7e 688 return(result);
mbed_official 159:7130f322cb7e 689 #else
mbed_official 159:7130f322cb7e 690 return(0U);
mbed_official 159:7130f322cb7e 691 #endif
mbed_official 159:7130f322cb7e 692 }
mbed_official 159:7130f322cb7e 693
mbed_official 159:7130f322cb7e 694
mbed_official 159:7130f322cb7e 695 /**
mbed_official 159:7130f322cb7e 696 \brief Set FPSCR
mbed_official 159:7130f322cb7e 697 \details Assigns the given value to the Floating Point Status/Control register.
mbed_official 159:7130f322cb7e 698 \param [in] fpscr Floating Point Status/Control value to set
mbed_official 159:7130f322cb7e 699 */
mbed_official 159:7130f322cb7e 700 /* #define __set_FPSCR __builtin_arm_set_fpscr */
mbed_official 159:7130f322cb7e 701 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
mbed_official 159:7130f322cb7e 702 {
mbed_official 159:7130f322cb7e 703 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
mbed_official 159:7130f322cb7e 704 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
mbed_official 159:7130f322cb7e 705 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
mbed_official 159:7130f322cb7e 706 #else
mbed_official 159:7130f322cb7e 707 (void)fpscr;
mbed_official 159:7130f322cb7e 708 #endif
mbed_official 159:7130f322cb7e 709 }
mbed_official 159:7130f322cb7e 710
mbed_official 159:7130f322cb7e 711 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 712 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
mbed_official 159:7130f322cb7e 713
mbed_official 159:7130f322cb7e 714
mbed_official 159:7130f322cb7e 715
mbed_official 159:7130f322cb7e 716 /*@} end of CMSIS_Core_RegAccFunctions */
mbed_official 159:7130f322cb7e 717
mbed_official 159:7130f322cb7e 718
mbed_official 159:7130f322cb7e 719 /* ########################## Core Instruction Access ######################### */
mbed_official 159:7130f322cb7e 720 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
mbed_official 159:7130f322cb7e 721 Access to dedicated instructions
mbed_official 159:7130f322cb7e 722 @{
mbed_official 159:7130f322cb7e 723 */
mbed_official 159:7130f322cb7e 724
mbed_official 159:7130f322cb7e 725 /* Define macros for porting to both thumb1 and thumb2.
mbed_official 159:7130f322cb7e 726 * For thumb1, use low register (r0-r7), specified by constraint "l"
mbed_official 159:7130f322cb7e 727 * Otherwise, use general registers, specified by constraint "r" */
mbed_official 159:7130f322cb7e 728 #if defined (__thumb__) && !defined (__thumb2__)
mbed_official 159:7130f322cb7e 729 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
mbed_official 159:7130f322cb7e 730 #define __CMSIS_GCC_USE_REG(r) "l" (r)
mbed_official 159:7130f322cb7e 731 #else
mbed_official 159:7130f322cb7e 732 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
mbed_official 159:7130f322cb7e 733 #define __CMSIS_GCC_USE_REG(r) "r" (r)
mbed_official 159:7130f322cb7e 734 #endif
mbed_official 159:7130f322cb7e 735
mbed_official 159:7130f322cb7e 736 /**
mbed_official 159:7130f322cb7e 737 \brief No Operation
mbed_official 159:7130f322cb7e 738 \details No Operation does nothing. This instruction can be used for code alignment purposes.
mbed_official 159:7130f322cb7e 739 */
mbed_official 159:7130f322cb7e 740 #define __NOP __builtin_arm_nop
mbed_official 159:7130f322cb7e 741
mbed_official 159:7130f322cb7e 742 /**
mbed_official 159:7130f322cb7e 743 \brief Wait For Interrupt
mbed_official 159:7130f322cb7e 744 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
mbed_official 159:7130f322cb7e 745 */
mbed_official 159:7130f322cb7e 746 #define __WFI __builtin_arm_wfi
mbed_official 159:7130f322cb7e 747
mbed_official 159:7130f322cb7e 748
mbed_official 159:7130f322cb7e 749 /**
mbed_official 159:7130f322cb7e 750 \brief Wait For Event
mbed_official 159:7130f322cb7e 751 \details Wait For Event is a hint instruction that permits the processor to enter
mbed_official 159:7130f322cb7e 752 a low-power state until one of a number of events occurs.
mbed_official 159:7130f322cb7e 753 */
mbed_official 159:7130f322cb7e 754 #define __WFE __builtin_arm_wfe
mbed_official 159:7130f322cb7e 755
mbed_official 159:7130f322cb7e 756
mbed_official 159:7130f322cb7e 757 /**
mbed_official 159:7130f322cb7e 758 \brief Send Event
mbed_official 159:7130f322cb7e 759 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
mbed_official 159:7130f322cb7e 760 */
mbed_official 159:7130f322cb7e 761 #define __SEV __builtin_arm_sev
mbed_official 159:7130f322cb7e 762
mbed_official 159:7130f322cb7e 763
mbed_official 159:7130f322cb7e 764 /**
mbed_official 159:7130f322cb7e 765 \brief Instruction Synchronization Barrier
mbed_official 159:7130f322cb7e 766 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
mbed_official 159:7130f322cb7e 767 so that all instructions following the ISB are fetched from cache or memory,
mbed_official 159:7130f322cb7e 768 after the instruction has been completed.
mbed_official 159:7130f322cb7e 769 */
mbed_official 159:7130f322cb7e 770 #define __ISB() __builtin_arm_isb(0xF);
mbed_official 159:7130f322cb7e 771
mbed_official 159:7130f322cb7e 772 /**
mbed_official 159:7130f322cb7e 773 \brief Data Synchronization Barrier
mbed_official 159:7130f322cb7e 774 \details Acts as a special kind of Data Memory Barrier.
mbed_official 159:7130f322cb7e 775 It completes when all explicit memory accesses before this instruction complete.
mbed_official 159:7130f322cb7e 776 */
mbed_official 159:7130f322cb7e 777 #define __DSB() __builtin_arm_dsb(0xF);
mbed_official 159:7130f322cb7e 778
mbed_official 159:7130f322cb7e 779
mbed_official 159:7130f322cb7e 780 /**
mbed_official 159:7130f322cb7e 781 \brief Data Memory Barrier
mbed_official 159:7130f322cb7e 782 \details Ensures the apparent order of the explicit memory operations before
mbed_official 159:7130f322cb7e 783 and after the instruction, without ensuring their completion.
mbed_official 159:7130f322cb7e 784 */
mbed_official 159:7130f322cb7e 785 #define __DMB() __builtin_arm_dmb(0xF);
mbed_official 159:7130f322cb7e 786
mbed_official 159:7130f322cb7e 787
mbed_official 159:7130f322cb7e 788 /**
mbed_official 159:7130f322cb7e 789 \brief Reverse byte order (32 bit)
mbed_official 159:7130f322cb7e 790 \details Reverses the byte order in integer value.
mbed_official 159:7130f322cb7e 791 \param [in] value Value to reverse
mbed_official 159:7130f322cb7e 792 \return Reversed value
mbed_official 159:7130f322cb7e 793 */
mbed_official 159:7130f322cb7e 794 #define __REV __builtin_bswap32
mbed_official 159:7130f322cb7e 795
mbed_official 159:7130f322cb7e 796
mbed_official 159:7130f322cb7e 797 /**
mbed_official 159:7130f322cb7e 798 \brief Reverse byte order (16 bit)
mbed_official 159:7130f322cb7e 799 \details Reverses the byte order in two unsigned short values.
mbed_official 159:7130f322cb7e 800 \param [in] value Value to reverse
mbed_official 159:7130f322cb7e 801 \return Reversed value
mbed_official 159:7130f322cb7e 802 */
mbed_official 159:7130f322cb7e 803 #define __REV16 __builtin_bswap16 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
mbed_official 159:7130f322cb7e 804 #if 0
mbed_official 159:7130f322cb7e 805 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
mbed_official 159:7130f322cb7e 806 {
mbed_official 159:7130f322cb7e 807 uint32_t result;
mbed_official 159:7130f322cb7e 808
mbed_official 159:7130f322cb7e 809 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
mbed_official 159:7130f322cb7e 810 return(result);
mbed_official 159:7130f322cb7e 811 }
mbed_official 159:7130f322cb7e 812 #endif
mbed_official 159:7130f322cb7e 813
mbed_official 159:7130f322cb7e 814
mbed_official 159:7130f322cb7e 815 /**
mbed_official 159:7130f322cb7e 816 \brief Reverse byte order in signed short value
mbed_official 159:7130f322cb7e 817 \details Reverses the byte order in a signed short value with sign extension to integer.
mbed_official 159:7130f322cb7e 818 \param [in] value Value to reverse
mbed_official 159:7130f322cb7e 819 \return Reversed value
mbed_official 159:7130f322cb7e 820 */
mbed_official 159:7130f322cb7e 821 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
mbed_official 159:7130f322cb7e 822 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
mbed_official 159:7130f322cb7e 823 {
mbed_official 159:7130f322cb7e 824 int32_t result;
mbed_official 159:7130f322cb7e 825
mbed_official 159:7130f322cb7e 826 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
mbed_official 159:7130f322cb7e 827 return(result);
mbed_official 159:7130f322cb7e 828 }
mbed_official 159:7130f322cb7e 829
mbed_official 159:7130f322cb7e 830
mbed_official 159:7130f322cb7e 831 /**
mbed_official 159:7130f322cb7e 832 \brief Rotate Right in unsigned value (32 bit)
mbed_official 159:7130f322cb7e 833 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
mbed_official 159:7130f322cb7e 834 \param [in] op1 Value to rotate
mbed_official 159:7130f322cb7e 835 \param [in] op2 Number of Bits to rotate
mbed_official 159:7130f322cb7e 836 \return Rotated value
mbed_official 159:7130f322cb7e 837 */
mbed_official 159:7130f322cb7e 838 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 839 {
mbed_official 159:7130f322cb7e 840 return (op1 >> op2) | (op1 << (32U - op2));
mbed_official 159:7130f322cb7e 841 }
mbed_official 159:7130f322cb7e 842
mbed_official 159:7130f322cb7e 843
mbed_official 159:7130f322cb7e 844 /**
mbed_official 159:7130f322cb7e 845 \brief Breakpoint
mbed_official 159:7130f322cb7e 846 \details Causes the processor to enter Debug state.
mbed_official 159:7130f322cb7e 847 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
mbed_official 159:7130f322cb7e 848 \param [in] value is ignored by the processor.
mbed_official 159:7130f322cb7e 849 If required, a debugger can use it to store additional information about the breakpoint.
mbed_official 159:7130f322cb7e 850 */
mbed_official 159:7130f322cb7e 851 #define __BKPT(value) __ASM volatile ("bkpt "#value)
mbed_official 159:7130f322cb7e 852
mbed_official 159:7130f322cb7e 853
mbed_official 159:7130f322cb7e 854 /**
mbed_official 159:7130f322cb7e 855 \brief Reverse bit order of value
mbed_official 159:7130f322cb7e 856 \details Reverses the bit order of the given value.
mbed_official 159:7130f322cb7e 857 \param [in] value Value to reverse
mbed_official 159:7130f322cb7e 858 \return Reversed value
mbed_official 159:7130f322cb7e 859 */
mbed_official 159:7130f322cb7e 860 /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
mbed_official 159:7130f322cb7e 861 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
mbed_official 159:7130f322cb7e 862 {
mbed_official 159:7130f322cb7e 863 uint32_t result;
mbed_official 159:7130f322cb7e 864
mbed_official 159:7130f322cb7e 865 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 866 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 867 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 868 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
mbed_official 159:7130f322cb7e 869 #else
mbed_official 159:7130f322cb7e 870 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
mbed_official 159:7130f322cb7e 871
mbed_official 159:7130f322cb7e 872 result = value; /* r will be reversed bits of v; first get LSB of v */
mbed_official 159:7130f322cb7e 873 for (value >>= 1U; value; value >>= 1U)
mbed_official 159:7130f322cb7e 874 {
mbed_official 159:7130f322cb7e 875 result <<= 1U;
mbed_official 159:7130f322cb7e 876 result |= value & 1U;
mbed_official 159:7130f322cb7e 877 s--;
mbed_official 159:7130f322cb7e 878 }
mbed_official 159:7130f322cb7e 879 result <<= s; /* shift when v's highest bits are zero */
mbed_official 159:7130f322cb7e 880 #endif
mbed_official 159:7130f322cb7e 881 return(result);
mbed_official 159:7130f322cb7e 882 }
mbed_official 159:7130f322cb7e 883
mbed_official 159:7130f322cb7e 884
mbed_official 159:7130f322cb7e 885 /**
mbed_official 159:7130f322cb7e 886 \brief Count leading zeros
mbed_official 159:7130f322cb7e 887 \details Counts the number of leading zeros of a data value.
mbed_official 159:7130f322cb7e 888 \param [in] value Value to count the leading zeros
mbed_official 159:7130f322cb7e 889 \return number of leading zeros in value
mbed_official 159:7130f322cb7e 890 */
mbed_official 159:7130f322cb7e 891 #define __CLZ __builtin_clz
mbed_official 159:7130f322cb7e 892
mbed_official 159:7130f322cb7e 893
mbed_official 159:7130f322cb7e 894 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 895 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 896 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
mbed_official 159:7130f322cb7e 897 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
mbed_official 159:7130f322cb7e 898 /**
mbed_official 159:7130f322cb7e 899 \brief LDR Exclusive (8 bit)
mbed_official 159:7130f322cb7e 900 \details Executes a exclusive LDR instruction for 8 bit value.
mbed_official 159:7130f322cb7e 901 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 902 \return value of type uint8_t at (*ptr)
mbed_official 159:7130f322cb7e 903 */
mbed_official 159:7130f322cb7e 904 #define __LDREXB (uint8_t)__builtin_arm_ldrex
mbed_official 159:7130f322cb7e 905
mbed_official 159:7130f322cb7e 906
mbed_official 159:7130f322cb7e 907 /**
mbed_official 159:7130f322cb7e 908 \brief LDR Exclusive (16 bit)
mbed_official 159:7130f322cb7e 909 \details Executes a exclusive LDR instruction for 16 bit values.
mbed_official 159:7130f322cb7e 910 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 911 \return value of type uint16_t at (*ptr)
mbed_official 159:7130f322cb7e 912 */
mbed_official 159:7130f322cb7e 913 #define __LDREXH (uint16_t)__builtin_arm_ldrex
mbed_official 159:7130f322cb7e 914
mbed_official 159:7130f322cb7e 915
mbed_official 159:7130f322cb7e 916 /**
mbed_official 159:7130f322cb7e 917 \brief LDR Exclusive (32 bit)
mbed_official 159:7130f322cb7e 918 \details Executes a exclusive LDR instruction for 32 bit values.
mbed_official 159:7130f322cb7e 919 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 920 \return value of type uint32_t at (*ptr)
mbed_official 159:7130f322cb7e 921 */
mbed_official 159:7130f322cb7e 922 #define __LDREXW (uint32_t)__builtin_arm_ldrex
mbed_official 159:7130f322cb7e 923
mbed_official 159:7130f322cb7e 924
mbed_official 159:7130f322cb7e 925 /**
mbed_official 159:7130f322cb7e 926 \brief STR Exclusive (8 bit)
mbed_official 159:7130f322cb7e 927 \details Executes a exclusive STR instruction for 8 bit values.
mbed_official 159:7130f322cb7e 928 \param [in] value Value to store
mbed_official 159:7130f322cb7e 929 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 930 \return 0 Function succeeded
mbed_official 159:7130f322cb7e 931 \return 1 Function failed
mbed_official 159:7130f322cb7e 932 */
mbed_official 159:7130f322cb7e 933 #define __STREXB (uint32_t)__builtin_arm_strex
mbed_official 159:7130f322cb7e 934
mbed_official 159:7130f322cb7e 935
mbed_official 159:7130f322cb7e 936 /**
mbed_official 159:7130f322cb7e 937 \brief STR Exclusive (16 bit)
mbed_official 159:7130f322cb7e 938 \details Executes a exclusive STR instruction for 16 bit values.
mbed_official 159:7130f322cb7e 939 \param [in] value Value to store
mbed_official 159:7130f322cb7e 940 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 941 \return 0 Function succeeded
mbed_official 159:7130f322cb7e 942 \return 1 Function failed
mbed_official 159:7130f322cb7e 943 */
mbed_official 159:7130f322cb7e 944 #define __STREXH (uint32_t)__builtin_arm_strex
mbed_official 159:7130f322cb7e 945
mbed_official 159:7130f322cb7e 946
mbed_official 159:7130f322cb7e 947 /**
mbed_official 159:7130f322cb7e 948 \brief STR Exclusive (32 bit)
mbed_official 159:7130f322cb7e 949 \details Executes a exclusive STR instruction for 32 bit values.
mbed_official 159:7130f322cb7e 950 \param [in] value Value to store
mbed_official 159:7130f322cb7e 951 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 952 \return 0 Function succeeded
mbed_official 159:7130f322cb7e 953 \return 1 Function failed
mbed_official 159:7130f322cb7e 954 */
mbed_official 159:7130f322cb7e 955 #define __STREXW (uint32_t)__builtin_arm_strex
mbed_official 159:7130f322cb7e 956
mbed_official 159:7130f322cb7e 957
mbed_official 159:7130f322cb7e 958 /**
mbed_official 159:7130f322cb7e 959 \brief Remove the exclusive lock
mbed_official 159:7130f322cb7e 960 \details Removes the exclusive lock which is created by LDREX.
mbed_official 159:7130f322cb7e 961 */
mbed_official 159:7130f322cb7e 962 #define __CLREX __builtin_arm_clrex
mbed_official 159:7130f322cb7e 963
mbed_official 159:7130f322cb7e 964 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 965 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 966 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
mbed_official 159:7130f322cb7e 967 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
mbed_official 159:7130f322cb7e 968
mbed_official 159:7130f322cb7e 969
mbed_official 159:7130f322cb7e 970 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 971 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 972 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
mbed_official 159:7130f322cb7e 973 /**
mbed_official 159:7130f322cb7e 974 \brief Signed Saturate
mbed_official 159:7130f322cb7e 975 \details Saturates a signed value.
mbed_official 159:7130f322cb7e 976 \param [in] value Value to be saturated
mbed_official 159:7130f322cb7e 977 \param [in] sat Bit position to saturate to (1..32)
mbed_official 159:7130f322cb7e 978 \return Saturated value
mbed_official 159:7130f322cb7e 979 */
mbed_official 159:7130f322cb7e 980 #define __SSAT __builtin_arm_ssat
mbed_official 159:7130f322cb7e 981
mbed_official 159:7130f322cb7e 982
mbed_official 159:7130f322cb7e 983 /**
mbed_official 159:7130f322cb7e 984 \brief Unsigned Saturate
mbed_official 159:7130f322cb7e 985 \details Saturates an unsigned value.
mbed_official 159:7130f322cb7e 986 \param [in] value Value to be saturated
mbed_official 159:7130f322cb7e 987 \param [in] sat Bit position to saturate to (0..31)
mbed_official 159:7130f322cb7e 988 \return Saturated value
mbed_official 159:7130f322cb7e 989 */
mbed_official 159:7130f322cb7e 990 #define __USAT __builtin_arm_usat
mbed_official 159:7130f322cb7e 991
mbed_official 159:7130f322cb7e 992
mbed_official 159:7130f322cb7e 993 /**
mbed_official 159:7130f322cb7e 994 \brief Rotate Right with Extend (32 bit)
mbed_official 159:7130f322cb7e 995 \details Moves each bit of a bitstring right by one bit.
mbed_official 159:7130f322cb7e 996 The carry input is shifted in at the left end of the bitstring.
mbed_official 159:7130f322cb7e 997 \param [in] value Value to rotate
mbed_official 159:7130f322cb7e 998 \return Rotated value
mbed_official 159:7130f322cb7e 999 */
mbed_official 159:7130f322cb7e 1000 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
mbed_official 159:7130f322cb7e 1001 {
mbed_official 159:7130f322cb7e 1002 uint32_t result;
mbed_official 159:7130f322cb7e 1003
mbed_official 159:7130f322cb7e 1004 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
mbed_official 159:7130f322cb7e 1005 return(result);
mbed_official 159:7130f322cb7e 1006 }
mbed_official 159:7130f322cb7e 1007
mbed_official 159:7130f322cb7e 1008
mbed_official 159:7130f322cb7e 1009 /**
mbed_official 159:7130f322cb7e 1010 \brief LDRT Unprivileged (8 bit)
mbed_official 159:7130f322cb7e 1011 \details Executes a Unprivileged LDRT instruction for 8 bit value.
mbed_official 159:7130f322cb7e 1012 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1013 \return value of type uint8_t at (*ptr)
mbed_official 159:7130f322cb7e 1014 */
mbed_official 159:7130f322cb7e 1015 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
mbed_official 159:7130f322cb7e 1016 {
mbed_official 159:7130f322cb7e 1017 uint32_t result;
mbed_official 159:7130f322cb7e 1018
mbed_official 159:7130f322cb7e 1019 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
mbed_official 159:7130f322cb7e 1020 return ((uint8_t) result); /* Add explicit type cast here */
mbed_official 159:7130f322cb7e 1021 }
mbed_official 159:7130f322cb7e 1022
mbed_official 159:7130f322cb7e 1023
mbed_official 159:7130f322cb7e 1024 /**
mbed_official 159:7130f322cb7e 1025 \brief LDRT Unprivileged (16 bit)
mbed_official 159:7130f322cb7e 1026 \details Executes a Unprivileged LDRT instruction for 16 bit values.
mbed_official 159:7130f322cb7e 1027 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1028 \return value of type uint16_t at (*ptr)
mbed_official 159:7130f322cb7e 1029 */
mbed_official 159:7130f322cb7e 1030 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
mbed_official 159:7130f322cb7e 1031 {
mbed_official 159:7130f322cb7e 1032 uint32_t result;
mbed_official 159:7130f322cb7e 1033
mbed_official 159:7130f322cb7e 1034 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
mbed_official 159:7130f322cb7e 1035 return ((uint16_t) result); /* Add explicit type cast here */
mbed_official 159:7130f322cb7e 1036 }
mbed_official 159:7130f322cb7e 1037
mbed_official 159:7130f322cb7e 1038
mbed_official 159:7130f322cb7e 1039 /**
mbed_official 159:7130f322cb7e 1040 \brief LDRT Unprivileged (32 bit)
mbed_official 159:7130f322cb7e 1041 \details Executes a Unprivileged LDRT instruction for 32 bit values.
mbed_official 159:7130f322cb7e 1042 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1043 \return value of type uint32_t at (*ptr)
mbed_official 159:7130f322cb7e 1044 */
mbed_official 159:7130f322cb7e 1045 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
mbed_official 159:7130f322cb7e 1046 {
mbed_official 159:7130f322cb7e 1047 uint32_t result;
mbed_official 159:7130f322cb7e 1048
mbed_official 159:7130f322cb7e 1049 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
mbed_official 159:7130f322cb7e 1050 return(result);
mbed_official 159:7130f322cb7e 1051 }
mbed_official 159:7130f322cb7e 1052
mbed_official 159:7130f322cb7e 1053
mbed_official 159:7130f322cb7e 1054 /**
mbed_official 159:7130f322cb7e 1055 \brief STRT Unprivileged (8 bit)
mbed_official 159:7130f322cb7e 1056 \details Executes a Unprivileged STRT instruction for 8 bit values.
mbed_official 159:7130f322cb7e 1057 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1058 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1059 */
mbed_official 159:7130f322cb7e 1060 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
mbed_official 159:7130f322cb7e 1061 {
mbed_official 159:7130f322cb7e 1062 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
mbed_official 159:7130f322cb7e 1063 }
mbed_official 159:7130f322cb7e 1064
mbed_official 159:7130f322cb7e 1065
mbed_official 159:7130f322cb7e 1066 /**
mbed_official 159:7130f322cb7e 1067 \brief STRT Unprivileged (16 bit)
mbed_official 159:7130f322cb7e 1068 \details Executes a Unprivileged STRT instruction for 16 bit values.
mbed_official 159:7130f322cb7e 1069 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1070 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1071 */
mbed_official 159:7130f322cb7e 1072 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
mbed_official 159:7130f322cb7e 1073 {
mbed_official 159:7130f322cb7e 1074 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
mbed_official 159:7130f322cb7e 1075 }
mbed_official 159:7130f322cb7e 1076
mbed_official 159:7130f322cb7e 1077
mbed_official 159:7130f322cb7e 1078 /**
mbed_official 159:7130f322cb7e 1079 \brief STRT Unprivileged (32 bit)
mbed_official 159:7130f322cb7e 1080 \details Executes a Unprivileged STRT instruction for 32 bit values.
mbed_official 159:7130f322cb7e 1081 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1082 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1083 */
mbed_official 159:7130f322cb7e 1084 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
mbed_official 159:7130f322cb7e 1085 {
mbed_official 159:7130f322cb7e 1086 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
mbed_official 159:7130f322cb7e 1087 }
mbed_official 159:7130f322cb7e 1088
mbed_official 159:7130f322cb7e 1089 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
mbed_official 159:7130f322cb7e 1090 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
mbed_official 159:7130f322cb7e 1091 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
mbed_official 159:7130f322cb7e 1092
mbed_official 159:7130f322cb7e 1093
mbed_official 159:7130f322cb7e 1094 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
mbed_official 159:7130f322cb7e 1095 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
mbed_official 159:7130f322cb7e 1096 /**
mbed_official 159:7130f322cb7e 1097 \brief Load-Acquire (8 bit)
mbed_official 159:7130f322cb7e 1098 \details Executes a LDAB instruction for 8 bit value.
mbed_official 159:7130f322cb7e 1099 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1100 \return value of type uint8_t at (*ptr)
mbed_official 159:7130f322cb7e 1101 */
mbed_official 159:7130f322cb7e 1102 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
mbed_official 159:7130f322cb7e 1103 {
mbed_official 159:7130f322cb7e 1104 uint32_t result;
mbed_official 159:7130f322cb7e 1105
mbed_official 159:7130f322cb7e 1106 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
mbed_official 159:7130f322cb7e 1107 return ((uint8_t) result);
mbed_official 159:7130f322cb7e 1108 }
mbed_official 159:7130f322cb7e 1109
mbed_official 159:7130f322cb7e 1110
mbed_official 159:7130f322cb7e 1111 /**
mbed_official 159:7130f322cb7e 1112 \brief Load-Acquire (16 bit)
mbed_official 159:7130f322cb7e 1113 \details Executes a LDAH instruction for 16 bit values.
mbed_official 159:7130f322cb7e 1114 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1115 \return value of type uint16_t at (*ptr)
mbed_official 159:7130f322cb7e 1116 */
mbed_official 159:7130f322cb7e 1117 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
mbed_official 159:7130f322cb7e 1118 {
mbed_official 159:7130f322cb7e 1119 uint32_t result;
mbed_official 159:7130f322cb7e 1120
mbed_official 159:7130f322cb7e 1121 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
mbed_official 159:7130f322cb7e 1122 return ((uint16_t) result);
mbed_official 159:7130f322cb7e 1123 }
mbed_official 159:7130f322cb7e 1124
mbed_official 159:7130f322cb7e 1125
mbed_official 159:7130f322cb7e 1126 /**
mbed_official 159:7130f322cb7e 1127 \brief Load-Acquire (32 bit)
mbed_official 159:7130f322cb7e 1128 \details Executes a LDA instruction for 32 bit values.
mbed_official 159:7130f322cb7e 1129 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1130 \return value of type uint32_t at (*ptr)
mbed_official 159:7130f322cb7e 1131 */
mbed_official 159:7130f322cb7e 1132 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
mbed_official 159:7130f322cb7e 1133 {
mbed_official 159:7130f322cb7e 1134 uint32_t result;
mbed_official 159:7130f322cb7e 1135
mbed_official 159:7130f322cb7e 1136 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
mbed_official 159:7130f322cb7e 1137 return(result);
mbed_official 159:7130f322cb7e 1138 }
mbed_official 159:7130f322cb7e 1139
mbed_official 159:7130f322cb7e 1140
mbed_official 159:7130f322cb7e 1141 /**
mbed_official 159:7130f322cb7e 1142 \brief Store-Release (8 bit)
mbed_official 159:7130f322cb7e 1143 \details Executes a STLB instruction for 8 bit values.
mbed_official 159:7130f322cb7e 1144 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1145 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1146 */
mbed_official 159:7130f322cb7e 1147 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
mbed_official 159:7130f322cb7e 1148 {
mbed_official 159:7130f322cb7e 1149 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
mbed_official 159:7130f322cb7e 1150 }
mbed_official 159:7130f322cb7e 1151
mbed_official 159:7130f322cb7e 1152
mbed_official 159:7130f322cb7e 1153 /**
mbed_official 159:7130f322cb7e 1154 \brief Store-Release (16 bit)
mbed_official 159:7130f322cb7e 1155 \details Executes a STLH instruction for 16 bit values.
mbed_official 159:7130f322cb7e 1156 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1157 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1158 */
mbed_official 159:7130f322cb7e 1159 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
mbed_official 159:7130f322cb7e 1160 {
mbed_official 159:7130f322cb7e 1161 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
mbed_official 159:7130f322cb7e 1162 }
mbed_official 159:7130f322cb7e 1163
mbed_official 159:7130f322cb7e 1164
mbed_official 159:7130f322cb7e 1165 /**
mbed_official 159:7130f322cb7e 1166 \brief Store-Release (32 bit)
mbed_official 159:7130f322cb7e 1167 \details Executes a STL instruction for 32 bit values.
mbed_official 159:7130f322cb7e 1168 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1169 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1170 */
mbed_official 159:7130f322cb7e 1171 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
mbed_official 159:7130f322cb7e 1172 {
mbed_official 159:7130f322cb7e 1173 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
mbed_official 159:7130f322cb7e 1174 }
mbed_official 159:7130f322cb7e 1175
mbed_official 159:7130f322cb7e 1176
mbed_official 159:7130f322cb7e 1177 /**
mbed_official 159:7130f322cb7e 1178 \brief Load-Acquire Exclusive (8 bit)
mbed_official 159:7130f322cb7e 1179 \details Executes a LDAB exclusive instruction for 8 bit value.
mbed_official 159:7130f322cb7e 1180 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1181 \return value of type uint8_t at (*ptr)
mbed_official 159:7130f322cb7e 1182 */
mbed_official 159:7130f322cb7e 1183 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
mbed_official 159:7130f322cb7e 1184
mbed_official 159:7130f322cb7e 1185
mbed_official 159:7130f322cb7e 1186 /**
mbed_official 159:7130f322cb7e 1187 \brief Load-Acquire Exclusive (16 bit)
mbed_official 159:7130f322cb7e 1188 \details Executes a LDAH exclusive instruction for 16 bit values.
mbed_official 159:7130f322cb7e 1189 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1190 \return value of type uint16_t at (*ptr)
mbed_official 159:7130f322cb7e 1191 */
mbed_official 159:7130f322cb7e 1192 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
mbed_official 159:7130f322cb7e 1193
mbed_official 159:7130f322cb7e 1194
mbed_official 159:7130f322cb7e 1195 /**
mbed_official 159:7130f322cb7e 1196 \brief Load-Acquire Exclusive (32 bit)
mbed_official 159:7130f322cb7e 1197 \details Executes a LDA exclusive instruction for 32 bit values.
mbed_official 159:7130f322cb7e 1198 \param [in] ptr Pointer to data
mbed_official 159:7130f322cb7e 1199 \return value of type uint32_t at (*ptr)
mbed_official 159:7130f322cb7e 1200 */
mbed_official 159:7130f322cb7e 1201 #define __LDAEX (uint32_t)__builtin_arm_ldaex
mbed_official 159:7130f322cb7e 1202
mbed_official 159:7130f322cb7e 1203
mbed_official 159:7130f322cb7e 1204 /**
mbed_official 159:7130f322cb7e 1205 \brief Store-Release Exclusive (8 bit)
mbed_official 159:7130f322cb7e 1206 \details Executes a STLB exclusive instruction for 8 bit values.
mbed_official 159:7130f322cb7e 1207 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1208 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1209 \return 0 Function succeeded
mbed_official 159:7130f322cb7e 1210 \return 1 Function failed
mbed_official 159:7130f322cb7e 1211 */
mbed_official 159:7130f322cb7e 1212 #define __STLEXB (uint32_t)__builtin_arm_stlex
mbed_official 159:7130f322cb7e 1213
mbed_official 159:7130f322cb7e 1214
mbed_official 159:7130f322cb7e 1215 /**
mbed_official 159:7130f322cb7e 1216 \brief Store-Release Exclusive (16 bit)
mbed_official 159:7130f322cb7e 1217 \details Executes a STLH exclusive instruction for 16 bit values.
mbed_official 159:7130f322cb7e 1218 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1219 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1220 \return 0 Function succeeded
mbed_official 159:7130f322cb7e 1221 \return 1 Function failed
mbed_official 159:7130f322cb7e 1222 */
mbed_official 159:7130f322cb7e 1223 #define __STLEXH (uint32_t)__builtin_arm_stlex
mbed_official 159:7130f322cb7e 1224
mbed_official 159:7130f322cb7e 1225
mbed_official 159:7130f322cb7e 1226 /**
mbed_official 159:7130f322cb7e 1227 \brief Store-Release Exclusive (32 bit)
mbed_official 159:7130f322cb7e 1228 \details Executes a STL exclusive instruction for 32 bit values.
mbed_official 159:7130f322cb7e 1229 \param [in] value Value to store
mbed_official 159:7130f322cb7e 1230 \param [in] ptr Pointer to location
mbed_official 159:7130f322cb7e 1231 \return 0 Function succeeded
mbed_official 159:7130f322cb7e 1232 \return 1 Function failed
mbed_official 159:7130f322cb7e 1233 */
mbed_official 159:7130f322cb7e 1234 #define __STLEX (uint32_t)__builtin_arm_stlex
mbed_official 159:7130f322cb7e 1235
mbed_official 159:7130f322cb7e 1236 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
mbed_official 159:7130f322cb7e 1237 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
mbed_official 159:7130f322cb7e 1238
mbed_official 159:7130f322cb7e 1239 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
mbed_official 159:7130f322cb7e 1240
mbed_official 159:7130f322cb7e 1241
mbed_official 159:7130f322cb7e 1242 /* ################### Compiler specific Intrinsics ########################### */
mbed_official 159:7130f322cb7e 1243 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
mbed_official 159:7130f322cb7e 1244 Access to dedicated SIMD instructions
mbed_official 159:7130f322cb7e 1245 @{
mbed_official 159:7130f322cb7e 1246 */
mbed_official 159:7130f322cb7e 1247
mbed_official 159:7130f322cb7e 1248 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
mbed_official 159:7130f322cb7e 1249
mbed_official 159:7130f322cb7e 1250 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1251 {
mbed_official 159:7130f322cb7e 1252 uint32_t result;
mbed_official 159:7130f322cb7e 1253
mbed_official 159:7130f322cb7e 1254 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1255 return(result);
mbed_official 159:7130f322cb7e 1256 }
mbed_official 159:7130f322cb7e 1257
mbed_official 159:7130f322cb7e 1258 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1259 {
mbed_official 159:7130f322cb7e 1260 uint32_t result;
mbed_official 159:7130f322cb7e 1261
mbed_official 159:7130f322cb7e 1262 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1263 return(result);
mbed_official 159:7130f322cb7e 1264 }
mbed_official 159:7130f322cb7e 1265
mbed_official 159:7130f322cb7e 1266 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1267 {
mbed_official 159:7130f322cb7e 1268 uint32_t result;
mbed_official 159:7130f322cb7e 1269
mbed_official 159:7130f322cb7e 1270 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1271 return(result);
mbed_official 159:7130f322cb7e 1272 }
mbed_official 159:7130f322cb7e 1273
mbed_official 159:7130f322cb7e 1274 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1275 {
mbed_official 159:7130f322cb7e 1276 uint32_t result;
mbed_official 159:7130f322cb7e 1277
mbed_official 159:7130f322cb7e 1278 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1279 return(result);
mbed_official 159:7130f322cb7e 1280 }
mbed_official 159:7130f322cb7e 1281
mbed_official 159:7130f322cb7e 1282 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1283 {
mbed_official 159:7130f322cb7e 1284 uint32_t result;
mbed_official 159:7130f322cb7e 1285
mbed_official 159:7130f322cb7e 1286 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1287 return(result);
mbed_official 159:7130f322cb7e 1288 }
mbed_official 159:7130f322cb7e 1289
mbed_official 159:7130f322cb7e 1290 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1291 {
mbed_official 159:7130f322cb7e 1292 uint32_t result;
mbed_official 159:7130f322cb7e 1293
mbed_official 159:7130f322cb7e 1294 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1295 return(result);
mbed_official 159:7130f322cb7e 1296 }
mbed_official 159:7130f322cb7e 1297
mbed_official 159:7130f322cb7e 1298
mbed_official 159:7130f322cb7e 1299 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1300 {
mbed_official 159:7130f322cb7e 1301 uint32_t result;
mbed_official 159:7130f322cb7e 1302
mbed_official 159:7130f322cb7e 1303 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1304 return(result);
mbed_official 159:7130f322cb7e 1305 }
mbed_official 159:7130f322cb7e 1306
mbed_official 159:7130f322cb7e 1307 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1308 {
mbed_official 159:7130f322cb7e 1309 uint32_t result;
mbed_official 159:7130f322cb7e 1310
mbed_official 159:7130f322cb7e 1311 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1312 return(result);
mbed_official 159:7130f322cb7e 1313 }
mbed_official 159:7130f322cb7e 1314
mbed_official 159:7130f322cb7e 1315 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1316 {
mbed_official 159:7130f322cb7e 1317 uint32_t result;
mbed_official 159:7130f322cb7e 1318
mbed_official 159:7130f322cb7e 1319 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1320 return(result);
mbed_official 159:7130f322cb7e 1321 }
mbed_official 159:7130f322cb7e 1322
mbed_official 159:7130f322cb7e 1323 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1324 {
mbed_official 159:7130f322cb7e 1325 uint32_t result;
mbed_official 159:7130f322cb7e 1326
mbed_official 159:7130f322cb7e 1327 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1328 return(result);
mbed_official 159:7130f322cb7e 1329 }
mbed_official 159:7130f322cb7e 1330
mbed_official 159:7130f322cb7e 1331 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1332 {
mbed_official 159:7130f322cb7e 1333 uint32_t result;
mbed_official 159:7130f322cb7e 1334
mbed_official 159:7130f322cb7e 1335 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1336 return(result);
mbed_official 159:7130f322cb7e 1337 }
mbed_official 159:7130f322cb7e 1338
mbed_official 159:7130f322cb7e 1339 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1340 {
mbed_official 159:7130f322cb7e 1341 uint32_t result;
mbed_official 159:7130f322cb7e 1342
mbed_official 159:7130f322cb7e 1343 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1344 return(result);
mbed_official 159:7130f322cb7e 1345 }
mbed_official 159:7130f322cb7e 1346
mbed_official 159:7130f322cb7e 1347
mbed_official 159:7130f322cb7e 1348 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1349 {
mbed_official 159:7130f322cb7e 1350 uint32_t result;
mbed_official 159:7130f322cb7e 1351
mbed_official 159:7130f322cb7e 1352 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1353 return(result);
mbed_official 159:7130f322cb7e 1354 }
mbed_official 159:7130f322cb7e 1355
mbed_official 159:7130f322cb7e 1356 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1357 {
mbed_official 159:7130f322cb7e 1358 uint32_t result;
mbed_official 159:7130f322cb7e 1359
mbed_official 159:7130f322cb7e 1360 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1361 return(result);
mbed_official 159:7130f322cb7e 1362 }
mbed_official 159:7130f322cb7e 1363
mbed_official 159:7130f322cb7e 1364 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1365 {
mbed_official 159:7130f322cb7e 1366 uint32_t result;
mbed_official 159:7130f322cb7e 1367
mbed_official 159:7130f322cb7e 1368 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1369 return(result);
mbed_official 159:7130f322cb7e 1370 }
mbed_official 159:7130f322cb7e 1371
mbed_official 159:7130f322cb7e 1372 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1373 {
mbed_official 159:7130f322cb7e 1374 uint32_t result;
mbed_official 159:7130f322cb7e 1375
mbed_official 159:7130f322cb7e 1376 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1377 return(result);
mbed_official 159:7130f322cb7e 1378 }
mbed_official 159:7130f322cb7e 1379
mbed_official 159:7130f322cb7e 1380 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1381 {
mbed_official 159:7130f322cb7e 1382 uint32_t result;
mbed_official 159:7130f322cb7e 1383
mbed_official 159:7130f322cb7e 1384 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1385 return(result);
mbed_official 159:7130f322cb7e 1386 }
mbed_official 159:7130f322cb7e 1387
mbed_official 159:7130f322cb7e 1388 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1389 {
mbed_official 159:7130f322cb7e 1390 uint32_t result;
mbed_official 159:7130f322cb7e 1391
mbed_official 159:7130f322cb7e 1392 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1393 return(result);
mbed_official 159:7130f322cb7e 1394 }
mbed_official 159:7130f322cb7e 1395
mbed_official 159:7130f322cb7e 1396 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1397 {
mbed_official 159:7130f322cb7e 1398 uint32_t result;
mbed_official 159:7130f322cb7e 1399
mbed_official 159:7130f322cb7e 1400 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1401 return(result);
mbed_official 159:7130f322cb7e 1402 }
mbed_official 159:7130f322cb7e 1403
mbed_official 159:7130f322cb7e 1404 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1405 {
mbed_official 159:7130f322cb7e 1406 uint32_t result;
mbed_official 159:7130f322cb7e 1407
mbed_official 159:7130f322cb7e 1408 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1409 return(result);
mbed_official 159:7130f322cb7e 1410 }
mbed_official 159:7130f322cb7e 1411
mbed_official 159:7130f322cb7e 1412 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1413 {
mbed_official 159:7130f322cb7e 1414 uint32_t result;
mbed_official 159:7130f322cb7e 1415
mbed_official 159:7130f322cb7e 1416 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1417 return(result);
mbed_official 159:7130f322cb7e 1418 }
mbed_official 159:7130f322cb7e 1419
mbed_official 159:7130f322cb7e 1420 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1421 {
mbed_official 159:7130f322cb7e 1422 uint32_t result;
mbed_official 159:7130f322cb7e 1423
mbed_official 159:7130f322cb7e 1424 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1425 return(result);
mbed_official 159:7130f322cb7e 1426 }
mbed_official 159:7130f322cb7e 1427
mbed_official 159:7130f322cb7e 1428 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1429 {
mbed_official 159:7130f322cb7e 1430 uint32_t result;
mbed_official 159:7130f322cb7e 1431
mbed_official 159:7130f322cb7e 1432 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1433 return(result);
mbed_official 159:7130f322cb7e 1434 }
mbed_official 159:7130f322cb7e 1435
mbed_official 159:7130f322cb7e 1436 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1437 {
mbed_official 159:7130f322cb7e 1438 uint32_t result;
mbed_official 159:7130f322cb7e 1439
mbed_official 159:7130f322cb7e 1440 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1441 return(result);
mbed_official 159:7130f322cb7e 1442 }
mbed_official 159:7130f322cb7e 1443
mbed_official 159:7130f322cb7e 1444 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1445 {
mbed_official 159:7130f322cb7e 1446 uint32_t result;
mbed_official 159:7130f322cb7e 1447
mbed_official 159:7130f322cb7e 1448 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1449 return(result);
mbed_official 159:7130f322cb7e 1450 }
mbed_official 159:7130f322cb7e 1451
mbed_official 159:7130f322cb7e 1452 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1453 {
mbed_official 159:7130f322cb7e 1454 uint32_t result;
mbed_official 159:7130f322cb7e 1455
mbed_official 159:7130f322cb7e 1456 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1457 return(result);
mbed_official 159:7130f322cb7e 1458 }
mbed_official 159:7130f322cb7e 1459
mbed_official 159:7130f322cb7e 1460 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1461 {
mbed_official 159:7130f322cb7e 1462 uint32_t result;
mbed_official 159:7130f322cb7e 1463
mbed_official 159:7130f322cb7e 1464 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1465 return(result);
mbed_official 159:7130f322cb7e 1466 }
mbed_official 159:7130f322cb7e 1467
mbed_official 159:7130f322cb7e 1468 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1469 {
mbed_official 159:7130f322cb7e 1470 uint32_t result;
mbed_official 159:7130f322cb7e 1471
mbed_official 159:7130f322cb7e 1472 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1473 return(result);
mbed_official 159:7130f322cb7e 1474 }
mbed_official 159:7130f322cb7e 1475
mbed_official 159:7130f322cb7e 1476 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1477 {
mbed_official 159:7130f322cb7e 1478 uint32_t result;
mbed_official 159:7130f322cb7e 1479
mbed_official 159:7130f322cb7e 1480 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1481 return(result);
mbed_official 159:7130f322cb7e 1482 }
mbed_official 159:7130f322cb7e 1483
mbed_official 159:7130f322cb7e 1484 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1485 {
mbed_official 159:7130f322cb7e 1486 uint32_t result;
mbed_official 159:7130f322cb7e 1487
mbed_official 159:7130f322cb7e 1488 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1489 return(result);
mbed_official 159:7130f322cb7e 1490 }
mbed_official 159:7130f322cb7e 1491
mbed_official 159:7130f322cb7e 1492 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1493 {
mbed_official 159:7130f322cb7e 1494 uint32_t result;
mbed_official 159:7130f322cb7e 1495
mbed_official 159:7130f322cb7e 1496 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1497 return(result);
mbed_official 159:7130f322cb7e 1498 }
mbed_official 159:7130f322cb7e 1499
mbed_official 159:7130f322cb7e 1500 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1501 {
mbed_official 159:7130f322cb7e 1502 uint32_t result;
mbed_official 159:7130f322cb7e 1503
mbed_official 159:7130f322cb7e 1504 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1505 return(result);
mbed_official 159:7130f322cb7e 1506 }
mbed_official 159:7130f322cb7e 1507
mbed_official 159:7130f322cb7e 1508 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1509 {
mbed_official 159:7130f322cb7e 1510 uint32_t result;
mbed_official 159:7130f322cb7e 1511
mbed_official 159:7130f322cb7e 1512 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1513 return(result);
mbed_official 159:7130f322cb7e 1514 }
mbed_official 159:7130f322cb7e 1515
mbed_official 159:7130f322cb7e 1516 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1517 {
mbed_official 159:7130f322cb7e 1518 uint32_t result;
mbed_official 159:7130f322cb7e 1519
mbed_official 159:7130f322cb7e 1520 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1521 return(result);
mbed_official 159:7130f322cb7e 1522 }
mbed_official 159:7130f322cb7e 1523
mbed_official 159:7130f322cb7e 1524 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1525 {
mbed_official 159:7130f322cb7e 1526 uint32_t result;
mbed_official 159:7130f322cb7e 1527
mbed_official 159:7130f322cb7e 1528 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1529 return(result);
mbed_official 159:7130f322cb7e 1530 }
mbed_official 159:7130f322cb7e 1531
mbed_official 159:7130f322cb7e 1532 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1533 {
mbed_official 159:7130f322cb7e 1534 uint32_t result;
mbed_official 159:7130f322cb7e 1535
mbed_official 159:7130f322cb7e 1536 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1537 return(result);
mbed_official 159:7130f322cb7e 1538 }
mbed_official 159:7130f322cb7e 1539
mbed_official 159:7130f322cb7e 1540 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1541 {
mbed_official 159:7130f322cb7e 1542 uint32_t result;
mbed_official 159:7130f322cb7e 1543
mbed_official 159:7130f322cb7e 1544 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1545 return(result);
mbed_official 159:7130f322cb7e 1546 }
mbed_official 159:7130f322cb7e 1547
mbed_official 159:7130f322cb7e 1548 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
mbed_official 159:7130f322cb7e 1549 {
mbed_official 159:7130f322cb7e 1550 uint32_t result;
mbed_official 159:7130f322cb7e 1551
mbed_official 159:7130f322cb7e 1552 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
mbed_official 159:7130f322cb7e 1553 return(result);
mbed_official 159:7130f322cb7e 1554 }
mbed_official 159:7130f322cb7e 1555
mbed_official 159:7130f322cb7e 1556 #define __SSAT16(ARG1,ARG2) \
mbed_official 159:7130f322cb7e 1557 ({ \
mbed_official 159:7130f322cb7e 1558 int32_t __RES, __ARG1 = (ARG1); \
mbed_official 159:7130f322cb7e 1559 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
mbed_official 159:7130f322cb7e 1560 __RES; \
mbed_official 159:7130f322cb7e 1561 })
mbed_official 159:7130f322cb7e 1562
mbed_official 159:7130f322cb7e 1563 #define __USAT16(ARG1,ARG2) \
mbed_official 159:7130f322cb7e 1564 ({ \
mbed_official 159:7130f322cb7e 1565 uint32_t __RES, __ARG1 = (ARG1); \
mbed_official 159:7130f322cb7e 1566 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
mbed_official 159:7130f322cb7e 1567 __RES; \
mbed_official 159:7130f322cb7e 1568 })
mbed_official 159:7130f322cb7e 1569
mbed_official 159:7130f322cb7e 1570 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
mbed_official 159:7130f322cb7e 1571 {
mbed_official 159:7130f322cb7e 1572 uint32_t result;
mbed_official 159:7130f322cb7e 1573
mbed_official 159:7130f322cb7e 1574 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
mbed_official 159:7130f322cb7e 1575 return(result);
mbed_official 159:7130f322cb7e 1576 }
mbed_official 159:7130f322cb7e 1577
mbed_official 159:7130f322cb7e 1578 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1579 {
mbed_official 159:7130f322cb7e 1580 uint32_t result;
mbed_official 159:7130f322cb7e 1581
mbed_official 159:7130f322cb7e 1582 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1583 return(result);
mbed_official 159:7130f322cb7e 1584 }
mbed_official 159:7130f322cb7e 1585
mbed_official 159:7130f322cb7e 1586 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
mbed_official 159:7130f322cb7e 1587 {
mbed_official 159:7130f322cb7e 1588 uint32_t result;
mbed_official 159:7130f322cb7e 1589
mbed_official 159:7130f322cb7e 1590 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
mbed_official 159:7130f322cb7e 1591 return(result);
mbed_official 159:7130f322cb7e 1592 }
mbed_official 159:7130f322cb7e 1593
mbed_official 159:7130f322cb7e 1594 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1595 {
mbed_official 159:7130f322cb7e 1596 uint32_t result;
mbed_official 159:7130f322cb7e 1597
mbed_official 159:7130f322cb7e 1598 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1599 return(result);
mbed_official 159:7130f322cb7e 1600 }
mbed_official 159:7130f322cb7e 1601
mbed_official 159:7130f322cb7e 1602 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1603 {
mbed_official 159:7130f322cb7e 1604 uint32_t result;
mbed_official 159:7130f322cb7e 1605
mbed_official 159:7130f322cb7e 1606 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1607 return(result);
mbed_official 159:7130f322cb7e 1608 }
mbed_official 159:7130f322cb7e 1609
mbed_official 159:7130f322cb7e 1610 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1611 {
mbed_official 159:7130f322cb7e 1612 uint32_t result;
mbed_official 159:7130f322cb7e 1613
mbed_official 159:7130f322cb7e 1614 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1615 return(result);
mbed_official 159:7130f322cb7e 1616 }
mbed_official 159:7130f322cb7e 1617
mbed_official 159:7130f322cb7e 1618 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
mbed_official 159:7130f322cb7e 1619 {
mbed_official 159:7130f322cb7e 1620 uint32_t result;
mbed_official 159:7130f322cb7e 1621
mbed_official 159:7130f322cb7e 1622 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
mbed_official 159:7130f322cb7e 1623 return(result);
mbed_official 159:7130f322cb7e 1624 }
mbed_official 159:7130f322cb7e 1625
mbed_official 159:7130f322cb7e 1626 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
mbed_official 159:7130f322cb7e 1627 {
mbed_official 159:7130f322cb7e 1628 uint32_t result;
mbed_official 159:7130f322cb7e 1629
mbed_official 159:7130f322cb7e 1630 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
mbed_official 159:7130f322cb7e 1631 return(result);
mbed_official 159:7130f322cb7e 1632 }
mbed_official 159:7130f322cb7e 1633
mbed_official 159:7130f322cb7e 1634 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
mbed_official 159:7130f322cb7e 1635 {
mbed_official 159:7130f322cb7e 1636 union llreg_u{
mbed_official 159:7130f322cb7e 1637 uint32_t w32[2];
mbed_official 159:7130f322cb7e 1638 uint64_t w64;
mbed_official 159:7130f322cb7e 1639 } llr;
mbed_official 159:7130f322cb7e 1640 llr.w64 = acc;
mbed_official 159:7130f322cb7e 1641
mbed_official 159:7130f322cb7e 1642 #ifndef __ARMEB__ /* Little endian */
mbed_official 159:7130f322cb7e 1643 __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
mbed_official 159:7130f322cb7e 1644 #else /* Big endian */
mbed_official 159:7130f322cb7e 1645 __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
mbed_official 159:7130f322cb7e 1646 #endif
mbed_official 159:7130f322cb7e 1647
mbed_official 159:7130f322cb7e 1648 return(llr.w64);
mbed_official 159:7130f322cb7e 1649 }
mbed_official 159:7130f322cb7e 1650
mbed_official 159:7130f322cb7e 1651 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
mbed_official 159:7130f322cb7e 1652 {
mbed_official 159:7130f322cb7e 1653 union llreg_u{
mbed_official 159:7130f322cb7e 1654 uint32_t w32[2];
mbed_official 159:7130f322cb7e 1655 uint64_t w64;
mbed_official 159:7130f322cb7e 1656 } llr;
mbed_official 159:7130f322cb7e 1657 llr.w64 = acc;
mbed_official 159:7130f322cb7e 1658
mbed_official 159:7130f322cb7e 1659 #ifndef __ARMEB__ /* Little endian */
mbed_official 159:7130f322cb7e 1660 __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
mbed_official 159:7130f322cb7e 1661 #else /* Big endian */
mbed_official 159:7130f322cb7e 1662 __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
mbed_official 159:7130f322cb7e 1663 #endif
mbed_official 159:7130f322cb7e 1664
mbed_official 159:7130f322cb7e 1665 return(llr.w64);
mbed_official 159:7130f322cb7e 1666 }
mbed_official 159:7130f322cb7e 1667
mbed_official 159:7130f322cb7e 1668 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1669 {
mbed_official 159:7130f322cb7e 1670 uint32_t result;
mbed_official 159:7130f322cb7e 1671
mbed_official 159:7130f322cb7e 1672 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1673 return(result);
mbed_official 159:7130f322cb7e 1674 }
mbed_official 159:7130f322cb7e 1675
mbed_official 159:7130f322cb7e 1676 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1677 {
mbed_official 159:7130f322cb7e 1678 uint32_t result;
mbed_official 159:7130f322cb7e 1679
mbed_official 159:7130f322cb7e 1680 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1681 return(result);
mbed_official 159:7130f322cb7e 1682 }
mbed_official 159:7130f322cb7e 1683
mbed_official 159:7130f322cb7e 1684 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
mbed_official 159:7130f322cb7e 1685 {
mbed_official 159:7130f322cb7e 1686 uint32_t result;
mbed_official 159:7130f322cb7e 1687
mbed_official 159:7130f322cb7e 1688 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
mbed_official 159:7130f322cb7e 1689 return(result);
mbed_official 159:7130f322cb7e 1690 }
mbed_official 159:7130f322cb7e 1691
mbed_official 159:7130f322cb7e 1692 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
mbed_official 159:7130f322cb7e 1693 {
mbed_official 159:7130f322cb7e 1694 uint32_t result;
mbed_official 159:7130f322cb7e 1695
mbed_official 159:7130f322cb7e 1696 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
mbed_official 159:7130f322cb7e 1697 return(result);
mbed_official 159:7130f322cb7e 1698 }
mbed_official 159:7130f322cb7e 1699
mbed_official 159:7130f322cb7e 1700 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
mbed_official 159:7130f322cb7e 1701 {
mbed_official 159:7130f322cb7e 1702 union llreg_u{
mbed_official 159:7130f322cb7e 1703 uint32_t w32[2];
mbed_official 159:7130f322cb7e 1704 uint64_t w64;
mbed_official 159:7130f322cb7e 1705 } llr;
mbed_official 159:7130f322cb7e 1706 llr.w64 = acc;
mbed_official 159:7130f322cb7e 1707
mbed_official 159:7130f322cb7e 1708 #ifndef __ARMEB__ /* Little endian */
mbed_official 159:7130f322cb7e 1709 __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
mbed_official 159:7130f322cb7e 1710 #else /* Big endian */
mbed_official 159:7130f322cb7e 1711 __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
mbed_official 159:7130f322cb7e 1712 #endif
mbed_official 159:7130f322cb7e 1713
mbed_official 159:7130f322cb7e 1714 return(llr.w64);
mbed_official 159:7130f322cb7e 1715 }
mbed_official 159:7130f322cb7e 1716
mbed_official 159:7130f322cb7e 1717 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
mbed_official 159:7130f322cb7e 1718 {
mbed_official 159:7130f322cb7e 1719 union llreg_u{
mbed_official 159:7130f322cb7e 1720 uint32_t w32[2];
mbed_official 159:7130f322cb7e 1721 uint64_t w64;
mbed_official 159:7130f322cb7e 1722 } llr;
mbed_official 159:7130f322cb7e 1723 llr.w64 = acc;
mbed_official 159:7130f322cb7e 1724
mbed_official 159:7130f322cb7e 1725 #ifndef __ARMEB__ /* Little endian */
mbed_official 159:7130f322cb7e 1726 __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
mbed_official 159:7130f322cb7e 1727 #else /* Big endian */
mbed_official 159:7130f322cb7e 1728 __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
mbed_official 159:7130f322cb7e 1729 #endif
mbed_official 159:7130f322cb7e 1730
mbed_official 159:7130f322cb7e 1731 return(llr.w64);
mbed_official 159:7130f322cb7e 1732 }
mbed_official 159:7130f322cb7e 1733
mbed_official 159:7130f322cb7e 1734 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
mbed_official 159:7130f322cb7e 1735 {
mbed_official 159:7130f322cb7e 1736 uint32_t result;
mbed_official 159:7130f322cb7e 1737
mbed_official 159:7130f322cb7e 1738 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1739 return(result);
mbed_official 159:7130f322cb7e 1740 }
mbed_official 159:7130f322cb7e 1741
mbed_official 159:7130f322cb7e 1742 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
mbed_official 159:7130f322cb7e 1743 {
mbed_official 159:7130f322cb7e 1744 int32_t result;
mbed_official 159:7130f322cb7e 1745
mbed_official 159:7130f322cb7e 1746 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1747 return(result);
mbed_official 159:7130f322cb7e 1748 }
mbed_official 159:7130f322cb7e 1749
mbed_official 159:7130f322cb7e 1750 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
mbed_official 159:7130f322cb7e 1751 {
mbed_official 159:7130f322cb7e 1752 int32_t result;
mbed_official 159:7130f322cb7e 1753
mbed_official 159:7130f322cb7e 1754 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
mbed_official 159:7130f322cb7e 1755 return(result);
mbed_official 159:7130f322cb7e 1756 }
mbed_official 159:7130f322cb7e 1757
mbed_official 159:7130f322cb7e 1758 #if 0
mbed_official 159:7130f322cb7e 1759 #define __PKHBT(ARG1,ARG2,ARG3) \
mbed_official 159:7130f322cb7e 1760 ({ \
mbed_official 159:7130f322cb7e 1761 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
mbed_official 159:7130f322cb7e 1762 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
mbed_official 159:7130f322cb7e 1763 __RES; \
mbed_official 159:7130f322cb7e 1764 })
mbed_official 159:7130f322cb7e 1765
mbed_official 159:7130f322cb7e 1766 #define __PKHTB(ARG1,ARG2,ARG3) \
mbed_official 159:7130f322cb7e 1767 ({ \
mbed_official 159:7130f322cb7e 1768 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
mbed_official 159:7130f322cb7e 1769 if (ARG3 == 0) \
mbed_official 159:7130f322cb7e 1770 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
mbed_official 159:7130f322cb7e 1771 else \
mbed_official 159:7130f322cb7e 1772 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
mbed_official 159:7130f322cb7e 1773 __RES; \
mbed_official 159:7130f322cb7e 1774 })
mbed_official 159:7130f322cb7e 1775 #endif
mbed_official 159:7130f322cb7e 1776
mbed_official 159:7130f322cb7e 1777 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
mbed_official 159:7130f322cb7e 1778 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
mbed_official 159:7130f322cb7e 1779
mbed_official 159:7130f322cb7e 1780 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
mbed_official 159:7130f322cb7e 1781 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
mbed_official 159:7130f322cb7e 1782
mbed_official 159:7130f322cb7e 1783 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
mbed_official 159:7130f322cb7e 1784 {
mbed_official 159:7130f322cb7e 1785 int32_t result;
mbed_official 159:7130f322cb7e 1786
mbed_official 159:7130f322cb7e 1787 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
mbed_official 159:7130f322cb7e 1788 return(result);
mbed_official 159:7130f322cb7e 1789 }
mbed_official 159:7130f322cb7e 1790
mbed_official 159:7130f322cb7e 1791 #endif /* (__ARM_FEATURE_DSP == 1) */
mbed_official 159:7130f322cb7e 1792 /*@} end of group CMSIS_SIMD_intrinsics */
mbed_official 159:7130f322cb7e 1793
mbed_official 159:7130f322cb7e 1794
mbed_official 159:7130f322cb7e 1795 #endif /* __CMSIS_ARMCLANG_H */