usbdrv/oddebug.c

Thu, 16 Feb 2017 14:45:20 +0100

author
Malte Di Donato <mdd@neo-soft.org>
date
Thu, 16 Feb 2017 14:45:20 +0100
changeset 2
93b48be0aa53
parent 0
9e9b2c78bd31
permissions
-rw-r--r--

added precompiled hex file

0
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
1 /* Name: oddebug.c
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
2 * Project: AVR library
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
3 * Author: Christian Starkjohann
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
4 * Creation Date: 2005-01-16
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
5 * Tabsize: 4
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
6 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
7 * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
8 */
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
9
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
10 #include "oddebug.h"
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
11
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
12 #if DEBUG_LEVEL > 0
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
13
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
14 #warning "Never compile production devices with debugging enabled"
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
15
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
16 static void uartPutc(char c)
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
17 {
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
18 while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
19 ODDBG_UDR = c;
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
20 }
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
21
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
22 static uchar hexAscii(uchar h)
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
23 {
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
24 h &= 0xf;
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
25 if(h >= 10)
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
26 h += 'a' - (uchar)10 - '0';
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
27 h += '0';
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
28 return h;
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
29 }
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
30
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
31 static void printHex(uchar c)
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
32 {
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
33 uartPutc(hexAscii(c >> 4));
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
34 uartPutc(hexAscii(c));
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
35 }
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
36
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
37 void odDebug(uchar prefix, uchar *data, uchar len)
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
38 {
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
39 printHex(prefix);
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
40 uartPutc(':');
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
41 while(len--){
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
42 uartPutc(' ');
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
43 printHex(*data++);
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
44 }
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
45 uartPutc('\r');
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
46 uartPutc('\n');
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
47 }
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
48
9e9b2c78bd31 added V-USB stack
Malte Di Donato <mdd@neo-soft.org>
parents:
diff changeset
49 #endif

mercurial