mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Committer:
funshine
Date:
Sat Apr 08 17:03:55 2017 +0000
Revision:
162:16168a1438f3
Parent:
151:5eaa88a5bcc7
add code to handle serial port rx error in uart_irq()

Who changed what in which revision?

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