FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Defines utility methods for bits manipulation. More...
Functions | |
static constexpr uint8_t | BV8 (uint8_t bit) |
Create a uint8_t bitmask for the given bit number. More... | |
static constexpr uint8_t | BV8 (uint8_t bit1, uint8_t bit2) |
Create a uint8_t bitmask for the given bits numbers. More... | |
static constexpr uint8_t | BV8 (uint8_t bit1, uint8_t bit2, uint8_t bit3) |
Create a uint8_t bitmask for the given bits numbers. More... | |
static constexpr uint8_t | BV8 (uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4) |
Create a uint8_t bitmask for the given bits numbers. More... | |
static constexpr uint8_t | BV8 (uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5) |
Create a uint8_t bitmask for the given bits numbers. More... | |
static constexpr uint8_t | BV8 (uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5, uint8_t bit6) |
Create a uint8_t bitmask for the given bits numbers. More... | |
static constexpr uint8_t | CBV8 (uint8_t bit) |
Create a uint8_t inverted bitmask for the given bit number. More... | |
static constexpr uint16_t | BV16 (uint8_t bit) |
Create a uint16_t bitmask for the given bit number. More... | |
static constexpr uint16_t | BV16 (uint8_t bit1, uint8_t bit2) |
Create a uint16_t bitmask for the given bits numbers. More... | |
static constexpr uint16_t | BV16 (uint8_t bit1, uint8_t bit2, uint8_t bit3) |
Create a uint16_t bitmask for the given bits numbers. More... | |
static constexpr uint16_t | BV16 (uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4) |
Create a uint16_t bitmask for the given bits numbers. More... | |
static constexpr uint16_t | BV16 (uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5) |
Create a uint16_t bitmask for the given bits numbers. More... | |
static constexpr uint16_t | BV16 (uint8_t bit1, uint8_t bit2, uint8_t bit3, uint8_t bit4, uint8_t bit5, uint8_t bit6) |
Create a uint16_t bitmask for the given bits numbers. More... | |
static constexpr uint16_t | CBV16 (uint8_t bit) |
Create a uint16_t inverted bitmask for the given bit number. More... | |
static constexpr uint8_t | COMPL (uint8_t value) |
Return the uint8_t 2-complement of a byte. More... | |
static constexpr uint8_t | LOW_BYTE (uint16_t value) |
Extract the low byte (aka Least Significant Byte, LSB) of a uint16_t value. More... | |
static constexpr uint8_t | HIGH_BYTE (uint16_t value) |
Extract the high byte (aka Most Significant Byte, MSB) of a uint16_t value. More... | |
static constexpr uint8_t | OR8 (uint8_t val1, uint8_t val2) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands. More... | |
static constexpr uint8_t | OR8 (uint8_t val1, uint8_t val2, uint8_t val3) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands. More... | |
static constexpr uint8_t | OR8 (uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands. More... | |
static constexpr uint8_t | OR8 (uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4, uint8_t val5) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands. More... | |
static constexpr uint8_t | OR8 (uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4, uint8_t val5, uint8_t val6) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands. More... | |
static constexpr uint8_t | IF8 (bool flag, uint8_t val) |
return val if flag is true , otherwise 0 , as an uint8_t . More... | |
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. More... | |
static constexpr uint8_t | ORIF8 (bool flag1, uint8_t val1, bool flag2, uint8_t val2, bool flag3, uint8_t val3) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands, conditioned by bool flags. More... | |
static constexpr uint8_t | ORIF8 (bool flag1, uint8_t val1, bool flag2, uint8_t val2, bool flag3, uint8_t val3, bool flag4, uint8_t val4) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands, conditioned by bool flags. More... | |
static constexpr uint8_t | ORIF8 (bool flag1, uint8_t val1, bool flag2, uint8_t val2, bool flag3, uint8_t val3, bool flag4, uint8_t val4, bool flag5, uint8_t val5) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands, conditioned by bool flags. More... | |
static constexpr uint8_t | ORIF8 (bool flag1, uint8_t val1, bool flag2, uint8_t val2, bool flag3, uint8_t val3, bool flag4, uint8_t val4, bool flag5, uint8_t val5, bool flag6, uint8_t val6) |
Create a uint8_t bitwise OR boolean operation between uint8_t operands, conditioned by bool flags. More... | |
Defines utility methods for bits manipulation.
Most functions defined here are constexpr
, which means that they can be evaluated at compile-time when constant arguments. These functions are used to ensure proper casting of results to the required types, i.e. uint8_t
or uint16_t
.
|
staticconstexpr |
|
staticconstexpr |
Create a uint8_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2)
expression.
bit1 | the first bit number for which to produce a bitmask, should be between 0 and 7 . |
bit2 | the second bit number for which to produce a bitmask, should be between 0 and 7 . |
|
staticconstexpr |
Create a uint8_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the first bit number for which to produce a bitmask, should be between 0 and 7 . |
bit2 | the second bit number for which to produce a bitmask, should be between 0 and 7 . |
bit3 | the third bit number for which to produce a bitmask, should be between 0 and 7 . |
|
staticconstexpr |
Create a uint8_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the first bit number for which to produce a bitmask, should be between 0 and 7 . |
bit2 | the second bit number for which to produce a bitmask, should be between 0 and 7 . |
bit3 | the third bit number for which to produce a bitmask, should be between 0 and 7 . |
bit4 | the fourth bit number for which to produce a bitmask, should be between 0 and 7 . |
|
staticconstexpr |
Create a uint8_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the first bit number for which to produce a bitmask, should be between 0 and 7 . |
bit2 | the second bit number for which to produce a bitmask, should be between 0 and 7 . |
bit3 | the third bit number for which to produce a bitmask, should be between 0 and 7 . |
bit4 | the fourth bit number for which to produce a bitmask, should be between 0 and 7 . |
bit5 | the fifth bit number for which to produce a bitmask, should be between 0 and 7 . |
|
staticconstexpr |
Create a uint8_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the first bit number for which to produce a bitmask, should be between 0 and 7 . |
bit2 | the second bit number for which to produce a bitmask, should be between 0 and 7 . |
bit3 | the third bit number for which to produce a bitmask, should be between 0 and 7 . |
bit4 | the fourth bit number for which to produce a bitmask, should be between 0 and 7 . |
bit5 | the fifth bit number for which to produce a bitmask, should be between 0 and 7 . |
bit6 | the sixth bit number for which to produce a bitmask, should be between 0 and 7 . |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Create a uint16_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2)
expression.
bit1 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit2 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
|
staticconstexpr |
Create a uint16_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit2 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit3 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
|
staticconstexpr |
Create a uint16_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit2 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit3 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit4 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
|
staticconstexpr |
Create a uint16_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit2 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit3 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit4 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit5 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
|
staticconstexpr |
Create a uint16_t
bitmask for the given bits numbers.
Concretely, this is simply the (1 << bit1) | (1 << bit2) ...
expression.
bit1 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit2 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit3 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit4 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit5 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
bit6 | the bit number for which to produce a bitmask, should be between 0 and 15 . |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands.
This method exists to ensure proper result cast to uint8_t
.
val1 | the first byte to be ORed. |
val2 | the second byte to be ORed. |
val3 | the third byte to be ORed. |
val4 | the third byte to be ORed. |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands.
This method exists to ensure proper result cast to uint8_t
.
val1 | the first byte to be ORed. |
val2 | the second byte to be ORed. |
val3 | the third byte to be ORed. |
val4 | the third byte to be ORed. |
val5 | the third byte to be ORed. |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands.
This method exists to ensure proper result cast to uint8_t
.
val1 | the first byte to be ORed. |
val2 | the second byte to be ORed. |
val3 | the third byte to be ORed. |
val4 | the third byte to be ORed. |
val5 | the third byte to be ORed. |
val6 | the third byte to be ORed. |
|
staticconstexpr |
return val
if flag
is true
, otherwise 0
, as an uint8_t
.
Concretely, this is simply the (flag ? val : 0U)
expression. This method exists to ensure proper result cast to uint8_t
.
flag | the flag used to determine if val should be returned or 0 |
val | the value returned if flag is true |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands, conditioned by bool
flags.
Concretely, this is simply the (flag1 ? val1 : 0) | (flag2 ? val2 : 0)
expression.
flag1 | the flag used to determine if val1 should be used or 0 |
val1 | the first byte to be ORed. |
flag2 | the flag used to determine if val2 should be used or 0 |
val2 | the second byte to be ORed. |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands, conditioned by bool
flags.
flag1 | the flag used to determine if val1 should be used or 0 |
val1 | the first byte to be ORed. |
flag2 | the flag used to determine if val2 should be used or 0 |
val2 | the second byte to be ORed. |
flag3 | the flag used to determine if val3 should be used or 0 |
val3 | the second byte to be ORed. |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands, conditioned by bool
flags.
flag1 | the flag used to determine if val1 should be used or 0 |
val1 | the first byte to be ORed. |
flag2 | the flag used to determine if val2 should be used or 0 |
val2 | the second byte to be ORed. |
flag3 | the flag used to determine if val3 should be used or 0 |
val3 | the second byte to be ORed. |
flag4 | the flag used to determine if val4 should be used or 0 |
val4 | the second byte to be ORed. |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands, conditioned by bool
flags.
flag1 | the flag used to determine if val1 should be used or 0 |
val1 | the first byte to be ORed. |
flag2 | the flag used to determine if val2 should be used or 0 |
val2 | the second byte to be ORed. |
flag3 | the flag used to determine if val3 should be used or 0 |
val3 | the second byte to be ORed. |
flag4 | the flag used to determine if val4 should be used or 0 |
val4 | the second byte to be ORed. |
flag5 | the flag used to determine if val5 should be used or 0 |
val5 | the second byte to be ORed. |
|
staticconstexpr |
Create a uint8_t
bitwise OR boolean operation between uint8_t
operands, conditioned by bool
flags.
flag1 | the flag used to determine if val1 should be used or 0 |
val1 | the first byte to be ORed. |
flag2 | the flag used to determine if val2 should be used or 0 |
val2 | the second byte to be ORed. |
flag3 | the flag used to determine if val3 should be used or 0 |
val3 | the second byte to be ORed. |
flag4 | the flag used to determine if val4 should be used or 0 |
val4 | the second byte to be ORed. |
flag5 | the flag used to determine if val5 should be used or 0 |
val5 | the second byte to be ORed. |
flag6 | the flag used to determine if val6 should be used or 0 |
val6 | the second byte to be ORed. |