Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Gpio Class Referenceabstract

OS-independent abstraction for GPIO. More...

#include <Gpio.hxx>

Inheritance diagram for Gpio:
CC3200Gpio< GPIO_BASE, GPIO_PIN > Esp32Gpio< PIN_NUM, INVERTED > GpioWrapper< PIN > MCP23017Gpio MCP2515GPI MCP2515GPO MmapGpioTemplate< STORAGE > PWMGPO PersistentGpio SN74HC595GPO< N > TivaGpio< GPIO_BASE, GPIO_PIN > TivaGpio< GPIO_BASE, GPIO_PIN >

Public Types

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...
 

Public Member Functions

constexpr Gpio ()
 Constructor.
 
virtual void write (Value new_state) const =0
 Writes a GPIO output pin (set or clear to a specific state).
 
void write (bool new_state) const
 Writes a GPIO output pin (set or clear to a specific state).
 
virtual Value read () const =0
 Retrieves the current Value of a GPIO input pin.
 
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.
 
virtual void set () const =0
 Sets the GPIO output pin to high.
 
virtual void clr () const =0
 Clears the GPIO output pin to low.
 
virtual void set_direction (Direction dir) const =0
 Sets the GPIO direction.
 
virtual Direction direction () const =0
 Gets the GPIO direction.
 

Detailed Description

OS-independent abstraction for GPIO.

Definition at line 42 of file Gpio.hxx.

Member Enumeration Documentation

◆ Direction

enum class Gpio::Direction
strong

Defines the options for GPIO direction.

This enum must always be used fully qualified (i.e. Gpio::Direction::DINPUT and Gpio::Direction::DOUTPUT).

Definition at line 72 of file Gpio.hxx.

◆ Value

enum Gpio::Value : bool

Defines the options for GPIO level.

Definition at line 61 of file Gpio.hxx.

Constructor & Destructor Documentation

◆ Gpio()

constexpr Gpio::Gpio ( )
inlineconstexpr

Constructor.

It is important that this is constexpr so that the Gpio object instances can be initialized by the data segment and be avalable before constructor calls.

Definition at line 48 of file Gpio.hxx.

Member Function Documentation

◆ clr()

◆ direction()

◆ is_clr()

bool Gpio::is_clr ( ) const
inline

Tests the GPIO input pin to see if it is clear.

Returns
true if input pin is currently low, false if currently high.

Definition at line 113 of file Gpio.hxx.

◆ is_set()

bool Gpio::is_set ( ) const
inline

Tests the GPIO input pin to see if it is set.

Returns
true if input pin is currently high, false if currently low.

Definition at line 105 of file Gpio.hxx.

◆ read()

virtual Value Gpio::read ( ) const
pure virtual

◆ set()

◆ set_direction()

virtual void Gpio::set_direction ( Direction  dir) const
pure virtual

◆ write() [1/2]

void Gpio::write ( bool  new_state) const
inline

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

This is an inline function because this class encapsulates that HIGH==true and LOW==false, thus a direct typecast belongs here and not to customer code.

Parameters
new_statebool representing the desired output state. true == high, false == low.

Definition at line 92 of file Gpio.hxx.

◆ write() [2/2]

virtual void Gpio::write ( Value  new_state) const
pure virtual

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

Parameters
new_statethe desired output state. See Value.

Implemented in GpioWrapper< PIN >, MCP23017Gpio, MCP2515GPO, PersistentGpio, PWMGPO, SN74HC595GPO< N >, Esp32Gpio< PIN_NUM, INVERTED >, CC3200Gpio< GPIO_BASE, GPIO_PIN >, TivaGpio< GPIO_BASE, GPIO_PIN >, and MmapGpioTemplate< STORAGE >.


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