35#ifndef _OS_MMAPGPIO_HXX_
36#define _OS_MMAPGPIO_HXX_
51template<
typename STORAGE>
64 STORAGE *
const ptr,
const unsigned bit_ofs,
const bool is_output)
65 :
ptr_(ptr + (bit_ofs >> 5))
73 if (new_state == Value::SET) {
92 return ((*
ptr_) & (1<<
bit_)) != 0 ? Value::SET : Value::CLR;
103 return isOutput_ ? Direction::DOUTPUT : Direction::DINPUT;
OS-independent abstraction for GPIO.
Value
Defines the options for GPIO level.
Direction
Defines the options for GPIO direction.
Gpio wrapper for a single bit in memory.
void clr() const OVERRIDE
Clears the GPIO output pin to low.
const unsigned bit_
Which bit. 0 == LSB, from there it goes up towards MSB.
void set_direction(Direction dir) const OVERRIDE
Sets the GPIO direction.
void write(Value new_state) const OVERRIDE
Writes a GPIO output pin (set or clear to a specific state).
Value read() const OVERRIDE
Retrieves the current Value of a GPIO input pin.
Direction direction() const OVERRIDE
Gets the GPIO direction.
const unsigned isOutput_
1 if this GPIO is an output, 0 if it's an input.
STORAGE *const ptr_
Pointer to storage.
constexpr MmapGpioTemplate(STORAGE *const ptr, const unsigned bit_ofs, const bool is_output)
Constructor.
void set() const OVERRIDE
Sets the GPIO output pin to high.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.