The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_DISCO_F407VG/cmsis_iccarm.h@169:a7c7b631e539, 2018-06-22 (annotated)
- Committer:
- Anna Bridge
- Date:
- Fri Jun 22 15:38:59 2018 +0100
- Revision:
- 169:a7c7b631e539
- Parent:
- 161:aa5281ff4a02
mbed library. Release version 162
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 161:aa5281ff4a02 | 1 | /**************************************************************************//** |
AnnaBridge | 161:aa5281ff4a02 | 2 | * @file cmsis_iccarm.h |
Anna Bridge |
169:a7c7b631e539 | 3 | * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file |
Anna Bridge |
169:a7c7b631e539 | 4 | * @version V5.0.5 |
Anna Bridge |
169:a7c7b631e539 | 5 | * @date 10. January 2018 |
AnnaBridge | 161:aa5281ff4a02 | 6 | ******************************************************************************/ |
AnnaBridge | 161:aa5281ff4a02 | 7 | |
AnnaBridge | 161:aa5281ff4a02 | 8 | //------------------------------------------------------------------------------ |
AnnaBridge | 161:aa5281ff4a02 | 9 | // |
Anna Bridge |
169:a7c7b631e539 | 10 | // Copyright (c) 2017-2018 IAR Systems |
AnnaBridge | 161:aa5281ff4a02 | 11 | // |
AnnaBridge | 161:aa5281ff4a02 | 12 | // Licensed under the Apache License, Version 2.0 (the "License") |
AnnaBridge | 161:aa5281ff4a02 | 13 | // you may not use this file except in compliance with the License. |
AnnaBridge | 161:aa5281ff4a02 | 14 | // You may obtain a copy of the License at |
AnnaBridge | 161:aa5281ff4a02 | 15 | // http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 161:aa5281ff4a02 | 16 | // |
AnnaBridge | 161:aa5281ff4a02 | 17 | // Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 161:aa5281ff4a02 | 18 | // distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 161:aa5281ff4a02 | 19 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 161:aa5281ff4a02 | 20 | // See the License for the specific language governing permissions and |
AnnaBridge | 161:aa5281ff4a02 | 21 | // limitations under the License. |
AnnaBridge | 161:aa5281ff4a02 | 22 | // |
AnnaBridge | 161:aa5281ff4a02 | 23 | //------------------------------------------------------------------------------ |
AnnaBridge | 161:aa5281ff4a02 | 24 | |
AnnaBridge | 161:aa5281ff4a02 | 25 | |
AnnaBridge | 161:aa5281ff4a02 | 26 | #ifndef __CMSIS_ICCARM_H__ |
AnnaBridge | 161:aa5281ff4a02 | 27 | #define __CMSIS_ICCARM_H__ |
AnnaBridge | 161:aa5281ff4a02 | 28 | |
AnnaBridge | 161:aa5281ff4a02 | 29 | #ifndef __ICCARM__ |
AnnaBridge | 161:aa5281ff4a02 | 30 | #error This file should only be compiled by ICCARM |
AnnaBridge | 161:aa5281ff4a02 | 31 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 32 | |
AnnaBridge | 161:aa5281ff4a02 | 33 | #pragma system_include |
AnnaBridge | 161:aa5281ff4a02 | 34 | |
AnnaBridge | 161:aa5281ff4a02 | 35 | #define __IAR_FT _Pragma("inline=forced") __intrinsic |
AnnaBridge | 161:aa5281ff4a02 | 36 | |
AnnaBridge | 161:aa5281ff4a02 | 37 | #if (__VER__ >= 8000000) |
AnnaBridge | 161:aa5281ff4a02 | 38 | #define __ICCARM_V8 1 |
AnnaBridge | 161:aa5281ff4a02 | 39 | #else |
AnnaBridge | 161:aa5281ff4a02 | 40 | #define __ICCARM_V8 0 |
AnnaBridge | 161:aa5281ff4a02 | 41 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 42 | |
AnnaBridge | 161:aa5281ff4a02 | 43 | #ifndef __ALIGNED |
AnnaBridge | 161:aa5281ff4a02 | 44 | #if __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 45 | #define __ALIGNED(x) __attribute__((aligned(x))) |
AnnaBridge | 161:aa5281ff4a02 | 46 | #elif (__VER__ >= 7080000) |
AnnaBridge | 161:aa5281ff4a02 | 47 | /* Needs IAR language extensions */ |
AnnaBridge | 161:aa5281ff4a02 | 48 | #define __ALIGNED(x) __attribute__((aligned(x))) |
AnnaBridge | 161:aa5281ff4a02 | 49 | #else |
AnnaBridge | 161:aa5281ff4a02 | 50 | #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored. |
AnnaBridge | 161:aa5281ff4a02 | 51 | #define __ALIGNED(x) |
AnnaBridge | 161:aa5281ff4a02 | 52 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 53 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 54 | |
AnnaBridge | 161:aa5281ff4a02 | 55 | |
AnnaBridge | 161:aa5281ff4a02 | 56 | /* Define compiler macros for CPU architecture, used in CMSIS 5. |
AnnaBridge | 161:aa5281ff4a02 | 57 | */ |
AnnaBridge | 161:aa5281ff4a02 | 58 | #if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__ |
AnnaBridge | 161:aa5281ff4a02 | 59 | /* Macros already defined */ |
AnnaBridge | 161:aa5281ff4a02 | 60 | #else |
AnnaBridge | 161:aa5281ff4a02 | 61 | #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__) |
AnnaBridge | 161:aa5281ff4a02 | 62 | #define __ARM_ARCH_8M_MAIN__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 63 | #elif defined(__ARM8M_BASELINE__) |
AnnaBridge | 161:aa5281ff4a02 | 64 | #define __ARM_ARCH_8M_BASE__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 65 | #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M' |
AnnaBridge | 161:aa5281ff4a02 | 66 | #if __ARM_ARCH == 6 |
AnnaBridge | 161:aa5281ff4a02 | 67 | #define __ARM_ARCH_6M__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 68 | #elif __ARM_ARCH == 7 |
AnnaBridge | 161:aa5281ff4a02 | 69 | #if __ARM_FEATURE_DSP |
AnnaBridge | 161:aa5281ff4a02 | 70 | #define __ARM_ARCH_7EM__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 71 | #else |
AnnaBridge | 161:aa5281ff4a02 | 72 | #define __ARM_ARCH_7M__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 73 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 74 | #endif /* __ARM_ARCH */ |
AnnaBridge | 161:aa5281ff4a02 | 75 | #endif /* __ARM_ARCH_PROFILE == 'M' */ |
AnnaBridge | 161:aa5281ff4a02 | 76 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 77 | |
AnnaBridge | 161:aa5281ff4a02 | 78 | /* Alternativ core deduction for older ICCARM's */ |
AnnaBridge | 161:aa5281ff4a02 | 79 | #if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \ |
AnnaBridge | 161:aa5281ff4a02 | 80 | !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__) |
AnnaBridge | 161:aa5281ff4a02 | 81 | #if defined(__ARM6M__) && (__CORE__ == __ARM6M__) |
AnnaBridge | 161:aa5281ff4a02 | 82 | #define __ARM_ARCH_6M__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 83 | #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__) |
AnnaBridge | 161:aa5281ff4a02 | 84 | #define __ARM_ARCH_7M__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 85 | #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__) |
AnnaBridge | 161:aa5281ff4a02 | 86 | #define __ARM_ARCH_7EM__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 87 | #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__) |
AnnaBridge | 161:aa5281ff4a02 | 88 | #define __ARM_ARCH_8M_BASE__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 89 | #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__) |
AnnaBridge | 161:aa5281ff4a02 | 90 | #define __ARM_ARCH_8M_MAIN__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 91 | #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__) |
AnnaBridge | 161:aa5281ff4a02 | 92 | #define __ARM_ARCH_8M_MAIN__ 1 |
AnnaBridge | 161:aa5281ff4a02 | 93 | #else |
AnnaBridge | 161:aa5281ff4a02 | 94 | #error "Unknown target." |
AnnaBridge | 161:aa5281ff4a02 | 95 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 96 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 97 | |
AnnaBridge | 161:aa5281ff4a02 | 98 | |
AnnaBridge | 161:aa5281ff4a02 | 99 | |
AnnaBridge | 161:aa5281ff4a02 | 100 | #if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1 |
AnnaBridge | 161:aa5281ff4a02 | 101 | #define __IAR_M0_FAMILY 1 |
AnnaBridge | 161:aa5281ff4a02 | 102 | #elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1 |
AnnaBridge | 161:aa5281ff4a02 | 103 | #define __IAR_M0_FAMILY 1 |
AnnaBridge | 161:aa5281ff4a02 | 104 | #else |
AnnaBridge | 161:aa5281ff4a02 | 105 | #define __IAR_M0_FAMILY 0 |
AnnaBridge | 161:aa5281ff4a02 | 106 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 107 | |
AnnaBridge | 161:aa5281ff4a02 | 108 | |
AnnaBridge | 161:aa5281ff4a02 | 109 | #ifndef __ASM |
AnnaBridge | 161:aa5281ff4a02 | 110 | #define __ASM __asm |
AnnaBridge | 161:aa5281ff4a02 | 111 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 112 | |
AnnaBridge | 161:aa5281ff4a02 | 113 | #ifndef __INLINE |
AnnaBridge | 161:aa5281ff4a02 | 114 | #define __INLINE inline |
AnnaBridge | 161:aa5281ff4a02 | 115 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 116 | |
AnnaBridge | 161:aa5281ff4a02 | 117 | #ifndef __NO_RETURN |
AnnaBridge | 161:aa5281ff4a02 | 118 | #if __ICCARM_V8 |
Anna Bridge |
169:a7c7b631e539 | 119 | #define __NO_RETURN __attribute__((__noreturn__)) |
AnnaBridge | 161:aa5281ff4a02 | 120 | #else |
AnnaBridge | 161:aa5281ff4a02 | 121 | #define __NO_RETURN _Pragma("object_attribute=__noreturn") |
AnnaBridge | 161:aa5281ff4a02 | 122 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 123 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 124 | |
AnnaBridge | 161:aa5281ff4a02 | 125 | #ifndef __PACKED |
AnnaBridge | 161:aa5281ff4a02 | 126 | #if __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 127 | #define __PACKED __attribute__((packed, aligned(1))) |
AnnaBridge | 161:aa5281ff4a02 | 128 | #else |
AnnaBridge | 161:aa5281ff4a02 | 129 | /* Needs IAR language extensions */ |
AnnaBridge | 161:aa5281ff4a02 | 130 | #define __PACKED __packed |
AnnaBridge | 161:aa5281ff4a02 | 131 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 132 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 133 | |
AnnaBridge | 161:aa5281ff4a02 | 134 | #ifndef __PACKED_STRUCT |
AnnaBridge | 161:aa5281ff4a02 | 135 | #if __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 136 | #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) |
AnnaBridge | 161:aa5281ff4a02 | 137 | #else |
AnnaBridge | 161:aa5281ff4a02 | 138 | /* Needs IAR language extensions */ |
AnnaBridge | 161:aa5281ff4a02 | 139 | #define __PACKED_STRUCT __packed struct |
AnnaBridge | 161:aa5281ff4a02 | 140 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 141 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 142 | |
AnnaBridge | 161:aa5281ff4a02 | 143 | #ifndef __PACKED_UNION |
AnnaBridge | 161:aa5281ff4a02 | 144 | #if __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 145 | #define __PACKED_UNION union __attribute__((packed, aligned(1))) |
AnnaBridge | 161:aa5281ff4a02 | 146 | #else |
AnnaBridge | 161:aa5281ff4a02 | 147 | /* Needs IAR language extensions */ |
AnnaBridge | 161:aa5281ff4a02 | 148 | #define __PACKED_UNION __packed union |
AnnaBridge | 161:aa5281ff4a02 | 149 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 150 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 151 | |
AnnaBridge | 161:aa5281ff4a02 | 152 | #ifndef __RESTRICT |
Anna Bridge |
169:a7c7b631e539 | 153 | #define __RESTRICT restrict |
Anna Bridge |
169:a7c7b631e539 | 154 | #endif |
Anna Bridge |
169:a7c7b631e539 | 155 | |
Anna Bridge |
169:a7c7b631e539 | 156 | #ifndef __STATIC_INLINE |
Anna Bridge |
169:a7c7b631e539 | 157 | #define __STATIC_INLINE static inline |
AnnaBridge | 161:aa5281ff4a02 | 158 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 159 | |
Anna Bridge |
169:a7c7b631e539 | 160 | #ifndef __FORCEINLINE |
Anna Bridge |
169:a7c7b631e539 | 161 | #define __FORCEINLINE _Pragma("inline=forced") |
Anna Bridge |
169:a7c7b631e539 | 162 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 163 | |
Anna Bridge |
169:a7c7b631e539 | 164 | #ifndef __STATIC_FORCEINLINE |
Anna Bridge |
169:a7c7b631e539 | 165 | #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE |
AnnaBridge | 161:aa5281ff4a02 | 166 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 167 | |
AnnaBridge | 161:aa5281ff4a02 | 168 | #ifndef __UNALIGNED_UINT16_READ |
AnnaBridge | 161:aa5281ff4a02 | 169 | #pragma language=save |
AnnaBridge | 161:aa5281ff4a02 | 170 | #pragma language=extended |
Anna Bridge |
169:a7c7b631e539 | 171 | __IAR_FT uint16_t __iar_uint16_read(void const *ptr) |
Anna Bridge |
169:a7c7b631e539 | 172 | { |
AnnaBridge | 161:aa5281ff4a02 | 173 | return *(__packed uint16_t*)(ptr); |
AnnaBridge | 161:aa5281ff4a02 | 174 | } |
AnnaBridge | 161:aa5281ff4a02 | 175 | #pragma language=restore |
AnnaBridge | 161:aa5281ff4a02 | 176 | #define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR) |
AnnaBridge | 161:aa5281ff4a02 | 177 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 178 | |
AnnaBridge | 161:aa5281ff4a02 | 179 | |
AnnaBridge | 161:aa5281ff4a02 | 180 | #ifndef __UNALIGNED_UINT16_WRITE |
AnnaBridge | 161:aa5281ff4a02 | 181 | #pragma language=save |
AnnaBridge | 161:aa5281ff4a02 | 182 | #pragma language=extended |
Anna Bridge |
169:a7c7b631e539 | 183 | __IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) |
Anna Bridge |
169:a7c7b631e539 | 184 | { |
AnnaBridge | 161:aa5281ff4a02 | 185 | *(__packed uint16_t*)(ptr) = val;; |
AnnaBridge | 161:aa5281ff4a02 | 186 | } |
AnnaBridge | 161:aa5281ff4a02 | 187 | #pragma language=restore |
AnnaBridge | 161:aa5281ff4a02 | 188 | #define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL) |
AnnaBridge | 161:aa5281ff4a02 | 189 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 190 | |
AnnaBridge | 161:aa5281ff4a02 | 191 | #ifndef __UNALIGNED_UINT32_READ |
AnnaBridge | 161:aa5281ff4a02 | 192 | #pragma language=save |
AnnaBridge | 161:aa5281ff4a02 | 193 | #pragma language=extended |
Anna Bridge |
169:a7c7b631e539 | 194 | __IAR_FT uint32_t __iar_uint32_read(void const *ptr) |
Anna Bridge |
169:a7c7b631e539 | 195 | { |
AnnaBridge | 161:aa5281ff4a02 | 196 | return *(__packed uint32_t*)(ptr); |
AnnaBridge | 161:aa5281ff4a02 | 197 | } |
AnnaBridge | 161:aa5281ff4a02 | 198 | #pragma language=restore |
AnnaBridge | 161:aa5281ff4a02 | 199 | #define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR) |
AnnaBridge | 161:aa5281ff4a02 | 200 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 201 | |
AnnaBridge | 161:aa5281ff4a02 | 202 | #ifndef __UNALIGNED_UINT32_WRITE |
AnnaBridge | 161:aa5281ff4a02 | 203 | #pragma language=save |
AnnaBridge | 161:aa5281ff4a02 | 204 | #pragma language=extended |
Anna Bridge |
169:a7c7b631e539 | 205 | __IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) |
Anna Bridge |
169:a7c7b631e539 | 206 | { |
AnnaBridge | 161:aa5281ff4a02 | 207 | *(__packed uint32_t*)(ptr) = val;; |
AnnaBridge | 161:aa5281ff4a02 | 208 | } |
AnnaBridge | 161:aa5281ff4a02 | 209 | #pragma language=restore |
AnnaBridge | 161:aa5281ff4a02 | 210 | #define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL) |
AnnaBridge | 161:aa5281ff4a02 | 211 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 212 | |
AnnaBridge | 161:aa5281ff4a02 | 213 | #ifndef __UNALIGNED_UINT32 /* deprecated */ |
AnnaBridge | 161:aa5281ff4a02 | 214 | #pragma language=save |
AnnaBridge | 161:aa5281ff4a02 | 215 | #pragma language=extended |
AnnaBridge | 161:aa5281ff4a02 | 216 | __packed struct __iar_u32 { uint32_t v; }; |
AnnaBridge | 161:aa5281ff4a02 | 217 | #pragma language=restore |
AnnaBridge | 161:aa5281ff4a02 | 218 | #define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v) |
AnnaBridge | 161:aa5281ff4a02 | 219 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 220 | |
AnnaBridge | 161:aa5281ff4a02 | 221 | #ifndef __USED |
AnnaBridge | 161:aa5281ff4a02 | 222 | #if __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 223 | #define __USED __attribute__((used)) |
AnnaBridge | 161:aa5281ff4a02 | 224 | #else |
AnnaBridge | 161:aa5281ff4a02 | 225 | #define __USED _Pragma("__root") |
AnnaBridge | 161:aa5281ff4a02 | 226 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 227 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 228 | |
AnnaBridge | 161:aa5281ff4a02 | 229 | #ifndef __WEAK |
AnnaBridge | 161:aa5281ff4a02 | 230 | #if __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 231 | #define __WEAK __attribute__((weak)) |
AnnaBridge | 161:aa5281ff4a02 | 232 | #else |
AnnaBridge | 161:aa5281ff4a02 | 233 | #define __WEAK _Pragma("__weak") |
AnnaBridge | 161:aa5281ff4a02 | 234 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 235 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 236 | |
AnnaBridge | 161:aa5281ff4a02 | 237 | |
AnnaBridge | 161:aa5281ff4a02 | 238 | #ifndef __ICCARM_INTRINSICS_VERSION__ |
AnnaBridge | 161:aa5281ff4a02 | 239 | #define __ICCARM_INTRINSICS_VERSION__ 0 |
AnnaBridge | 161:aa5281ff4a02 | 240 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 241 | |
AnnaBridge | 161:aa5281ff4a02 | 242 | #if __ICCARM_INTRINSICS_VERSION__ == 2 |
AnnaBridge | 161:aa5281ff4a02 | 243 | |
AnnaBridge | 161:aa5281ff4a02 | 244 | #if defined(__CLZ) |
AnnaBridge | 161:aa5281ff4a02 | 245 | #undef __CLZ |
AnnaBridge | 161:aa5281ff4a02 | 246 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 247 | #if defined(__REVSH) |
AnnaBridge | 161:aa5281ff4a02 | 248 | #undef __REVSH |
AnnaBridge | 161:aa5281ff4a02 | 249 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 250 | #if defined(__RBIT) |
AnnaBridge | 161:aa5281ff4a02 | 251 | #undef __RBIT |
AnnaBridge | 161:aa5281ff4a02 | 252 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 253 | #if defined(__SSAT) |
AnnaBridge | 161:aa5281ff4a02 | 254 | #undef __SSAT |
AnnaBridge | 161:aa5281ff4a02 | 255 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 256 | #if defined(__USAT) |
AnnaBridge | 161:aa5281ff4a02 | 257 | #undef __USAT |
AnnaBridge | 161:aa5281ff4a02 | 258 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 259 | |
AnnaBridge | 161:aa5281ff4a02 | 260 | #include "iccarm_builtin.h" |
AnnaBridge | 161:aa5281ff4a02 | 261 | |
AnnaBridge | 161:aa5281ff4a02 | 262 | #define __disable_fault_irq __iar_builtin_disable_fiq |
AnnaBridge | 161:aa5281ff4a02 | 263 | #define __disable_irq __iar_builtin_disable_interrupt |
AnnaBridge | 161:aa5281ff4a02 | 264 | #define __enable_fault_irq __iar_builtin_enable_fiq |
AnnaBridge | 161:aa5281ff4a02 | 265 | #define __enable_irq __iar_builtin_enable_interrupt |
Anna Bridge |
169:a7c7b631e539 | 266 | #define __arm_rsr __iar_builtin_rsr |
Anna Bridge |
169:a7c7b631e539 | 267 | #define __arm_wsr __iar_builtin_wsr |
AnnaBridge | 161:aa5281ff4a02 | 268 | |
AnnaBridge | 161:aa5281ff4a02 | 269 | |
AnnaBridge | 161:aa5281ff4a02 | 270 | #define __get_APSR() (__arm_rsr("APSR")) |
AnnaBridge | 161:aa5281ff4a02 | 271 | #define __get_BASEPRI() (__arm_rsr("BASEPRI")) |
AnnaBridge | 161:aa5281ff4a02 | 272 | #define __get_CONTROL() (__arm_rsr("CONTROL")) |
AnnaBridge | 161:aa5281ff4a02 | 273 | #define __get_FAULTMASK() (__arm_rsr("FAULTMASK")) |
AnnaBridge | 161:aa5281ff4a02 | 274 | |
AnnaBridge | 161:aa5281ff4a02 | 275 | #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ |
AnnaBridge | 161:aa5281ff4a02 | 276 | (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) |
AnnaBridge | 161:aa5281ff4a02 | 277 | #define __get_FPSCR() (__arm_rsr("FPSCR")) |
AnnaBridge | 161:aa5281ff4a02 | 278 | #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 279 | #else |
AnnaBridge | 161:aa5281ff4a02 | 280 | #define __get_FPSCR() ( 0 ) |
AnnaBridge | 161:aa5281ff4a02 | 281 | #define __set_FPSCR(VALUE) ((void)VALUE) |
AnnaBridge | 161:aa5281ff4a02 | 282 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 283 | |
AnnaBridge | 161:aa5281ff4a02 | 284 | #define __get_IPSR() (__arm_rsr("IPSR")) |
AnnaBridge | 161:aa5281ff4a02 | 285 | #define __get_MSP() (__arm_rsr("MSP")) |
Anna Bridge |
169:a7c7b631e539 | 286 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 287 | (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 288 | // without main extensions, the non-secure MSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 289 | #define __get_MSPLIM() (0U) |
Anna Bridge |
169:a7c7b631e539 | 290 | #else |
Anna Bridge |
169:a7c7b631e539 | 291 | #define __get_MSPLIM() (__arm_rsr("MSPLIM")) |
Anna Bridge |
169:a7c7b631e539 | 292 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 293 | #define __get_PRIMASK() (__arm_rsr("PRIMASK")) |
AnnaBridge | 161:aa5281ff4a02 | 294 | #define __get_PSP() (__arm_rsr("PSP")) |
Anna Bridge |
169:a7c7b631e539 | 295 | |
Anna Bridge |
169:a7c7b631e539 | 296 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 297 | (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 298 | // without main extensions, the non-secure PSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 299 | #define __get_PSPLIM() (0U) |
Anna Bridge |
169:a7c7b631e539 | 300 | #else |
Anna Bridge |
169:a7c7b631e539 | 301 | #define __get_PSPLIM() (__arm_rsr("PSPLIM")) |
Anna Bridge |
169:a7c7b631e539 | 302 | #endif |
Anna Bridge |
169:a7c7b631e539 | 303 | |
AnnaBridge | 161:aa5281ff4a02 | 304 | #define __get_xPSR() (__arm_rsr("xPSR")) |
AnnaBridge | 161:aa5281ff4a02 | 305 | |
AnnaBridge | 161:aa5281ff4a02 | 306 | #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 307 | #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 308 | #define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 309 | #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 310 | #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE))) |
Anna Bridge |
169:a7c7b631e539 | 311 | |
Anna Bridge |
169:a7c7b631e539 | 312 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 313 | (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 314 | // without main extensions, the non-secure MSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 315 | #define __set_MSPLIM(VALUE) ((void)(VALUE)) |
Anna Bridge |
169:a7c7b631e539 | 316 | #else |
Anna Bridge |
169:a7c7b631e539 | 317 | #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE))) |
Anna Bridge |
169:a7c7b631e539 | 318 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 319 | #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 320 | #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE))) |
Anna Bridge |
169:a7c7b631e539 | 321 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 322 | (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 323 | // without main extensions, the non-secure PSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 324 | #define __set_PSPLIM(VALUE) ((void)(VALUE)) |
Anna Bridge |
169:a7c7b631e539 | 325 | #else |
Anna Bridge |
169:a7c7b631e539 | 326 | #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE))) |
Anna Bridge |
169:a7c7b631e539 | 327 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 328 | |
AnnaBridge | 161:aa5281ff4a02 | 329 | #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 330 | #define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 331 | #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 332 | #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 333 | #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 334 | #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 335 | #define __TZ_get_SP_NS() (__arm_rsr("SP_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 336 | #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 337 | #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 338 | #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 339 | #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 340 | #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 341 | #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 342 | #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 343 | #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 344 | #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 345 | #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS")) |
AnnaBridge | 161:aa5281ff4a02 | 346 | #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE))) |
AnnaBridge | 161:aa5281ff4a02 | 347 | |
Anna Bridge |
169:a7c7b631e539 | 348 | #define __NOP __iar_builtin_no_operation |
AnnaBridge | 161:aa5281ff4a02 | 349 | |
Anna Bridge |
169:a7c7b631e539 | 350 | #define __CLZ __iar_builtin_CLZ |
Anna Bridge |
169:a7c7b631e539 | 351 | #define __CLREX __iar_builtin_CLREX |
AnnaBridge | 161:aa5281ff4a02 | 352 | |
Anna Bridge |
169:a7c7b631e539 | 353 | #define __DMB __iar_builtin_DMB |
Anna Bridge |
169:a7c7b631e539 | 354 | #define __DSB __iar_builtin_DSB |
Anna Bridge |
169:a7c7b631e539 | 355 | #define __ISB __iar_builtin_ISB |
AnnaBridge | 161:aa5281ff4a02 | 356 | |
AnnaBridge | 161:aa5281ff4a02 | 357 | #define __LDREXB __iar_builtin_LDREXB |
AnnaBridge | 161:aa5281ff4a02 | 358 | #define __LDREXH __iar_builtin_LDREXH |
AnnaBridge | 161:aa5281ff4a02 | 359 | #define __LDREXW __iar_builtin_LDREX |
AnnaBridge | 161:aa5281ff4a02 | 360 | |
AnnaBridge | 161:aa5281ff4a02 | 361 | #define __RBIT __iar_builtin_RBIT |
AnnaBridge | 161:aa5281ff4a02 | 362 | #define __REV __iar_builtin_REV |
AnnaBridge | 161:aa5281ff4a02 | 363 | #define __REV16 __iar_builtin_REV16 |
AnnaBridge | 161:aa5281ff4a02 | 364 | |
Anna Bridge |
169:a7c7b631e539 | 365 | __IAR_FT int16_t __REVSH(int16_t val) |
Anna Bridge |
169:a7c7b631e539 | 366 | { |
Anna Bridge |
169:a7c7b631e539 | 367 | return (int16_t) __iar_builtin_REVSH(val); |
AnnaBridge | 161:aa5281ff4a02 | 368 | } |
AnnaBridge | 161:aa5281ff4a02 | 369 | |
AnnaBridge | 161:aa5281ff4a02 | 370 | #define __ROR __iar_builtin_ROR |
AnnaBridge | 161:aa5281ff4a02 | 371 | #define __RRX __iar_builtin_RRX |
AnnaBridge | 161:aa5281ff4a02 | 372 | |
AnnaBridge | 161:aa5281ff4a02 | 373 | #define __SEV __iar_builtin_SEV |
AnnaBridge | 161:aa5281ff4a02 | 374 | |
AnnaBridge | 161:aa5281ff4a02 | 375 | #if !__IAR_M0_FAMILY |
AnnaBridge | 161:aa5281ff4a02 | 376 | #define __SSAT __iar_builtin_SSAT |
AnnaBridge | 161:aa5281ff4a02 | 377 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 378 | |
AnnaBridge | 161:aa5281ff4a02 | 379 | #define __STREXB __iar_builtin_STREXB |
AnnaBridge | 161:aa5281ff4a02 | 380 | #define __STREXH __iar_builtin_STREXH |
AnnaBridge | 161:aa5281ff4a02 | 381 | #define __STREXW __iar_builtin_STREX |
AnnaBridge | 161:aa5281ff4a02 | 382 | |
AnnaBridge | 161:aa5281ff4a02 | 383 | #if !__IAR_M0_FAMILY |
AnnaBridge | 161:aa5281ff4a02 | 384 | #define __USAT __iar_builtin_USAT |
AnnaBridge | 161:aa5281ff4a02 | 385 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 386 | |
AnnaBridge | 161:aa5281ff4a02 | 387 | #define __WFE __iar_builtin_WFE |
AnnaBridge | 161:aa5281ff4a02 | 388 | #define __WFI __iar_builtin_WFI |
AnnaBridge | 161:aa5281ff4a02 | 389 | |
AnnaBridge | 161:aa5281ff4a02 | 390 | #if __ARM_MEDIA__ |
AnnaBridge | 161:aa5281ff4a02 | 391 | #define __SADD8 __iar_builtin_SADD8 |
AnnaBridge | 161:aa5281ff4a02 | 392 | #define __QADD8 __iar_builtin_QADD8 |
AnnaBridge | 161:aa5281ff4a02 | 393 | #define __SHADD8 __iar_builtin_SHADD8 |
AnnaBridge | 161:aa5281ff4a02 | 394 | #define __UADD8 __iar_builtin_UADD8 |
AnnaBridge | 161:aa5281ff4a02 | 395 | #define __UQADD8 __iar_builtin_UQADD8 |
AnnaBridge | 161:aa5281ff4a02 | 396 | #define __UHADD8 __iar_builtin_UHADD8 |
AnnaBridge | 161:aa5281ff4a02 | 397 | #define __SSUB8 __iar_builtin_SSUB8 |
AnnaBridge | 161:aa5281ff4a02 | 398 | #define __QSUB8 __iar_builtin_QSUB8 |
AnnaBridge | 161:aa5281ff4a02 | 399 | #define __SHSUB8 __iar_builtin_SHSUB8 |
AnnaBridge | 161:aa5281ff4a02 | 400 | #define __USUB8 __iar_builtin_USUB8 |
AnnaBridge | 161:aa5281ff4a02 | 401 | #define __UQSUB8 __iar_builtin_UQSUB8 |
AnnaBridge | 161:aa5281ff4a02 | 402 | #define __UHSUB8 __iar_builtin_UHSUB8 |
AnnaBridge | 161:aa5281ff4a02 | 403 | #define __SADD16 __iar_builtin_SADD16 |
AnnaBridge | 161:aa5281ff4a02 | 404 | #define __QADD16 __iar_builtin_QADD16 |
AnnaBridge | 161:aa5281ff4a02 | 405 | #define __SHADD16 __iar_builtin_SHADD16 |
AnnaBridge | 161:aa5281ff4a02 | 406 | #define __UADD16 __iar_builtin_UADD16 |
AnnaBridge | 161:aa5281ff4a02 | 407 | #define __UQADD16 __iar_builtin_UQADD16 |
AnnaBridge | 161:aa5281ff4a02 | 408 | #define __UHADD16 __iar_builtin_UHADD16 |
AnnaBridge | 161:aa5281ff4a02 | 409 | #define __SSUB16 __iar_builtin_SSUB16 |
AnnaBridge | 161:aa5281ff4a02 | 410 | #define __QSUB16 __iar_builtin_QSUB16 |
AnnaBridge | 161:aa5281ff4a02 | 411 | #define __SHSUB16 __iar_builtin_SHSUB16 |
AnnaBridge | 161:aa5281ff4a02 | 412 | #define __USUB16 __iar_builtin_USUB16 |
AnnaBridge | 161:aa5281ff4a02 | 413 | #define __UQSUB16 __iar_builtin_UQSUB16 |
AnnaBridge | 161:aa5281ff4a02 | 414 | #define __UHSUB16 __iar_builtin_UHSUB16 |
AnnaBridge | 161:aa5281ff4a02 | 415 | #define __SASX __iar_builtin_SASX |
AnnaBridge | 161:aa5281ff4a02 | 416 | #define __QASX __iar_builtin_QASX |
AnnaBridge | 161:aa5281ff4a02 | 417 | #define __SHASX __iar_builtin_SHASX |
AnnaBridge | 161:aa5281ff4a02 | 418 | #define __UASX __iar_builtin_UASX |
AnnaBridge | 161:aa5281ff4a02 | 419 | #define __UQASX __iar_builtin_UQASX |
AnnaBridge | 161:aa5281ff4a02 | 420 | #define __UHASX __iar_builtin_UHASX |
AnnaBridge | 161:aa5281ff4a02 | 421 | #define __SSAX __iar_builtin_SSAX |
AnnaBridge | 161:aa5281ff4a02 | 422 | #define __QSAX __iar_builtin_QSAX |
AnnaBridge | 161:aa5281ff4a02 | 423 | #define __SHSAX __iar_builtin_SHSAX |
AnnaBridge | 161:aa5281ff4a02 | 424 | #define __USAX __iar_builtin_USAX |
AnnaBridge | 161:aa5281ff4a02 | 425 | #define __UQSAX __iar_builtin_UQSAX |
AnnaBridge | 161:aa5281ff4a02 | 426 | #define __UHSAX __iar_builtin_UHSAX |
AnnaBridge | 161:aa5281ff4a02 | 427 | #define __USAD8 __iar_builtin_USAD8 |
AnnaBridge | 161:aa5281ff4a02 | 428 | #define __USADA8 __iar_builtin_USADA8 |
AnnaBridge | 161:aa5281ff4a02 | 429 | #define __SSAT16 __iar_builtin_SSAT16 |
AnnaBridge | 161:aa5281ff4a02 | 430 | #define __USAT16 __iar_builtin_USAT16 |
AnnaBridge | 161:aa5281ff4a02 | 431 | #define __UXTB16 __iar_builtin_UXTB16 |
AnnaBridge | 161:aa5281ff4a02 | 432 | #define __UXTAB16 __iar_builtin_UXTAB16 |
AnnaBridge | 161:aa5281ff4a02 | 433 | #define __SXTB16 __iar_builtin_SXTB16 |
AnnaBridge | 161:aa5281ff4a02 | 434 | #define __SXTAB16 __iar_builtin_SXTAB16 |
AnnaBridge | 161:aa5281ff4a02 | 435 | #define __SMUAD __iar_builtin_SMUAD |
AnnaBridge | 161:aa5281ff4a02 | 436 | #define __SMUADX __iar_builtin_SMUADX |
AnnaBridge | 161:aa5281ff4a02 | 437 | #define __SMMLA __iar_builtin_SMMLA |
AnnaBridge | 161:aa5281ff4a02 | 438 | #define __SMLAD __iar_builtin_SMLAD |
AnnaBridge | 161:aa5281ff4a02 | 439 | #define __SMLADX __iar_builtin_SMLADX |
AnnaBridge | 161:aa5281ff4a02 | 440 | #define __SMLALD __iar_builtin_SMLALD |
AnnaBridge | 161:aa5281ff4a02 | 441 | #define __SMLALDX __iar_builtin_SMLALDX |
AnnaBridge | 161:aa5281ff4a02 | 442 | #define __SMUSD __iar_builtin_SMUSD |
AnnaBridge | 161:aa5281ff4a02 | 443 | #define __SMUSDX __iar_builtin_SMUSDX |
AnnaBridge | 161:aa5281ff4a02 | 444 | #define __SMLSD __iar_builtin_SMLSD |
AnnaBridge | 161:aa5281ff4a02 | 445 | #define __SMLSDX __iar_builtin_SMLSDX |
AnnaBridge | 161:aa5281ff4a02 | 446 | #define __SMLSLD __iar_builtin_SMLSLD |
AnnaBridge | 161:aa5281ff4a02 | 447 | #define __SMLSLDX __iar_builtin_SMLSLDX |
AnnaBridge | 161:aa5281ff4a02 | 448 | #define __SEL __iar_builtin_SEL |
AnnaBridge | 161:aa5281ff4a02 | 449 | #define __QADD __iar_builtin_QADD |
AnnaBridge | 161:aa5281ff4a02 | 450 | #define __QSUB __iar_builtin_QSUB |
AnnaBridge | 161:aa5281ff4a02 | 451 | #define __PKHBT __iar_builtin_PKHBT |
AnnaBridge | 161:aa5281ff4a02 | 452 | #define __PKHTB __iar_builtin_PKHTB |
AnnaBridge | 161:aa5281ff4a02 | 453 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 454 | |
AnnaBridge | 161:aa5281ff4a02 | 455 | #else /* __ICCARM_INTRINSICS_VERSION__ == 2 */ |
AnnaBridge | 161:aa5281ff4a02 | 456 | |
AnnaBridge | 161:aa5281ff4a02 | 457 | #if __IAR_M0_FAMILY |
AnnaBridge | 161:aa5281ff4a02 | 458 | /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ |
AnnaBridge | 161:aa5281ff4a02 | 459 | #define __CLZ __cmsis_iar_clz_not_active |
AnnaBridge | 161:aa5281ff4a02 | 460 | #define __SSAT __cmsis_iar_ssat_not_active |
AnnaBridge | 161:aa5281ff4a02 | 461 | #define __USAT __cmsis_iar_usat_not_active |
AnnaBridge | 161:aa5281ff4a02 | 462 | #define __RBIT __cmsis_iar_rbit_not_active |
AnnaBridge | 161:aa5281ff4a02 | 463 | #define __get_APSR __cmsis_iar_get_APSR_not_active |
AnnaBridge | 161:aa5281ff4a02 | 464 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 465 | |
AnnaBridge | 161:aa5281ff4a02 | 466 | |
AnnaBridge | 161:aa5281ff4a02 | 467 | #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ |
AnnaBridge | 161:aa5281ff4a02 | 468 | (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) |
AnnaBridge | 161:aa5281ff4a02 | 469 | #define __get_FPSCR __cmsis_iar_get_FPSR_not_active |
AnnaBridge | 161:aa5281ff4a02 | 470 | #define __set_FPSCR __cmsis_iar_set_FPSR_not_active |
AnnaBridge | 161:aa5281ff4a02 | 471 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 472 | |
Anna Bridge |
169:a7c7b631e539 | 473 | #ifdef __INTRINSICS_INCLUDED |
Anna Bridge |
169:a7c7b631e539 | 474 | #error intrinsics.h is already included previously! |
Anna Bridge |
169:a7c7b631e539 | 475 | #endif |
Anna Bridge |
169:a7c7b631e539 | 476 | |
AnnaBridge | 161:aa5281ff4a02 | 477 | #include <intrinsics.h> |
AnnaBridge | 161:aa5281ff4a02 | 478 | |
AnnaBridge | 161:aa5281ff4a02 | 479 | #if __IAR_M0_FAMILY |
AnnaBridge | 161:aa5281ff4a02 | 480 | /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ |
AnnaBridge | 161:aa5281ff4a02 | 481 | #undef __CLZ |
AnnaBridge | 161:aa5281ff4a02 | 482 | #undef __SSAT |
AnnaBridge | 161:aa5281ff4a02 | 483 | #undef __USAT |
AnnaBridge | 161:aa5281ff4a02 | 484 | #undef __RBIT |
AnnaBridge | 161:aa5281ff4a02 | 485 | #undef __get_APSR |
AnnaBridge | 161:aa5281ff4a02 | 486 | |
Anna Bridge |
169:a7c7b631e539 | 487 | __STATIC_INLINE uint8_t __CLZ(uint32_t data) |
Anna Bridge |
169:a7c7b631e539 | 488 | { |
Anna Bridge |
169:a7c7b631e539 | 489 | if (data == 0U) { return 32U; } |
AnnaBridge | 161:aa5281ff4a02 | 490 | |
Anna Bridge |
169:a7c7b631e539 | 491 | uint32_t count = 0U; |
Anna Bridge |
169:a7c7b631e539 | 492 | uint32_t mask = 0x80000000U; |
AnnaBridge | 161:aa5281ff4a02 | 493 | |
Anna Bridge |
169:a7c7b631e539 | 494 | while ((data & mask) == 0U) |
AnnaBridge | 161:aa5281ff4a02 | 495 | { |
Anna Bridge |
169:a7c7b631e539 | 496 | count += 1U; |
Anna Bridge |
169:a7c7b631e539 | 497 | mask = mask >> 1U; |
AnnaBridge | 161:aa5281ff4a02 | 498 | } |
Anna Bridge |
169:a7c7b631e539 | 499 | return count; |
AnnaBridge | 161:aa5281ff4a02 | 500 | } |
AnnaBridge | 161:aa5281ff4a02 | 501 | |
Anna Bridge |
169:a7c7b631e539 | 502 | __STATIC_INLINE uint32_t __RBIT(uint32_t v) |
Anna Bridge |
169:a7c7b631e539 | 503 | { |
Anna Bridge |
169:a7c7b631e539 | 504 | uint8_t sc = 31U; |
AnnaBridge | 161:aa5281ff4a02 | 505 | uint32_t r = v; |
AnnaBridge | 161:aa5281ff4a02 | 506 | for (v >>= 1U; v; v >>= 1U) |
AnnaBridge | 161:aa5281ff4a02 | 507 | { |
AnnaBridge | 161:aa5281ff4a02 | 508 | r <<= 1U; |
AnnaBridge | 161:aa5281ff4a02 | 509 | r |= v & 1U; |
AnnaBridge | 161:aa5281ff4a02 | 510 | sc--; |
AnnaBridge | 161:aa5281ff4a02 | 511 | } |
AnnaBridge | 161:aa5281ff4a02 | 512 | return (r << sc); |
AnnaBridge | 161:aa5281ff4a02 | 513 | } |
AnnaBridge | 161:aa5281ff4a02 | 514 | |
Anna Bridge |
169:a7c7b631e539 | 515 | __STATIC_INLINE uint32_t __get_APSR(void) |
Anna Bridge |
169:a7c7b631e539 | 516 | { |
AnnaBridge | 161:aa5281ff4a02 | 517 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 518 | __asm("MRS %0,APSR" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 519 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 520 | } |
AnnaBridge | 161:aa5281ff4a02 | 521 | |
AnnaBridge | 161:aa5281ff4a02 | 522 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 523 | |
AnnaBridge | 161:aa5281ff4a02 | 524 | #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ |
AnnaBridge | 161:aa5281ff4a02 | 525 | (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) |
AnnaBridge | 161:aa5281ff4a02 | 526 | #undef __get_FPSCR |
AnnaBridge | 161:aa5281ff4a02 | 527 | #undef __set_FPSCR |
AnnaBridge | 161:aa5281ff4a02 | 528 | #define __get_FPSCR() (0) |
AnnaBridge | 161:aa5281ff4a02 | 529 | #define __set_FPSCR(VALUE) ((void)VALUE) |
AnnaBridge | 161:aa5281ff4a02 | 530 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 531 | |
AnnaBridge | 161:aa5281ff4a02 | 532 | #pragma diag_suppress=Pe940 |
AnnaBridge | 161:aa5281ff4a02 | 533 | #pragma diag_suppress=Pe177 |
AnnaBridge | 161:aa5281ff4a02 | 534 | |
AnnaBridge | 161:aa5281ff4a02 | 535 | #define __enable_irq __enable_interrupt |
AnnaBridge | 161:aa5281ff4a02 | 536 | #define __disable_irq __disable_interrupt |
AnnaBridge | 161:aa5281ff4a02 | 537 | #define __NOP __no_operation |
AnnaBridge | 161:aa5281ff4a02 | 538 | |
AnnaBridge | 161:aa5281ff4a02 | 539 | #define __get_xPSR __get_PSR |
AnnaBridge | 161:aa5281ff4a02 | 540 | |
AnnaBridge | 161:aa5281ff4a02 | 541 | #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0) |
AnnaBridge | 161:aa5281ff4a02 | 542 | |
Anna Bridge |
169:a7c7b631e539 | 543 | __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) |
Anna Bridge |
169:a7c7b631e539 | 544 | { |
AnnaBridge | 161:aa5281ff4a02 | 545 | return __LDREX((unsigned long *)ptr); |
AnnaBridge | 161:aa5281ff4a02 | 546 | } |
AnnaBridge | 161:aa5281ff4a02 | 547 | |
Anna Bridge |
169:a7c7b631e539 | 548 | __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) |
Anna Bridge |
169:a7c7b631e539 | 549 | { |
AnnaBridge | 161:aa5281ff4a02 | 550 | return __STREX(value, (unsigned long *)ptr); |
AnnaBridge | 161:aa5281ff4a02 | 551 | } |
AnnaBridge | 161:aa5281ff4a02 | 552 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 553 | |
AnnaBridge | 161:aa5281ff4a02 | 554 | |
AnnaBridge | 161:aa5281ff4a02 | 555 | /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ |
AnnaBridge | 161:aa5281ff4a02 | 556 | #if (__CORTEX_M >= 0x03) |
AnnaBridge | 161:aa5281ff4a02 | 557 | |
Anna Bridge |
169:a7c7b631e539 | 558 | __IAR_FT uint32_t __RRX(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 559 | { |
AnnaBridge | 161:aa5281ff4a02 | 560 | uint32_t result; |
AnnaBridge | 161:aa5281ff4a02 | 561 | __ASM("RRX %0, %1" : "=r"(result) : "r" (value) : "cc"); |
AnnaBridge | 161:aa5281ff4a02 | 562 | return(result); |
AnnaBridge | 161:aa5281ff4a02 | 563 | } |
AnnaBridge | 161:aa5281ff4a02 | 564 | |
Anna Bridge |
169:a7c7b631e539 | 565 | __IAR_FT void __set_BASEPRI_MAX(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 566 | { |
AnnaBridge | 161:aa5281ff4a02 | 567 | __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 568 | } |
AnnaBridge | 161:aa5281ff4a02 | 569 | |
AnnaBridge | 161:aa5281ff4a02 | 570 | |
Anna Bridge |
169:a7c7b631e539 | 571 | #define __enable_fault_irq __enable_fiq |
AnnaBridge | 161:aa5281ff4a02 | 572 | #define __disable_fault_irq __disable_fiq |
AnnaBridge | 161:aa5281ff4a02 | 573 | |
AnnaBridge | 161:aa5281ff4a02 | 574 | |
AnnaBridge | 161:aa5281ff4a02 | 575 | #endif /* (__CORTEX_M >= 0x03) */ |
AnnaBridge | 161:aa5281ff4a02 | 576 | |
Anna Bridge |
169:a7c7b631e539 | 577 | __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) |
Anna Bridge |
169:a7c7b631e539 | 578 | { |
AnnaBridge | 161:aa5281ff4a02 | 579 | return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2)); |
AnnaBridge | 161:aa5281ff4a02 | 580 | } |
AnnaBridge | 161:aa5281ff4a02 | 581 | |
AnnaBridge | 161:aa5281ff4a02 | 582 | #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ |
AnnaBridge | 161:aa5281ff4a02 | 583 | (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) |
AnnaBridge | 161:aa5281ff4a02 | 584 | |
Anna Bridge |
169:a7c7b631e539 | 585 | __IAR_FT uint32_t __get_MSPLIM(void) |
Anna Bridge |
169:a7c7b631e539 | 586 | { |
Anna Bridge |
169:a7c7b631e539 | 587 | uint32_t res; |
Anna Bridge |
169:a7c7b631e539 | 588 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 589 | (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 590 | // without main extensions, the non-secure MSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 591 | res = 0U; |
Anna Bridge |
169:a7c7b631e539 | 592 | #else |
Anna Bridge |
169:a7c7b631e539 | 593 | __asm volatile("MRS %0,MSPLIM" : "=r" (res)); |
Anna Bridge |
169:a7c7b631e539 | 594 | #endif |
Anna Bridge |
169:a7c7b631e539 | 595 | return res; |
Anna Bridge |
169:a7c7b631e539 | 596 | } |
Anna Bridge |
169:a7c7b631e539 | 597 | |
Anna Bridge |
169:a7c7b631e539 | 598 | __IAR_FT void __set_MSPLIM(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 599 | { |
Anna Bridge |
169:a7c7b631e539 | 600 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 601 | (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 602 | // without main extensions, the non-secure MSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 603 | (void)value; |
Anna Bridge |
169:a7c7b631e539 | 604 | #else |
Anna Bridge |
169:a7c7b631e539 | 605 | __asm volatile("MSR MSPLIM,%0" :: "r" (value)); |
Anna Bridge |
169:a7c7b631e539 | 606 | #endif |
Anna Bridge |
169:a7c7b631e539 | 607 | } |
Anna Bridge |
169:a7c7b631e539 | 608 | |
Anna Bridge |
169:a7c7b631e539 | 609 | __IAR_FT uint32_t __get_PSPLIM(void) |
Anna Bridge |
169:a7c7b631e539 | 610 | { |
Anna Bridge |
169:a7c7b631e539 | 611 | uint32_t res; |
Anna Bridge |
169:a7c7b631e539 | 612 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 613 | (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 614 | // without main extensions, the non-secure PSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 615 | res = 0U; |
Anna Bridge |
169:a7c7b631e539 | 616 | #else |
Anna Bridge |
169:a7c7b631e539 | 617 | __asm volatile("MRS %0,PSPLIM" : "=r" (res)); |
Anna Bridge |
169:a7c7b631e539 | 618 | #endif |
Anna Bridge |
169:a7c7b631e539 | 619 | return res; |
Anna Bridge |
169:a7c7b631e539 | 620 | } |
Anna Bridge |
169:a7c7b631e539 | 621 | |
Anna Bridge |
169:a7c7b631e539 | 622 | __IAR_FT void __set_PSPLIM(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 623 | { |
Anna Bridge |
169:a7c7b631e539 | 624 | #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ |
Anna Bridge |
169:a7c7b631e539 | 625 | (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) |
Anna Bridge |
169:a7c7b631e539 | 626 | // without main extensions, the non-secure PSPLIM is RAZ/WI |
Anna Bridge |
169:a7c7b631e539 | 627 | (void)value; |
Anna Bridge |
169:a7c7b631e539 | 628 | #else |
Anna Bridge |
169:a7c7b631e539 | 629 | __asm volatile("MSR PSPLIM,%0" :: "r" (value)); |
Anna Bridge |
169:a7c7b631e539 | 630 | #endif |
Anna Bridge |
169:a7c7b631e539 | 631 | } |
Anna Bridge |
169:a7c7b631e539 | 632 | |
Anna Bridge |
169:a7c7b631e539 | 633 | __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 634 | { |
AnnaBridge | 161:aa5281ff4a02 | 635 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 636 | __asm volatile("MRS %0,CONTROL_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 637 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 638 | } |
AnnaBridge | 161:aa5281ff4a02 | 639 | |
Anna Bridge |
169:a7c7b631e539 | 640 | __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 641 | { |
AnnaBridge | 161:aa5281ff4a02 | 642 | __asm volatile("MSR CONTROL_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 643 | } |
AnnaBridge | 161:aa5281ff4a02 | 644 | |
Anna Bridge |
169:a7c7b631e539 | 645 | __IAR_FT uint32_t __TZ_get_PSP_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 646 | { |
AnnaBridge | 161:aa5281ff4a02 | 647 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 648 | __asm volatile("MRS %0,PSP_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 649 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 650 | } |
AnnaBridge | 161:aa5281ff4a02 | 651 | |
Anna Bridge |
169:a7c7b631e539 | 652 | __IAR_FT void __TZ_set_PSP_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 653 | { |
AnnaBridge | 161:aa5281ff4a02 | 654 | __asm volatile("MSR PSP_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 655 | } |
AnnaBridge | 161:aa5281ff4a02 | 656 | |
Anna Bridge |
169:a7c7b631e539 | 657 | __IAR_FT uint32_t __TZ_get_MSP_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 658 | { |
AnnaBridge | 161:aa5281ff4a02 | 659 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 660 | __asm volatile("MRS %0,MSP_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 661 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 662 | } |
AnnaBridge | 161:aa5281ff4a02 | 663 | |
Anna Bridge |
169:a7c7b631e539 | 664 | __IAR_FT void __TZ_set_MSP_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 665 | { |
AnnaBridge | 161:aa5281ff4a02 | 666 | __asm volatile("MSR MSP_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 667 | } |
AnnaBridge | 161:aa5281ff4a02 | 668 | |
Anna Bridge |
169:a7c7b631e539 | 669 | __IAR_FT uint32_t __TZ_get_SP_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 670 | { |
AnnaBridge | 161:aa5281ff4a02 | 671 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 672 | __asm volatile("MRS %0,SP_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 673 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 674 | } |
Anna Bridge |
169:a7c7b631e539 | 675 | __IAR_FT void __TZ_set_SP_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 676 | { |
AnnaBridge | 161:aa5281ff4a02 | 677 | __asm volatile("MSR SP_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 678 | } |
AnnaBridge | 161:aa5281ff4a02 | 679 | |
Anna Bridge |
169:a7c7b631e539 | 680 | __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 681 | { |
AnnaBridge | 161:aa5281ff4a02 | 682 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 683 | __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 684 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 685 | } |
AnnaBridge | 161:aa5281ff4a02 | 686 | |
Anna Bridge |
169:a7c7b631e539 | 687 | __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 688 | { |
AnnaBridge | 161:aa5281ff4a02 | 689 | __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 690 | } |
AnnaBridge | 161:aa5281ff4a02 | 691 | |
Anna Bridge |
169:a7c7b631e539 | 692 | __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 693 | { |
AnnaBridge | 161:aa5281ff4a02 | 694 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 695 | __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 696 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 697 | } |
AnnaBridge | 161:aa5281ff4a02 | 698 | |
Anna Bridge |
169:a7c7b631e539 | 699 | __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 700 | { |
AnnaBridge | 161:aa5281ff4a02 | 701 | __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 702 | } |
AnnaBridge | 161:aa5281ff4a02 | 703 | |
Anna Bridge |
169:a7c7b631e539 | 704 | __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 705 | { |
AnnaBridge | 161:aa5281ff4a02 | 706 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 707 | __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 708 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 709 | } |
AnnaBridge | 161:aa5281ff4a02 | 710 | |
Anna Bridge |
169:a7c7b631e539 | 711 | __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 712 | { |
AnnaBridge | 161:aa5281ff4a02 | 713 | __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 714 | } |
AnnaBridge | 161:aa5281ff4a02 | 715 | |
Anna Bridge |
169:a7c7b631e539 | 716 | __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 717 | { |
AnnaBridge | 161:aa5281ff4a02 | 718 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 719 | __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 720 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 721 | } |
Anna Bridge |
169:a7c7b631e539 | 722 | __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 723 | { |
AnnaBridge | 161:aa5281ff4a02 | 724 | __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 725 | } |
AnnaBridge | 161:aa5281ff4a02 | 726 | |
Anna Bridge |
169:a7c7b631e539 | 727 | __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) |
Anna Bridge |
169:a7c7b631e539 | 728 | { |
AnnaBridge | 161:aa5281ff4a02 | 729 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 730 | __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res)); |
AnnaBridge | 161:aa5281ff4a02 | 731 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 732 | } |
AnnaBridge | 161:aa5281ff4a02 | 733 | |
Anna Bridge |
169:a7c7b631e539 | 734 | __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) |
Anna Bridge |
169:a7c7b631e539 | 735 | { |
AnnaBridge | 161:aa5281ff4a02 | 736 | __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value)); |
AnnaBridge | 161:aa5281ff4a02 | 737 | } |
AnnaBridge | 161:aa5281ff4a02 | 738 | |
AnnaBridge | 161:aa5281ff4a02 | 739 | #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ |
AnnaBridge | 161:aa5281ff4a02 | 740 | |
AnnaBridge | 161:aa5281ff4a02 | 741 | #endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */ |
AnnaBridge | 161:aa5281ff4a02 | 742 | |
AnnaBridge | 161:aa5281ff4a02 | 743 | #define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value)) |
AnnaBridge | 161:aa5281ff4a02 | 744 | |
AnnaBridge | 161:aa5281ff4a02 | 745 | #if __IAR_M0_FAMILY |
Anna Bridge |
169:a7c7b631e539 | 746 | __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) |
Anna Bridge |
169:a7c7b631e539 | 747 | { |
Anna Bridge |
169:a7c7b631e539 | 748 | if ((sat >= 1U) && (sat <= 32U)) |
Anna Bridge |
169:a7c7b631e539 | 749 | { |
AnnaBridge | 161:aa5281ff4a02 | 750 | const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); |
AnnaBridge | 161:aa5281ff4a02 | 751 | const int32_t min = -1 - max ; |
Anna Bridge |
169:a7c7b631e539 | 752 | if (val > max) |
Anna Bridge |
169:a7c7b631e539 | 753 | { |
AnnaBridge | 161:aa5281ff4a02 | 754 | return max; |
Anna Bridge |
169:a7c7b631e539 | 755 | } |
Anna Bridge |
169:a7c7b631e539 | 756 | else if (val < min) |
Anna Bridge |
169:a7c7b631e539 | 757 | { |
AnnaBridge | 161:aa5281ff4a02 | 758 | return min; |
AnnaBridge | 161:aa5281ff4a02 | 759 | } |
AnnaBridge | 161:aa5281ff4a02 | 760 | } |
AnnaBridge | 161:aa5281ff4a02 | 761 | return val; |
AnnaBridge | 161:aa5281ff4a02 | 762 | } |
AnnaBridge | 161:aa5281ff4a02 | 763 | |
Anna Bridge |
169:a7c7b631e539 | 764 | __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) |
Anna Bridge |
169:a7c7b631e539 | 765 | { |
Anna Bridge |
169:a7c7b631e539 | 766 | if (sat <= 31U) |
Anna Bridge |
169:a7c7b631e539 | 767 | { |
AnnaBridge | 161:aa5281ff4a02 | 768 | const uint32_t max = ((1U << sat) - 1U); |
Anna Bridge |
169:a7c7b631e539 | 769 | if (val > (int32_t)max) |
Anna Bridge |
169:a7c7b631e539 | 770 | { |
AnnaBridge | 161:aa5281ff4a02 | 771 | return max; |
Anna Bridge |
169:a7c7b631e539 | 772 | } |
Anna Bridge |
169:a7c7b631e539 | 773 | else if (val < 0) |
Anna Bridge |
169:a7c7b631e539 | 774 | { |
AnnaBridge | 161:aa5281ff4a02 | 775 | return 0U; |
AnnaBridge | 161:aa5281ff4a02 | 776 | } |
AnnaBridge | 161:aa5281ff4a02 | 777 | } |
AnnaBridge | 161:aa5281ff4a02 | 778 | return (uint32_t)val; |
AnnaBridge | 161:aa5281ff4a02 | 779 | } |
AnnaBridge | 161:aa5281ff4a02 | 780 | #endif |
AnnaBridge | 161:aa5281ff4a02 | 781 | |
AnnaBridge | 161:aa5281ff4a02 | 782 | #if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ |
AnnaBridge | 161:aa5281ff4a02 | 783 | |
Anna Bridge |
169:a7c7b631e539 | 784 | __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) |
Anna Bridge |
169:a7c7b631e539 | 785 | { |
AnnaBridge | 161:aa5281ff4a02 | 786 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 787 | __ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 788 | return ((uint8_t)res); |
AnnaBridge | 161:aa5281ff4a02 | 789 | } |
AnnaBridge | 161:aa5281ff4a02 | 790 | |
Anna Bridge |
169:a7c7b631e539 | 791 | __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) |
Anna Bridge |
169:a7c7b631e539 | 792 | { |
AnnaBridge | 161:aa5281ff4a02 | 793 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 794 | __ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 795 | return ((uint16_t)res); |
AnnaBridge | 161:aa5281ff4a02 | 796 | } |
AnnaBridge | 161:aa5281ff4a02 | 797 | |
Anna Bridge |
169:a7c7b631e539 | 798 | __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) |
Anna Bridge |
169:a7c7b631e539 | 799 | { |
AnnaBridge | 161:aa5281ff4a02 | 800 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 801 | __ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 802 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 803 | } |
AnnaBridge | 161:aa5281ff4a02 | 804 | |
Anna Bridge |
169:a7c7b631e539 | 805 | __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) |
Anna Bridge |
169:a7c7b631e539 | 806 | { |
AnnaBridge | 161:aa5281ff4a02 | 807 | __ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 808 | } |
AnnaBridge | 161:aa5281ff4a02 | 809 | |
Anna Bridge |
169:a7c7b631e539 | 810 | __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) |
Anna Bridge |
169:a7c7b631e539 | 811 | { |
AnnaBridge | 161:aa5281ff4a02 | 812 | __ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 813 | } |
AnnaBridge | 161:aa5281ff4a02 | 814 | |
Anna Bridge |
169:a7c7b631e539 | 815 | __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) |
Anna Bridge |
169:a7c7b631e539 | 816 | { |
AnnaBridge | 161:aa5281ff4a02 | 817 | __ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 818 | } |
AnnaBridge | 161:aa5281ff4a02 | 819 | |
AnnaBridge | 161:aa5281ff4a02 | 820 | #endif /* (__CORTEX_M >= 0x03) */ |
AnnaBridge | 161:aa5281ff4a02 | 821 | |
AnnaBridge | 161:aa5281ff4a02 | 822 | #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ |
AnnaBridge | 161:aa5281ff4a02 | 823 | (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) |
AnnaBridge | 161:aa5281ff4a02 | 824 | |
AnnaBridge | 161:aa5281ff4a02 | 825 | |
Anna Bridge |
169:a7c7b631e539 | 826 | __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 827 | { |
AnnaBridge | 161:aa5281ff4a02 | 828 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 829 | __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 830 | return ((uint8_t)res); |
AnnaBridge | 161:aa5281ff4a02 | 831 | } |
AnnaBridge | 161:aa5281ff4a02 | 832 | |
Anna Bridge |
169:a7c7b631e539 | 833 | __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 834 | { |
AnnaBridge | 161:aa5281ff4a02 | 835 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 836 | __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 837 | return ((uint16_t)res); |
AnnaBridge | 161:aa5281ff4a02 | 838 | } |
AnnaBridge | 161:aa5281ff4a02 | 839 | |
Anna Bridge |
169:a7c7b631e539 | 840 | __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 841 | { |
AnnaBridge | 161:aa5281ff4a02 | 842 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 843 | __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 844 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 845 | } |
AnnaBridge | 161:aa5281ff4a02 | 846 | |
Anna Bridge |
169:a7c7b631e539 | 847 | __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 848 | { |
AnnaBridge | 161:aa5281ff4a02 | 849 | __ASM volatile ("STLB %1, [%0]" :: "r" (*ptr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 850 | } |
AnnaBridge | 161:aa5281ff4a02 | 851 | |
Anna Bridge |
169:a7c7b631e539 | 852 | __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 853 | { |
AnnaBridge | 161:aa5281ff4a02 | 854 | __ASM volatile ("STLH %1, [%0]" :: "r" (*ptr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 855 | } |
AnnaBridge | 161:aa5281ff4a02 | 856 | |
Anna Bridge |
169:a7c7b631e539 | 857 | __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 858 | { |
AnnaBridge | 161:aa5281ff4a02 | 859 | __ASM volatile ("STL %1, [%0]" :: "r" (*ptr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 860 | } |
AnnaBridge | 161:aa5281ff4a02 | 861 | |
Anna Bridge |
169:a7c7b631e539 | 862 | __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 863 | { |
AnnaBridge | 161:aa5281ff4a02 | 864 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 865 | __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 866 | return ((uint8_t)res); |
AnnaBridge | 161:aa5281ff4a02 | 867 | } |
AnnaBridge | 161:aa5281ff4a02 | 868 | |
Anna Bridge |
169:a7c7b631e539 | 869 | __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 870 | { |
AnnaBridge | 161:aa5281ff4a02 | 871 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 872 | __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 873 | return ((uint16_t)res); |
AnnaBridge | 161:aa5281ff4a02 | 874 | } |
AnnaBridge | 161:aa5281ff4a02 | 875 | |
Anna Bridge |
169:a7c7b631e539 | 876 | __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 877 | { |
AnnaBridge | 161:aa5281ff4a02 | 878 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 879 | __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 880 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 881 | } |
AnnaBridge | 161:aa5281ff4a02 | 882 | |
Anna Bridge |
169:a7c7b631e539 | 883 | __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 884 | { |
AnnaBridge | 161:aa5281ff4a02 | 885 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 886 | __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 887 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 888 | } |
AnnaBridge | 161:aa5281ff4a02 | 889 | |
Anna Bridge |
169:a7c7b631e539 | 890 | __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 891 | { |
AnnaBridge | 161:aa5281ff4a02 | 892 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 893 | __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 894 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 895 | } |
AnnaBridge | 161:aa5281ff4a02 | 896 | |
Anna Bridge |
169:a7c7b631e539 | 897 | __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) |
Anna Bridge |
169:a7c7b631e539 | 898 | { |
AnnaBridge | 161:aa5281ff4a02 | 899 | uint32_t res; |
AnnaBridge | 161:aa5281ff4a02 | 900 | __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory"); |
AnnaBridge | 161:aa5281ff4a02 | 901 | return res; |
AnnaBridge | 161:aa5281ff4a02 | 902 | } |
AnnaBridge | 161:aa5281ff4a02 | 903 | |
AnnaBridge | 161:aa5281ff4a02 | 904 | #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ |
AnnaBridge | 161:aa5281ff4a02 | 905 | |
AnnaBridge | 161:aa5281ff4a02 | 906 | #undef __IAR_FT |
AnnaBridge | 161:aa5281ff4a02 | 907 | #undef __IAR_M0_FAMILY |
AnnaBridge | 161:aa5281ff4a02 | 908 | #undef __ICCARM_V8 |
AnnaBridge | 161:aa5281ff4a02 | 909 | |
AnnaBridge | 161:aa5281ff4a02 | 910 | #pragma diag_default=Pe940 |
AnnaBridge | 161:aa5281ff4a02 | 911 | #pragma diag_default=Pe177 |
AnnaBridge | 161:aa5281ff4a02 | 912 | |
AnnaBridge | 161:aa5281ff4a02 | 913 | #endif /* __CMSIS_ICCARM_H__ */ |