Contiki 3.x
debug.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * Definition of some debugging functions.
5  *
6  * putstring() and puthex() are from msp430/watchdog.c
7  *
8  * \author
9  * George Oikonomou - <oikonomou@users.sourceforge.net>
10  */
11 
12 #include "8051def.h"
13 #include "debug.h"
14 
15 static const char hexconv[] = "0123456789abcdef";
16 static const char binconv[] = "01";
17 /*---------------------------------------------------------------------------*/
18 void
19 putstring(char *s)
20 {
21  while(*s) {
22  putchar(*s++);
23  }
24 }
25 /*---------------------------------------------------------------------------*/
26 void
27 puthex(uint8_t c)
28 {
29  putchar(hexconv[c >> 4]);
30  putchar(hexconv[c & 0x0f]);
31 }
32 /*---------------------------------------------------------------------------*/
33 void
34 putbin(uint8_t c)
35 {
36  unsigned char i = 0x80;
37  while(i) {
38  putchar(binconv[(c & i) != 0]);
39  i >>= 1;
40  }
41 }
42 /*---------------------------------------------------------------------------*/
43 void
44 putdec(uint8_t c)
45 {
46  uint8_t div;
47  uint8_t hassent = 0;
48  for(div = 100; div > 0; div /= 10) {
49  uint8_t disp = c / div;
50  c %= div;
51  if((disp != 0) || (hassent) || (div == 1)) {
52  hassent = 1;
53  putchar('0' + disp);
54  }
55  }
56 }
Header file for debugging functions used by the sensinode port.