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