ads1115 only
Fork of mbed by
platform/mbed_assert.h@130:d75b3fe1f5cb, 2016-11-24 (annotated)
- Committer:
- <>
- Date:
- Thu Nov 24 11:01:25 2016 +0000
- Revision:
- 130:d75b3fe1f5cb
- Parent:
- 128:9bcdf88f62b0
Release 130 of the mbed library
Ports for Upcoming Targets
Fixes and Changes
3127: Fixed the issue about push/pop of VFP register. https://github.com/ARMmbed/mbed-os/pull/3127
3176: Modifying micro:bit pin names to mirror micro:bit edge connector https://github.com/ARMmbed/mbed-os/pull/3176
3160: Fix wrong index at LPC43xx tx end ring assignment https://github.com/ARMmbed/mbed-os/pull/3160
3217: Add I2C_ASYNCH capability for DISCO_F469NI https://github.com/ARMmbed/mbed-os/pull/3217
3211: [NUC472/M453] Support single UART shared by multiple serial objects and other updates https://github.com/ARMmbed/mbed-os/pull/3211
3198: NUCLEO_F410RB: Add I2C_ASYNCH capability https://github.com/ARMmbed/mbed-os/pull/3198
3194: Update K64 sdk drivers https://github.com/ARMmbed/mbed-os/pull/3194
3159: User trim values for NCS36510 https://github.com/ARMmbed/mbed-os/pull/3159
3243: Fix make exporters compilation https://github.com/ARMmbed/mbed-os/pull/3243
3231: STM32F3: DISCO_F303VC - Add missing UART and ADC pin muxing options https://github.com/ARMmbed/mbed-os/pull/3231
3233: K20xx Calculate PWM clock relative to bus clock https://github.com/ARMmbed/mbed-os/pull/3233
3237: Added back USART 6 pins https://github.com/ARMmbed/mbed-os/pull/3237
3253: Fix default polarity on LPC43XX PWM driver https://github.com/ARMmbed/mbed-os/pull/3253
3238: Dev i2c stm32f4hal https://github.com/ARMmbed/mbed-os/pull/3238
3251: Dev stm32l0 cube v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3251
3252: [NORDIC - NRF51 - MBED 2] Fix non handled RTC IRQ https://github.com/ARMmbed/mbed-os/pull/3252
Who changed what in which revision?
User | Revision | Line number | New 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_ASSERT_H |
<> | 128:9bcdf88f62b0 | 20 | #define MBED_ASSERT_H |
<> | 128:9bcdf88f62b0 | 21 | |
<> | 130:d75b3fe1f5cb | 22 | #include "mbed_preprocessor.h" |
<> | 130:d75b3fe1f5cb | 23 | |
<> | 128:9bcdf88f62b0 | 24 | #ifdef __cplusplus |
<> | 128:9bcdf88f62b0 | 25 | extern "C" { |
<> | 128:9bcdf88f62b0 | 26 | #endif |
<> | 128:9bcdf88f62b0 | 27 | |
<> | 128:9bcdf88f62b0 | 28 | /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes. |
<> | 128:9bcdf88f62b0 | 29 | * This function is active only if NDEBUG is not defined prior to including this |
<> | 128:9bcdf88f62b0 | 30 | * assert header file. |
<> | 128:9bcdf88f62b0 | 31 | * In case of MBED_ASSERT failing condition, error() is called with the assertation message. |
<> | 128:9bcdf88f62b0 | 32 | * @param expr Expresion to be checked. |
<> | 128:9bcdf88f62b0 | 33 | * @param file File where assertation failed. |
<> | 128:9bcdf88f62b0 | 34 | * @param line Failing assertation line number. |
<> | 128:9bcdf88f62b0 | 35 | */ |
<> | 128:9bcdf88f62b0 | 36 | void mbed_assert_internal(const char *expr, const char *file, int line); |
<> | 128:9bcdf88f62b0 | 37 | |
<> | 128:9bcdf88f62b0 | 38 | #ifdef __cplusplus |
<> | 128:9bcdf88f62b0 | 39 | } |
<> | 128:9bcdf88f62b0 | 40 | #endif |
<> | 128:9bcdf88f62b0 | 41 | |
<> | 128:9bcdf88f62b0 | 42 | #ifdef NDEBUG |
<> | 128:9bcdf88f62b0 | 43 | #define MBED_ASSERT(expr) ((void)0) |
<> | 128:9bcdf88f62b0 | 44 | |
<> | 128:9bcdf88f62b0 | 45 | #else |
<> | 128:9bcdf88f62b0 | 46 | #define MBED_ASSERT(expr) \ |
<> | 128:9bcdf88f62b0 | 47 | do { \ |
<> | 128:9bcdf88f62b0 | 48 | if (!(expr)) { \ |
<> | 128:9bcdf88f62b0 | 49 | mbed_assert_internal(#expr, __FILE__, __LINE__); \ |
<> | 128:9bcdf88f62b0 | 50 | } \ |
<> | 128:9bcdf88f62b0 | 51 | } while (0) |
<> | 128:9bcdf88f62b0 | 52 | #endif |
<> | 128:9bcdf88f62b0 | 53 | |
<> | 130:d75b3fe1f5cb | 54 | |
<> | 130:d75b3fe1f5cb | 55 | /** MBED_STATIC_ASSERT |
<> | 130:d75b3fe1f5cb | 56 | * Declare compile-time assertions, results in compile-time error if condition is false |
<> | 130:d75b3fe1f5cb | 57 | * |
<> | 130:d75b3fe1f5cb | 58 | * The assertion acts as a declaration that can be placed at file scope, in a |
<> | 130:d75b3fe1f5cb | 59 | * code block (except after a label), or as a member of a C++ class/struct/union. |
<> | 130:d75b3fe1f5cb | 60 | * |
<> | 130:d75b3fe1f5cb | 61 | * @note |
<> | 130:d75b3fe1f5cb | 62 | * Use of MBED_STATIC_ASSERT as a member of a struct/union is limited: |
<> | 130:d75b3fe1f5cb | 63 | * - In C++, MBED_STATIC_ASSERT is valid in class/struct/union scope. |
<> | 130:d75b3fe1f5cb | 64 | * - In C, MBED_STATIC_ASSERT is not valid in struct/union scope, and |
<> | 130:d75b3fe1f5cb | 65 | * MBED_STRUCT_STATIC_ASSERT is provided as an alternative that is valid |
<> | 130:d75b3fe1f5cb | 66 | * in C and C++ class/struct/union scope. |
<> | 130:d75b3fe1f5cb | 67 | * |
<> | 130:d75b3fe1f5cb | 68 | * @code |
<> | 130:d75b3fe1f5cb | 69 | * MBED_STATIC_ASSERT(MBED_LIBRARY_VERSION >= 120, |
<> | 130:d75b3fe1f5cb | 70 | * "The mbed library must be at least version 120"); |
<> | 130:d75b3fe1f5cb | 71 | * |
<> | 130:d75b3fe1f5cb | 72 | * int main() { |
<> | 130:d75b3fe1f5cb | 73 | * MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), |
<> | 130:d75b3fe1f5cb | 74 | * "An int must be larger than a char"); |
<> | 130:d75b3fe1f5cb | 75 | * } |
<> | 130:d75b3fe1f5cb | 76 | * @endcode |
<> | 130:d75b3fe1f5cb | 77 | */ |
<> | 130:d75b3fe1f5cb | 78 | #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L) |
<> | 130:d75b3fe1f5cb | 79 | #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg) |
<> | 130:d75b3fe1f5cb | 80 | #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L |
<> | 130:d75b3fe1f5cb | 81 | #define MBED_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg) |
<> | 130:d75b3fe1f5cb | 82 | #elif defined(__cplusplus) && defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) \ |
<> | 130:d75b3fe1f5cb | 83 | && (__GNUC__*100 + __GNUC_MINOR__) > 403L |
<> | 130:d75b3fe1f5cb | 84 | #define MBED_STATIC_ASSERT(expr, msg) __extension__ static_assert(expr, msg) |
<> | 130:d75b3fe1f5cb | 85 | #elif !defined(__cplusplus) && defined(__GNUC__) && !defined(__CC_ARM) \ |
<> | 130:d75b3fe1f5cb | 86 | && (__GNUC__*100 + __GNUC_MINOR__) > 406L |
<> | 130:d75b3fe1f5cb | 87 | #define MBED_STATIC_ASSERT(expr, msg) __extension__ _Static_assert(expr, msg) |
<> | 130:d75b3fe1f5cb | 88 | #elif defined(__ICCARM__) |
<> | 130:d75b3fe1f5cb | 89 | #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg) |
<> | 130:d75b3fe1f5cb | 90 | #else |
<> | 130:d75b3fe1f5cb | 91 | #define MBED_STATIC_ASSERT(expr, msg) \ |
<> | 130:d75b3fe1f5cb | 92 | enum {MBED_CONCAT(MBED_ASSERTION_AT_, __LINE__) = sizeof(char[(expr) ? 1 : -1])} |
<> | 130:d75b3fe1f5cb | 93 | #endif |
<> | 130:d75b3fe1f5cb | 94 | |
<> | 130:d75b3fe1f5cb | 95 | /** MBED_STRUCT_STATIC_ASSERT |
<> | 130:d75b3fe1f5cb | 96 | * Declare compile-time assertions, results in compile-time error if condition is false |
<> | 130:d75b3fe1f5cb | 97 | * |
<> | 130:d75b3fe1f5cb | 98 | * Unlike MBED_STATIC_ASSERT, MBED_STRUCT_STATIC_ASSERT can and must be used |
<> | 130:d75b3fe1f5cb | 99 | * as a member of a C/C++ class/struct/union. |
<> | 130:d75b3fe1f5cb | 100 | * |
<> | 130:d75b3fe1f5cb | 101 | * @code |
<> | 130:d75b3fe1f5cb | 102 | * struct thing { |
<> | 130:d75b3fe1f5cb | 103 | * MBED_STATIC_ASSERT(2 + 2 == 4, |
<> | 130:d75b3fe1f5cb | 104 | * "Hopefully the universe is mathematically consistent"); |
<> | 130:d75b3fe1f5cb | 105 | * }; |
<> | 130:d75b3fe1f5cb | 106 | * @endcode |
<> | 130:d75b3fe1f5cb | 107 | */ |
<> | 130:d75b3fe1f5cb | 108 | #define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1 |
<> | 130:d75b3fe1f5cb | 109 | |
<> | 130:d75b3fe1f5cb | 110 | |
<> | 128:9bcdf88f62b0 | 111 | #endif |
<> | 128:9bcdf88f62b0 | 112 | |
<> | 128:9bcdf88f62b0 | 113 | /** @}*/ |