Embedded Artistry Framework
Embedded Systems C++ Framework
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
embvm::gpio::inputOutput< TPull > Class Template Referenceabstract

This class defines a GPIO input/output interface. More...

#include <gpio.hpp>

Inheritance diagram for embvm::gpio::inputOutput< TPull >:
Inheritance graph

Public Member Functions

virtual void set (bool v) noexcept=0
 Set the current GPIO pin state. More...
 
virtual bool get () noexcept=0
 Get the current GPIO pin state. More...
 
gpio::pull pull () const noexcept
 Get the current pull configuration. More...
 
gpio::direction direction () const noexcept
 Check the direction of the GPIO pin. More...
 
void start () noexcept
 Start the driver. More...
 
void stop () noexcept
 Stop the driver. More...
 
void restart () noexcept
 Restart the driver. More...
 
type_safe::boolean started () const noexcept
 Check if the driver has been started. More...
 
constexpr embvm::DriverType_t DriverType () const noexcept
 Returns the registered type ID of the driver. More...
 
constexpr const std::string_view & name () const noexcept
 Provides a string_view reference of the driver name. More...
 
constexpr const char * name_cstr () const noexcept
 Provides a c-string version of the driver name. More...
 
virtual DriverBaseoperator++ () noexcept
 Increment operator is a no-op, but is used for iterator compatibility. More...
 

Static Public Member Functions

static constexpr embvm::DriverType type () noexcept
 GPIO Driver Type ID. More...
 

Protected Member Functions

 inputOutput () noexcept
 Default constructor. More...
 
 inputOutput (const char *name) noexcept
 Construct an gpio::inputOutput with a C-string name. More...
 
 inputOutput (const std::string &name) noexcept
 Construct an gpio::inputOutput with a std::string name. More...
 
 inputOutput (const std::string_view &name) noexcept
 Construct an gpio::inputOutput with a std::string_view name. More...
 
virtual gpio::pull pull_ (gpio::pull p) noexcept=0
 Set the pull configuration in hardware. More...
 
 ~inputOutput () noexcept override=default
 Default destructor. More...
 
void start_ () noexcept override=0
 Derived classes override the start_ method to control driver-specific startup behavior. More...
 
void stop_ () noexcept override=0
 Derived classes override the start_ method to control driver-specific startup behavior. More...
 

Protected Attributes

type_safe::boolean started_ = false
 Tracks the driver state. More...
 
const std::string_view name_
 Name of the driver instance. More...
 
const embvm::DriverType_t type_
 Type ID of the driver instance. More...
 

Private Types

using gpio_base = base< gpio::direction::inout >
 Convenience alias for the associated gpio::base definition. More...
 

Detailed Description

template<gpio::pull TPull = gpio::pull::none>
class embvm::gpio::inputOutput< TPull >

This class defines a GPIO input/output interface.

The gpio::inputOutput class defines interfaces which are common to all GPIO input/output objects.

To implement a GPIO input/output driver, derive from this class:

template<uint8_t TPinID, gpio::pull TPull = gpio::pull::none>
class aardvarkGPIOinputOutput final : public gpio::inputOutput<TPull>
{...};

Derived classes must implement the following functions:

Derived class start_() must call the pull_() function to set the pull-up/pull-down appropriately.

Derived classes must implement pure virtual embvm::DriverBase functions:

Template Parameters
TPullThe pull setting for the GPIO pin.

Member Typedef Documentation

◆ gpio_base

template<gpio::pull TPull = gpio::pull::none>
using embvm::gpio::inputOutput< TPull >::gpio_base = base<gpio::direction::inout>
private

Convenience alias for the associated gpio::base definition.

Constructor & Destructor Documentation

◆ inputOutput() [1/4]

template<gpio::pull TPull = gpio::pull::none>
embvm::gpio::inputOutput< TPull >::inputOutput ( )
inlineprotectednoexcept

Default constructor.

Initializes the gpio::inputOutput instance with a generic name.

◆ inputOutput() [2/4]

template<gpio::pull TPull = gpio::pull::none>
embvm::gpio::inputOutput< TPull >::inputOutput ( const char *  name)
inlineexplicitprotectednoexcept

Construct an gpio::inputOutput with a C-string name.

Initializes the gpio::inputOutput instance with a name.

Parameters
nameThe name of the GPIO instance.

◆ inputOutput() [3/4]

template<gpio::pull TPull = gpio::pull::none>
embvm::gpio::inputOutput< TPull >::inputOutput ( const std::string &  name)
inlineexplicitprotectednoexcept

Construct an gpio::inputOutput with a std::string name.

Initializes the gpio::inputOutput instance with a name.

Parameters
nameThe name of the GPIO instance. gpio::inputOutput() uses a std::string_view, so the std::string must remain valid

◆ inputOutput() [4/4]

template<gpio::pull TPull = gpio::pull::none>
embvm::gpio::inputOutput< TPull >::inputOutput ( const std::string_view &  name)
inlineexplicitprotectednoexcept

Construct an gpio::inputOutput with a std::string_view name.

Initializes the gpio::inputOutput instance with a name.

Parameters
nameThe name of the GPIO instance.

◆ ~inputOutput()

template<gpio::pull TPull = gpio::pull::none>
embvm::gpio::inputOutput< TPull >::~inputOutput ( )
overrideprotecteddefaultnoexcept

Default destructor.

Member Function Documentation

◆ direction()

gpio::direction embvm::gpio::base< TDir >::direction ( ) const
inlinenoexceptinherited

Check the direction of the GPIO pin.

Returns
The configured direction of this GPIO pin.

◆ DriverType()

constexpr embvm::DriverType_t embvm::DriverBase::DriverType ( ) const
inlinenoexceptinherited

Returns the registered type ID of the driver.

When using DriverBase interfaces, clients can retrieve the registered driver type in order to up-cast to the correct interface.

The type is returned as a embvm::DriverType_t rather than a embvm::DriverType enum to work with custom user-defined types. Enforcing a embvm::DriverType return value would prevent clients from defining and using their own custom types.

Returns
the registered driver type as a embvm::DriverType_t value

References embvm::DriverBase::type_.

◆ get()

template<gpio::pull TPull = gpio::pull::none>
virtual bool embvm::gpio::inputOutput< TPull >::get ( )
pure virtualnoexcept

Get the current GPIO pin state.

Derived classes must implement the get() function.

Returns
true if the GPIO is set (logic 1), false otherwise (logic 0).

◆ name()

constexpr const std::string_view& embvm::DriverBase::name ( ) const
inlinenoexceptinherited

Provides a string_view reference of the driver name.

Returns
std::string_view ref containing the driver name.

References embvm::DriverBase::name_.

◆ name_cstr()

constexpr const char* embvm::DriverBase::name_cstr ( ) const
inlinenoexceptinherited

Provides a c-string version of the driver name.

Returns
c-string containing the driver name

References embvm::DriverBase::name_.

◆ operator++()

virtual DriverBase& embvm::DriverBase::operator++ ( )
inlinevirtualnoexceptinherited

Increment operator is a no-op, but is used for iterator compatibility.

◆ pull()

template<gpio::pull TPull = gpio::pull::none>
gpio::pull embvm::gpio::inputOutput< TPull >::pull ( ) const
inlinenoexcept

Get the current pull configuration.

Returns
The currently configured GPIO pull setting.

◆ pull_()

template<gpio::pull TPull = gpio::pull::none>
virtual gpio::pull embvm::gpio::inputOutput< TPull >::pull_ ( gpio::pull  p)
protectedpure virtualnoexcept

Set the pull configuration in hardware.

Derived classes must implement the pull_() function.

Returns
The currently configured GPIO pull setting.

◆ restart()

void embvm::DriverBase::restart ( )
inlinenoexceptinherited

Restart the driver.

Calls stop() and then start() on the driver. If the driver is not started, then it will be started after the start() function is invoked.

References embvm::DriverBase::start(), and embvm::DriverBase::stop().

◆ set()

template<gpio::pull TPull = gpio::pull::none>
virtual void embvm::gpio::inputOutput< TPull >::set ( bool  v)
pure virtualnoexcept

Set the current GPIO pin state.

Derived classes must implement the set() function.

Parameters
vThe desired GPIO state. True for logic 1, false for logic 0.

◆ start()

void embvm::DriverBase::start ( )
inlinenoexceptinherited

◆ start_()

template<gpio::pull TPull = gpio::pull::none>
void embvm::gpio::inputOutput< TPull >::start_ ( )
overrideprotectedpure virtualnoexcept

Derived classes override the start_ method to control driver-specific startup behavior.

(Template Method Pattern)

Implements embvm::gpio::base< gpio::direction::inout >.

◆ started()

type_safe::boolean embvm::DriverBase::started ( ) const
inlinenoexceptinherited

Check if the driver has been started.

Returns
true if the driver is running (started), false if not running (stopped).

References embvm::DriverBase::started_.

Referenced by embdrv::aardvarkSPIMaster::configure_(), embdrv::aardvarkGPIOInput< 4 >::get(), embdrv::aardvarkGPIOOutput< 5 >::set(), embdrv::vl53l1x::start_(), embdrv::aardvarkAdapter::start_(), and embdrv::aardvarkAdapter::stop_().

◆ stop()

void embvm::DriverBase::stop ( )
inlinenoexceptinherited

◆ stop_()

template<gpio::pull TPull = gpio::pull::none>
void embvm::gpio::inputOutput< TPull >::stop_ ( )
overrideprotectedpure virtualnoexcept

Derived classes override the start_ method to control driver-specific startup behavior.

(Template Method Pattern)

Implements embvm::gpio::base< gpio::direction::inout >.

◆ type()

static constexpr embvm::DriverType embvm::gpio::base< TDir >::type ( )
inlinestaticnoexceptinherited

GPIO Driver Type ID.

Returns
GPIO type ID.

Member Data Documentation

◆ name_

const std::string_view embvm::DriverBase::name_
protectedinherited

Name of the driver instance.

Referenced by embvm::DriverBase::name(), and embvm::DriverBase::name_cstr().

◆ started_

type_safe::boolean embvm::DriverBase::started_ = false
protectedinherited

Tracks the driver state.

True if the driver has been started, false if it has been stopped or not yet started.

Referenced by embvm::DriverBase::start(), embvm::DriverBase::started(), and embvm::DriverBase::stop().

◆ type_

const embvm::DriverType_t embvm::DriverBase::type_
protectedinherited

Type ID of the driver instance.

Referenced by embvm::DriverBase::DriverType().


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