23 #ifndef BYTEORDERING_H 24 #define BYTEORDERING_H 45 #define SWAP16(val) ((((uint16_t) (val)) << 8) | \ 46 (((uint16_t) (val)) >> 8) \ 48 #define SWAP32(val) (((((uint32_t) (val)) & 0x000000ff) << 24) | \ 49 ((((uint32_t) (val)) & 0x0000ff00) << 8) | \ 50 ((((uint32_t) (val)) & 0x00ff0000) >> 8) | \ 51 ((((uint32_t) (val)) & 0xff000000) >> 24) \ 54 #if LITTLE_ENDIAN || __AVR__ 59 #error "Endianess undefined! Please define LITTLE_ENDIAN=1 or BIG_ENDIAN=1." 108 #define HTOL16(val) SWAP16(val) 109 #define HTOL32(val) SWAP32(val) 110 #define LTOH16(val) SWAP16(val) 111 #define LTOH32(val) SWAP32(val) 113 #define HTOL16(val) (val) 114 #define HTOL32(val) (val) 115 #define LTOH16(val) (val) 116 #define LTOH32(val) (val) 130 uint16_t htol16(uint16_t h);
141 uint32_t htol32(uint32_t h);
152 uint16_t ltoh16(uint16_t l);
163 uint32_t ltoh32(uint32_t l);
165 uint16_t
read16(
const uint8_t* p);
166 uint32_t
read32(
const uint8_t* p);
167 void write16(uint8_t* p, uint16_t i);
168 void write32(uint8_t* p, uint32_t i);
172 #define htol16(h) swap16(h) 173 #define htol32(h) swap32(h) 174 #define ltoh16(l) swap16(l) 175 #define ltoh32(l) swap32(l) 177 uint16_t
read16(
const uint8_t* p);
178 uint32_t
read32(
const uint8_t* p);
179 void write16(uint8_t* p, uint16_t i);
180 void write32(uint8_t* p, uint32_t i);
184 #define htol16(h) (h) 185 #define htol32(h) (h) 186 #define ltoh16(l) (l) 187 #define ltoh32(l) (l) 190 #define read16(p) (*(const uint16_t*) (p)) 191 #define read32(p) (*(const uint32_t*) (p)) 192 #define write16(p, i) { *((uint16_t*) (p)) = i; } 193 #define write32(p, i) { *((uint32_t*) (p)) = i; } 195 uint16_t
read16(
const uint8_t* p);
196 uint32_t
read32(
const uint8_t* p);
197 void write16(uint8_t* p, uint16_t i);
198 void write32(uint8_t* p, uint32_t i);
208 uint16_t swap16(uint16_t i);
209 uint32_t swap32(uint32_t i);
void write16(uint8_t *p, uint16_t i)
uint32_t read32(const uint8_t *p)
void write32(uint8_t *p, uint32_t i)
uint16_t read16(const uint8_t *p)