Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/error.h@46:b2af06471858, 2016-01-14 (annotated)
- Committer:
- jeroenvz
- Date:
- Thu Jan 14 18:52:28 2016 +0000
- Revision:
- 46:b2af06471858
- Parent:
- 0:9b334a45a8ff
- LPCXpresso Interrupt fix
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bogdanm | 0:9b334a45a8ff | 1 | /***************************************************************************//** |
| bogdanm | 0:9b334a45a8ff | 2 | * @file error.h |
| bogdanm | 0:9b334a45a8ff | 3 | ******************************************************************************* |
| bogdanm | 0:9b334a45a8ff | 4 | * @section License |
| bogdanm | 0:9b334a45a8ff | 5 | * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> |
| bogdanm | 0:9b334a45a8ff | 6 | ******************************************************************************* |
| bogdanm | 0:9b334a45a8ff | 7 | * |
| bogdanm | 0:9b334a45a8ff | 8 | * Permission is granted to anyone to use this software for any purpose, |
| bogdanm | 0:9b334a45a8ff | 9 | * including commercial applications, and to alter it and redistribute it |
| bogdanm | 0:9b334a45a8ff | 10 | * freely, subject to the following restrictions: |
| bogdanm | 0:9b334a45a8ff | 11 | * |
| bogdanm | 0:9b334a45a8ff | 12 | * 1. The origin of this software must not be misrepresented; you must not |
| bogdanm | 0:9b334a45a8ff | 13 | * claim that you wrote the original software. |
| bogdanm | 0:9b334a45a8ff | 14 | * 2. Altered source versions must be plainly marked as such, and must not be |
| bogdanm | 0:9b334a45a8ff | 15 | * misrepresented as being the original software. |
| bogdanm | 0:9b334a45a8ff | 16 | * 3. This notice may not be removed or altered from any source distribution. |
| bogdanm | 0:9b334a45a8ff | 17 | * |
| bogdanm | 0:9b334a45a8ff | 18 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
| bogdanm | 0:9b334a45a8ff | 19 | * obligation to support this Software. Silicon Labs is providing the |
| bogdanm | 0:9b334a45a8ff | 20 | * Software "AS IS", with no express or implied warranties of any kind, |
| bogdanm | 0:9b334a45a8ff | 21 | * including, but not limited to, any implied warranties of merchantability |
| bogdanm | 0:9b334a45a8ff | 22 | * or fitness for any particular purpose or warranties against infringement |
| bogdanm | 0:9b334a45a8ff | 23 | * of any proprietary rights of a third party. |
| bogdanm | 0:9b334a45a8ff | 24 | * |
| bogdanm | 0:9b334a45a8ff | 25 | * Silicon Labs will not be liable for any consequential, incidental, or |
| bogdanm | 0:9b334a45a8ff | 26 | * special damages, or any other relief, or for any claim by any third party, |
| bogdanm | 0:9b334a45a8ff | 27 | * arising from your use of this Software. |
| bogdanm | 0:9b334a45a8ff | 28 | * |
| bogdanm | 0:9b334a45a8ff | 29 | ******************************************************************************/ |
| bogdanm | 0:9b334a45a8ff | 30 | |
| bogdanm | 0:9b334a45a8ff | 31 | #ifndef MBED_ERROR_H |
| bogdanm | 0:9b334a45a8ff | 32 | #define MBED_ERROR_H |
| bogdanm | 0:9b334a45a8ff | 33 | |
| bogdanm | 0:9b334a45a8ff | 34 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. |
| bogdanm | 0:9b334a45a8ff | 35 | * |
| bogdanm | 0:9b334a45a8ff | 36 | * @code |
| bogdanm | 0:9b334a45a8ff | 37 | * #error "That shouldn't have happened!" |
| bogdanm | 0:9b334a45a8ff | 38 | * @endcode |
| bogdanm | 0:9b334a45a8ff | 39 | * |
| bogdanm | 0:9b334a45a8ff | 40 | * If the compiler evaluates this line, it will report the error and stop the compile. |
| bogdanm | 0:9b334a45a8ff | 41 | * |
| bogdanm | 0:9b334a45a8ff | 42 | * For example, you could use this to check some user-defined compile-time variables: |
| bogdanm | 0:9b334a45a8ff | 43 | * |
| bogdanm | 0:9b334a45a8ff | 44 | * @code |
| bogdanm | 0:9b334a45a8ff | 45 | * #define NUM_PORTS 7 |
| bogdanm | 0:9b334a45a8ff | 46 | * #if (NUM_PORTS > 4) |
| bogdanm | 0:9b334a45a8ff | 47 | * #error "NUM_PORTS must be less than 4" |
| bogdanm | 0:9b334a45a8ff | 48 | * #endif |
| bogdanm | 0:9b334a45a8ff | 49 | * @endcode |
| bogdanm | 0:9b334a45a8ff | 50 | * |
| bogdanm | 0:9b334a45a8ff | 51 | * Reporting Run-Time Errors: |
| bogdanm | 0:9b334a45a8ff | 52 | * To generate a fatal run-time error, you can use the mbed error() function. |
| bogdanm | 0:9b334a45a8ff | 53 | * |
| bogdanm | 0:9b334a45a8ff | 54 | * @code |
| bogdanm | 0:9b334a45a8ff | 55 | * error("That shouldn't have happened!"); |
| bogdanm | 0:9b334a45a8ff | 56 | * @endcode |
| bogdanm | 0:9b334a45a8ff | 57 | * |
| bogdanm | 0:9b334a45a8ff | 58 | * If the mbed running the program executes this function, it will print the |
| bogdanm | 0:9b334a45a8ff | 59 | * message via the USB serial port, and then die with the blue lights of death! |
| bogdanm | 0:9b334a45a8ff | 60 | * |
| bogdanm | 0:9b334a45a8ff | 61 | * The message can use printf-style formatting, so you can report variables in the |
| bogdanm | 0:9b334a45a8ff | 62 | * message too. For example, you could use this to check a run-time condition: |
| bogdanm | 0:9b334a45a8ff | 63 | * |
| bogdanm | 0:9b334a45a8ff | 64 | * @code |
| bogdanm | 0:9b334a45a8ff | 65 | * if(x >= 5) { |
| bogdanm | 0:9b334a45a8ff | 66 | * error("expected x to be less than 5, but got %d", x); |
| bogdanm | 0:9b334a45a8ff | 67 | * } |
| bogdanm | 0:9b334a45a8ff | 68 | * #endcode |
| bogdanm | 0:9b334a45a8ff | 69 | */ |
| bogdanm | 0:9b334a45a8ff | 70 | |
| bogdanm | 0:9b334a45a8ff | 71 | #ifdef __cplusplus |
| bogdanm | 0:9b334a45a8ff | 72 | extern "C" { |
| bogdanm | 0:9b334a45a8ff | 73 | #endif |
| bogdanm | 0:9b334a45a8ff | 74 | |
| bogdanm | 0:9b334a45a8ff | 75 | void error(const char* format, ...); |
| bogdanm | 0:9b334a45a8ff | 76 | |
| bogdanm | 0:9b334a45a8ff | 77 | #ifdef __cplusplus |
| bogdanm | 0:9b334a45a8ff | 78 | } |
| bogdanm | 0:9b334a45a8ff | 79 | #endif |
| bogdanm | 0:9b334a45a8ff | 80 | |
| bogdanm | 0:9b334a45a8ff | 81 | #endif |
