XOOMの動作状況を聞き処理を変えてみました。 USBケーブルを抜いた際に処理を終了するようにしました。

Dependencies:   mbed

Committer:
abe00makoto
Date:
Fri May 27 18:51:15 2011 +0000
Revision:
3:432e5675d240
Parent:
0:9fb6c423e32c
nexus one support
maybe support add XOOM ,nexus S

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abe00makoto 0:9fb6c423e32c 1
abe00makoto 0:9fb6c423e32c 2
abe00makoto 0:9fb6c423e32c 3 #include "mbed.h"
abe00makoto 0:9fb6c423e32c 4 #include "Utils.h"
abe00makoto 0:9fb6c423e32c 5
abe00makoto 0:9fb6c423e32c 6 void printfBytes(const char* s, const u8* data, int len)
abe00makoto 0:9fb6c423e32c 7 {
abe00makoto 0:9fb6c423e32c 8 printf("%s %d:",s,len);
abe00makoto 0:9fb6c423e32c 9 if (len > 256)
abe00makoto 0:9fb6c423e32c 10 len = 256;
abe00makoto 0:9fb6c423e32c 11 while (len-- > 0)
abe00makoto 0:9fb6c423e32c 12 printf(" %02X",*data++);
abe00makoto 0:9fb6c423e32c 13 printf("\r\n");
abe00makoto 0:9fb6c423e32c 14 }
abe00makoto 0:9fb6c423e32c 15
abe00makoto 0:9fb6c423e32c 16 void printHexLine(const u8* d, int addr, int len)
abe00makoto 0:9fb6c423e32c 17 {
abe00makoto 0:9fb6c423e32c 18 printf("%04X ",addr);
abe00makoto 0:9fb6c423e32c 19 int i;
abe00makoto 0:9fb6c423e32c 20 for (i = 0; i < len; i++)
abe00makoto 0:9fb6c423e32c 21 printf("%02X ",d[i]);
abe00makoto 0:9fb6c423e32c 22 for (;i < 16; i++)
abe00makoto 0:9fb6c423e32c 23 printf(" ");
abe00makoto 0:9fb6c423e32c 24 char s[16+1];
abe00makoto 0:9fb6c423e32c 25 memset(s,0,sizeof(s));
abe00makoto 0:9fb6c423e32c 26 for (i = 0; i < len; i++)
abe00makoto 0:9fb6c423e32c 27 {
abe00makoto 0:9fb6c423e32c 28 int c = d[i];
abe00makoto 0:9fb6c423e32c 29 if (c < 0x20 || c > 0x7E)
abe00makoto 0:9fb6c423e32c 30 c = '.';
abe00makoto 0:9fb6c423e32c 31 s[i] = c;
abe00makoto 0:9fb6c423e32c 32 }
abe00makoto 0:9fb6c423e32c 33 printf("%s\r\n",s);
abe00makoto 0:9fb6c423e32c 34 }
abe00makoto 0:9fb6c423e32c 35
abe00makoto 0:9fb6c423e32c 36 void printHex(const u8* d, int len)
abe00makoto 0:9fb6c423e32c 37 {
abe00makoto 0:9fb6c423e32c 38 int addr = 0;
abe00makoto 0:9fb6c423e32c 39 while (len)
abe00makoto 0:9fb6c423e32c 40 {
abe00makoto 0:9fb6c423e32c 41 int count = len;
abe00makoto 0:9fb6c423e32c 42 if (count > 16)
abe00makoto 0:9fb6c423e32c 43 count = 16;
abe00makoto 0:9fb6c423e32c 44 printHexLine(d+addr,addr,count);
abe00makoto 0:9fb6c423e32c 45 addr += 16;
abe00makoto 0:9fb6c423e32c 46 len -= count;
abe00makoto 0:9fb6c423e32c 47 }
abe00makoto 0:9fb6c423e32c 48 }