ads1115 only
Fork of mbed by
Debug.h@4:5d1359a283bc, 2008-11-27 (annotated)
- Committer:
- simon.ford@mbed.co.uk
- Date:
- Thu Nov 27 16:23:24 2008 +0000
- Revision:
- 4:5d1359a283bc
- Parent:
- 1:6b7f447ca868
- Child:
- 5:62573be585e9
New version of framework: vectors, environment, platform, base and file system
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon.ford@mbed.co.uk | 0:82220227f4fa | 1 | /* mbed Microcontroller Library - Debug |
simon.ford@mbed.co.uk | 0:82220227f4fa | 2 | * Copyright (c) 2007-2008, sford |
simon.ford@mbed.co.uk | 0:82220227f4fa | 3 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 4 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 5 | #ifndef MBED_DEBUG_H |
simon.ford@mbed.co.uk | 0:82220227f4fa | 6 | #define MBED_DEBUG_H |
simon.ford@mbed.co.uk | 0:82220227f4fa | 7 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 8 | namespace mbed { |
simon.ford@mbed.co.uk | 0:82220227f4fa | 9 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 10 | /* Section: debug |
simon.ford@mbed.co.uk | 0:82220227f4fa | 11 | * Error reporting and debugging functions |
simon.ford@mbed.co.uk | 0:82220227f4fa | 12 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 13 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 14 | // As seen by user, for documentation purposes only |
simon.ford@mbed.co.uk | 0:82220227f4fa | 15 | #if 0 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 16 | /* Function: ERROR |
simon.ford@mbed.co.uk | 0:82220227f4fa | 17 | * Report a fatal runtime error. Attempts to report the specified error message through the |
simon.ford@mbed.co.uk | 0:82220227f4fa | 18 | * USB serial port, then dies with a fatal runtime error (siren lights) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 19 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 20 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 21 | * format - printf-style format string, followed by associated variables |
simon.ford@mbed.co.uk | 0:82220227f4fa | 22 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 23 | void ERROR(const char* format, ...); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 24 | #endif |
simon.ford@mbed.co.uk | 0:82220227f4fa | 25 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 26 | #define ERROR(FMT, ...) mbed_error(__FILE__, __LINE__, FMT, ##__VA_ARGS__) |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 27 | void mbed_error(const char* file, int line, const char* fmt=0, ...) __attribute__((noreturn)); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 28 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 29 | // Internal use for "official" errors |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 30 | void mbed_error(const char* file, int line, int code, const char* fmt=0, ...) __attribute__((noreturn)); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 31 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 32 | // As seen by user, for documentation purposes only |
simon.ford@mbed.co.uk | 0:82220227f4fa | 33 | #if 0 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 34 | /* Function: ASSERT |
simon.ford@mbed.co.uk | 0:82220227f4fa | 35 | * Assert a condition is true, and report a fatal runtime error on failure. If |
simon.ford@mbed.co.uk | 0:82220227f4fa | 36 | * the condition is true (non-zero), the function simply returns. If the |
simon.ford@mbed.co.uk | 0:82220227f4fa | 37 | * condition is false (0), it attempts to report the specified error message through the |
simon.ford@mbed.co.uk | 0:82220227f4fa | 38 | * USB serial port, then dies with a fatal runtime error (siren lights) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 39 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 40 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 41 | * condition - The condition variable to be tested. 0 causes an error to be reported |
simon.ford@mbed.co.uk | 0:82220227f4fa | 42 | * format - printf-style format string, followed by associated variables |
simon.ford@mbed.co.uk | 0:82220227f4fa | 43 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 44 | void ASSERT(int condition, const char* fmt = 0, ...); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 45 | #endif |
simon.ford@mbed.co.uk | 0:82220227f4fa | 46 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 47 | #define ASSERT(COND, ...) (COND ? (void)0 : mbed_error(__FILE__, __LINE__, ##__VA_ARGS__)) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 48 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 49 | // As seen by user, for documentation purposes only |
simon.ford@mbed.co.uk | 0:82220227f4fa | 50 | #if 0 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 51 | /* Function: DEBUG |
simon.ford@mbed.co.uk | 0:82220227f4fa | 52 | * Report a debug message. Attempts to report the specified |
simon.ford@mbed.co.uk | 0:82220227f4fa | 53 | * debug message through the USB serial port. |
simon.ford@mbed.co.uk | 0:82220227f4fa | 54 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 55 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 56 | * format - printf-style format string, followed by associated variables |
simon.ford@mbed.co.uk | 0:82220227f4fa | 57 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 58 | void DEBUG(const char* format, ...); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 59 | #endif |
simon.ford@mbed.co.uk | 0:82220227f4fa | 60 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 61 | // Actual macro and prototype |
simon.ford@mbed.co.uk | 0:82220227f4fa | 62 | #define DEBUG(...) mbed_debug(__FILE__, __LINE__, __VA_ARGS__) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 63 | void mbed_debug(const char* file, int line, const char* format, ...); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 64 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 65 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 66 | /* Function: DEBUG_LED1 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 67 | * Set the state of LED1 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 68 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 69 | void DEBUG_LED1(int v); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 70 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 71 | /* Function: DEBUG_LED2 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 72 | * Set the state of LED2 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 73 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 74 | void DEBUG_LED2(int v); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 75 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 76 | /* Function: DEBUG_LED3 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 77 | * Set the state of LED3 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 78 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 79 | void DEBUG_LED3(int v); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 80 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 81 | /* Function: DEBUG_LED4 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 82 | * Set the state of LED4 |
simon.ford@mbed.co.uk | 0:82220227f4fa | 83 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 84 | void DEBUG_LED4(int v); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 85 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 86 | } // namepsace mbed |
simon.ford@mbed.co.uk | 0:82220227f4fa | 87 | |
simon.ford@mbed.co.uk | 1:6b7f447ca868 | 88 | #endif |
simon.ford@mbed.co.uk | 1:6b7f447ca868 | 89 |