Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcozecchini 0:9fca2b23d0ba 1
marcozecchini 0:9fca2b23d0ba 2 /** \addtogroup platform */
marcozecchini 0:9fca2b23d0ba 3 /** @{*/
marcozecchini 0:9fca2b23d0ba 4 /**
marcozecchini 0:9fca2b23d0ba 5 * \defgroup platform_error Error functions
marcozecchini 0:9fca2b23d0ba 6 * @{
marcozecchini 0:9fca2b23d0ba 7 */
marcozecchini 0:9fca2b23d0ba 8 /* mbed Microcontroller Library
marcozecchini 0:9fca2b23d0ba 9 * Copyright (c) 2006-2013 ARM Limited
marcozecchini 0:9fca2b23d0ba 10 *
marcozecchini 0:9fca2b23d0ba 11 * Licensed under the Apache License, Version 2.0 (the "License");
marcozecchini 0:9fca2b23d0ba 12 * you may not use this file except in compliance with the License.
marcozecchini 0:9fca2b23d0ba 13 * You may obtain a copy of the License at
marcozecchini 0:9fca2b23d0ba 14 *
marcozecchini 0:9fca2b23d0ba 15 * http://www.apache.org/licenses/LICENSE-2.0
marcozecchini 0:9fca2b23d0ba 16 *
marcozecchini 0:9fca2b23d0ba 17 * Unless required by applicable law or agreed to in writing, software
marcozecchini 0:9fca2b23d0ba 18 * distributed under the License is distributed on an "AS IS" BASIS,
marcozecchini 0:9fca2b23d0ba 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
marcozecchini 0:9fca2b23d0ba 20 * See the License for the specific language governing permissions and
marcozecchini 0:9fca2b23d0ba 21 * limitations under the License.
marcozecchini 0:9fca2b23d0ba 22 */
marcozecchini 0:9fca2b23d0ba 23 #ifndef MBED_ERROR_H
marcozecchini 0:9fca2b23d0ba 24 #define MBED_ERROR_H
marcozecchini 0:9fca2b23d0ba 25
marcozecchini 0:9fca2b23d0ba 26
marcozecchini 0:9fca2b23d0ba 27
marcozecchini 0:9fca2b23d0ba 28 /** To generate a fatal compile-time error, you can use the pre-processor #error directive.
marcozecchini 0:9fca2b23d0ba 29 *
marcozecchini 0:9fca2b23d0ba 30 * @param format C string that contains data stream to be printed.
marcozecchini 0:9fca2b23d0ba 31 * Code snippets below show valid format.
marcozecchini 0:9fca2b23d0ba 32 *
marcozecchini 0:9fca2b23d0ba 33 * @code
marcozecchini 0:9fca2b23d0ba 34 * #error "That shouldn't have happened!"
marcozecchini 0:9fca2b23d0ba 35 * @endcode
marcozecchini 0:9fca2b23d0ba 36 *
marcozecchini 0:9fca2b23d0ba 37 * If the compiler evaluates this line, it will report the error and stop the compile.
marcozecchini 0:9fca2b23d0ba 38 *
marcozecchini 0:9fca2b23d0ba 39 * For example, you could use this to check some user-defined compile-time variables:
marcozecchini 0:9fca2b23d0ba 40 *
marcozecchini 0:9fca2b23d0ba 41 * @code
marcozecchini 0:9fca2b23d0ba 42 * #define NUM_PORTS 7
marcozecchini 0:9fca2b23d0ba 43 * #if (NUM_PORTS > 4)
marcozecchini 0:9fca2b23d0ba 44 * #error "NUM_PORTS must be less than 4"
marcozecchini 0:9fca2b23d0ba 45 * #endif
marcozecchini 0:9fca2b23d0ba 46 * @endcode
marcozecchini 0:9fca2b23d0ba 47 *
marcozecchini 0:9fca2b23d0ba 48 * Reporting Run-Time Errors:
marcozecchini 0:9fca2b23d0ba 49 * To generate a fatal run-time error, you can use the mbed error() function.
marcozecchini 0:9fca2b23d0ba 50 *
marcozecchini 0:9fca2b23d0ba 51 * @code
marcozecchini 0:9fca2b23d0ba 52 * error("That shouldn't have happened!");
marcozecchini 0:9fca2b23d0ba 53 * @endcode
marcozecchini 0:9fca2b23d0ba 54 *
marcozecchini 0:9fca2b23d0ba 55 * If the mbed running the program executes this function, it will print the
marcozecchini 0:9fca2b23d0ba 56 * message via the USB serial port, and then die with the blue lights of death!
marcozecchini 0:9fca2b23d0ba 57 *
marcozecchini 0:9fca2b23d0ba 58 * The message can use printf-style formatting, so you can report variables in the
marcozecchini 0:9fca2b23d0ba 59 * message too. For example, you could use this to check a run-time condition:
marcozecchini 0:9fca2b23d0ba 60 *
marcozecchini 0:9fca2b23d0ba 61 * @code
marcozecchini 0:9fca2b23d0ba 62 * if(x >= 5) {
marcozecchini 0:9fca2b23d0ba 63 * error("expected x to be less than 5, but got %d", x);
marcozecchini 0:9fca2b23d0ba 64 * }
marcozecchini 0:9fca2b23d0ba 65 * @endcode
marcozecchini 0:9fca2b23d0ba 66 *
marcozecchini 0:9fca2b23d0ba 67 *
marcozecchini 0:9fca2b23d0ba 68 */
marcozecchini 0:9fca2b23d0ba 69
marcozecchini 0:9fca2b23d0ba 70 #ifdef __cplusplus
marcozecchini 0:9fca2b23d0ba 71 extern "C" {
marcozecchini 0:9fca2b23d0ba 72 #endif
marcozecchini 0:9fca2b23d0ba 73 void error(const char* format, ...);
marcozecchini 0:9fca2b23d0ba 74
marcozecchini 0:9fca2b23d0ba 75 #ifdef __cplusplus
marcozecchini 0:9fca2b23d0ba 76 }
marcozecchini 0:9fca2b23d0ba 77 #endif
marcozecchini 0:9fca2b23d0ba 78
marcozecchini 0:9fca2b23d0ba 79 #endif
marcozecchini 0:9fca2b23d0ba 80
marcozecchini 0:9fca2b23d0ba 81 /** @}*/
marcozecchini 0:9fca2b23d0ba 82 /** @}*/