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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

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

Committer:
Anna Bridge
Date:
Fri Jun 22 15:38:59 2018 +0100
Revision:
169:a7c7b631e539
Parent:
160:5571c4ff569f
mbed library. Release version 162

Who changed what in which revision?

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