![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code to control a Traxster robot using a Wimote and Android app
Fork of BlueUSB by
BlueUSB/Utils.h@1:accdaa84fe8d, 2014-04-28 (annotated)
- Committer:
- aswild
- Date:
- Mon Apr 28 16:06:32 2014 +0000
- Revision:
- 1:accdaa84fe8d
- Parent:
- Utils.h@0:606b230e5b4a
Wiimote controlled Traxster robot using BlueUSB
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
peterbarrett1967 | 0:606b230e5b4a | 1 | |
peterbarrett1967 | 0:606b230e5b4a | 2 | typedef unsigned char u8; |
peterbarrett1967 | 0:606b230e5b4a | 3 | typedef unsigned short u16; |
peterbarrett1967 | 0:606b230e5b4a | 4 | typedef unsigned long u32; |
peterbarrett1967 | 0:606b230e5b4a | 5 | |
peterbarrett1967 | 0:606b230e5b4a | 6 | void DelayMS(int ms); |
peterbarrett1967 | 0:606b230e5b4a | 7 | |
peterbarrett1967 | 0:606b230e5b4a | 8 | void printfBytes(const char* label,const u8* data, int len); |
peterbarrett1967 | 0:606b230e5b4a | 9 | void printHex(const u8* d, int len); |
peterbarrett1967 | 0:606b230e5b4a | 10 | |
peterbarrett1967 | 0:606b230e5b4a | 11 | #ifndef min |
peterbarrett1967 | 0:606b230e5b4a | 12 | #define min(_a,_b) ((_a) < (_b) ? (_a) : (_b)) |
peterbarrett1967 | 0:606b230e5b4a | 13 | #endif |
peterbarrett1967 | 0:606b230e5b4a | 14 | |
peterbarrett1967 | 0:606b230e5b4a | 15 | inline int LE16(const u8* d) |
peterbarrett1967 | 0:606b230e5b4a | 16 | { |
peterbarrett1967 | 0:606b230e5b4a | 17 | return d[0] | (d[1] << 8); |
peterbarrett1967 | 0:606b230e5b4a | 18 | } |
peterbarrett1967 | 0:606b230e5b4a | 19 | |
peterbarrett1967 | 0:606b230e5b4a | 20 | inline u32 BE32(const u8* d) |
peterbarrett1967 | 0:606b230e5b4a | 21 | { |
peterbarrett1967 | 0:606b230e5b4a | 22 | return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3]; |
peterbarrett1967 | 0:606b230e5b4a | 23 | } |
peterbarrett1967 | 0:606b230e5b4a | 24 | |
peterbarrett1967 | 0:606b230e5b4a | 25 | inline void BE32(u32 n, u8* d) |
peterbarrett1967 | 0:606b230e5b4a | 26 | { |
peterbarrett1967 | 0:606b230e5b4a | 27 | d[0] = (u8)(n >> 24); |
peterbarrett1967 | 0:606b230e5b4a | 28 | d[1] = (u8)(n >> 16); |
peterbarrett1967 | 0:606b230e5b4a | 29 | d[2] = (u8)(n >> 8); |
peterbarrett1967 | 0:606b230e5b4a | 30 | d[3] = (u8)n; |
peterbarrett1967 | 0:606b230e5b4a | 31 | } |
peterbarrett1967 | 0:606b230e5b4a | 32 | |
peterbarrett1967 | 0:606b230e5b4a | 33 | inline void BE16(u32 n, u8* d) |
peterbarrett1967 | 0:606b230e5b4a | 34 | { |
peterbarrett1967 | 0:606b230e5b4a | 35 | d[0] = (u8)(n >> 8); |
peterbarrett1967 | 0:606b230e5b4a | 36 | d[1] = (u8)n; |
peterbarrett1967 | 0:606b230e5b4a | 37 | } |