]> git.gir.st - tmk_keyboard.git/blob - ps2_vusb/usart_print.c
added protocol stack: pjrc, vusb
[tmk_keyboard.git] / ps2_vusb / usart_print.c
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 "usart_print.h"
12 #include "sendchar.h"
13
14
15 int8_t sendchar(uint8_t c)
16 {
17 while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */
18 ODDBG_UDR = c;
19 return 0;
20 }
21
22 void uartPutc(char c)
23 {
24 while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */
25 ODDBG_UDR = c;
26 }
27
28 static uchar hexAscii(uchar h)
29 {
30 h &= 0xf;
31 if(h >= 10)
32 h += 'a' - (uchar)10 - '0';
33 h += '0';
34 return h;
35 }
36
37 void printHex(uchar c)
38 {
39 uartPutc(hexAscii(c >> 4));
40 uartPutc(hexAscii(c));
41 }
42
43 void odDebug(uchar prefix, uchar *data, uchar len)
44 {
45 printHex(prefix);
46 uartPutc(':');
47 while(len--){
48 uartPutc(' ');
49 printHex(*data++);
50 }
51 uartPutc('\r');
52 uartPutc('\n');
53 }
Imprint / Impressum