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