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