Shruti Rawool / pir-motion-sensor

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_ASSERT_H
skrawool 0:3954a906acc2 20 #define MBED_ASSERT_H
skrawool 0:3954a906acc2 21
skrawool 0:3954a906acc2 22 #include "mbed_preprocessor.h"
skrawool 0:3954a906acc2 23
skrawool 0:3954a906acc2 24 #ifdef __cplusplus
skrawool 0:3954a906acc2 25 extern "C" {
skrawool 0:3954a906acc2 26 #endif
skrawool 0:3954a906acc2 27
skrawool 0:3954a906acc2 28 /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
skrawool 0:3954a906acc2 29 * This function is active only if NDEBUG is not defined prior to including this
skrawool 0:3954a906acc2 30 * assert header file.
skrawool 0:3954a906acc2 31 * In case of MBED_ASSERT failing condition, error() is called with the assertation message.
skrawool 0:3954a906acc2 32 * @param expr Expresion to be checked.
skrawool 0:3954a906acc2 33 * @param file File where assertation failed.
skrawool 0:3954a906acc2 34 * @param line Failing assertation line number.
skrawool 0:3954a906acc2 35 */
skrawool 0:3954a906acc2 36 void mbed_assert_internal(const char *expr, const char *file, int line);
skrawool 0:3954a906acc2 37
skrawool 0:3954a906acc2 38 #ifdef __cplusplus
skrawool 0:3954a906acc2 39 }
skrawool 0:3954a906acc2 40 #endif
skrawool 0:3954a906acc2 41
skrawool 0:3954a906acc2 42 #ifdef NDEBUG
skrawool 0:3954a906acc2 43 #define MBED_ASSERT(expr) ((void)0)
skrawool 0:3954a906acc2 44
skrawool 0:3954a906acc2 45 #else
skrawool 0:3954a906acc2 46 #define MBED_ASSERT(expr) \
skrawool 0:3954a906acc2 47 do { \
skrawool 0:3954a906acc2 48 if (!(expr)) { \
skrawool 0:3954a906acc2 49 mbed_assert_internal(#expr, __FILE__, __LINE__); \
skrawool 0:3954a906acc2 50 } \
skrawool 0:3954a906acc2 51 } while (0)
skrawool 0:3954a906acc2 52 #endif
skrawool 0:3954a906acc2 53
skrawool 0:3954a906acc2 54
skrawool 0:3954a906acc2 55 /** MBED_STATIC_ASSERT
skrawool 0:3954a906acc2 56 * Declare compile-time assertions, results in compile-time error if condition is false
skrawool 0:3954a906acc2 57 *
skrawool 0:3954a906acc2 58 * The assertion acts as a declaration that can be placed at file scope, in a
skrawool 0:3954a906acc2 59 * code block (except after a label), or as a member of a C++ class/struct/union.
skrawool 0:3954a906acc2 60 *
skrawool 0:3954a906acc2 61 * @note
skrawool 0:3954a906acc2 62 * Use of MBED_STATIC_ASSERT as a member of a struct/union is limited:
skrawool 0:3954a906acc2 63 * - In C++, MBED_STATIC_ASSERT is valid in class/struct/union scope.
skrawool 0:3954a906acc2 64 * - In C, MBED_STATIC_ASSERT is not valid in struct/union scope, and
skrawool 0:3954a906acc2 65 * MBED_STRUCT_STATIC_ASSERT is provided as an alternative that is valid
skrawool 0:3954a906acc2 66 * in C and C++ class/struct/union scope.
skrawool 0:3954a906acc2 67 *
skrawool 0:3954a906acc2 68 * @code
skrawool 0:3954a906acc2 69 * MBED_STATIC_ASSERT(MBED_LIBRARY_VERSION >= 120,
skrawool 0:3954a906acc2 70 * "The mbed library must be at least version 120");
skrawool 0:3954a906acc2 71 *
skrawool 0:3954a906acc2 72 * int main() {
skrawool 0:3954a906acc2 73 * MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
skrawool 0:3954a906acc2 74 * "An int must be larger than a char");
skrawool 0:3954a906acc2 75 * }
skrawool 0:3954a906acc2 76 * @endcode
skrawool 0:3954a906acc2 77 */
skrawool 0:3954a906acc2 78 #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
skrawool 0:3954a906acc2 79 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
skrawool 0:3954a906acc2 80 #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
skrawool 0:3954a906acc2 81 #define MBED_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
skrawool 0:3954a906acc2 82 #elif defined(__cplusplus) && defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) \
skrawool 0:3954a906acc2 83 && (__GNUC__*100 + __GNUC_MINOR__) > 403L
skrawool 0:3954a906acc2 84 #define MBED_STATIC_ASSERT(expr, msg) __extension__ static_assert(expr, msg)
skrawool 0:3954a906acc2 85 #elif !defined(__cplusplus) && defined(__GNUC__) && !defined(__CC_ARM) \
skrawool 0:3954a906acc2 86 && (__GNUC__*100 + __GNUC_MINOR__) > 406L
skrawool 0:3954a906acc2 87 #define MBED_STATIC_ASSERT(expr, msg) __extension__ _Static_assert(expr, msg)
skrawool 0:3954a906acc2 88 #elif defined(__ICCARM__)
skrawool 0:3954a906acc2 89 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
skrawool 0:3954a906acc2 90 #else
skrawool 0:3954a906acc2 91 #define MBED_STATIC_ASSERT(expr, msg) \
skrawool 0:3954a906acc2 92 enum {MBED_CONCAT(MBED_ASSERTION_AT_, __LINE__) = sizeof(char[(expr) ? 1 : -1])}
skrawool 0:3954a906acc2 93 #endif
skrawool 0:3954a906acc2 94
skrawool 0:3954a906acc2 95 /** MBED_STRUCT_STATIC_ASSERT
skrawool 0:3954a906acc2 96 * Declare compile-time assertions, results in compile-time error if condition is false
skrawool 0:3954a906acc2 97 *
skrawool 0:3954a906acc2 98 * Unlike MBED_STATIC_ASSERT, MBED_STRUCT_STATIC_ASSERT can and must be used
skrawool 0:3954a906acc2 99 * as a member of a C/C++ class/struct/union.
skrawool 0:3954a906acc2 100 *
skrawool 0:3954a906acc2 101 * @code
skrawool 0:3954a906acc2 102 * struct thing {
skrawool 0:3954a906acc2 103 * MBED_STATIC_ASSERT(2 + 2 == 4,
skrawool 0:3954a906acc2 104 * "Hopefully the universe is mathematically consistent");
skrawool 0:3954a906acc2 105 * };
skrawool 0:3954a906acc2 106 * @endcode
skrawool 0:3954a906acc2 107 */
skrawool 0:3954a906acc2 108 #define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
skrawool 0:3954a906acc2 109
skrawool 0:3954a906acc2 110
skrawool 0:3954a906acc2 111 #endif
skrawool 0:3954a906acc2 112
skrawool 0:3954a906acc2 113 /** @}*/