3-phase PV router
Loading...
Searching...
No Matches
utils_bits.h
Go to the documentation of this file.
1
13
14#ifndef UTILS_BITS_H
15#define UTILS_BITS_H
16
17#include <stdint.h>
18
26template< typename T >
27constexpr void bit_set(T& _dest, const uint8_t bit)
28{
29 _dest |= static_cast< T >(1) << bit;
30}
31
40template< typename T >
41constexpr uint8_t bit_read(const T& _src, const uint8_t bit)
42{
43 return (_src >> bit) & static_cast< T >(1);
44}
45
54template< typename T >
55constexpr uint8_t bit_clear(T& _dest, const uint8_t bit)
56{
57 return _dest &= ~(static_cast< T >(1) << bit);
58}
59
60#endif // UTILS_BITS_H
constexpr void bit_set(T &_dest, const uint8_t bit)
Set the specified bit to 1.
Definition utils_bits.h:27
constexpr uint8_t bit_read(const T &_src, const uint8_t bit)
Read the specified bit.
Definition utils_bits.h:41
constexpr uint8_t bit_clear(T &_dest, const uint8_t bit)
Clear the specified bit.
Definition utils_bits.h:55