3-phase PV router
Loading...
Searching...
No Matches
utils_bits.h
Go to the documentation of this file.
1
14
15#ifndef UTILS_BITS_H
16#define UTILS_BITS_H
17
18#include <stdint.h>
19
20inline constexpr uint8_t unused_pin{ 0xff };
21
29template< typename T >
30constexpr void bit_set(T& _dest, const uint8_t bit)
31{
32 _dest |= static_cast< T >(1) << bit;
33}
34
43template< typename T >
44constexpr uint8_t bit_read(const T& _src, const uint8_t bit)
45{
46 return (_src >> bit) & static_cast< T >(1);
47}
48
57template< typename T >
58constexpr uint8_t bit_clear(T& _dest, const uint8_t bit)
59{
60 return _dest &= ~(static_cast< T >(1) << bit);
61}
62
63#endif // UTILS_BITS_H
constexpr void bit_set(T &_dest, const uint8_t bit)
Set the specified bit to 1.
Definition utils_bits.h:30
constexpr uint8_t bit_read(const T &_src, const uint8_t bit)
Read the specified bit.
Definition utils_bits.h:44
constexpr uint8_t bit_clear(T &_dest, const uint8_t bit)
Clear the specified bit.
Definition utils_bits.h:58
constexpr uint8_t unused_pin
Definition utils_bits.h:20