this is the Peter Barrett USBHostShell program, a bit modified for being a bit more talkactive, just to let u know how the USB protocol layer is going on, and all the data trasnfers. Also there is a small implementation of HID descriptors, but not functional... yet :S the aim is to at least implement the gamepad HID, and make an array of function pointer to each HID function

Dependencies:   mbed

Committer:
Sergio
Date:
Mon Sep 13 12:40:05 2010 +0000
Revision:
0:e1e03118b8fe

        

Who changed what in which revision?

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