Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GpioWrapper< PIN > Class Template Reference

Creates an implementation of an os-independent Gpio object from a hardware-specific static Gpio structure. More...

#include <GpioWrapper.hxx>

Inheritance diagram for GpioWrapper< PIN >:
Gpio

Public Member Functions

constexpr GpioWrapper ()
 This constructor is constexpr which ensures that the object can be initialized in the data section.
 
void write (Value new_state) const OVERRIDE
 Writes a GPIO output pin (set or clear to a specific state).
 
void set () const OVERRIDE
 Sets the GPIO output pin to high.
 
void clr () const OVERRIDE
 Clears the GPIO output pin to low.
 
Value read () const OVERRIDE
 Retrieves the current Value of a GPIO input pin.
 
void set_direction (Direction dir) const OVERRIDE
 Sets the GPIO direction.
 
Direction direction () const OVERRIDE
 Gets the GPIO direction.
 
- Public Member Functions inherited from Gpio
constexpr Gpio ()
 Constructor.
 
void write (bool new_state) const
 Writes a GPIO output pin (set or clear to a specific state).
 
bool is_set () const
 Tests the GPIO input pin to see if it is set.
 
bool is_clr () const
 Tests the GPIO input pin to see if it is clear.
 

Static Public Member Functions

static constexpr const Gpioinstance ()
 

Static Public Attributes

static const GpioWrapper instance_
 Defines the linker symbol for the wrapped Gpio instance.
 

Additional Inherited Members

- Public Types inherited from Gpio
enum  Value : bool { CLR = false , SET = true , VLOW = CLR , VHIGH = SET }
 Defines the options for GPIO level. More...
 
enum class  Direction { DINPUT , DOUTPUT }
 Defines the options for GPIO direction. More...
 

Detailed Description

template<class PIN>
class GpioWrapper< PIN >

Creates an implementation of an os-independent Gpio object from a hardware-specific static Gpio structure.

Does not permit changing the direction of the hardware pin. For an example usage, see BLINKER_Pin::instance() in BlinkerGPIO.hxx.

Definition at line 45 of file GpioWrapper.hxx.

Constructor & Destructor Documentation

◆ GpioWrapper()

template<class PIN >
constexpr GpioWrapper< PIN >::GpioWrapper ( )
inlineconstexpr

This constructor is constexpr which ensures that the object can be initialized in the data section.

Definition at line 50 of file GpioWrapper.hxx.

Member Function Documentation

◆ clr()

template<class PIN >
void GpioWrapper< PIN >::clr ( ) const
inlinevirtual

Clears the GPIO output pin to low.

Implements Gpio.

Definition at line 64 of file GpioWrapper.hxx.

◆ direction()

template<class PIN >
Direction GpioWrapper< PIN >::direction ( ) const
inlinevirtual

Gets the GPIO direction.

Returns
INPUT or OUTPUT

Implements Gpio.

Definition at line 88 of file GpioWrapper.hxx.

◆ instance()

template<class PIN >
static constexpr const Gpio * GpioWrapper< PIN >::instance ( )
inlinestaticconstexpr
Returns
the static Gpio object instance controlling this pin.

Definition at line 101 of file GpioWrapper.hxx.

◆ read()

template<class PIN >
Value GpioWrapper< PIN >::read ( ) const
inlinevirtual

Retrieves the current Value of a GPIO input pin.

Returns
SET if currently high, CLR if currently low.

Implements Gpio.

Definition at line 69 of file GpioWrapper.hxx.

◆ set()

template<class PIN >
void GpioWrapper< PIN >::set ( ) const
inlinevirtual

Sets the GPIO output pin to high.

Implements Gpio.

Definition at line 59 of file GpioWrapper.hxx.

◆ set_direction()

template<class PIN >
void GpioWrapper< PIN >::set_direction ( Direction  dir) const
inlinevirtual

Sets the GPIO direction.

Parameters
dirINPUT or OUTPUT

Implements Gpio.

Definition at line 74 of file GpioWrapper.hxx.

◆ write()

template<class PIN >
void GpioWrapper< PIN >::write ( Value  new_state) const
inlinevirtual

Writes a GPIO output pin (set or clear to a specific state).

Parameters
new_statethe desired output state. See Value.

Implements Gpio.

Definition at line 54 of file GpioWrapper.hxx.

Member Data Documentation

◆ instance_

template<class PIN >
const GpioWrapper< PIN > GpioWrapper< PIN >::instance_
static

Defines the linker symbol for the wrapped Gpio instance.

Definition at line 106 of file GpioWrapper.hxx.


The documentation for this class was generated from the following file: