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:
Wed Jan 17 16:13:02 2018 +0000
Revision:
160:5571c4ff569f
Child:
169:a7c7b631e539
mbed library. Release version 158

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 160:5571c4ff569f 3 * @brief CMSIS compiler ICCARM (IAR compiler) header file
Anna Bridge 160:5571c4ff569f 4 * @version V5.0.3
Anna Bridge 160:5571c4ff569f 5 * @date 29. August 2017
Anna Bridge 160:5571c4ff569f 6 ******************************************************************************/
Anna Bridge 160:5571c4ff569f 7
Anna Bridge 160:5571c4ff569f 8 //------------------------------------------------------------------------------
Anna Bridge 160:5571c4ff569f 9 //
Anna Bridge 160:5571c4ff569f 10 // Copyright (c) 2017 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 160:5571c4ff569f 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 160:5571c4ff569f 153 #define __RESTRICT restrict
Anna Bridge 160:5571c4ff569f 154 #endif
Anna Bridge 160:5571c4ff569f 155
Anna Bridge 160:5571c4ff569f 156
Anna Bridge 160:5571c4ff569f 157 #ifndef __STATIC_INLINE
Anna Bridge 160:5571c4ff569f 158 #define __STATIC_INLINE static inline
Anna Bridge 160:5571c4ff569f 159 #endif
Anna Bridge 160:5571c4ff569f 160
Anna Bridge 160:5571c4ff569f 161 #ifndef __UNALIGNED_UINT16_READ
Anna Bridge 160:5571c4ff569f 162 #pragma language=save
Anna Bridge 160:5571c4ff569f 163 #pragma language=extended
Anna Bridge 160:5571c4ff569f 164 __IAR_FT uint16_t __iar_uint16_read(void const *ptr) {
Anna Bridge 160:5571c4ff569f 165 return *(__packed uint16_t*)(ptr);
Anna Bridge 160:5571c4ff569f 166 }
Anna Bridge 160:5571c4ff569f 167 #pragma language=restore
Anna Bridge 160:5571c4ff569f 168 #define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR)
Anna Bridge 160:5571c4ff569f 169 #endif
Anna Bridge 160:5571c4ff569f 170
Anna Bridge 160:5571c4ff569f 171
Anna Bridge 160:5571c4ff569f 172 #ifndef __UNALIGNED_UINT16_WRITE
Anna Bridge 160:5571c4ff569f 173 #pragma language=save
Anna Bridge 160:5571c4ff569f 174 #pragma language=extended
Anna Bridge 160:5571c4ff569f 175 __IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) {
Anna Bridge 160:5571c4ff569f 176 *(__packed uint16_t*)(ptr) = val;;
Anna Bridge 160:5571c4ff569f 177 }
Anna Bridge 160:5571c4ff569f 178 #pragma language=restore
Anna Bridge 160:5571c4ff569f 179 #define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
Anna Bridge 160:5571c4ff569f 180 #endif
Anna Bridge 160:5571c4ff569f 181
Anna Bridge 160:5571c4ff569f 182 #ifndef __UNALIGNED_UINT32_READ
Anna Bridge 160:5571c4ff569f 183 #pragma language=save
Anna Bridge 160:5571c4ff569f 184 #pragma language=extended
Anna Bridge 160:5571c4ff569f 185 __IAR_FT uint32_t __iar_uint32_read(void const *ptr) {
Anna Bridge 160:5571c4ff569f 186 return *(__packed uint32_t*)(ptr);
Anna Bridge 160:5571c4ff569f 187 }
Anna Bridge 160:5571c4ff569f 188 #pragma language=restore
Anna Bridge 160:5571c4ff569f 189 #define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR)
Anna Bridge 160:5571c4ff569f 190 #endif
Anna Bridge 160:5571c4ff569f 191
Anna Bridge 160:5571c4ff569f 192 #ifndef __UNALIGNED_UINT32_WRITE
Anna Bridge 160:5571c4ff569f 193 #pragma language=save
Anna Bridge 160:5571c4ff569f 194 #pragma language=extended
Anna Bridge 160:5571c4ff569f 195 __IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) {
Anna Bridge 160:5571c4ff569f 196 *(__packed uint32_t*)(ptr) = val;;
Anna Bridge 160:5571c4ff569f 197 }
Anna Bridge 160:5571c4ff569f 198 #pragma language=restore
Anna Bridge 160:5571c4ff569f 199 #define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
Anna Bridge 160:5571c4ff569f 200 #endif
Anna Bridge 160:5571c4ff569f 201
Anna Bridge 160:5571c4ff569f 202 #ifndef __UNALIGNED_UINT32 /* deprecated */
Anna Bridge 160:5571c4ff569f 203 #pragma language=save
Anna Bridge 160:5571c4ff569f 204 #pragma language=extended
Anna Bridge 160:5571c4ff569f 205 __packed struct __iar_u32 { uint32_t v; };
Anna Bridge 160:5571c4ff569f 206 #pragma language=restore
Anna Bridge 160:5571c4ff569f 207 #define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
Anna Bridge 160:5571c4ff569f 208 #endif
Anna Bridge 160:5571c4ff569f 209
Anna Bridge 160:5571c4ff569f 210 #ifndef __USED
Anna Bridge 160:5571c4ff569f 211 #if __ICCARM_V8
Anna Bridge 160:5571c4ff569f 212 #define __USED __attribute__((used))
Anna Bridge 160:5571c4ff569f 213 #else
Anna Bridge 160:5571c4ff569f 214 #define __USED _Pragma("__root")
Anna Bridge 160:5571c4ff569f 215 #endif
Anna Bridge 160:5571c4ff569f 216 #endif
Anna Bridge 160:5571c4ff569f 217
Anna Bridge 160:5571c4ff569f 218 #ifndef __WEAK
Anna Bridge 160:5571c4ff569f 219 #if __ICCARM_V8
Anna Bridge 160:5571c4ff569f 220 #define __WEAK __attribute__((weak))
Anna Bridge 160:5571c4ff569f 221 #else
Anna Bridge 160:5571c4ff569f 222 #define __WEAK _Pragma("__weak")
Anna Bridge 160:5571c4ff569f 223 #endif
Anna Bridge 160:5571c4ff569f 224 #endif
Anna Bridge 160:5571c4ff569f 225
Anna Bridge 160:5571c4ff569f 226
Anna Bridge 160:5571c4ff569f 227 #ifndef __ICCARM_INTRINSICS_VERSION__
Anna Bridge 160:5571c4ff569f 228 #define __ICCARM_INTRINSICS_VERSION__ 0
Anna Bridge 160:5571c4ff569f 229 #endif
Anna Bridge 160:5571c4ff569f 230
Anna Bridge 160:5571c4ff569f 231 #if __ICCARM_INTRINSICS_VERSION__ == 2
Anna Bridge 160:5571c4ff569f 232
Anna Bridge 160:5571c4ff569f 233 #if defined(__CLZ)
Anna Bridge 160:5571c4ff569f 234 #undef __CLZ
Anna Bridge 160:5571c4ff569f 235 #endif
Anna Bridge 160:5571c4ff569f 236 #if defined(__REVSH)
Anna Bridge 160:5571c4ff569f 237 #undef __REVSH
Anna Bridge 160:5571c4ff569f 238 #endif
Anna Bridge 160:5571c4ff569f 239 #if defined(__RBIT)
Anna Bridge 160:5571c4ff569f 240 #undef __RBIT
Anna Bridge 160:5571c4ff569f 241 #endif
Anna Bridge 160:5571c4ff569f 242 #if defined(__SSAT)
Anna Bridge 160:5571c4ff569f 243 #undef __SSAT
Anna Bridge 160:5571c4ff569f 244 #endif
Anna Bridge 160:5571c4ff569f 245 #if defined(__USAT)
Anna Bridge 160:5571c4ff569f 246 #undef __USAT
Anna Bridge 160:5571c4ff569f 247 #endif
Anna Bridge 160:5571c4ff569f 248
Anna Bridge 160:5571c4ff569f 249 #include "iccarm_builtin.h"
Anna Bridge 160:5571c4ff569f 250
Anna Bridge 160:5571c4ff569f 251 #define __disable_fault_irq __iar_builtin_disable_fiq
Anna Bridge 160:5571c4ff569f 252 #define __disable_irq __iar_builtin_disable_interrupt
Anna Bridge 160:5571c4ff569f 253 #define __enable_fault_irq __iar_builtin_enable_fiq
Anna Bridge 160:5571c4ff569f 254 #define __enable_irq __iar_builtin_enable_interrupt
Anna Bridge 160:5571c4ff569f 255 #define __arm_rsr __iar_builtin_rsr
Anna Bridge 160:5571c4ff569f 256 #define __arm_wsr __iar_builtin_wsr
Anna Bridge 160:5571c4ff569f 257
Anna Bridge 160:5571c4ff569f 258
Anna Bridge 160:5571c4ff569f 259 #define __get_APSR() (__arm_rsr("APSR"))
Anna Bridge 160:5571c4ff569f 260 #define __get_BASEPRI() (__arm_rsr("BASEPRI"))
Anna Bridge 160:5571c4ff569f 261 #define __get_CONTROL() (__arm_rsr("CONTROL"))
Anna Bridge 160:5571c4ff569f 262 #define __get_FAULTMASK() (__arm_rsr("FAULTMASK"))
Anna Bridge 160:5571c4ff569f 263
Anna Bridge 160:5571c4ff569f 264 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
Anna Bridge 160:5571c4ff569f 265 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
Anna Bridge 160:5571c4ff569f 266 #define __get_FPSCR() (__arm_rsr("FPSCR"))
Anna Bridge 160:5571c4ff569f 267 #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE)))
Anna Bridge 160:5571c4ff569f 268 #else
Anna Bridge 160:5571c4ff569f 269 #define __get_FPSCR() ( 0 )
Anna Bridge 160:5571c4ff569f 270 #define __set_FPSCR(VALUE) ((void)VALUE)
Anna Bridge 160:5571c4ff569f 271 #endif
Anna Bridge 160:5571c4ff569f 272
Anna Bridge 160:5571c4ff569f 273 #define __get_IPSR() (__arm_rsr("IPSR"))
Anna Bridge 160:5571c4ff569f 274 #define __get_MSP() (__arm_rsr("MSP"))
Anna Bridge 160:5571c4ff569f 275 #define __get_MSPLIM() (__arm_rsr("MSPLIM"))
Anna Bridge 160:5571c4ff569f 276 #define __get_PRIMASK() (__arm_rsr("PRIMASK"))
Anna Bridge 160:5571c4ff569f 277 #define __get_PSP() (__arm_rsr("PSP"))
Anna Bridge 160:5571c4ff569f 278 #define __get_PSPLIM() (__arm_rsr("PSPLIM"))
Anna Bridge 160:5571c4ff569f 279 #define __get_xPSR() (__arm_rsr("xPSR"))
Anna Bridge 160:5571c4ff569f 280
Anna Bridge 160:5571c4ff569f 281 #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE)))
Anna Bridge 160:5571c4ff569f 282 #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE)))
Anna Bridge 160:5571c4ff569f 283 #define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE)))
Anna Bridge 160:5571c4ff569f 284 #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE)))
Anna Bridge 160:5571c4ff569f 285 #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE)))
Anna Bridge 160:5571c4ff569f 286 #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE)))
Anna Bridge 160:5571c4ff569f 287 #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE)))
Anna Bridge 160:5571c4ff569f 288 #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE)))
Anna Bridge 160:5571c4ff569f 289 #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE)))
Anna Bridge 160:5571c4ff569f 290
Anna Bridge 160:5571c4ff569f 291 #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS"))
Anna Bridge 160:5571c4ff569f 292 #define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 293 #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS"))
Anna Bridge 160:5571c4ff569f 294 #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 295 #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS"))
Anna Bridge 160:5571c4ff569f 296 #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 297 #define __TZ_get_SP_NS() (__arm_rsr("SP_NS"))
Anna Bridge 160:5571c4ff569f 298 #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 299 #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS"))
Anna Bridge 160:5571c4ff569f 300 #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 301 #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS"))
Anna Bridge 160:5571c4ff569f 302 #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 303 #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS"))
Anna Bridge 160:5571c4ff569f 304 #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 305 #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS"))
Anna Bridge 160:5571c4ff569f 306 #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 307 #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS"))
Anna Bridge 160:5571c4ff569f 308 #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE)))
Anna Bridge 160:5571c4ff569f 309
Anna Bridge 160:5571c4ff569f 310 #define __NOP __iar_builtin_no_operation
Anna Bridge 160:5571c4ff569f 311
Anna Bridge 160:5571c4ff569f 312 __IAR_FT uint8_t __CLZ(uint32_t val) {
Anna Bridge 160:5571c4ff569f 313 return __iar_builtin_CLZ(val);
Anna Bridge 160:5571c4ff569f 314 }
Anna Bridge 160:5571c4ff569f 315
Anna Bridge 160:5571c4ff569f 316 #define __CLREX __iar_builtin_CLREX
Anna Bridge 160:5571c4ff569f 317
Anna Bridge 160:5571c4ff569f 318 #define __DMB __iar_builtin_DMB
Anna Bridge 160:5571c4ff569f 319 #define __DSB __iar_builtin_DSB
Anna Bridge 160:5571c4ff569f 320 #define __ISB __iar_builtin_ISB
Anna Bridge 160:5571c4ff569f 321
Anna Bridge 160:5571c4ff569f 322 #define __LDREXB __iar_builtin_LDREXB
Anna Bridge 160:5571c4ff569f 323 #define __LDREXH __iar_builtin_LDREXH
Anna Bridge 160:5571c4ff569f 324 #define __LDREXW __iar_builtin_LDREX
Anna Bridge 160:5571c4ff569f 325
Anna Bridge 160:5571c4ff569f 326 #define __RBIT __iar_builtin_RBIT
Anna Bridge 160:5571c4ff569f 327 #define __REV __iar_builtin_REV
Anna Bridge 160:5571c4ff569f 328 #define __REV16 __iar_builtin_REV16
Anna Bridge 160:5571c4ff569f 329
Anna Bridge 160:5571c4ff569f 330 __IAR_FT int32_t __REVSH(int32_t val) {
Anna Bridge 160:5571c4ff569f 331 return __iar_builtin_REVSH((int16_t)val);
Anna Bridge 160:5571c4ff569f 332 }
Anna Bridge 160:5571c4ff569f 333
Anna Bridge 160:5571c4ff569f 334 #define __ROR __iar_builtin_ROR
Anna Bridge 160:5571c4ff569f 335 #define __RRX __iar_builtin_RRX
Anna Bridge 160:5571c4ff569f 336
Anna Bridge 160:5571c4ff569f 337 #define __SEV __iar_builtin_SEV
Anna Bridge 160:5571c4ff569f 338
Anna Bridge 160:5571c4ff569f 339 #if !__IAR_M0_FAMILY
Anna Bridge 160:5571c4ff569f 340 #define __SSAT __iar_builtin_SSAT
Anna Bridge 160:5571c4ff569f 341 #endif
Anna Bridge 160:5571c4ff569f 342
Anna Bridge 160:5571c4ff569f 343 #define __STREXB __iar_builtin_STREXB
Anna Bridge 160:5571c4ff569f 344 #define __STREXH __iar_builtin_STREXH
Anna Bridge 160:5571c4ff569f 345 #define __STREXW __iar_builtin_STREX
Anna Bridge 160:5571c4ff569f 346
Anna Bridge 160:5571c4ff569f 347 #if !__IAR_M0_FAMILY
Anna Bridge 160:5571c4ff569f 348 #define __USAT __iar_builtin_USAT
Anna Bridge 160:5571c4ff569f 349 #endif
Anna Bridge 160:5571c4ff569f 350
Anna Bridge 160:5571c4ff569f 351 #define __WFE __iar_builtin_WFE
Anna Bridge 160:5571c4ff569f 352 #define __WFI __iar_builtin_WFI
Anna Bridge 160:5571c4ff569f 353
Anna Bridge 160:5571c4ff569f 354 #if __ARM_MEDIA__
Anna Bridge 160:5571c4ff569f 355 #define __SADD8 __iar_builtin_SADD8
Anna Bridge 160:5571c4ff569f 356 #define __QADD8 __iar_builtin_QADD8
Anna Bridge 160:5571c4ff569f 357 #define __SHADD8 __iar_builtin_SHADD8
Anna Bridge 160:5571c4ff569f 358 #define __UADD8 __iar_builtin_UADD8
Anna Bridge 160:5571c4ff569f 359 #define __UQADD8 __iar_builtin_UQADD8
Anna Bridge 160:5571c4ff569f 360 #define __UHADD8 __iar_builtin_UHADD8
Anna Bridge 160:5571c4ff569f 361 #define __SSUB8 __iar_builtin_SSUB8
Anna Bridge 160:5571c4ff569f 362 #define __QSUB8 __iar_builtin_QSUB8
Anna Bridge 160:5571c4ff569f 363 #define __SHSUB8 __iar_builtin_SHSUB8
Anna Bridge 160:5571c4ff569f 364 #define __USUB8 __iar_builtin_USUB8
Anna Bridge 160:5571c4ff569f 365 #define __UQSUB8 __iar_builtin_UQSUB8
Anna Bridge 160:5571c4ff569f 366 #define __UHSUB8 __iar_builtin_UHSUB8
Anna Bridge 160:5571c4ff569f 367 #define __SADD16 __iar_builtin_SADD16
Anna Bridge 160:5571c4ff569f 368 #define __QADD16 __iar_builtin_QADD16
Anna Bridge 160:5571c4ff569f 369 #define __SHADD16 __iar_builtin_SHADD16
Anna Bridge 160:5571c4ff569f 370 #define __UADD16 __iar_builtin_UADD16
Anna Bridge 160:5571c4ff569f 371 #define __UQADD16 __iar_builtin_UQADD16
Anna Bridge 160:5571c4ff569f 372 #define __UHADD16 __iar_builtin_UHADD16
Anna Bridge 160:5571c4ff569f 373 #define __SSUB16 __iar_builtin_SSUB16
Anna Bridge 160:5571c4ff569f 374 #define __QSUB16 __iar_builtin_QSUB16
Anna Bridge 160:5571c4ff569f 375 #define __SHSUB16 __iar_builtin_SHSUB16
Anna Bridge 160:5571c4ff569f 376 #define __USUB16 __iar_builtin_USUB16
Anna Bridge 160:5571c4ff569f 377 #define __UQSUB16 __iar_builtin_UQSUB16
Anna Bridge 160:5571c4ff569f 378 #define __UHSUB16 __iar_builtin_UHSUB16
Anna Bridge 160:5571c4ff569f 379 #define __SASX __iar_builtin_SASX
Anna Bridge 160:5571c4ff569f 380 #define __QASX __iar_builtin_QASX
Anna Bridge 160:5571c4ff569f 381 #define __SHASX __iar_builtin_SHASX
Anna Bridge 160:5571c4ff569f 382 #define __UASX __iar_builtin_UASX
Anna Bridge 160:5571c4ff569f 383 #define __UQASX __iar_builtin_UQASX
Anna Bridge 160:5571c4ff569f 384 #define __UHASX __iar_builtin_UHASX
Anna Bridge 160:5571c4ff569f 385 #define __SSAX __iar_builtin_SSAX
Anna Bridge 160:5571c4ff569f 386 #define __QSAX __iar_builtin_QSAX
Anna Bridge 160:5571c4ff569f 387 #define __SHSAX __iar_builtin_SHSAX
Anna Bridge 160:5571c4ff569f 388 #define __USAX __iar_builtin_USAX
Anna Bridge 160:5571c4ff569f 389 #define __UQSAX __iar_builtin_UQSAX
Anna Bridge 160:5571c4ff569f 390 #define __UHSAX __iar_builtin_UHSAX
Anna Bridge 160:5571c4ff569f 391 #define __USAD8 __iar_builtin_USAD8
Anna Bridge 160:5571c4ff569f 392 #define __USADA8 __iar_builtin_USADA8
Anna Bridge 160:5571c4ff569f 393 #define __SSAT16 __iar_builtin_SSAT16
Anna Bridge 160:5571c4ff569f 394 #define __USAT16 __iar_builtin_USAT16
Anna Bridge 160:5571c4ff569f 395 #define __UXTB16 __iar_builtin_UXTB16
Anna Bridge 160:5571c4ff569f 396 #define __UXTAB16 __iar_builtin_UXTAB16
Anna Bridge 160:5571c4ff569f 397 #define __SXTB16 __iar_builtin_SXTB16
Anna Bridge 160:5571c4ff569f 398 #define __SXTAB16 __iar_builtin_SXTAB16
Anna Bridge 160:5571c4ff569f 399 #define __SMUAD __iar_builtin_SMUAD
Anna Bridge 160:5571c4ff569f 400 #define __SMUADX __iar_builtin_SMUADX
Anna Bridge 160:5571c4ff569f 401 #define __SMMLA __iar_builtin_SMMLA
Anna Bridge 160:5571c4ff569f 402 #define __SMLAD __iar_builtin_SMLAD
Anna Bridge 160:5571c4ff569f 403 #define __SMLADX __iar_builtin_SMLADX
Anna Bridge 160:5571c4ff569f 404 #define __SMLALD __iar_builtin_SMLALD
Anna Bridge 160:5571c4ff569f 405 #define __SMLALDX __iar_builtin_SMLALDX
Anna Bridge 160:5571c4ff569f 406 #define __SMUSD __iar_builtin_SMUSD
Anna Bridge 160:5571c4ff569f 407 #define __SMUSDX __iar_builtin_SMUSDX
Anna Bridge 160:5571c4ff569f 408 #define __SMLSD __iar_builtin_SMLSD
Anna Bridge 160:5571c4ff569f 409 #define __SMLSDX __iar_builtin_SMLSDX
Anna Bridge 160:5571c4ff569f 410 #define __SMLSLD __iar_builtin_SMLSLD
Anna Bridge 160:5571c4ff569f 411 #define __SMLSLDX __iar_builtin_SMLSLDX
Anna Bridge 160:5571c4ff569f 412 #define __SEL __iar_builtin_SEL
Anna Bridge 160:5571c4ff569f 413 #define __QADD __iar_builtin_QADD
Anna Bridge 160:5571c4ff569f 414 #define __QSUB __iar_builtin_QSUB
Anna Bridge 160:5571c4ff569f 415 #define __PKHBT __iar_builtin_PKHBT
Anna Bridge 160:5571c4ff569f 416 #define __PKHTB __iar_builtin_PKHTB
Anna Bridge 160:5571c4ff569f 417 #endif
Anna Bridge 160:5571c4ff569f 418
Anna Bridge 160:5571c4ff569f 419 #else /* __ICCARM_INTRINSICS_VERSION__ == 2 */
Anna Bridge 160:5571c4ff569f 420
Anna Bridge 160:5571c4ff569f 421 #if __IAR_M0_FAMILY
Anna Bridge 160:5571c4ff569f 422 /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
Anna Bridge 160:5571c4ff569f 423 #define __CLZ __cmsis_iar_clz_not_active
Anna Bridge 160:5571c4ff569f 424 #define __SSAT __cmsis_iar_ssat_not_active
Anna Bridge 160:5571c4ff569f 425 #define __USAT __cmsis_iar_usat_not_active
Anna Bridge 160:5571c4ff569f 426 #define __RBIT __cmsis_iar_rbit_not_active
Anna Bridge 160:5571c4ff569f 427 #define __get_APSR __cmsis_iar_get_APSR_not_active
Anna Bridge 160:5571c4ff569f 428 #endif
Anna Bridge 160:5571c4ff569f 429
Anna Bridge 160:5571c4ff569f 430
Anna Bridge 160:5571c4ff569f 431 #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
Anna Bridge 160:5571c4ff569f 432 (defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
Anna Bridge 160:5571c4ff569f 433 #define __get_FPSCR __cmsis_iar_get_FPSR_not_active
Anna Bridge 160:5571c4ff569f 434 #define __set_FPSCR __cmsis_iar_set_FPSR_not_active
Anna Bridge 160:5571c4ff569f 435 #endif
Anna Bridge 160:5571c4ff569f 436
Anna Bridge 160:5571c4ff569f 437 #include <intrinsics.h>
Anna Bridge 160:5571c4ff569f 438
Anna Bridge 160:5571c4ff569f 439 #if __IAR_M0_FAMILY
Anna Bridge 160:5571c4ff569f 440 /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
Anna Bridge 160:5571c4ff569f 441 #undef __CLZ
Anna Bridge 160:5571c4ff569f 442 #undef __SSAT
Anna Bridge 160:5571c4ff569f 443 #undef __USAT
Anna Bridge 160:5571c4ff569f 444 #undef __RBIT
Anna Bridge 160:5571c4ff569f 445 #undef __get_APSR
Anna Bridge 160:5571c4ff569f 446
Anna Bridge 160:5571c4ff569f 447 __STATIC_INLINE uint8_t __CLZ(uint32_t data) {
Anna Bridge 160:5571c4ff569f 448 if (data == 0u) { return 32u; }
Anna Bridge 160:5571c4ff569f 449
Anna Bridge 160:5571c4ff569f 450 uint32_t count = 0;
Anna Bridge 160:5571c4ff569f 451 uint32_t mask = 0x80000000;
Anna Bridge 160:5571c4ff569f 452
Anna Bridge 160:5571c4ff569f 453 while ((data & mask) == 0)
Anna Bridge 160:5571c4ff569f 454 {
Anna Bridge 160:5571c4ff569f 455 count += 1u;
Anna Bridge 160:5571c4ff569f 456 mask = mask >> 1u;
Anna Bridge 160:5571c4ff569f 457 }
Anna Bridge 160:5571c4ff569f 458 return (count);
Anna Bridge 160:5571c4ff569f 459 }
Anna Bridge 160:5571c4ff569f 460
Anna Bridge 160:5571c4ff569f 461 __STATIC_INLINE uint32_t __RBIT(uint32_t v) {
Anna Bridge 160:5571c4ff569f 462 uint8_t sc = 31;
Anna Bridge 160:5571c4ff569f 463 uint32_t r = v;
Anna Bridge 160:5571c4ff569f 464 for (v >>= 1U; v; v >>= 1U)
Anna Bridge 160:5571c4ff569f 465 {
Anna Bridge 160:5571c4ff569f 466 r <<= 1U;
Anna Bridge 160:5571c4ff569f 467 r |= v & 1U;
Anna Bridge 160:5571c4ff569f 468 sc--;
Anna Bridge 160:5571c4ff569f 469 }
Anna Bridge 160:5571c4ff569f 470 return (r << sc);
Anna Bridge 160:5571c4ff569f 471 }
Anna Bridge 160:5571c4ff569f 472
Anna Bridge 160:5571c4ff569f 473 __STATIC_INLINE uint32_t __get_APSR(void) {
Anna Bridge 160:5571c4ff569f 474 uint32_t res;
Anna Bridge 160:5571c4ff569f 475 __asm("MRS %0,APSR" : "=r" (res));
Anna Bridge 160:5571c4ff569f 476 return res;
Anna Bridge 160:5571c4ff569f 477 }
Anna Bridge 160:5571c4ff569f 478
Anna Bridge 160:5571c4ff569f 479 #endif
Anna Bridge 160:5571c4ff569f 480
Anna Bridge 160:5571c4ff569f 481 #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
Anna Bridge 160:5571c4ff569f 482 (defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
Anna Bridge 160:5571c4ff569f 483 #undef __get_FPSCR
Anna Bridge 160:5571c4ff569f 484 #undef __set_FPSCR
Anna Bridge 160:5571c4ff569f 485 #define __get_FPSCR() (0)
Anna Bridge 160:5571c4ff569f 486 #define __set_FPSCR(VALUE) ((void)VALUE)
Anna Bridge 160:5571c4ff569f 487 #endif
Anna Bridge 160:5571c4ff569f 488
Anna Bridge 160:5571c4ff569f 489 #pragma diag_suppress=Pe940
Anna Bridge 160:5571c4ff569f 490 #pragma diag_suppress=Pe177
Anna Bridge 160:5571c4ff569f 491
Anna Bridge 160:5571c4ff569f 492 #define __enable_irq __enable_interrupt
Anna Bridge 160:5571c4ff569f 493 #define __disable_irq __disable_interrupt
Anna Bridge 160:5571c4ff569f 494 #define __NOP __no_operation
Anna Bridge 160:5571c4ff569f 495
Anna Bridge 160:5571c4ff569f 496 #define __get_xPSR __get_PSR
Anna Bridge 160:5571c4ff569f 497
Anna Bridge 160:5571c4ff569f 498 #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0)
Anna Bridge 160:5571c4ff569f 499
Anna Bridge 160:5571c4ff569f 500 __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) {
Anna Bridge 160:5571c4ff569f 501 return __LDREX((unsigned long *)ptr);
Anna Bridge 160:5571c4ff569f 502 }
Anna Bridge 160:5571c4ff569f 503
Anna Bridge 160:5571c4ff569f 504 __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) {
Anna Bridge 160:5571c4ff569f 505 return __STREX(value, (unsigned long *)ptr);
Anna Bridge 160:5571c4ff569f 506 }
Anna Bridge 160:5571c4ff569f 507 #endif
Anna Bridge 160:5571c4ff569f 508
Anna Bridge 160:5571c4ff569f 509
Anna Bridge 160:5571c4ff569f 510 /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
Anna Bridge 160:5571c4ff569f 511 #if (__CORTEX_M >= 0x03)
Anna Bridge 160:5571c4ff569f 512
Anna Bridge 160:5571c4ff569f 513 __IAR_FT uint32_t __RRX(uint32_t value) {
Anna Bridge 160:5571c4ff569f 514 uint32_t result;
Anna Bridge 160:5571c4ff569f 515 __ASM("RRX %0, %1" : "=r"(result) : "r" (value) : "cc");
Anna Bridge 160:5571c4ff569f 516 return(result);
Anna Bridge 160:5571c4ff569f 517 }
Anna Bridge 160:5571c4ff569f 518
Anna Bridge 160:5571c4ff569f 519 __IAR_FT void __set_BASEPRI_MAX(uint32_t value) {
Anna Bridge 160:5571c4ff569f 520 __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value));
Anna Bridge 160:5571c4ff569f 521 }
Anna Bridge 160:5571c4ff569f 522
Anna Bridge 160:5571c4ff569f 523
Anna Bridge 160:5571c4ff569f 524 #define __enable_fault_irq __enable_fiq
Anna Bridge 160:5571c4ff569f 525 #define __disable_fault_irq __disable_fiq
Anna Bridge 160:5571c4ff569f 526
Anna Bridge 160:5571c4ff569f 527
Anna Bridge 160:5571c4ff569f 528 #endif /* (__CORTEX_M >= 0x03) */
Anna Bridge 160:5571c4ff569f 529
Anna Bridge 160:5571c4ff569f 530 __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) {
Anna Bridge 160:5571c4ff569f 531 return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2));
Anna Bridge 160:5571c4ff569f 532 }
Anna Bridge 160:5571c4ff569f 533
Anna Bridge 160:5571c4ff569f 534 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
Anna Bridge 160:5571c4ff569f 535 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
Anna Bridge 160:5571c4ff569f 536
Anna Bridge 160:5571c4ff569f 537 __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) {
Anna Bridge 160:5571c4ff569f 538 uint32_t res;
Anna Bridge 160:5571c4ff569f 539 __asm volatile("MRS %0,CONTROL_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 540 return res;
Anna Bridge 160:5571c4ff569f 541 }
Anna Bridge 160:5571c4ff569f 542
Anna Bridge 160:5571c4ff569f 543 __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 544 __asm volatile("MSR CONTROL_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 545 }
Anna Bridge 160:5571c4ff569f 546
Anna Bridge 160:5571c4ff569f 547 __IAR_FT uint32_t __TZ_get_PSP_NS(void) {
Anna Bridge 160:5571c4ff569f 548 uint32_t res;
Anna Bridge 160:5571c4ff569f 549 __asm volatile("MRS %0,PSP_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 550 return res;
Anna Bridge 160:5571c4ff569f 551 }
Anna Bridge 160:5571c4ff569f 552
Anna Bridge 160:5571c4ff569f 553 __IAR_FT void __TZ_set_PSP_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 554 __asm volatile("MSR PSP_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 555 }
Anna Bridge 160:5571c4ff569f 556
Anna Bridge 160:5571c4ff569f 557 __IAR_FT uint32_t __TZ_get_MSP_NS(void) {
Anna Bridge 160:5571c4ff569f 558 uint32_t res;
Anna Bridge 160:5571c4ff569f 559 __asm volatile("MRS %0,MSP_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 560 return res;
Anna Bridge 160:5571c4ff569f 561 }
Anna Bridge 160:5571c4ff569f 562
Anna Bridge 160:5571c4ff569f 563 __IAR_FT void __TZ_set_MSP_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 564 __asm volatile("MSR MSP_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 565 }
Anna Bridge 160:5571c4ff569f 566
Anna Bridge 160:5571c4ff569f 567 __IAR_FT uint32_t __TZ_get_SP_NS(void) {
Anna Bridge 160:5571c4ff569f 568 uint32_t res;
Anna Bridge 160:5571c4ff569f 569 __asm volatile("MRS %0,SP_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 570 return res;
Anna Bridge 160:5571c4ff569f 571 }
Anna Bridge 160:5571c4ff569f 572 __IAR_FT void __TZ_set_SP_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 573 __asm volatile("MSR SP_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 574 }
Anna Bridge 160:5571c4ff569f 575
Anna Bridge 160:5571c4ff569f 576 __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) {
Anna Bridge 160:5571c4ff569f 577 uint32_t res;
Anna Bridge 160:5571c4ff569f 578 __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 579 return res;
Anna Bridge 160:5571c4ff569f 580 }
Anna Bridge 160:5571c4ff569f 581
Anna Bridge 160:5571c4ff569f 582 __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 583 __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 584 }
Anna Bridge 160:5571c4ff569f 585
Anna Bridge 160:5571c4ff569f 586 __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) {
Anna Bridge 160:5571c4ff569f 587 uint32_t res;
Anna Bridge 160:5571c4ff569f 588 __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 589 return res;
Anna Bridge 160:5571c4ff569f 590 }
Anna Bridge 160:5571c4ff569f 591
Anna Bridge 160:5571c4ff569f 592 __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 593 __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 594 }
Anna Bridge 160:5571c4ff569f 595
Anna Bridge 160:5571c4ff569f 596 __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) {
Anna Bridge 160:5571c4ff569f 597 uint32_t res;
Anna Bridge 160:5571c4ff569f 598 __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 599 return res;
Anna Bridge 160:5571c4ff569f 600 }
Anna Bridge 160:5571c4ff569f 601
Anna Bridge 160:5571c4ff569f 602 __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 603 __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 604 }
Anna Bridge 160:5571c4ff569f 605
Anna Bridge 160:5571c4ff569f 606 __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) {
Anna Bridge 160:5571c4ff569f 607 uint32_t res;
Anna Bridge 160:5571c4ff569f 608 __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 609 return res;
Anna Bridge 160:5571c4ff569f 610 }
Anna Bridge 160:5571c4ff569f 611 __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 612 __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 613 }
Anna Bridge 160:5571c4ff569f 614
Anna Bridge 160:5571c4ff569f 615 __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) {
Anna Bridge 160:5571c4ff569f 616 uint32_t res;
Anna Bridge 160:5571c4ff569f 617 __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res));
Anna Bridge 160:5571c4ff569f 618 return res;
Anna Bridge 160:5571c4ff569f 619 }
Anna Bridge 160:5571c4ff569f 620
Anna Bridge 160:5571c4ff569f 621 __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) {
Anna Bridge 160:5571c4ff569f 622 __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value));
Anna Bridge 160:5571c4ff569f 623 }
Anna Bridge 160:5571c4ff569f 624
Anna Bridge 160:5571c4ff569f 625 #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
Anna Bridge 160:5571c4ff569f 626
Anna Bridge 160:5571c4ff569f 627 #endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */
Anna Bridge 160:5571c4ff569f 628
Anna Bridge 160:5571c4ff569f 629 #define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value))
Anna Bridge 160:5571c4ff569f 630
Anna Bridge 160:5571c4ff569f 631 #if __IAR_M0_FAMILY
Anna Bridge 160:5571c4ff569f 632 __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) {
Anna Bridge 160:5571c4ff569f 633 if ((sat >= 1U) && (sat <= 32U)) {
Anna Bridge 160:5571c4ff569f 634 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
Anna Bridge 160:5571c4ff569f 635 const int32_t min = -1 - max ;
Anna Bridge 160:5571c4ff569f 636 if (val > max) {
Anna Bridge 160:5571c4ff569f 637 return max;
Anna Bridge 160:5571c4ff569f 638 } else if (val < min) {
Anna Bridge 160:5571c4ff569f 639 return min;
Anna Bridge 160:5571c4ff569f 640 }
Anna Bridge 160:5571c4ff569f 641 }
Anna Bridge 160:5571c4ff569f 642 return val;
Anna Bridge 160:5571c4ff569f 643 }
Anna Bridge 160:5571c4ff569f 644
Anna Bridge 160:5571c4ff569f 645 __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) {
Anna Bridge 160:5571c4ff569f 646 if (sat <= 31U) {
Anna Bridge 160:5571c4ff569f 647 const uint32_t max = ((1U << sat) - 1U);
Anna Bridge 160:5571c4ff569f 648 if (val > (int32_t)max) {
Anna Bridge 160:5571c4ff569f 649 return max;
Anna Bridge 160:5571c4ff569f 650 } else if (val < 0) {
Anna Bridge 160:5571c4ff569f 651 return 0U;
Anna Bridge 160:5571c4ff569f 652 }
Anna Bridge 160:5571c4ff569f 653 }
Anna Bridge 160:5571c4ff569f 654 return (uint32_t)val;
Anna Bridge 160:5571c4ff569f 655 }
Anna Bridge 160:5571c4ff569f 656 #endif
Anna Bridge 160:5571c4ff569f 657
Anna Bridge 160:5571c4ff569f 658 #if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
Anna Bridge 160:5571c4ff569f 659
Anna Bridge 160:5571c4ff569f 660 __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) {
Anna Bridge 160:5571c4ff569f 661 uint32_t res;
Anna Bridge 160:5571c4ff569f 662 __ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
Anna Bridge 160:5571c4ff569f 663 return ((uint8_t)res);
Anna Bridge 160:5571c4ff569f 664 }
Anna Bridge 160:5571c4ff569f 665
Anna Bridge 160:5571c4ff569f 666 __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) {
Anna Bridge 160:5571c4ff569f 667 uint32_t res;
Anna Bridge 160:5571c4ff569f 668 __ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
Anna Bridge 160:5571c4ff569f 669 return ((uint16_t)res);
Anna Bridge 160:5571c4ff569f 670 }
Anna Bridge 160:5571c4ff569f 671
Anna Bridge 160:5571c4ff569f 672 __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) {
Anna Bridge 160:5571c4ff569f 673 uint32_t res;
Anna Bridge 160:5571c4ff569f 674 __ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
Anna Bridge 160:5571c4ff569f 675 return res;
Anna Bridge 160:5571c4ff569f 676 }
Anna Bridge 160:5571c4ff569f 677
Anna Bridge 160:5571c4ff569f 678 __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) {
Anna Bridge 160:5571c4ff569f 679 __ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
Anna Bridge 160:5571c4ff569f 680 }
Anna Bridge 160:5571c4ff569f 681
Anna Bridge 160:5571c4ff569f 682 __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) {
Anna Bridge 160:5571c4ff569f 683 __ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
Anna Bridge 160:5571c4ff569f 684 }
Anna Bridge 160:5571c4ff569f 685
Anna Bridge 160:5571c4ff569f 686 __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) {
Anna Bridge 160:5571c4ff569f 687 __ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 688 }
Anna Bridge 160:5571c4ff569f 689
Anna Bridge 160:5571c4ff569f 690 #endif /* (__CORTEX_M >= 0x03) */
Anna Bridge 160:5571c4ff569f 691
Anna Bridge 160:5571c4ff569f 692 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
Anna Bridge 160:5571c4ff569f 693 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
Anna Bridge 160:5571c4ff569f 694
Anna Bridge 160:5571c4ff569f 695
Anna Bridge 160:5571c4ff569f 696 __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) {
Anna Bridge 160:5571c4ff569f 697 uint32_t res;
Anna Bridge 160:5571c4ff569f 698 __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
Anna Bridge 160:5571c4ff569f 699 return ((uint8_t)res);
Anna Bridge 160:5571c4ff569f 700 }
Anna Bridge 160:5571c4ff569f 701
Anna Bridge 160:5571c4ff569f 702 __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) {
Anna Bridge 160:5571c4ff569f 703 uint32_t res;
Anna Bridge 160:5571c4ff569f 704 __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
Anna Bridge 160:5571c4ff569f 705 return ((uint16_t)res);
Anna Bridge 160:5571c4ff569f 706 }
Anna Bridge 160:5571c4ff569f 707
Anna Bridge 160:5571c4ff569f 708 __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) {
Anna Bridge 160:5571c4ff569f 709 uint32_t res;
Anna Bridge 160:5571c4ff569f 710 __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
Anna Bridge 160:5571c4ff569f 711 return res;
Anna Bridge 160:5571c4ff569f 712 }
Anna Bridge 160:5571c4ff569f 713
Anna Bridge 160:5571c4ff569f 714 __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) {
Anna Bridge 160:5571c4ff569f 715 __ASM volatile ("STLB %1, [%0]" :: "r" (*ptr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 716 }
Anna Bridge 160:5571c4ff569f 717
Anna Bridge 160:5571c4ff569f 718 __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) {
Anna Bridge 160:5571c4ff569f 719 __ASM volatile ("STLH %1, [%0]" :: "r" (*ptr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 720 }
Anna Bridge 160:5571c4ff569f 721
Anna Bridge 160:5571c4ff569f 722 __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) {
Anna Bridge 160:5571c4ff569f 723 __ASM volatile ("STL %1, [%0]" :: "r" (*ptr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 724 }
Anna Bridge 160:5571c4ff569f 725
Anna Bridge 160:5571c4ff569f 726 __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) {
Anna Bridge 160:5571c4ff569f 727 uint32_t res;
Anna Bridge 160:5571c4ff569f 728 __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
Anna Bridge 160:5571c4ff569f 729 return ((uint8_t)res);
Anna Bridge 160:5571c4ff569f 730 }
Anna Bridge 160:5571c4ff569f 731
Anna Bridge 160:5571c4ff569f 732 __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) {
Anna Bridge 160:5571c4ff569f 733 uint32_t res;
Anna Bridge 160:5571c4ff569f 734 __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
Anna Bridge 160:5571c4ff569f 735 return ((uint16_t)res);
Anna Bridge 160:5571c4ff569f 736 }
Anna Bridge 160:5571c4ff569f 737
Anna Bridge 160:5571c4ff569f 738 __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) {
Anna Bridge 160:5571c4ff569f 739 uint32_t res;
Anna Bridge 160:5571c4ff569f 740 __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
Anna Bridge 160:5571c4ff569f 741 return res;
Anna Bridge 160:5571c4ff569f 742 }
Anna Bridge 160:5571c4ff569f 743
Anna Bridge 160:5571c4ff569f 744 __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) {
Anna Bridge 160:5571c4ff569f 745 uint32_t res;
Anna Bridge 160:5571c4ff569f 746 __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 747 return res;
Anna Bridge 160:5571c4ff569f 748 }
Anna Bridge 160:5571c4ff569f 749
Anna Bridge 160:5571c4ff569f 750 __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) {
Anna Bridge 160:5571c4ff569f 751 uint32_t res;
Anna Bridge 160:5571c4ff569f 752 __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 753 return res;
Anna Bridge 160:5571c4ff569f 754 }
Anna Bridge 160:5571c4ff569f 755
Anna Bridge 160:5571c4ff569f 756 __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) {
Anna Bridge 160:5571c4ff569f 757 uint32_t res;
Anna Bridge 160:5571c4ff569f 758 __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory");
Anna Bridge 160:5571c4ff569f 759 return res;
Anna Bridge 160:5571c4ff569f 760 }
Anna Bridge 160:5571c4ff569f 761
Anna Bridge 160:5571c4ff569f 762 #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
Anna Bridge 160:5571c4ff569f 763
Anna Bridge 160:5571c4ff569f 764 #undef __IAR_FT
Anna Bridge 160:5571c4ff569f 765 #undef __IAR_M0_FAMILY
Anna Bridge 160:5571c4ff569f 766 #undef __ICCARM_V8
Anna Bridge 160:5571c4ff569f 767
Anna Bridge 160:5571c4ff569f 768 #pragma diag_default=Pe940
Anna Bridge 160:5571c4ff569f 769 #pragma diag_default=Pe177
Anna Bridge 160:5571c4ff569f 770
Anna Bridge 160:5571c4ff569f 771 #endif /* __CMSIS_ICCARM_H__ */