mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Mon Feb 18 09:41:56 2013 +0000
Revision:
9:663789d7729f
Parent:
8:c14af7958ef5
Update mbed-KL25Z to latest build

Who changed what in which revision?

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