Speeduino
Loading...
Searching...
No Matches
bit_manip.h
Go to the documentation of this file.
1#pragma once
2
9#define BIT_SET(var,pos) ((var) |= (1U<<(pos)))
10
12#define BIT_CLEAR(var,pos) ((var) &= ~(1U<<(pos)))
13
15#define BIT_CHECK(var,pos) !!((var) & (1U<<(pos)))
16
18#define BIT_TOGGLE(var,pos) ((var)^= 1UL << (pos))
19
21#define BIT_WRITE(var, pos, bitvalue) ((bitvalue) ? BIT_SET((var), (pos)) : BIT_CLEAR((var), (pos)))
22
24static constexpr uint8_t setBits(uint8_t n)
25{
26 return (1U << n) - 1U;
27}
static constexpr uint8_t setBits(uint8_t n)
Set the first n bits of a byte.
Definition bit_manip.h:24