00

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ganlikun 0:13413ea9a877 1 /**************************************************************************//**
ganlikun 0:13413ea9a877 2 * @file cmsis_compiler.h
ganlikun 0:13413ea9a877 3 * @brief CMSIS compiler specific macros, functions, instructions
ganlikun 0:13413ea9a877 4 * @version V1.00
ganlikun 0:13413ea9a877 5 * @date 22. Feb 2017
ganlikun 0:13413ea9a877 6 ******************************************************************************/
ganlikun 0:13413ea9a877 7 /*
ganlikun 0:13413ea9a877 8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
ganlikun 0:13413ea9a877 9 *
ganlikun 0:13413ea9a877 10 * SPDX-License-Identifier: Apache-2.0
ganlikun 0:13413ea9a877 11 *
ganlikun 0:13413ea9a877 12 * Licensed under the Apache License, Version 2.0 (the License); you may
ganlikun 0:13413ea9a877 13 * not use this file except in compliance with the License.
ganlikun 0:13413ea9a877 14 * You may obtain a copy of the License at
ganlikun 0:13413ea9a877 15 *
ganlikun 0:13413ea9a877 16 * www.apache.org/licenses/LICENSE-2.0
ganlikun 0:13413ea9a877 17 *
ganlikun 0:13413ea9a877 18 * Unless required by applicable law or agreed to in writing, software
ganlikun 0:13413ea9a877 19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
ganlikun 0:13413ea9a877 20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ganlikun 0:13413ea9a877 21 * See the License for the specific language governing permissions and
ganlikun 0:13413ea9a877 22 * limitations under the License.
ganlikun 0:13413ea9a877 23 */
ganlikun 0:13413ea9a877 24
ganlikun 0:13413ea9a877 25 #ifndef __CMSIS_COMPILER_H
ganlikun 0:13413ea9a877 26 #define __CMSIS_COMPILER_H
ganlikun 0:13413ea9a877 27
ganlikun 0:13413ea9a877 28 #include <stdint.h>
ganlikun 0:13413ea9a877 29
ganlikun 0:13413ea9a877 30 /*
ganlikun 0:13413ea9a877 31 * ARM Compiler 4/5
ganlikun 0:13413ea9a877 32 */
ganlikun 0:13413ea9a877 33 #if defined ( __CC_ARM )
ganlikun 0:13413ea9a877 34 #include "cmsis_armcc.h"
ganlikun 0:13413ea9a877 35
ganlikun 0:13413ea9a877 36
ganlikun 0:13413ea9a877 37 /*
ganlikun 0:13413ea9a877 38 * ARM Compiler 6 (armclang)
ganlikun 0:13413ea9a877 39 */
ganlikun 0:13413ea9a877 40 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
ganlikun 0:13413ea9a877 41 #include "cmsis_armclang.h"
ganlikun 0:13413ea9a877 42
ganlikun 0:13413ea9a877 43
ganlikun 0:13413ea9a877 44 /*
ganlikun 0:13413ea9a877 45 * GNU Compiler
ganlikun 0:13413ea9a877 46 */
ganlikun 0:13413ea9a877 47 #elif defined ( __GNUC__ )
ganlikun 0:13413ea9a877 48 #include "cmsis_gcc.h"
ganlikun 0:13413ea9a877 49
ganlikun 0:13413ea9a877 50
ganlikun 0:13413ea9a877 51 /*
ganlikun 0:13413ea9a877 52 * IAR Compiler
ganlikun 0:13413ea9a877 53 */
ganlikun 0:13413ea9a877 54 #elif defined ( __ICCARM__ )
ganlikun 0:13413ea9a877 55
ganlikun 0:13413ea9a877 56 #ifndef __ASM
ganlikun 0:13413ea9a877 57 #define __ASM __asm
ganlikun 0:13413ea9a877 58 #endif
ganlikun 0:13413ea9a877 59 #ifndef __INLINE
ganlikun 0:13413ea9a877 60 #define __INLINE inline
ganlikun 0:13413ea9a877 61 #endif
ganlikun 0:13413ea9a877 62 #ifndef __STATIC_INLINE
ganlikun 0:13413ea9a877 63 #define __STATIC_INLINE static inline
ganlikun 0:13413ea9a877 64 #endif
ganlikun 0:13413ea9a877 65
ganlikun 0:13413ea9a877 66 #include <cmsis_iar.h>
ganlikun 0:13413ea9a877 67
ganlikun 0:13413ea9a877 68 #ifndef __NO_RETURN
ganlikun 0:13413ea9a877 69 #define __NO_RETURN __noreturn
ganlikun 0:13413ea9a877 70 #endif
ganlikun 0:13413ea9a877 71 #ifndef __USED
ganlikun 0:13413ea9a877 72 #define __USED __root
ganlikun 0:13413ea9a877 73 #endif
ganlikun 0:13413ea9a877 74 #ifndef __WEAK
ganlikun 0:13413ea9a877 75 #define __WEAK __weak
ganlikun 0:13413ea9a877 76 #endif
ganlikun 0:13413ea9a877 77 #ifndef __UNALIGNED_UINT32
ganlikun 0:13413ea9a877 78 __packed struct T_UINT32 { uint32_t v; };
ganlikun 0:13413ea9a877 79 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
ganlikun 0:13413ea9a877 80 #endif
ganlikun 0:13413ea9a877 81 #ifndef __ALIGNED
ganlikun 0:13413ea9a877 82 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
ganlikun 0:13413ea9a877 83 #define __ALIGNED(x)
ganlikun 0:13413ea9a877 84 #endif
ganlikun 0:13413ea9a877 85 #ifndef __PACKED
ganlikun 0:13413ea9a877 86 #define __PACKED __packed
ganlikun 0:13413ea9a877 87 #endif
ganlikun 0:13413ea9a877 88
ganlikun 0:13413ea9a877 89
ganlikun 0:13413ea9a877 90 /*
ganlikun 0:13413ea9a877 91 * TI ARM Compiler
ganlikun 0:13413ea9a877 92 */
ganlikun 0:13413ea9a877 93 #elif defined ( __TI_ARM__ )
ganlikun 0:13413ea9a877 94 #include <cmsis_ccs.h>
ganlikun 0:13413ea9a877 95
ganlikun 0:13413ea9a877 96 #ifndef __ASM
ganlikun 0:13413ea9a877 97 #define __ASM __asm
ganlikun 0:13413ea9a877 98 #endif
ganlikun 0:13413ea9a877 99 #ifndef __INLINE
ganlikun 0:13413ea9a877 100 #define __INLINE inline
ganlikun 0:13413ea9a877 101 #endif
ganlikun 0:13413ea9a877 102 #ifndef __STATIC_INLINE
ganlikun 0:13413ea9a877 103 #define __STATIC_INLINE static inline
ganlikun 0:13413ea9a877 104 #endif
ganlikun 0:13413ea9a877 105 #ifndef __NO_RETURN
ganlikun 0:13413ea9a877 106 #define __NO_RETURN __attribute__((noreturn))
ganlikun 0:13413ea9a877 107 #endif
ganlikun 0:13413ea9a877 108 #ifndef __USED
ganlikun 0:13413ea9a877 109 #define __USED __attribute__((used))
ganlikun 0:13413ea9a877 110 #endif
ganlikun 0:13413ea9a877 111 #ifndef __WEAK
ganlikun 0:13413ea9a877 112 #define __WEAK __attribute__((weak))
ganlikun 0:13413ea9a877 113 #endif
ganlikun 0:13413ea9a877 114 #ifndef __UNALIGNED_UINT32
ganlikun 0:13413ea9a877 115 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
ganlikun 0:13413ea9a877 116 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
ganlikun 0:13413ea9a877 117 #endif
ganlikun 0:13413ea9a877 118 #ifndef __ALIGNED
ganlikun 0:13413ea9a877 119 #define __ALIGNED(x) __attribute__((aligned(x)))
ganlikun 0:13413ea9a877 120 #endif
ganlikun 0:13413ea9a877 121 #ifndef __PACKED
ganlikun 0:13413ea9a877 122 #define __PACKED __attribute__((packed))
ganlikun 0:13413ea9a877 123 #endif
ganlikun 0:13413ea9a877 124
ganlikun 0:13413ea9a877 125
ganlikun 0:13413ea9a877 126 /*
ganlikun 0:13413ea9a877 127 * TASKING Compiler
ganlikun 0:13413ea9a877 128 */
ganlikun 0:13413ea9a877 129 #elif defined ( __TASKING__ )
ganlikun 0:13413ea9a877 130 /*
ganlikun 0:13413ea9a877 131 * The CMSIS functions have been implemented as intrinsics in the compiler.
ganlikun 0:13413ea9a877 132 * Please use "carm -?i" to get an up to date list of all intrinsics,
ganlikun 0:13413ea9a877 133 * Including the CMSIS ones.
ganlikun 0:13413ea9a877 134 */
ganlikun 0:13413ea9a877 135
ganlikun 0:13413ea9a877 136 #ifndef __ASM
ganlikun 0:13413ea9a877 137 #define __ASM __asm
ganlikun 0:13413ea9a877 138 #endif
ganlikun 0:13413ea9a877 139 #ifndef __INLINE
ganlikun 0:13413ea9a877 140 #define __INLINE inline
ganlikun 0:13413ea9a877 141 #endif
ganlikun 0:13413ea9a877 142 #ifndef __STATIC_INLINE
ganlikun 0:13413ea9a877 143 #define __STATIC_INLINE static inline
ganlikun 0:13413ea9a877 144 #endif
ganlikun 0:13413ea9a877 145 #ifndef __NO_RETURN
ganlikun 0:13413ea9a877 146 #define __NO_RETURN __attribute__((noreturn))
ganlikun 0:13413ea9a877 147 #endif
ganlikun 0:13413ea9a877 148 #ifndef __USED
ganlikun 0:13413ea9a877 149 #define __USED __attribute__((used))
ganlikun 0:13413ea9a877 150 #endif
ganlikun 0:13413ea9a877 151 #ifndef __WEAK
ganlikun 0:13413ea9a877 152 #define __WEAK __attribute__((weak))
ganlikun 0:13413ea9a877 153 #endif
ganlikun 0:13413ea9a877 154 #ifndef __UNALIGNED_UINT32
ganlikun 0:13413ea9a877 155 struct __packed__ T_UINT32 { uint32_t v; };
ganlikun 0:13413ea9a877 156 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
ganlikun 0:13413ea9a877 157 #endif
ganlikun 0:13413ea9a877 158 #ifndef __ALIGNED
ganlikun 0:13413ea9a877 159 #define __ALIGNED(x) __align(x)
ganlikun 0:13413ea9a877 160 #endif
ganlikun 0:13413ea9a877 161 #ifndef __PACKED
ganlikun 0:13413ea9a877 162 #define __PACKED __packed__
ganlikun 0:13413ea9a877 163 #endif
ganlikun 0:13413ea9a877 164
ganlikun 0:13413ea9a877 165
ganlikun 0:13413ea9a877 166 /*
ganlikun 0:13413ea9a877 167 * COSMIC Compiler
ganlikun 0:13413ea9a877 168 */
ganlikun 0:13413ea9a877 169 #elif defined ( __CSMC__ )
ganlikun 0:13413ea9a877 170 #include <cmsis_csm.h>
ganlikun 0:13413ea9a877 171
ganlikun 0:13413ea9a877 172 #ifndef __ASM
ganlikun 0:13413ea9a877 173 #define __ASM _asm
ganlikun 0:13413ea9a877 174 #endif
ganlikun 0:13413ea9a877 175 #ifndef __INLINE
ganlikun 0:13413ea9a877 176 #define __INLINE inline
ganlikun 0:13413ea9a877 177 #endif
ganlikun 0:13413ea9a877 178 #ifndef __STATIC_INLINE
ganlikun 0:13413ea9a877 179 #define __STATIC_INLINE static inline
ganlikun 0:13413ea9a877 180 #endif
ganlikun 0:13413ea9a877 181 #ifndef __NO_RETURN
ganlikun 0:13413ea9a877 182 // NO RETURN is automatically detected hence no warning here
ganlikun 0:13413ea9a877 183 #define __NO_RETURN
ganlikun 0:13413ea9a877 184 #endif
ganlikun 0:13413ea9a877 185 #ifndef __USED
ganlikun 0:13413ea9a877 186 #warning No compiler specific solution for __USED. __USED is ignored.
ganlikun 0:13413ea9a877 187 #define __USED
ganlikun 0:13413ea9a877 188 #endif
ganlikun 0:13413ea9a877 189 #ifndef __WEAK
ganlikun 0:13413ea9a877 190 #define __WEAK __weak
ganlikun 0:13413ea9a877 191 #endif
ganlikun 0:13413ea9a877 192 #ifndef __UNALIGNED_UINT32
ganlikun 0:13413ea9a877 193 @packed struct T_UINT32 { uint32_t v; };
ganlikun 0:13413ea9a877 194 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
ganlikun 0:13413ea9a877 195 #endif
ganlikun 0:13413ea9a877 196 #ifndef __ALIGNED
ganlikun 0:13413ea9a877 197 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
ganlikun 0:13413ea9a877 198 #define __ALIGNED(x)
ganlikun 0:13413ea9a877 199 #endif
ganlikun 0:13413ea9a877 200 #ifndef __PACKED
ganlikun 0:13413ea9a877 201 #define __PACKED @packed
ganlikun 0:13413ea9a877 202 #endif
ganlikun 0:13413ea9a877 203
ganlikun 0:13413ea9a877 204
ganlikun 0:13413ea9a877 205 #else
ganlikun 0:13413ea9a877 206 #error Unknown compiler.
ganlikun 0:13413ea9a877 207 #endif
ganlikun 0:13413ea9a877 208
ganlikun 0:13413ea9a877 209
ganlikun 0:13413ea9a877 210 #endif /* __CMSIS_COMPILER_H */
ganlikun 0:13413ea9a877 211
ganlikun 0:13413ea9a877 212