Zephyr C++ Toolkit
|
#include <GpioReal.hpp>
Public Member Functions | |
GpioReal (const char *name, const struct gpio_dt_spec *spec, Direction direction=Direction::Input, LogicMode logicMode=LogicMode::ActiveHigh) | |
Create a new real GPIO pin. | |
~GpioReal () | |
Destroy the GPIO. Does nothing. | |
void | setPhysical (bool value) override |
bool | getPhysical () const override |
void | configureInterrupt (InterruptMode interruptMode, std::function< void()> callback) override |
![]() | |
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 | setDirection (Direction direction) |
virtual void | setLogicMode (LogicMode logicMode) |
virtual void | setPullMode (PullMode pullMode) |
Protected Member Functions | |
void | configurePinBasedOnSettings () override |
Static Protected Member Functions | |
static void | interruptCallback (const struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pins) |
Protected Attributes | |
const struct gpio_dt_spec * | m_spec |
GpioCallbackDataAndObject | m_gpioCallbackDataAndObject |
![]() | |
const char * | m_name |
Direction | m_direction |
LogicMode | m_logicMode |
PullMode | m_pullMode |
InterruptMode | m_interruptMode |
std::function< void()> | m_interruptUserCallback |
Additional Inherited Members | |
![]() | |
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 } |
Implements a real Zephyr GPIO pin. Implements the IGpio interface.
Create these in your real application code.
zct::GpioReal::GpioReal | ( | const char * | name, |
const struct gpio_dt_spec * | spec, | ||
Direction | direction = Direction::Input , |
||
LogicMode | logicMode = LogicMode::ActiveHigh |
||
) |
Create a new real GPIO pin.
name | The name of the GPIO. Used for logging purposes. |
spec | The Zephyr GPIO DT spec struct. |
direction | The direction of the GPIO. |
logicMode | The logic mode of the GPIO. LogicMode::ActiveHigh is the default (0V is inactive, +VCC is active). |
zct::GpioReal::~GpioReal | ( | ) |
Destroy the GPIO. Does nothing.
|
overridevirtual |
Configure an interrupt on the GPIO.
interruptMode | The interrupt mode to set. |
callback | The callback to call when the interrupt occurs. This will be called in a interrupt context. |
Implements zct::IGpio.
|
overrideprotectedvirtual |
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.
Implements zct::IGpio.
|
overridevirtual |
Get the physical value of the GPIO.
This ignores the logic mode of the GPIO and returns the physical value directly.
Implements zct::IGpio.
|
staticprotected |
Static callback handler function which has the correct signature so that it can be passed to Zephyr's gpio_init_callback() function.
This in turn calls the user provided callback function in configureInterrupt().
dev | The device that triggered the interrupt. |
cb | The callback structure. |
pins | The pins that triggered the interrupt. |
Set the physical value of the GPIO.
This ignores the logic mode of the GPIO and sets the physical value directly.
value | The physical value to set. |
Implements zct::IGpio.
|
protected |
Structure for holding callback info, if used.
Needs to be a pointer to a member of the class.
|
protected |
The Zephyr GPIO DT spec struct.