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:
Sun Dec 30 05:16:28 2012 +0000
Revision:
1:ae49669c5e92
Parent:
0:44619612f575
Bluetooth PS3 interface for m3pi. User must pair bluetooth dongle address to PS3 controller with other program. Works but needs tweaking.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
srsmitherman 1:ae49669c5e92 1 #ifndef UTILS_H
srsmitherman 1:ae49669c5e92 2 #define UTILS_H
kenbumono 0:44619612f575 3
kenbumono 0:44619612f575 4 typedef unsigned char u8;
kenbumono 0:44619612f575 5 typedef unsigned short u16;
kenbumono 0:44619612f575 6 typedef unsigned long u32;
kenbumono 0:44619612f575 7
kenbumono 0:44619612f575 8 void DelayMS(int ms);
kenbumono 0:44619612f575 9
kenbumono 0:44619612f575 10 void printfBytes(const char* label,const u8* data, int len);
kenbumono 0:44619612f575 11 void printHex(const u8* d, int len);
kenbumono 0:44619612f575 12
kenbumono 0:44619612f575 13 #ifndef min
kenbumono 0:44619612f575 14 #define min(_a,_b) ((_a) < (_b) ? (_a) : (_b))
kenbumono 0:44619612f575 15 #endif
kenbumono 0:44619612f575 16
kenbumono 0:44619612f575 17 inline int LE16(const u8* d)
kenbumono 0:44619612f575 18 {
kenbumono 0:44619612f575 19 return d[0] | (d[1] << 8);
kenbumono 0:44619612f575 20 }
kenbumono 0:44619612f575 21
kenbumono 0:44619612f575 22 inline u32 BE32(const u8* d)
kenbumono 0:44619612f575 23 {
kenbumono 0:44619612f575 24 return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
kenbumono 0:44619612f575 25 }
kenbumono 0:44619612f575 26
kenbumono 0:44619612f575 27 inline void BE32(u32 n, u8* d)
kenbumono 0:44619612f575 28 {
kenbumono 0:44619612f575 29 d[0] = (u8)(n >> 24);
kenbumono 0:44619612f575 30 d[1] = (u8)(n >> 16);
kenbumono 0:44619612f575 31 d[2] = (u8)(n >> 8);
kenbumono 0:44619612f575 32 d[3] = (u8)n;
kenbumono 0:44619612f575 33 }
kenbumono 0:44619612f575 34
kenbumono 0:44619612f575 35 inline void BE16(u32 n, u8* d)
kenbumono 0:44619612f575 36 {
kenbumono 0:44619612f575 37 d[0] = (u8)(n >> 8);
kenbumono 0:44619612f575 38 d[1] = (u8)n;
kenbumono 0:44619612f575 39 }
srsmitherman 1:ae49669c5e92 40 #endif