![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is the project for the Old Model Robots for OU's Dr. Davis's Configurable Robots Research. This is being published so future robots can be set up easily.
Dependencies: FatFileSystem MCP3008 Motor PinDetect QTR_8A SRF05 SSD1308_128x64_I2C mbed
blueusb/Utils.h@0:bcad524c1856, 2017-11-01 (annotated)
- Committer:
- DrewSchaef
- Date:
- Wed Nov 01 15:57:59 2017 +0000
- Revision:
- 0:bcad524c1856
Published the project to allow access for future work on the Configurable Robots Research Project(s).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DrewSchaef | 0:bcad524c1856 | 1 | #ifndef UTILS_H |
DrewSchaef | 0:bcad524c1856 | 2 | #define UTILS_H |
DrewSchaef | 0:bcad524c1856 | 3 | |
DrewSchaef | 0:bcad524c1856 | 4 | typedef unsigned char u8; |
DrewSchaef | 0:bcad524c1856 | 5 | typedef unsigned short u16; |
DrewSchaef | 0:bcad524c1856 | 6 | typedef unsigned long u32; |
DrewSchaef | 0:bcad524c1856 | 7 | |
DrewSchaef | 0:bcad524c1856 | 8 | void DelayMS(int ms); |
DrewSchaef | 0:bcad524c1856 | 9 | |
DrewSchaef | 0:bcad524c1856 | 10 | void printfBytes(const char* label,const u8* data, int len); |
DrewSchaef | 0:bcad524c1856 | 11 | void printHex(const u8* d, int len); |
DrewSchaef | 0:bcad524c1856 | 12 | |
DrewSchaef | 0:bcad524c1856 | 13 | #ifndef min |
DrewSchaef | 0:bcad524c1856 | 14 | #define min(_a,_b) ((_a) < (_b) ? (_a) : (_b)) |
DrewSchaef | 0:bcad524c1856 | 15 | #endif |
DrewSchaef | 0:bcad524c1856 | 16 | |
DrewSchaef | 0:bcad524c1856 | 17 | inline int LE16(const u8* d) |
DrewSchaef | 0:bcad524c1856 | 18 | { |
DrewSchaef | 0:bcad524c1856 | 19 | return d[0] | (d[1] << 8); |
DrewSchaef | 0:bcad524c1856 | 20 | } |
DrewSchaef | 0:bcad524c1856 | 21 | |
DrewSchaef | 0:bcad524c1856 | 22 | inline u32 BE32(const u8* d) |
DrewSchaef | 0:bcad524c1856 | 23 | { |
DrewSchaef | 0:bcad524c1856 | 24 | return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3]; |
DrewSchaef | 0:bcad524c1856 | 25 | } |
DrewSchaef | 0:bcad524c1856 | 26 | |
DrewSchaef | 0:bcad524c1856 | 27 | inline void BE32(u32 n, u8* d) |
DrewSchaef | 0:bcad524c1856 | 28 | { |
DrewSchaef | 0:bcad524c1856 | 29 | d[0] = (u8)(n >> 24); |
DrewSchaef | 0:bcad524c1856 | 30 | d[1] = (u8)(n >> 16); |
DrewSchaef | 0:bcad524c1856 | 31 | d[2] = (u8)(n >> 8); |
DrewSchaef | 0:bcad524c1856 | 32 | d[3] = (u8)n; |
DrewSchaef | 0:bcad524c1856 | 33 | } |
DrewSchaef | 0:bcad524c1856 | 34 | |
DrewSchaef | 0:bcad524c1856 | 35 | inline void BE16(u32 n, u8* d) |
DrewSchaef | 0:bcad524c1856 | 36 | { |
DrewSchaef | 0:bcad524c1856 | 37 | d[0] = (u8)(n >> 8); |
DrewSchaef | 0:bcad524c1856 | 38 | d[1] = (u8)n; |
DrewSchaef | 0:bcad524c1856 | 39 | } |
DrewSchaef | 0:bcad524c1856 | 40 | |
DrewSchaef | 0:bcad524c1856 | 41 | #endif |