BLE demo for mbed Ported RunningElectronics's SBDBT firmware for BLE. It can communicate with iOS

Dependencies:   FatFileSystem mbed

Fork of BTstack by Norimasa Okamoto

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