Simons Wii controlled m3pi program

Dependencies:   mbed m3pi ID12RFIDIRQ

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Utils.h Source File

Utils.h

00001 #ifndef UTILS_H
00002 #define UTILS_H
00003 
00004 typedef unsigned char u8;
00005 typedef unsigned short u16;
00006 typedef unsigned long u32;
00007 
00008 void DelayMS(int ms);
00009 
00010 void printfBytes(const char* label,const u8* data, int len);
00011 void printHex(const u8* d, int len);
00012 
00013 #ifndef min
00014 #define min(_a,_b) ((_a) < (_b) ? (_a) : (_b))
00015 #endif
00016 
00017 inline int LE16(const u8* d)
00018 {
00019     return d[0] | (d[1] << 8);
00020 }
00021 
00022 inline u32 BE32(const u8* d)
00023 {
00024     return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
00025 }
00026 
00027 inline void BE32(u32 n, u8* d)
00028 {
00029     d[0] = (u8)(n >> 24);
00030     d[1] = (u8)(n >> 16);
00031     d[2] = (u8)(n >> 8);
00032     d[3] = (u8)n;
00033 }
00034 
00035 inline void BE16(u32 n, u8* d)
00036 {
00037     d[0] = (u8)(n >> 8);
00038     d[1] = (u8)n;
00039 }
00040 
00041 #endif