The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Fri Sep 15 14:46:57 2017 +0100
Revision:
151:675da3299148
Parent:
148:fd96258d940d
Child:
160:5571c4ff569f
Release 151 of the mbed library.

Who changed what in which revision?

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