class library to access fischertechnik interfaces via USB
Dependencies: FatFileSystem mbed myBlueUSB neigbourhood rfcomm sdp
myBlueUSB/Utils.h@0:7da612835693, 2011-06-15 (annotated)
- Committer:
- networker
- Date:
- Wed Jun 15 19:12:25 2011 +0000
- Revision:
- 0:7da612835693
initial version
; Bluetooth support incomplete
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
networker |
0:7da612835693 | 1 | #ifndef UTILS_H |
networker |
0:7da612835693 | 2 | #define UTILS_H |
networker |
0:7da612835693 | 3 | |
networker |
0:7da612835693 | 4 | typedef unsigned char u8; |
networker |
0:7da612835693 | 5 | typedef unsigned short u16; |
networker |
0:7da612835693 | 6 | typedef unsigned long u32; |
networker |
0:7da612835693 | 7 | |
networker |
0:7da612835693 | 8 | void DelayMS(int ms); |
networker |
0:7da612835693 | 9 | |
networker |
0:7da612835693 | 10 | void printfBytes(const char* label,const u8* data, int len); |
networker |
0:7da612835693 | 11 | void printHex(const u8* d, int len); |
networker |
0:7da612835693 | 12 | //void printf(const BD_ADDR* addr); |
networker |
0:7da612835693 | 13 | |
networker |
0:7da612835693 | 14 | #ifndef min |
networker |
0:7da612835693 | 15 | #define min(_a,_b) ((_a) < (_b) ? (_a) : (_b)) |
networker |
0:7da612835693 | 16 | #endif |
networker |
0:7da612835693 | 17 | |
networker |
0:7da612835693 | 18 | inline int LE16(const u8* d) |
networker |
0:7da612835693 | 19 | { |
networker |
0:7da612835693 | 20 | return d[0] | (d[1] << 8); |
networker |
0:7da612835693 | 21 | } |
networker |
0:7da612835693 | 22 | |
networker |
0:7da612835693 | 23 | inline u32 BE32(const u8* d) |
networker |
0:7da612835693 | 24 | { |
networker |
0:7da612835693 | 25 | return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3]; |
networker |
0:7da612835693 | 26 | } |
networker |
0:7da612835693 | 27 | |
networker |
0:7da612835693 | 28 | inline void BE32(u32 n, u8* d) |
networker |
0:7da612835693 | 29 | { |
networker |
0:7da612835693 | 30 | d[0] = (u8)(n >> 24); |
networker |
0:7da612835693 | 31 | d[1] = (u8)(n >> 16); |
networker |
0:7da612835693 | 32 | d[2] = (u8)(n >> 8); |
networker |
0:7da612835693 | 33 | d[3] = (u8)n; |
networker |
0:7da612835693 | 34 | } |
networker |
0:7da612835693 | 35 | |
networker |
0:7da612835693 | 36 | inline void BE16(u32 n, u8* d) |
networker |
0:7da612835693 | 37 | { |
networker |
0:7da612835693 | 38 | d[0] = (u8)(n >> 8); |
networker |
0:7da612835693 | 39 | d[1] = (u8)n; |
networker |
0:7da612835693 | 40 | } |
networker |
0:7da612835693 | 41 | |
networker |
0:7da612835693 | 42 | #endif |