Wirepas SDK
bitfield.h
Go to the documentation of this file.
1 #ifndef BITFIELD_H
2 #define BITFIELD_H
3 
4 typedef uint8_t bitfield_t;
5 
6 #define BITFIELD_T_SIZE (sizeof(bitfield_t) * 8)
7 
8 #define BITFIELD_SET(arr, bit) \
9  ((arr)[ ((bit) / BITFIELD_T_SIZE ) ]) |= (1 << ((bit) % BITFIELD_T_SIZE))
10 
11 // BitField_clear(table,0) -> clear the 1st bit in array "table"
12 #define BITFIELD_CLEAR(arr, bit) \
13  ((arr)[ ((bit) / BITFIELD_T_SIZE ) ]) &= ~(1 << ((bit) % BITFIELD_T_SIZE))
14 
15 #define BITFIELD_GET(arr, bit) \
16  (((arr)[ ((bit) / BITFIELD_T_SIZE) ]) & (1 << ((bit) % BITFIELD_T_SIZE)))
17 
18 #endif
bitfield_t
uint8_t bitfield_t
Definition: bitfield.h:4