Contiki 2.6
|
00001 00002 #include "compiler.h" 00003 #include "delay.h" 00004 00005 #include <avr/pgmspace.h> 00006 00007 /*-----------------------------------------------------------------------------------*/ 00008 static void 00009 delay(void) 00010 { 00011 unsigned char i; 00012 for(i = 0; i < 1; ++i) { 00013 Delay_10ms(1); 00014 } 00015 } 00016 /*-----------------------------------------------------------------------------------*/ 00017 static char buffer[40]; 00018 static const char hextab[] PROGMEM = 00019 {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; 00020 /*-----------------------------------------------------------------------------------*/ 00021 static void 00022 print_buffer(unsigned char len) 00023 { 00024 unsigned char i; 00025 00026 for(i = 0; i < len; ++i) { 00027 delay(); 00028 UDR0 = buffer[i]; 00029 } 00030 } 00031 /*-----------------------------------------------------------------------------------*/ 00032 void 00033 debug_print8(unsigned char v) 00034 { 00035 /* buffer[0] = v / 100 + '0'; 00036 buffer[1] = (v / 10) % 10 + '0'; 00037 buffer[2] = v % 10 + '0'; 00038 buffer[3] = ' '; 00039 buffer[4] = PRG_RDB(hextab + (v >> 4)); 00040 buffer[5] = PRG_RDB(hextab + (v & 0x0f)); 00041 buffer[6] = '\n'; 00042 print_buffer(7);*/ 00043 } 00044 /*-----------------------------------------------------------------------------------*/ 00045 void 00046 debug_print16(unsigned short v) 00047 { 00048 /* buffer[0] = v / 10000 + '0'; 00049 buffer[1] = (v / 1000) % 10 + '0'; 00050 buffer[2] = (v / 100) % 10 + '0'; 00051 buffer[3] = (v / 10) % 10 + '0'; 00052 buffer[4] = v % 10 + '0'; 00053 buffer[5] = ' '; 00054 buffer[6] = PRG_RDB(hextab + ((v & 0xf000) >> 12)); 00055 buffer[7] = PRG_RDB(hextab + ((v & 0x0f00) >> 8)); 00056 buffer[8] = PRG_RDB(hextab + ((v & 0xf0) >> 4)); 00057 buffer[9] = PRG_RDB(hextab + (v & 0x0f)); 00058 buffer[10] = '\n'; 00059 print_buffer(11);*/ 00060 } 00061 /*-----------------------------------------------------------------------------------*/ 00062 void 00063 debug_print(char *str) 00064 { 00065 /* unsigned char i; 00066 00067 for(i = 0; PRG_RDB(str + i) != 0; ++i) { 00068 buffer[i] = PRG_RDB(str + i); 00069 } 00070 print_buffer(i);*/ 00071 } 00072 /*-----------------------------------------------------------------------------------*/