41 static constexpr uint8_t
BV8(uint8_t bit)
43 return uint8_t(1 << bit);
54 static constexpr uint8_t
BV8(uint8_t bit1, uint8_t bit2)
56 return uint8_t(
BV8(bit1) |
BV8(bit2));
69 static constexpr uint8_t
BV8(uint8_t bit1, uint8_t bit2, uint8_t bit3)
71 return uint8_t(
BV8(bit1, bit2) |
BV8(bit3));
86 static constexpr uint8_t
BV8(uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4)
88 return uint8_t(
BV8(bit1, bit2) |
BV8(bit3, bit4));
105 static constexpr uint8_t
BV8(uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5)
107 return uint8_t(
BV8(bit1, bit2, bit3) |
BV8(bit4, bit5));
126 static constexpr uint8_t
BV8(uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5, uint8_t bit6)
128 return uint8_t(
BV8(bit1, bit2, bit3) |
BV8(bit4, bit5, bit6));
137 static constexpr uint8_t
CBV8(uint8_t bit)
139 return uint8_t(~
BV8(bit));
148 static constexpr uint16_t
BV16(uint8_t bit)
150 return uint16_t(1 << bit);
161 static constexpr uint16_t
BV16(uint8_t bit1, uint8_t bit2)
163 return uint16_t(
BV16(bit1) |
BV16(bit2));
176 static constexpr uint16_t
BV16(uint8_t bit1, uint8_t bit2, uint8_t bit3)
178 return uint16_t(
BV16(bit1, bit2) |
BV16(bit3));
193 static constexpr uint16_t
BV16(uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4)
195 return uint16_t(
BV16(bit1, bit2) |
BV16(bit3, bit4));
212 static constexpr uint16_t
BV16(uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5)
214 return uint16_t(
BV16(bit1, bit2, bit3) |
BV16(bit4, bit5));
233 static constexpr uint16_t
BV16(uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5, uint8_t bit6)
235 return uint16_t(
BV16(bit1, bit2, bit3) |
BV16(bit4, bit5, bit6));
244 static constexpr uint16_t
CBV16(uint8_t bit)
246 return uint16_t(~
BV16(bit));
253 static constexpr uint8_t
COMPL(uint8_t value)
255 return uint8_t(~value);
263 return uint8_t(value & uint16_t(UINT8_MAX));
271 return uint8_t(value >> 8);
281 static constexpr uint8_t
OR8(uint8_t val1, uint8_t val2)
283 return uint8_t(val1 | val2);
293 static constexpr uint8_t
OR8(uint8_t val1, uint8_t val2, uint8_t val3)
295 return uint8_t(val1 |
OR8(val2, val3));
306 static constexpr uint8_t
OR8(uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4)
308 return uint8_t(
OR8(val1, val2) |
OR8(val3, val4));
320 static constexpr uint8_t
OR8(uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4, uint8_t val5)
322 return uint8_t(val1 |
OR8(val2, val3, val4, val5));
335 static constexpr uint8_t
OR8(uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4, uint8_t val5, uint8_t val6)
337 return uint8_t(
OR8(val1, val2, val3) |
OR8(val4, val5, val6));
347 static constexpr uint8_t
IF8(
bool flag, uint8_t val)
349 return uint8_t(flag ? val : 0U);
361 static constexpr uint8_t
ORIF8(
bool flag1, uint8_t val1,
bool flag2, uint8_t val2)
363 return OR8(
IF8(flag1, val1),
IF8(flag2, val2));
376 static constexpr uint8_t
ORIF8(
bool flag1, uint8_t val1,
bool flag2, uint8_t val2,
bool flag3, uint8_t val3)
378 return OR8(
IF8(flag1, val1),
IF8(flag2, val2),
IF8(flag3, val3));
394 bool flag1, uint8_t val1,
bool flag2, uint8_t val2,
bool flag3, uint8_t val3,
bool flag4, uint8_t val4)
396 return OR8(
IF8(flag1, val1),
IF8(flag2, val2),
IF8(flag3, val3),
IF8(flag4, val4));
413 static constexpr uint8_t
ORIF8(
bool flag1, uint8_t val1,
bool flag2, uint8_t val2,
bool flag3, uint8_t val3,
414 bool flag4, uint8_t val4,
bool flag5, uint8_t val5)
416 return OR8(
IF8(flag1, val1),
IF8(flag2, val2),
IF8(flag3, val3),
IF8(flag4, val4),
IF8(flag5, val5));
435 static constexpr uint8_t
ORIF8(
bool flag1, uint8_t val1,
bool flag2, uint8_t val2,
bool flag3, uint8_t val3,
436 bool flag4, uint8_t val4,
bool flag5, uint8_t val5,
bool flag6, uint8_t val6)
438 return OR8(
IF8(flag1, val1),
IF8(flag2, val2),
IF8(flag3, val3),
439 IF8(flag4, val4),
IF8(flag5, val5),
IF8(flag6, val6));
Defines utility methods for bits manipulation.
static constexpr uint8_t COMPL(uint8_t value)
Return the uint8_t 2-complement of a byte.
static constexpr uint8_t HIGH_BYTE(uint16_t value)
Extract the high byte (aka Most Significant Byte, MSB) of a uint16_t value.
static constexpr uint8_t CBV8(uint8_t bit)
Create a uint8_t inverted bitmask for the given bit number.
static constexpr uint8_t IF8(bool flag, uint8_t val)
return val if flag is true, otherwise 0, as an uint8_t.
static constexpr uint8_t BV8(uint8_t bit)
Create a uint8_t bitmask for the given bit number.
static constexpr uint16_t BV16(uint8_t bit)
Create a uint16_t bitmask for the given bit number.
static constexpr uint8_t LOW_BYTE(uint16_t value)
Extract the low byte (aka Least Significant Byte, LSB) of a uint16_t value.
static constexpr uint8_t ORIF8(bool flag1, uint8_t val1, bool flag2, uint8_t val2)
Create a uint8_t bitwise OR boolean operation between uint8_t operands, conditioned by bool flags.
static constexpr uint8_t OR8(uint8_t val1, uint8_t val2)
Create a uint8_t bitwise OR boolean operation between uint8_t operands.
static constexpr uint16_t CBV16(uint8_t bit)
Create a uint16_t inverted bitmask for the given bit number.