ads1115 only

Fork of mbed by mbed official

Committer:
<>
Date:
Thu Oct 27 16:45:56 2016 +0100
Revision:
128:9bcdf88f62b0
Child:
130:d75b3fe1f5cb
Release 128 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

2966: Add kw24 support https://github.com/ARMmbed/mbed-os/pull/2966
3068: MultiTech mDot - clean up PeripheralPins.c and add new pin names https://github.com/ARMmbed/mbed-os/pull/3068
3089: Kinetis HAL: Remove clock initialization code from serial and ticker https://github.com/ARMmbed/mbed-os/pull/3089
2943: [NRF5] NVIC_SetVector functionality https://github.com/ARMmbed/mbed-os/pull/2943
2938: InterruptIn changes in NCS36510 HAL. https://github.com/ARMmbed/mbed-os/pull/2938
3108: Fix sleep function for NRF52. https://github.com/ARMmbed/mbed-os/pull/3108
3076: STM32F1: Correct timer master value reading https://github.com/ARMmbed/mbed-os/pull/3076
3085: Add LOWPOWERTIMER capability for NUCLEO_F303ZE https://github.com/ARMmbed/mbed-os/pull/3085
3046: [BEETLE] Update BLE stack on Beetle board https://github.com/ARMmbed/mbed-os/pull/3046
3122: [Silicon Labs] Update of Silicon Labs HAL https://github.com/ARMmbed/mbed-os/pull/3122
3022: OnSemi RAM usage fix https://github.com/ARMmbed/mbed-os/pull/3022
3121: STM32F3: Correct UART4 and UART5 defines when using DEVICE_SERIAL_ASYNCH https://github.com/ARMmbed/mbed-os/pull/3121
3142: Targets- NUMAKER_PFM_NUC47216 remove mbed 2 https://github.com/ARMmbed/mbed-os/pull/3142

Who changed what in which revision?

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