Zephyr C++ Toolkit
Loading...
Searching...
No Matches
zct::IGpio Class Referenceabstract

#include <IGpio.hpp>

Inheritance diagram for zct::IGpio:

Public Types

enum class  Direction { Input , Output }
 
enum class  LogicMode { ActiveHigh , ActiveLow }
 
enum class  PullMode { None , PullUp , PullDown }
 
enum class  InterruptMode {
  Disable , EdgeRising , EdgeFalling , EdgeBoth ,
  LevelLow , LevelHigh , LevelToInactive , LevelToActive ,
  LevelInactive , LevelActive
}
 

Public Member Functions

 IGpio (const char *name, Direction direction=Direction::Input, LogicMode logicMode=LogicMode::ActiveHigh, PullMode pullMode=PullMode::None)
 Create a new GPIO.
 
virtual ~IGpio ()=default
 Destroy the GPIO.
 
virtual void set (bool value)
 
virtual bool get () const
 
virtual void setPhysical (bool value)=0
 
virtual bool getPhysical () const =0
 
virtual void setDirection (Direction direction)
 
virtual void setLogicMode (LogicMode logicMode)
 
virtual void configureInterrupt (InterruptMode interruptMode, std::function< void()> callback)=0
 
virtual void setPullMode (PullMode pullMode)
 

Protected Member Functions

virtual void configurePinBasedOnSettings ()=0
 

Protected Attributes

const charm_name
 
Direction m_direction
 
LogicMode m_logicMode
 
PullMode m_pullMode
 
InterruptMode m_interruptMode
 
std::function< void()> m_interruptUserCallback
 

Detailed Description

Member Enumeration Documentation

◆ Direction

Enumerator
Input 
Output 

◆ InterruptMode

Enumerates the possible interrupt modes of a GPIO.

Enumerator
Disable 
EdgeRising 
EdgeFalling 
EdgeBoth 
LevelLow 
LevelHigh 
LevelToInactive 
LevelToActive 
LevelInactive 
LevelActive 

◆ LogicMode

Enumerates the possible logic modes of a GPIO.

  • Active high means that true is equal to a high voltage, false is 0V.
  • Active low means that true is equal to 0V, false is high voltage.
Enumerator
ActiveHigh 
ActiveLow 

◆ PullMode

Enumerator
None 
PullUp 
PullDown 

Constructor & Destructor Documentation

◆ IGpio()

zct::IGpio::IGpio ( const char name,
Direction  direction = Direction::Input,
LogicMode  logicMode = LogicMode::ActiveHigh,
PullMode  pullMode = PullMode::None 
)

Create a new GPIO.

Parameters
nameThe name of the GPIO. Used for logging purposes.
directionThe direction of the GPIO.
logicModeThe logic mode of the GPIO.

◆ ~IGpio()

virtual zct::IGpio::~IGpio ( )
virtualdefault

Destroy the GPIO.

Member Function Documentation

◆ configureInterrupt()

virtual void zct::IGpio::configureInterrupt ( InterruptMode  interruptMode,
std::function< void()>  callback 
)
pure virtual

Configure an interrupt on the GPIO.

Parameters
interruptModeThe interrupt mode to set.
callbackThe callback to call when the interrupt occurs.

Implemented in zct::GpioMock, and zct::GpioReal.

Examples
/examples/IntegrationTest/src/App.cpp.

◆ configurePinBasedOnSettings()

virtual void zct::IGpio::configurePinBasedOnSettings ( )
protectedpure virtual

Configure the pin based on the current settings. The real GPIO will call the Zephyr gpio_pin_configure_dt() function. The mock GPIO will do nothing.

Implemented in zct::GpioMock, and zct::GpioReal.

◆ get()

bool zct::IGpio::get ( ) const
virtual

Get the logical value of the GPIO.

Can be called on an output or input GPIO.

Returns
The logical value of the GPIO.

◆ getPhysical()

virtual bool zct::IGpio::getPhysical ( ) const
pure virtual

Get the physical value of the GPIO.

This ignores the logic mode of the GPIO and returns the physical value directly.

Returns
The physical value of the GPIO.

Implemented in zct::GpioMock, and zct::GpioReal.

◆ set()

void zct::IGpio::set ( bool  value)
virtual

Set the logical value of the GPIO.

Will assert if the GPIO is not configured as an output.

Parameters
valueThe logical value to set.
Examples
/examples/IntegrationTest/src/App.cpp.

◆ setDirection()

void zct::IGpio::setDirection ( Direction  direction)
virtual

Set the direction of the GPIO.

Parameters
directionThe direction to set.
Examples
/examples/IntegrationTest/src/App.cpp.

◆ setLogicMode()

void zct::IGpio::setLogicMode ( LogicMode  logicMode)
virtual

Set the logic mode of the GPIO.

Parameters
logicModeThe logic mode to set.

Reimplemented in zct::GpioMock.

◆ setPhysical()

virtual void zct::IGpio::setPhysical ( bool  value)
pure virtual

Set the physical value of the GPIO.

This ignores the logic mode of the GPIO and sets the physical value directly.

Parameters
valueThe physical value to set.

Implemented in zct::GpioMock, and zct::GpioReal.

◆ setPullMode()

void zct::IGpio::setPullMode ( PullMode  pullMode)
virtual

Set the pull mode of the GPIO.

Parameters
pullModeThe pull mode to set.

Member Data Documentation

◆ m_direction

Direction zct::IGpio::m_direction
protected

◆ m_interruptMode

InterruptMode zct::IGpio::m_interruptMode
protected

◆ m_interruptUserCallback

std::function<void()> zct::IGpio::m_interruptUserCallback
protected

◆ m_logicMode

LogicMode zct::IGpio::m_logicMode
protected

◆ m_name

const char* zct::IGpio::m_name
protected

◆ m_pullMode

PullMode zct::IGpio::m_pullMode
protected

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