mbed library sources. Supersedes mbed-src.

Dependents:   SPIne CH_Communicatuin_Test CH_Communicatuin_Test2 MCP_SPIne ... more

Fork of mbed-dev-f303 by Ben Katz

Committer:
<>
Date:
Fri Oct 28 11:17:30 2016 +0100
Revision:
149:156823d33999
Child:
151:5eaa88a5bcc7
This updates the lib to the mbed lib v128

NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 149:156823d33999 1
<> 149:156823d33999 2 /** \addtogroup platform */
<> 149:156823d33999 3 /** @{*/
<> 149:156823d33999 4 /* mbed Microcontroller Library
<> 149:156823d33999 5 * Copyright (c) 2006-2013 ARM Limited
<> 149:156823d33999 6 *
<> 149:156823d33999 7 * Licensed under the Apache License, Version 2.0 (the "License");
<> 149:156823d33999 8 * you may not use this file except in compliance with the License.
<> 149:156823d33999 9 * You may obtain a copy of the License at
<> 149:156823d33999 10 *
<> 149:156823d33999 11 * http://www.apache.org/licenses/LICENSE-2.0
<> 149:156823d33999 12 *
<> 149:156823d33999 13 * Unless required by applicable law or agreed to in writing, software
<> 149:156823d33999 14 * distributed under the License is distributed on an "AS IS" BASIS,
<> 149:156823d33999 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 149:156823d33999 16 * See the License for the specific language governing permissions and
<> 149:156823d33999 17 * limitations under the License.
<> 149:156823d33999 18 */
<> 149:156823d33999 19 #ifndef MBED_TOOLCHAIN_H
<> 149:156823d33999 20 #define MBED_TOOLCHAIN_H
<> 149:156823d33999 21
<> 149:156823d33999 22
<> 149:156823d33999 23 // Warning for unsupported compilers
<> 149:156823d33999 24 #if !defined(__GNUC__) /* GCC */ \
<> 149:156823d33999 25 && !defined(__CC_ARM) /* ARMCC */ \
<> 149:156823d33999 26 && !defined(__clang__) /* LLVM/Clang */ \
<> 149:156823d33999 27 && !defined(__ICCARM__) /* IAR */
<> 149:156823d33999 28 #warning "This compiler is not yet supported."
<> 149:156823d33999 29 #endif
<> 149:156823d33999 30
<> 149:156823d33999 31
<> 149:156823d33999 32 // Attributes
<> 149:156823d33999 33
<> 149:156823d33999 34 /** MBED_PACKED
<> 149:156823d33999 35 * Pack a structure, preventing any padding from being added between fields.
<> 149:156823d33999 36 *
<> 149:156823d33999 37 * @code
<> 149:156823d33999 38 * #include "toolchain.h"
<> 149:156823d33999 39 *
<> 149:156823d33999 40 * MBED_PACKED(struct) foo {
<> 149:156823d33999 41 * char x;
<> 149:156823d33999 42 * int y;
<> 149:156823d33999 43 * };
<> 149:156823d33999 44 * @endcode
<> 149:156823d33999 45 */
<> 149:156823d33999 46 #ifndef MBED_PACKED
<> 149:156823d33999 47 #if defined(__ICCARM__)
<> 149:156823d33999 48 #define MBED_PACKED(struct) __packed struct
<> 149:156823d33999 49 #else
<> 149:156823d33999 50 #define MBED_PACKED(struct) struct __attribute__((packed))
<> 149:156823d33999 51 #endif
<> 149:156823d33999 52 #endif
<> 149:156823d33999 53
<> 149:156823d33999 54 /** MBED_ALIGN(N)
<> 149:156823d33999 55 * Declare a variable to be aligned on an N-byte boundary.
<> 149:156823d33999 56 *
<> 149:156823d33999 57 * @note
<> 149:156823d33999 58 * IAR does not support alignment greater than word size on the stack
<> 149:156823d33999 59 *
<> 149:156823d33999 60 * @code
<> 149:156823d33999 61 * #include "toolchain.h"
<> 149:156823d33999 62 *
<> 149:156823d33999 63 * MBED_ALIGN(16) char a;
<> 149:156823d33999 64 * @endcode
<> 149:156823d33999 65 */
<> 149:156823d33999 66 #ifndef MBED_ALIGN
<> 149:156823d33999 67 #if defined(__ICCARM__)
<> 149:156823d33999 68 #define _MBED_ALIGN(N) _Pragma(#N)
<> 149:156823d33999 69 #define MBED_ALIGN(N) _MBED_ALIGN(data_alignment=N)
<> 149:156823d33999 70 #else
<> 149:156823d33999 71 #define MBED_ALIGN(N) __attribute__((aligned(N)))
<> 149:156823d33999 72 #endif
<> 149:156823d33999 73 #endif
<> 149:156823d33999 74
<> 149:156823d33999 75 /** MBED_UNUSED
<> 149:156823d33999 76 * Declare a function argument to be unused, suppressing compiler warnings
<> 149:156823d33999 77 *
<> 149:156823d33999 78 * @code
<> 149:156823d33999 79 * #include "toolchain.h"
<> 149:156823d33999 80 *
<> 149:156823d33999 81 * void foo(MBED_UNUSED int arg) {
<> 149:156823d33999 82 *
<> 149:156823d33999 83 * }
<> 149:156823d33999 84 * @endcode
<> 149:156823d33999 85 */
<> 149:156823d33999 86 #ifndef MBED_UNUSED
<> 149:156823d33999 87 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
<> 149:156823d33999 88 #define MBED_UNUSED __attribute__((__unused__))
<> 149:156823d33999 89 #else
<> 149:156823d33999 90 #define MBED_UNUSED
<> 149:156823d33999 91 #endif
<> 149:156823d33999 92 #endif
<> 149:156823d33999 93
<> 149:156823d33999 94 /** MBED_WEAK
<> 149:156823d33999 95 * Mark a function as being weak.
<> 149:156823d33999 96 *
<> 149:156823d33999 97 * @note
<> 149:156823d33999 98 * weak functions are not friendly to making code re-usable, as they can only
<> 149:156823d33999 99 * be overridden once (and if they are multiply overridden the linker will emit
<> 149:156823d33999 100 * no warning). You should not normally use weak symbols as part of the API to
<> 149:156823d33999 101 * re-usable modules.
<> 149:156823d33999 102 *
<> 149:156823d33999 103 * @code
<> 149:156823d33999 104 * #include "toolchain.h"
<> 149:156823d33999 105 *
<> 149:156823d33999 106 * MBED_WEAK void foo() {
<> 149:156823d33999 107 * // a weak implementation of foo that can be overriden by a definition
<> 149:156823d33999 108 * // without __weak
<> 149:156823d33999 109 * }
<> 149:156823d33999 110 * @endcode
<> 149:156823d33999 111 */
<> 149:156823d33999 112 #ifndef MBED_WEAK
<> 149:156823d33999 113 #if defined(__ICCARM__)
<> 149:156823d33999 114 #define MBED_WEAK __weak
<> 149:156823d33999 115 #else
<> 149:156823d33999 116 #define MBED_WEAK __attribute__((weak))
<> 149:156823d33999 117 #endif
<> 149:156823d33999 118 #endif
<> 149:156823d33999 119
<> 149:156823d33999 120 /** MBED_PURE
<> 149:156823d33999 121 * Hint to the compiler that a function depends only on parameters
<> 149:156823d33999 122 *
<> 149:156823d33999 123 * @code
<> 149:156823d33999 124 * #include "toolchain.h"
<> 149:156823d33999 125 *
<> 149:156823d33999 126 * MBED_PURE int foo(int arg){
<> 149:156823d33999 127 * // no access to global variables
<> 149:156823d33999 128 * }
<> 149:156823d33999 129 * @endcode
<> 149:156823d33999 130 */
<> 149:156823d33999 131 #ifndef MBED_PURE
<> 149:156823d33999 132 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
<> 149:156823d33999 133 #define MBED_PURE __attribute__((const))
<> 149:156823d33999 134 #else
<> 149:156823d33999 135 #define MBED_PURE
<> 149:156823d33999 136 #endif
<> 149:156823d33999 137 #endif
<> 149:156823d33999 138
<> 149:156823d33999 139 /** MBED_FORCEINLINE
<> 149:156823d33999 140 * Declare a function that must always be inlined. Failure to inline
<> 149:156823d33999 141 * such a function will result in an error.
<> 149:156823d33999 142 *
<> 149:156823d33999 143 * @code
<> 149:156823d33999 144 * #include "toolchain.h"
<> 149:156823d33999 145 *
<> 149:156823d33999 146 * MBED_FORCEINLINE void foo() {
<> 149:156823d33999 147 *
<> 149:156823d33999 148 * }
<> 149:156823d33999 149 * @endcode
<> 149:156823d33999 150 */
<> 149:156823d33999 151 #ifndef MBED_FORCEINLINE
<> 149:156823d33999 152 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
<> 149:156823d33999 153 #define MBED_FORCEINLINE static inline __attribute__((always_inline))
<> 149:156823d33999 154 #elif defined(__ICCARM__)
<> 149:156823d33999 155 #define MBED_FORCEINLINE _Pragma("inline=forced") static
<> 149:156823d33999 156 #else
<> 149:156823d33999 157 #define MBED_FORCEINLINE static inline
<> 149:156823d33999 158 #endif
<> 149:156823d33999 159 #endif
<> 149:156823d33999 160
<> 149:156823d33999 161 /** MBED_NORETURN
<> 149:156823d33999 162 * Declare a function that will never return.
<> 149:156823d33999 163 *
<> 149:156823d33999 164 * @code
<> 149:156823d33999 165 * #include "toolchain.h"
<> 149:156823d33999 166 *
<> 149:156823d33999 167 * MBED_NORETURN void foo() {
<> 149:156823d33999 168 * // must never return
<> 149:156823d33999 169 * while (1) {}
<> 149:156823d33999 170 * }
<> 149:156823d33999 171 * @endcode
<> 149:156823d33999 172 */
<> 149:156823d33999 173 #ifndef MBED_NORETURN
<> 149:156823d33999 174 #if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
<> 149:156823d33999 175 #define MBED_NORETURN __attribute__((noreturn))
<> 149:156823d33999 176 #elif defined(__ICCARM__)
<> 149:156823d33999 177 #define MBED_NORETURN __noreturn
<> 149:156823d33999 178 #else
<> 149:156823d33999 179 #define MBED_NORETURN
<> 149:156823d33999 180 #endif
<> 149:156823d33999 181 #endif
<> 149:156823d33999 182
<> 149:156823d33999 183 /** MBED_UNREACHABLE
<> 149:156823d33999 184 * An unreachable statement. If the statement is reached,
<> 149:156823d33999 185 * behaviour is undefined. Useful in situations where the compiler
<> 149:156823d33999 186 * cannot deduce the unreachability of code.
<> 149:156823d33999 187 *
<> 149:156823d33999 188 * @code
<> 149:156823d33999 189 * #include "toolchain.h"
<> 149:156823d33999 190 *
<> 149:156823d33999 191 * void foo(int arg) {
<> 149:156823d33999 192 * switch (arg) {
<> 149:156823d33999 193 * case 1: return 1;
<> 149:156823d33999 194 * case 2: return 2;
<> 149:156823d33999 195 * ...
<> 149:156823d33999 196 * }
<> 149:156823d33999 197 * MBED_UNREACHABLE;
<> 149:156823d33999 198 * }
<> 149:156823d33999 199 * @endcode
<> 149:156823d33999 200 */
<> 149:156823d33999 201 #ifndef MBED_UNREACHABLE
<> 149:156823d33999 202 #if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
<> 149:156823d33999 203 #define MBED_UNREACHABLE __builtin_unreachable()
<> 149:156823d33999 204 #else
<> 149:156823d33999 205 #define MBED_UNREACHABLE while (1)
<> 149:156823d33999 206 #endif
<> 149:156823d33999 207 #endif
<> 149:156823d33999 208
<> 149:156823d33999 209 /** MBED_DEPRECATED("message string")
<> 149:156823d33999 210 * Mark a function declaration as deprecated, if it used then a warning will be
<> 149:156823d33999 211 * issued by the compiler possibly including the provided message. Note that not
<> 149:156823d33999 212 * all compilers are able to display the message.
<> 149:156823d33999 213 *
<> 149:156823d33999 214 * @code
<> 149:156823d33999 215 * #include "toolchain.h"
<> 149:156823d33999 216 *
<> 149:156823d33999 217 * MBED_DEPRECATED("don't foo any more, bar instead")
<> 149:156823d33999 218 * void foo(int arg);
<> 149:156823d33999 219 * @endcode
<> 149:156823d33999 220 */
<> 149:156823d33999 221 #ifndef MBED_DEPRECATED
<> 149:156823d33999 222 #if defined(__GNUC__) || defined(__clang__)
<> 149:156823d33999 223 #define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
<> 149:156823d33999 224 #elif defined(__CC_ARM)
<> 149:156823d33999 225 #define MBED_DEPRECATED(M) __attribute__((deprecated))
<> 149:156823d33999 226 #else
<> 149:156823d33999 227 #define MBED_DEPRECATED(M)
<> 149:156823d33999 228 #endif
<> 149:156823d33999 229 #endif
<> 149:156823d33999 230
<> 149:156823d33999 231 /** MBED_DEPRECATED_SINCE("version", "message string")
<> 149:156823d33999 232 * Mark a function declaration as deprecated, noting that the declaration was
<> 149:156823d33999 233 * deprecated on the specified version. If the function is used then a warning
<> 149:156823d33999 234 * will be issued by the compiler possibly including the provided message.
<> 149:156823d33999 235 * Note that not all compilers are able to display this message.
<> 149:156823d33999 236 *
<> 149:156823d33999 237 * @code
<> 149:156823d33999 238 * #include "toolchain.h"
<> 149:156823d33999 239 *
<> 149:156823d33999 240 * MBED_DEPRECATED_SINCE("mbed-os-5.1", "don't foo any more, bar instead")
<> 149:156823d33999 241 * void foo(int arg);
<> 149:156823d33999 242 * @endcode
<> 149:156823d33999 243 */
<> 149:156823d33999 244 #define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
<> 149:156823d33999 245
<> 149:156823d33999 246 /** MBED_CALLER_ADDR()
<> 149:156823d33999 247 * Returns the caller of the current function.
<> 149:156823d33999 248 *
<> 149:156823d33999 249 * @note
<> 149:156823d33999 250 * This macro is only implemented for GCC and ARMCC.
<> 149:156823d33999 251 *
<> 149:156823d33999 252 * @code
<> 149:156823d33999 253 * #include "toolchain.h"
<> 149:156823d33999 254 *
<> 149:156823d33999 255 * printf("This function was called from %p", MBED_CALLER_ADDR());
<> 149:156823d33999 256 * @endcode
<> 149:156823d33999 257 *
<> 149:156823d33999 258 * @return Address of the calling function
<> 149:156823d33999 259 */
<> 149:156823d33999 260 #ifndef MBED_CALLER_ADDR
<> 149:156823d33999 261 #if (defined(__GNUC__) || defined(__clang__)) && !defined(__CC_ARM)
<> 149:156823d33999 262 #define MBED_CALLER_ADDR() __builtin_extract_return_addr(__builtin_return_address(0))
<> 149:156823d33999 263 #elif defined(__CC_ARM)
<> 149:156823d33999 264 #define MBED_CALLER_ADDR() __builtin_return_address(0)
<> 149:156823d33999 265 #else
<> 149:156823d33999 266 #define MBED_CALLER_ADDR() (NULL)
<> 149:156823d33999 267 #endif
<> 149:156823d33999 268 #endif
<> 149:156823d33999 269
<> 149:156823d33999 270 // FILEHANDLE declaration
<> 149:156823d33999 271 #if defined(TOOLCHAIN_ARM)
<> 149:156823d33999 272 #include <rt_sys.h>
<> 149:156823d33999 273 #endif
<> 149:156823d33999 274
<> 149:156823d33999 275 #ifndef FILEHANDLE
<> 149:156823d33999 276 typedef int FILEHANDLE;
<> 149:156823d33999 277 #endif
<> 149:156823d33999 278
<> 149:156823d33999 279 // Backwards compatibility
<> 149:156823d33999 280 #ifndef WEAK
<> 149:156823d33999 281 #define WEAK MBED_WEAK
<> 149:156823d33999 282 #endif
<> 149:156823d33999 283
<> 149:156823d33999 284 #ifndef PACKED
<> 149:156823d33999 285 #define PACKED MBED_PACKED()
<> 149:156823d33999 286 #endif
<> 149:156823d33999 287
<> 149:156823d33999 288 #ifndef EXTERN
<> 149:156823d33999 289 #define EXTERN extern
<> 149:156823d33999 290 #endif
<> 149:156823d33999 291
<> 149:156823d33999 292 #endif
<> 149:156823d33999 293
<> 149:156823d33999 294 /** @}*/