LPC11U35 ADC Tick & USBSerial
Dependents: SmallDoseMeter_SingleCH_AE_lpc11u35_V1_00
mbed/error.h@0:871ab6846b18, 2018-02-19 (annotated)
- Committer:
- H_Tsunemoto
- Date:
- Mon Feb 19 08:51:33 2018 +0000
- Revision:
- 0:871ab6846b18
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
H_Tsunemoto | 0:871ab6846b18 | 1 | /* mbed Microcontroller Library |
H_Tsunemoto | 0:871ab6846b18 | 2 | * Copyright (c) 2006-2013 ARM Limited |
H_Tsunemoto | 0:871ab6846b18 | 3 | * |
H_Tsunemoto | 0:871ab6846b18 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
H_Tsunemoto | 0:871ab6846b18 | 5 | * you may not use this file except in compliance with the License. |
H_Tsunemoto | 0:871ab6846b18 | 6 | * You may obtain a copy of the License at |
H_Tsunemoto | 0:871ab6846b18 | 7 | * |
H_Tsunemoto | 0:871ab6846b18 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
H_Tsunemoto | 0:871ab6846b18 | 9 | * |
H_Tsunemoto | 0:871ab6846b18 | 10 | * Unless required by applicable law or agreed to in writing, software |
H_Tsunemoto | 0:871ab6846b18 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
H_Tsunemoto | 0:871ab6846b18 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
H_Tsunemoto | 0:871ab6846b18 | 13 | * See the License for the specific language governing permissions and |
H_Tsunemoto | 0:871ab6846b18 | 14 | * limitations under the License. |
H_Tsunemoto | 0:871ab6846b18 | 15 | */ |
H_Tsunemoto | 0:871ab6846b18 | 16 | #ifndef MBED_ERROR_H |
H_Tsunemoto | 0:871ab6846b18 | 17 | #define MBED_ERROR_H |
H_Tsunemoto | 0:871ab6846b18 | 18 | |
H_Tsunemoto | 0:871ab6846b18 | 19 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. |
H_Tsunemoto | 0:871ab6846b18 | 20 | * |
H_Tsunemoto | 0:871ab6846b18 | 21 | * @code |
H_Tsunemoto | 0:871ab6846b18 | 22 | * #error "That shouldn't have happened!" |
H_Tsunemoto | 0:871ab6846b18 | 23 | * @endcode |
H_Tsunemoto | 0:871ab6846b18 | 24 | * |
H_Tsunemoto | 0:871ab6846b18 | 25 | * If the compiler evaluates this line, it will report the error and stop the compile. |
H_Tsunemoto | 0:871ab6846b18 | 26 | * |
H_Tsunemoto | 0:871ab6846b18 | 27 | * For example, you could use this to check some user-defined compile-time variables: |
H_Tsunemoto | 0:871ab6846b18 | 28 | * |
H_Tsunemoto | 0:871ab6846b18 | 29 | * @code |
H_Tsunemoto | 0:871ab6846b18 | 30 | * #define NUM_PORTS 7 |
H_Tsunemoto | 0:871ab6846b18 | 31 | * #if (NUM_PORTS > 4) |
H_Tsunemoto | 0:871ab6846b18 | 32 | * #error "NUM_PORTS must be less than 4" |
H_Tsunemoto | 0:871ab6846b18 | 33 | * #endif |
H_Tsunemoto | 0:871ab6846b18 | 34 | * @endcode |
H_Tsunemoto | 0:871ab6846b18 | 35 | * |
H_Tsunemoto | 0:871ab6846b18 | 36 | * Reporting Run-Time Errors: |
H_Tsunemoto | 0:871ab6846b18 | 37 | * To generate a fatal run-time error, you can use the mbed error() function. |
H_Tsunemoto | 0:871ab6846b18 | 38 | * |
H_Tsunemoto | 0:871ab6846b18 | 39 | * @code |
H_Tsunemoto | 0:871ab6846b18 | 40 | * error("That shouldn't have happened!"); |
H_Tsunemoto | 0:871ab6846b18 | 41 | * @endcode |
H_Tsunemoto | 0:871ab6846b18 | 42 | * |
H_Tsunemoto | 0:871ab6846b18 | 43 | * If the mbed running the program executes this function, it will print the |
H_Tsunemoto | 0:871ab6846b18 | 44 | * message via the USB serial port, and then die with the blue lights of death! |
H_Tsunemoto | 0:871ab6846b18 | 45 | * |
H_Tsunemoto | 0:871ab6846b18 | 46 | * The message can use printf-style formatting, so you can report variables in the |
H_Tsunemoto | 0:871ab6846b18 | 47 | * message too. For example, you could use this to check a run-time condition: |
H_Tsunemoto | 0:871ab6846b18 | 48 | * |
H_Tsunemoto | 0:871ab6846b18 | 49 | * @code |
H_Tsunemoto | 0:871ab6846b18 | 50 | * if(x >= 5) { |
H_Tsunemoto | 0:871ab6846b18 | 51 | * error("expected x to be less than 5, but got %d", x); |
H_Tsunemoto | 0:871ab6846b18 | 52 | * } |
H_Tsunemoto | 0:871ab6846b18 | 53 | * #endcode |
H_Tsunemoto | 0:871ab6846b18 | 54 | */ |
H_Tsunemoto | 0:871ab6846b18 | 55 | |
H_Tsunemoto | 0:871ab6846b18 | 56 | #include "toolchain.h" |
H_Tsunemoto | 0:871ab6846b18 | 57 | |
H_Tsunemoto | 0:871ab6846b18 | 58 | #ifdef __cplusplus |
H_Tsunemoto | 0:871ab6846b18 | 59 | extern "C" { |
H_Tsunemoto | 0:871ab6846b18 | 60 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 61 | |
H_Tsunemoto | 0:871ab6846b18 | 62 | void error(const char* format, ...); |
H_Tsunemoto | 0:871ab6846b18 | 63 | |
H_Tsunemoto | 0:871ab6846b18 | 64 | #ifdef __cplusplus |
H_Tsunemoto | 0:871ab6846b18 | 65 | } |
H_Tsunemoto | 0:871ab6846b18 | 66 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 67 | |
H_Tsunemoto | 0:871ab6846b18 | 68 | #endif |