1*2fd737d3SMatthias Ringwald /**************************************************************************//** 2*2fd737d3SMatthias Ringwald * @file cmsis_compiler.h 3*2fd737d3SMatthias Ringwald * @brief CMSIS compiler generic header file 4*2fd737d3SMatthias Ringwald * @version V5.0.4 5*2fd737d3SMatthias Ringwald * @date 10. January 2018 6*2fd737d3SMatthias Ringwald ******************************************************************************/ 7*2fd737d3SMatthias Ringwald /* 8*2fd737d3SMatthias Ringwald * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 9*2fd737d3SMatthias Ringwald * 10*2fd737d3SMatthias Ringwald * SPDX-License-Identifier: Apache-2.0 11*2fd737d3SMatthias Ringwald * 12*2fd737d3SMatthias Ringwald * Licensed under the Apache License, Version 2.0 (the License); you may 13*2fd737d3SMatthias Ringwald * not use this file except in compliance with the License. 14*2fd737d3SMatthias Ringwald * You may obtain a copy of the License at 15*2fd737d3SMatthias Ringwald * 16*2fd737d3SMatthias Ringwald * www.apache.org/licenses/LICENSE-2.0 17*2fd737d3SMatthias Ringwald * 18*2fd737d3SMatthias Ringwald * Unless required by applicable law or agreed to in writing, software 19*2fd737d3SMatthias Ringwald * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20*2fd737d3SMatthias Ringwald * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21*2fd737d3SMatthias Ringwald * See the License for the specific language governing permissions and 22*2fd737d3SMatthias Ringwald * limitations under the License. 23*2fd737d3SMatthias Ringwald */ 24*2fd737d3SMatthias Ringwald 25*2fd737d3SMatthias Ringwald #ifndef __CMSIS_COMPILER_H 26*2fd737d3SMatthias Ringwald #define __CMSIS_COMPILER_H 27*2fd737d3SMatthias Ringwald 28*2fd737d3SMatthias Ringwald #include <stdint.h> 29*2fd737d3SMatthias Ringwald 30*2fd737d3SMatthias Ringwald /* 31*2fd737d3SMatthias Ringwald * Arm Compiler 4/5 32*2fd737d3SMatthias Ringwald */ 33*2fd737d3SMatthias Ringwald #if defined ( __CC_ARM ) 34*2fd737d3SMatthias Ringwald #include "cmsis_armcc.h" 35*2fd737d3SMatthias Ringwald 36*2fd737d3SMatthias Ringwald 37*2fd737d3SMatthias Ringwald /* 38*2fd737d3SMatthias Ringwald * Arm Compiler 6 (armclang) 39*2fd737d3SMatthias Ringwald */ 40*2fd737d3SMatthias Ringwald #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41*2fd737d3SMatthias Ringwald #include "cmsis_armclang.h" 42*2fd737d3SMatthias Ringwald 43*2fd737d3SMatthias Ringwald 44*2fd737d3SMatthias Ringwald /* 45*2fd737d3SMatthias Ringwald * GNU Compiler 46*2fd737d3SMatthias Ringwald */ 47*2fd737d3SMatthias Ringwald #elif defined ( __GNUC__ ) 48*2fd737d3SMatthias Ringwald #include "cmsis_gcc.h" 49*2fd737d3SMatthias Ringwald 50*2fd737d3SMatthias Ringwald 51*2fd737d3SMatthias Ringwald /* 52*2fd737d3SMatthias Ringwald * IAR Compiler 53*2fd737d3SMatthias Ringwald */ 54*2fd737d3SMatthias Ringwald #elif defined ( __ICCARM__ ) 55*2fd737d3SMatthias Ringwald #include <cmsis_iccarm.h> 56*2fd737d3SMatthias Ringwald 57*2fd737d3SMatthias Ringwald 58*2fd737d3SMatthias Ringwald /* 59*2fd737d3SMatthias Ringwald * TI Arm Compiler 60*2fd737d3SMatthias Ringwald */ 61*2fd737d3SMatthias Ringwald #elif defined ( __TI_ARM__ ) 62*2fd737d3SMatthias Ringwald #include <cmsis_ccs.h> 63*2fd737d3SMatthias Ringwald 64*2fd737d3SMatthias Ringwald #ifndef __ASM 65*2fd737d3SMatthias Ringwald #define __ASM __asm 66*2fd737d3SMatthias Ringwald #endif 67*2fd737d3SMatthias Ringwald #ifndef __INLINE 68*2fd737d3SMatthias Ringwald #define __INLINE inline 69*2fd737d3SMatthias Ringwald #endif 70*2fd737d3SMatthias Ringwald #ifndef __STATIC_INLINE 71*2fd737d3SMatthias Ringwald #define __STATIC_INLINE static inline 72*2fd737d3SMatthias Ringwald #endif 73*2fd737d3SMatthias Ringwald #ifndef __STATIC_FORCEINLINE 74*2fd737d3SMatthias Ringwald #define __STATIC_FORCEINLINE __STATIC_INLINE 75*2fd737d3SMatthias Ringwald #endif 76*2fd737d3SMatthias Ringwald #ifndef __NO_RETURN 77*2fd737d3SMatthias Ringwald #define __NO_RETURN __attribute__((noreturn)) 78*2fd737d3SMatthias Ringwald #endif 79*2fd737d3SMatthias Ringwald #ifndef __USED 80*2fd737d3SMatthias Ringwald #define __USED __attribute__((used)) 81*2fd737d3SMatthias Ringwald #endif 82*2fd737d3SMatthias Ringwald #ifndef __WEAK 83*2fd737d3SMatthias Ringwald #define __WEAK __attribute__((weak)) 84*2fd737d3SMatthias Ringwald #endif 85*2fd737d3SMatthias Ringwald #ifndef __PACKED 86*2fd737d3SMatthias Ringwald #define __PACKED __attribute__((packed)) 87*2fd737d3SMatthias Ringwald #endif 88*2fd737d3SMatthias Ringwald #ifndef __PACKED_STRUCT 89*2fd737d3SMatthias Ringwald #define __PACKED_STRUCT struct __attribute__((packed)) 90*2fd737d3SMatthias Ringwald #endif 91*2fd737d3SMatthias Ringwald #ifndef __PACKED_UNION 92*2fd737d3SMatthias Ringwald #define __PACKED_UNION union __attribute__((packed)) 93*2fd737d3SMatthias Ringwald #endif 94*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32 /* deprecated */ 95*2fd737d3SMatthias Ringwald struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 96*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 97*2fd737d3SMatthias Ringwald #endif 98*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE 99*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 100*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 101*2fd737d3SMatthias Ringwald #endif 102*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ 103*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 104*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 105*2fd737d3SMatthias Ringwald #endif 106*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE 107*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 108*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 109*2fd737d3SMatthias Ringwald #endif 110*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ 111*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 112*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 113*2fd737d3SMatthias Ringwald #endif 114*2fd737d3SMatthias Ringwald #ifndef __ALIGNED 115*2fd737d3SMatthias Ringwald #define __ALIGNED(x) __attribute__((aligned(x))) 116*2fd737d3SMatthias Ringwald #endif 117*2fd737d3SMatthias Ringwald #ifndef __RESTRICT 118*2fd737d3SMatthias Ringwald #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 119*2fd737d3SMatthias Ringwald #define __RESTRICT 120*2fd737d3SMatthias Ringwald #endif 121*2fd737d3SMatthias Ringwald 122*2fd737d3SMatthias Ringwald 123*2fd737d3SMatthias Ringwald /* 124*2fd737d3SMatthias Ringwald * TASKING Compiler 125*2fd737d3SMatthias Ringwald */ 126*2fd737d3SMatthias Ringwald #elif defined ( __TASKING__ ) 127*2fd737d3SMatthias Ringwald /* 128*2fd737d3SMatthias Ringwald * The CMSIS functions have been implemented as intrinsics in the compiler. 129*2fd737d3SMatthias Ringwald * Please use "carm -?i" to get an up to date list of all intrinsics, 130*2fd737d3SMatthias Ringwald * Including the CMSIS ones. 131*2fd737d3SMatthias Ringwald */ 132*2fd737d3SMatthias Ringwald 133*2fd737d3SMatthias Ringwald #ifndef __ASM 134*2fd737d3SMatthias Ringwald #define __ASM __asm 135*2fd737d3SMatthias Ringwald #endif 136*2fd737d3SMatthias Ringwald #ifndef __INLINE 137*2fd737d3SMatthias Ringwald #define __INLINE inline 138*2fd737d3SMatthias Ringwald #endif 139*2fd737d3SMatthias Ringwald #ifndef __STATIC_INLINE 140*2fd737d3SMatthias Ringwald #define __STATIC_INLINE static inline 141*2fd737d3SMatthias Ringwald #endif 142*2fd737d3SMatthias Ringwald #ifndef __STATIC_FORCEINLINE 143*2fd737d3SMatthias Ringwald #define __STATIC_FORCEINLINE __STATIC_INLINE 144*2fd737d3SMatthias Ringwald #endif 145*2fd737d3SMatthias Ringwald #ifndef __NO_RETURN 146*2fd737d3SMatthias Ringwald #define __NO_RETURN __attribute__((noreturn)) 147*2fd737d3SMatthias Ringwald #endif 148*2fd737d3SMatthias Ringwald #ifndef __USED 149*2fd737d3SMatthias Ringwald #define __USED __attribute__((used)) 150*2fd737d3SMatthias Ringwald #endif 151*2fd737d3SMatthias Ringwald #ifndef __WEAK 152*2fd737d3SMatthias Ringwald #define __WEAK __attribute__((weak)) 153*2fd737d3SMatthias Ringwald #endif 154*2fd737d3SMatthias Ringwald #ifndef __PACKED 155*2fd737d3SMatthias Ringwald #define __PACKED __packed__ 156*2fd737d3SMatthias Ringwald #endif 157*2fd737d3SMatthias Ringwald #ifndef __PACKED_STRUCT 158*2fd737d3SMatthias Ringwald #define __PACKED_STRUCT struct __packed__ 159*2fd737d3SMatthias Ringwald #endif 160*2fd737d3SMatthias Ringwald #ifndef __PACKED_UNION 161*2fd737d3SMatthias Ringwald #define __PACKED_UNION union __packed__ 162*2fd737d3SMatthias Ringwald #endif 163*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32 /* deprecated */ 164*2fd737d3SMatthias Ringwald struct __packed__ T_UINT32 { uint32_t v; }; 165*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 166*2fd737d3SMatthias Ringwald #endif 167*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE 168*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 169*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 170*2fd737d3SMatthias Ringwald #endif 171*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ 172*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 173*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 174*2fd737d3SMatthias Ringwald #endif 175*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE 176*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 177*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 178*2fd737d3SMatthias Ringwald #endif 179*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ 180*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 181*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 182*2fd737d3SMatthias Ringwald #endif 183*2fd737d3SMatthias Ringwald #ifndef __ALIGNED 184*2fd737d3SMatthias Ringwald #define __ALIGNED(x) __align(x) 185*2fd737d3SMatthias Ringwald #endif 186*2fd737d3SMatthias Ringwald #ifndef __RESTRICT 187*2fd737d3SMatthias Ringwald #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 188*2fd737d3SMatthias Ringwald #define __RESTRICT 189*2fd737d3SMatthias Ringwald #endif 190*2fd737d3SMatthias Ringwald 191*2fd737d3SMatthias Ringwald 192*2fd737d3SMatthias Ringwald /* 193*2fd737d3SMatthias Ringwald * COSMIC Compiler 194*2fd737d3SMatthias Ringwald */ 195*2fd737d3SMatthias Ringwald #elif defined ( __CSMC__ ) 196*2fd737d3SMatthias Ringwald #include <cmsis_csm.h> 197*2fd737d3SMatthias Ringwald 198*2fd737d3SMatthias Ringwald #ifndef __ASM 199*2fd737d3SMatthias Ringwald #define __ASM _asm 200*2fd737d3SMatthias Ringwald #endif 201*2fd737d3SMatthias Ringwald #ifndef __INLINE 202*2fd737d3SMatthias Ringwald #define __INLINE inline 203*2fd737d3SMatthias Ringwald #endif 204*2fd737d3SMatthias Ringwald #ifndef __STATIC_INLINE 205*2fd737d3SMatthias Ringwald #define __STATIC_INLINE static inline 206*2fd737d3SMatthias Ringwald #endif 207*2fd737d3SMatthias Ringwald #ifndef __STATIC_FORCEINLINE 208*2fd737d3SMatthias Ringwald #define __STATIC_FORCEINLINE __STATIC_INLINE 209*2fd737d3SMatthias Ringwald #endif 210*2fd737d3SMatthias Ringwald #ifndef __NO_RETURN 211*2fd737d3SMatthias Ringwald // NO RETURN is automatically detected hence no warning here 212*2fd737d3SMatthias Ringwald #define __NO_RETURN 213*2fd737d3SMatthias Ringwald #endif 214*2fd737d3SMatthias Ringwald #ifndef __USED 215*2fd737d3SMatthias Ringwald #warning No compiler specific solution for __USED. __USED is ignored. 216*2fd737d3SMatthias Ringwald #define __USED 217*2fd737d3SMatthias Ringwald #endif 218*2fd737d3SMatthias Ringwald #ifndef __WEAK 219*2fd737d3SMatthias Ringwald #define __WEAK __weak 220*2fd737d3SMatthias Ringwald #endif 221*2fd737d3SMatthias Ringwald #ifndef __PACKED 222*2fd737d3SMatthias Ringwald #define __PACKED @packed 223*2fd737d3SMatthias Ringwald #endif 224*2fd737d3SMatthias Ringwald #ifndef __PACKED_STRUCT 225*2fd737d3SMatthias Ringwald #define __PACKED_STRUCT @packed struct 226*2fd737d3SMatthias Ringwald #endif 227*2fd737d3SMatthias Ringwald #ifndef __PACKED_UNION 228*2fd737d3SMatthias Ringwald #define __PACKED_UNION @packed union 229*2fd737d3SMatthias Ringwald #endif 230*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32 /* deprecated */ 231*2fd737d3SMatthias Ringwald @packed struct T_UINT32 { uint32_t v; }; 232*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 233*2fd737d3SMatthias Ringwald #endif 234*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE 235*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 236*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 237*2fd737d3SMatthias Ringwald #endif 238*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ 239*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 240*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 241*2fd737d3SMatthias Ringwald #endif 242*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE 243*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 244*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 245*2fd737d3SMatthias Ringwald #endif 246*2fd737d3SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ 247*2fd737d3SMatthias Ringwald __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 248*2fd737d3SMatthias Ringwald #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 249*2fd737d3SMatthias Ringwald #endif 250*2fd737d3SMatthias Ringwald #ifndef __ALIGNED 251*2fd737d3SMatthias Ringwald #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 252*2fd737d3SMatthias Ringwald #define __ALIGNED(x) 253*2fd737d3SMatthias Ringwald #endif 254*2fd737d3SMatthias Ringwald #ifndef __RESTRICT 255*2fd737d3SMatthias Ringwald #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 256*2fd737d3SMatthias Ringwald #define __RESTRICT 257*2fd737d3SMatthias Ringwald #endif 258*2fd737d3SMatthias Ringwald 259*2fd737d3SMatthias Ringwald 260*2fd737d3SMatthias Ringwald #else 261*2fd737d3SMatthias Ringwald #error Unknown compiler. 262*2fd737d3SMatthias Ringwald #endif 263*2fd737d3SMatthias Ringwald 264*2fd737d3SMatthias Ringwald 265*2fd737d3SMatthias Ringwald #endif /* __CMSIS_COMPILER_H */ 266*2fd737d3SMatthias Ringwald 267