Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lypinator 0:bb348c97df44 1
lypinator 0:bb348c97df44 2 /** \addtogroup platform */
lypinator 0:bb348c97df44 3 /** @{*/
lypinator 0:bb348c97df44 4 /**
lypinator 0:bb348c97df44 5 * \defgroup platform_Assert Assert macros
lypinator 0:bb348c97df44 6 * @{
lypinator 0:bb348c97df44 7 */
lypinator 0:bb348c97df44 8 /* mbed Microcontroller Library
lypinator 0:bb348c97df44 9 * Copyright (c) 2006-2013 ARM Limited
lypinator 0:bb348c97df44 10 *
lypinator 0:bb348c97df44 11 * Licensed under the Apache License, Version 2.0 (the "License");
lypinator 0:bb348c97df44 12 * you may not use this file except in compliance with the License.
lypinator 0:bb348c97df44 13 * You may obtain a copy of the License at
lypinator 0:bb348c97df44 14 *
lypinator 0:bb348c97df44 15 * http://www.apache.org/licenses/LICENSE-2.0
lypinator 0:bb348c97df44 16 *
lypinator 0:bb348c97df44 17 * Unless required by applicable law or agreed to in writing, software
lypinator 0:bb348c97df44 18 * distributed under the License is distributed on an "AS IS" BASIS,
lypinator 0:bb348c97df44 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
lypinator 0:bb348c97df44 20 * See the License for the specific language governing permissions and
lypinator 0:bb348c97df44 21 * limitations under the License.
lypinator 0:bb348c97df44 22 */
lypinator 0:bb348c97df44 23 #ifndef MBED_ASSERT_H
lypinator 0:bb348c97df44 24 #define MBED_ASSERT_H
lypinator 0:bb348c97df44 25
lypinator 0:bb348c97df44 26 #include "mbed_preprocessor.h"
lypinator 0:bb348c97df44 27
lypinator 0:bb348c97df44 28 #ifdef __cplusplus
lypinator 0:bb348c97df44 29 extern "C" {
lypinator 0:bb348c97df44 30 #endif
lypinator 0:bb348c97df44 31
lypinator 0:bb348c97df44 32 /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
lypinator 0:bb348c97df44 33 * This function is active only if NDEBUG is not defined prior to including this
lypinator 0:bb348c97df44 34 * assert header file.
lypinator 0:bb348c97df44 35 * In case of MBED_ASSERT failing condition, error() is called with the assertation message.
lypinator 0:bb348c97df44 36 * @param expr Expresion to be checked.
lypinator 0:bb348c97df44 37 * @param file File where assertation failed.
lypinator 0:bb348c97df44 38 * @param line Failing assertation line number.
lypinator 0:bb348c97df44 39 */
lypinator 0:bb348c97df44 40 void mbed_assert_internal(const char *expr, const char *file, int line);
lypinator 0:bb348c97df44 41
lypinator 0:bb348c97df44 42 #ifdef __cplusplus
lypinator 0:bb348c97df44 43 }
lypinator 0:bb348c97df44 44 #endif
lypinator 0:bb348c97df44 45
lypinator 0:bb348c97df44 46 /** MBED_ASSERT
lypinator 0:bb348c97df44 47 * Declare runtime assertions: results in runtime error if condition is false
lypinator 0:bb348c97df44 48 *
lypinator 0:bb348c97df44 49 * @note
lypinator 0:bb348c97df44 50 * Use of MBED_ASSERT is limited to Debug and Develop builds.
lypinator 0:bb348c97df44 51 *
lypinator 0:bb348c97df44 52 * @code
lypinator 0:bb348c97df44 53 *
lypinator 0:bb348c97df44 54 * int Configure(serial_t *obj) {
lypinator 0:bb348c97df44 55 * MBED_ASSERT(obj);
lypinator 0:bb348c97df44 56 * }
lypinator 0:bb348c97df44 57 * @endcode
lypinator 0:bb348c97df44 58 */
lypinator 0:bb348c97df44 59 #ifdef NDEBUG
lypinator 0:bb348c97df44 60 #define MBED_ASSERT(expr) ((void)0)
lypinator 0:bb348c97df44 61
lypinator 0:bb348c97df44 62 #else
lypinator 0:bb348c97df44 63 #define MBED_ASSERT(expr) \
lypinator 0:bb348c97df44 64 do { \
lypinator 0:bb348c97df44 65 if (!(expr)) { \
lypinator 0:bb348c97df44 66 mbed_assert_internal(#expr, __FILE__, __LINE__); \
lypinator 0:bb348c97df44 67 } \
lypinator 0:bb348c97df44 68 } while (0)
lypinator 0:bb348c97df44 69 #endif
lypinator 0:bb348c97df44 70
lypinator 0:bb348c97df44 71
lypinator 0:bb348c97df44 72 /** MBED_STATIC_ASSERT
lypinator 0:bb348c97df44 73 * Declare compile-time assertions, results in compile-time error if condition is false
lypinator 0:bb348c97df44 74 *
lypinator 0:bb348c97df44 75 * The assertion acts as a declaration that can be placed at file scope, in a
lypinator 0:bb348c97df44 76 * code block (except after a label), or as a member of a C++ class/struct/union.
lypinator 0:bb348c97df44 77 *
lypinator 0:bb348c97df44 78 * @note
lypinator 0:bb348c97df44 79 * Use of MBED_STATIC_ASSERT as a member of a struct/union is limited:
lypinator 0:bb348c97df44 80 * - In C++, MBED_STATIC_ASSERT is valid in class/struct/union scope.
lypinator 0:bb348c97df44 81 * - In C, MBED_STATIC_ASSERT is not valid in struct/union scope, and
lypinator 0:bb348c97df44 82 * MBED_STRUCT_STATIC_ASSERT is provided as an alternative that is valid
lypinator 0:bb348c97df44 83 * in C and C++ class/struct/union scope.
lypinator 0:bb348c97df44 84 *
lypinator 0:bb348c97df44 85 * @code
lypinator 0:bb348c97df44 86 * MBED_STATIC_ASSERT(MBED_LIBRARY_VERSION >= 120,
lypinator 0:bb348c97df44 87 * "The mbed library must be at least version 120");
lypinator 0:bb348c97df44 88 *
lypinator 0:bb348c97df44 89 * int main() {
lypinator 0:bb348c97df44 90 * MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
lypinator 0:bb348c97df44 91 * "An int must be larger than a char");
lypinator 0:bb348c97df44 92 * }
lypinator 0:bb348c97df44 93 * @endcode
lypinator 0:bb348c97df44 94 */
lypinator 0:bb348c97df44 95 #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
lypinator 0:bb348c97df44 96 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
lypinator 0:bb348c97df44 97 #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
lypinator 0:bb348c97df44 98 #define MBED_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
lypinator 0:bb348c97df44 99 #elif defined(__cplusplus) && defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) \
lypinator 0:bb348c97df44 100 && (__GNUC__*100 + __GNUC_MINOR__) > 403L
lypinator 0:bb348c97df44 101 #define MBED_STATIC_ASSERT(expr, msg) __extension__ static_assert(expr, msg)
lypinator 0:bb348c97df44 102 #elif !defined(__cplusplus) && defined(__GNUC__) && !defined(__CC_ARM) \
lypinator 0:bb348c97df44 103 && (__GNUC__*100 + __GNUC_MINOR__) > 406L
lypinator 0:bb348c97df44 104 #define MBED_STATIC_ASSERT(expr, msg) __extension__ _Static_assert(expr, msg)
lypinator 0:bb348c97df44 105 #elif defined(__ICCARM__)
lypinator 0:bb348c97df44 106 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
lypinator 0:bb348c97df44 107 #else
lypinator 0:bb348c97df44 108 #define MBED_STATIC_ASSERT(expr, msg) \
lypinator 0:bb348c97df44 109 enum {MBED_CONCAT(MBED_ASSERTION_AT_, __LINE__) = sizeof(char[(expr) ? 1 : -1])}
lypinator 0:bb348c97df44 110 #endif
lypinator 0:bb348c97df44 111
lypinator 0:bb348c97df44 112 /** MBED_STRUCT_STATIC_ASSERT
lypinator 0:bb348c97df44 113 * Declare compile-time assertions, results in compile-time error if condition is false
lypinator 0:bb348c97df44 114 *
lypinator 0:bb348c97df44 115 * Unlike MBED_STATIC_ASSERT, MBED_STRUCT_STATIC_ASSERT can and must be used
lypinator 0:bb348c97df44 116 * as a member of a C/C++ class/struct/union.
lypinator 0:bb348c97df44 117 *
lypinator 0:bb348c97df44 118 * @code
lypinator 0:bb348c97df44 119 * struct thing {
lypinator 0:bb348c97df44 120 * MBED_STATIC_ASSERT(2 + 2 == 4,
lypinator 0:bb348c97df44 121 * "Hopefully the universe is mathematically consistent");
lypinator 0:bb348c97df44 122 * };
lypinator 0:bb348c97df44 123 * @endcode
lypinator 0:bb348c97df44 124 */
lypinator 0:bb348c97df44 125 #define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
lypinator 0:bb348c97df44 126
lypinator 0:bb348c97df44 127
lypinator 0:bb348c97df44 128 #endif
lypinator 0:bb348c97df44 129
lypinator 0:bb348c97df44 130 /**@}*/
lypinator 0:bb348c97df44 131
lypinator 0:bb348c97df44 132 /**@}*/
lypinator 0:bb348c97df44 133