PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

Committer:
skrawool
Date:
Mon Dec 05 16:39:27 2016 +0000
Revision:
0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266

Who changed what in which revision?

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