Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

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