diff options
Diffstat (limited to 'protocol/vusb/usbdrv/oddebug.c')
| -rw-r--r-- | protocol/vusb/usbdrv/oddebug.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/protocol/vusb/usbdrv/oddebug.c b/protocol/vusb/usbdrv/oddebug.c new file mode 100644 index 000000000..945457c1f --- /dev/null +++ b/protocol/vusb/usbdrv/oddebug.c | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* Name: oddebug.c | ||
| 2 | * Project: AVR library | ||
| 3 | * Author: Christian Starkjohann | ||
| 4 | * Creation Date: 2005-01-16 | ||
| 5 | * Tabsize: 4 | ||
| 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH | ||
| 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) | ||
| 8 | * This Revision: $Id: oddebug.c 692 2008-11-07 15:07:40Z cs $ | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include "oddebug.h" | ||
| 12 | |||
| 13 | #if DEBUG_LEVEL > 0 | ||
| 14 | |||
| 15 | #warning "Never compile production devices with debugging enabled" | ||
| 16 | |||
| 17 | static void uartPutc(char c) | ||
| 18 | { | ||
| 19 | while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ | ||
| 20 | ODDBG_UDR = c; | ||
| 21 | } | ||
| 22 | |||
| 23 | static uchar hexAscii(uchar h) | ||
| 24 | { | ||
| 25 | h &= 0xf; | ||
| 26 | if(h >= 10) | ||
| 27 | h += 'a' - (uchar)10 - '0'; | ||
| 28 | h += '0'; | ||
| 29 | return h; | ||
| 30 | } | ||
| 31 | |||
| 32 | static void printHex(uchar c) | ||
| 33 | { | ||
| 34 | uartPutc(hexAscii(c >> 4)); | ||
| 35 | uartPutc(hexAscii(c)); | ||
| 36 | } | ||
| 37 | |||
| 38 | void odDebug(uchar prefix, uchar *data, uchar len) | ||
| 39 | { | ||
| 40 | printHex(prefix); | ||
| 41 | uartPutc(':'); | ||
| 42 | while(len--){ | ||
| 43 | uartPutc(' '); | ||
| 44 | printHex(*data++); | ||
| 45 | } | ||
| 46 | uartPutc('\r'); | ||
| 47 | uartPutc('\n'); | ||
| 48 | } | ||
| 49 | |||
| 50 | #endif | ||
