Thu, 16 Feb 2017 14:50:25 +0100
Added schematics and PCB layout
0 | 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 | */ | |
9 | ||
10 | #include "oddebug.h" | |
11 | ||
12 | #if DEBUG_LEVEL > 0 | |
13 | ||
14 | #warning "Never compile production devices with debugging enabled" | |
15 | ||
16 | static void uartPutc(char c) | |
17 | { | |
18 | while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ | |
19 | ODDBG_UDR = c; | |
20 | } | |
21 | ||
22 | static uchar hexAscii(uchar h) | |
23 | { | |
24 | h &= 0xf; | |
25 | if(h >= 10) | |
26 | h += 'a' - (uchar)10 - '0'; | |
27 | h += '0'; | |
28 | return h; | |
29 | } | |
30 | ||
31 | static void printHex(uchar c) | |
32 | { | |
33 | uartPutc(hexAscii(c >> 4)); | |
34 | uartPutc(hexAscii(c)); | |
35 | } | |
36 | ||
37 | void odDebug(uchar prefix, uchar *data, uchar len) | |
38 | { | |
39 | printHex(prefix); | |
40 | uartPutc(':'); | |
41 | while(len--){ | |
42 | uartPutc(' '); | |
43 | printHex(*data++); | |
44 | } | |
45 | uartPutc('\r'); | |
46 | uartPutc('\n'); | |
47 | } | |
48 | ||
49 | #endif |