20#if defined(__DOXYGEN__)
21inline constexpr void togglePin(uint8_t pin);
23inline constexpr void setPinON(uint8_t pin);
25inline constexpr void setPinOFF(uint8_t pin);
26template< u
int16_t usedPins >
27inline void setPinsState(uint16_t pinsON, uint16_t pinsOFF);
31template< u
int16_t pins >
33template< u
int16_t pins >
36inline constexpr void togglePin(uint8_t pin) __attribute__((always_inline));
38inline constexpr void setPinON(uint8_t pin) __attribute__((always_inline));
40inline constexpr void setPinOFF(uint8_t pin) __attribute__((always_inline));
41template< u
int16_t usedPins >
42inline void setPinsState(uint16_t pinsON, uint16_t pinsOFF) __attribute__((always_inline));
44inline constexpr bool getPinState(uint8_t pin) __attribute__((always_inline));
46template< u
int16_t pins >
48template< uint16_t pins >
86 const volatile uint8_t &port{ (pin < 8) ? PORTD : ((pin < 14) ? PORTB : PORTC) };
87 volatile uint8_t &toggle{ (pin < 8) ? PIND : ((pin < 14) ? PINB : PINC) };
88 const uint8_t mask{
static_cast< uint8_t
>(1U << ((pin < 8) ? pin : ((pin < 14) ? pin - 8 : pin - 14))) };
90 if (
static_cast< bool >(port & mask) != bState)
159template< u
int16_t usedPins >
162 if constexpr (lowByte(usedPins) != 0)
164 PORTD =
static_cast< uint8_t
>((PORTD & ~lowByte(pinsOFF)) | lowByte(pinsON));
166 if constexpr (highByte(usedPins) != 0)
168 PORTB =
static_cast< uint8_t
>((PORTB & ~highByte(pinsOFF)) | highByte(pinsON));
203template< u
int16_t pins >
206 if constexpr (lowByte(pins) != 0)
208 DDRD |= lowByte(pins);
210 if constexpr (highByte(pins) != 0)
212 DDRB |= highByte(pins);
223template< u
int16_t pins >
226 if constexpr (lowByte(pins) != 0)
228 DDRD &=
static_cast< uint8_t
>(~lowByte(pins));
229 PORTD |= lowByte(pins);
231 if constexpr (highByte(pins) != 0)
233 DDRB &=
static_cast< uint8_t
>(~highByte(pins));
234 PORTB |= highByte(pins);
Bit manipulation utility functions.
constexpr void bit_set(T &_dest, const uint8_t bit)
Set the specified bit to 1.
constexpr uint8_t bit_read(const T &_src, const uint8_t bit)
Read the specified bit.
constexpr uint8_t bit_clear(T &_dest, const uint8_t bit)
Clear the specified bit.
void setPinsState(uint16_t pinsON, uint16_t pinsOFF)
Switch pins ON and OFF, with one write per port.
constexpr bool getPinState(uint8_t pin)
Get the Pin State.
void setPinState(const uint8_t pin, const bool bState)
Set the Pin state for the specified pin.
constexpr void togglePin(uint8_t pin)
Toggle the specified pin.
constexpr void setPinON(uint8_t pin)
Set the Pin state to ON for the specified pin.
constexpr void setPinOFF(uint8_t pin)
Set the Pin state to OFF for the specified pin.
void setPinsAsInputPullup()
Set the pins as INPUT_PULLUP.
void setPinsAsOutput()
Set the pins as OUTPUT.