A compilation of code from different sources to provide support for a Playstation 3 controller via bluetooth on the m3pi.

Dependencies:   TextLCD mbed

Fork of mbed_TANK_PS3 by Yasuhiko YAMAMOTO

Committer:
srsmitherman
Date:
Tue Jan 01 02:10:08 2013 +0000
Revision:
2:895f70862eb9
Parent:
0:44619612f575
M3pi support

Who changed what in which revision?

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