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