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 by
Debug.h@1:6b7f447ca868, 2008-04-30 (annotated)
- Committer:
- simon.ford@mbed.co.uk
- Date:
- Wed Apr 30 15:43:24 2008 +0000
- Revision:
- 1:6b7f447ca868
- Parent:
- 0:82220227f4fa
- Child:
- 4:5d1359a283bc
Fixes:
- ADC bug
- Newlines at end of files
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 | #include "DebugTracer.h" |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 9 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 10 | namespace mbed { |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 11 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 12 | /* Section: debug |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 13 | * Error reporting and debugging functions |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 14 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 15 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 16 | // As seen by user, for documentation purposes only |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 17 | #if 0 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 18 | /* Function: ERROR |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 19 | * Report a fatal runtime error. Attempts to report the specified error message through the |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 20 | * USB serial port, then dies with a fatal runtime error (siren lights) |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 21 | * |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 22 | * Variables: |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 23 | * format - printf-style format string, followed by associated variables |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 24 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 25 | void ERROR(const char* format, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 26 | #endif |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 27 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 28 | #define ERROR(...) mbed_error(__FILE__, __LINE__, __VA_ARGS__) |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 29 | void mbed_error(const char* file, int line, const char* fmt, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 30 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 31 | // Internal use for "official" errors |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 32 | void mbed_error(const char* file, int line, int code, const char* fmt, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 33 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 34 | // As seen by user, for documentation purposes only |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 35 | #if 0 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 36 | /* Function: ASSERT |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 37 | * Assert a condition is true, and report a fatal runtime error on failure. If |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 38 | * the condition is true (non-zero), the function simply returns. If the |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 39 | * condition is false (0), it attempts to report the specified error message through the |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 40 | * USB serial port, then dies with a fatal runtime error (siren lights) |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 41 | * |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 42 | * Variables: |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 43 | * condition - The condition variable to be tested. 0 causes an error to be reported |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 44 | * format - printf-style format string, followed by associated variables |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 45 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 46 | void ASSERT(int condition, const char* fmt = 0, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 47 | #endif |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 48 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 49 | #define ASSERT(...) mbed_assert(__FILE__, __LINE__, __VA_ARGS__) |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 50 | void mbed_assert(const char* file, int line, int condition, const char* fmt = 0, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 51 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 52 | // Internal use for "official" errors |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 53 | void mbed_assert(const char* file, int line, int condition, int code, const char* fmt = 0, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 54 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 55 | // As seen by user, for documentation purposes only |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 56 | #if 0 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 57 | /* Function: DEBUG |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 58 | * Report a debug message. Attempts to report the specified |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 59 | * debug message through the USB serial port. |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 60 | * |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 61 | * Variables: |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 62 | * format - printf-style format string, followed by associated variables |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 63 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 64 | void DEBUG(const char* format, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 65 | #endif |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 66 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 67 | // Actual macro and prototype |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 68 | #define DEBUG(...) mbed_debug(__FILE__, __LINE__, __VA_ARGS__) |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 69 | void mbed_debug(const char* file, int line, const char* format, ...); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 70 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 71 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 72 | /* Function: DEBUG_LED1 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 73 | * Set the state of LED1 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 74 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 75 | void DEBUG_LED1(int v); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 76 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 77 | /* Function: DEBUG_LED2 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 78 | * Set the state of LED2 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 79 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 80 | void DEBUG_LED2(int v); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 81 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 82 | /* Function: DEBUG_LED3 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 83 | * Set the state of LED3 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 84 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 85 | void DEBUG_LED3(int v); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 86 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 87 | /* Function: DEBUG_LED4 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 88 | * Set the state of LED4 |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 89 | */ |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 90 | void DEBUG_LED4(int v); |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 91 | |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 92 | } // namepsace mbed |
| simon.ford@mbed.co.uk | 0:82220227f4fa | 93 | |
| simon.ford@mbed.co.uk | 1:6b7f447ca868 | 94 | #endif |
| simon.ford@mbed.co.uk | 1:6b7f447ca868 | 95 |