47#ifndef ELEC_C7222_DEVICES_GPIO_H_
48#define ELEC_C7222_DEVICES_GPIO_H_
GPIO input-only wrapper with pull configuration and optional IRQ.
Definition gpio.hpp:129
bool Read() const
Read the current GPIO level.
void EnableIrq(GpioInputEvent events, std::function< void(uint32_t)> handler)
Enable GPIO IRQs for the given event set and handler.
void CallIrqHandler(uint32_t events) const
Invoke the registered IRQ handler (if any).
GpioIn(uint32_t pin, const Config &config)
Create a GPIO input with the given configuration.
void ApplyConfig()
Apply internal configuration to the hardware.
uint32_t GetPin() const
Return the GPIO number.
Definition gpio.hpp:199
bool HasHandler() const
Return true if an IRQ handler is currently registered.
Definition gpio.hpp:212
Config config_
Cached configuration used to (re)apply platform settings.
Definition gpio.hpp:234
void DisableIrq()
Disable any IRQs configured for this input.
void Configure(const Config &config)
Apply a new configuration.
virtual ~GpioIn()
Destructor.
Config GetConfig() const
Return the cached configuration.
Definition gpio.hpp:205
GpioIn(uint32_t pin)
Create a GPIO input with default configuration.
Definition gpio.hpp:157
uint32_t pin_
GPIO pin number managed by this instance.
Definition gpio.hpp:232
GPIO output-only wrapper with output configuration and drive strength.
Definition gpio.hpp:245
void ApplyConfig()
Apply internal configuration to the hardware.
GpioOut(uint32_t pin)
Create a GPIO output with default configuration.
Definition gpio.hpp:274
uint32_t pin_
GPIO pin number managed by this instance.
Definition gpio.hpp:326
Config config_
Cached configuration used to (re)apply platform settings.
Definition gpio.hpp:328
virtual ~GpioOut()
Destructor.
void Write(bool value)
Write an output value.
void Configure(const Config &config)
Apply a new configuration.
void Toggle()
Toggle the pin output.
Config GetConfig() const
Return the cached configuration.
Definition gpio.hpp:313
GpioOut(uint32_t pin, const Config &config)
Create a GPIO output with the given configuration.
uint32_t GetPin() const
Return the GPIO number.
Definition gpio.hpp:307
Disable both copy and move operations.
Definition non_copyable.hpp:75
C7222 course abstractions namespace.
Definition ble.hpp:20
GpioPullMode
GPIO pull configuration.
Definition gpio.hpp:65
@ PullDown
Enable pull-down.
GpioDriveStrength
GPIO drive strength.
Definition gpio.hpp:83
GpioInputEvent
GPIO input event bitmask for IRQ configuration.
Definition gpio.hpp:96
@ LevelLow
Trigger on low level.
@ RisingEdge
Trigger on low-to-high edge.
@ FallingEdge
Trigger on high-to-low edge.
@ All
Trigger on all level and edge events.
@ BothEdges
Trigger on rising or falling edge.
@ BothLevels
Trigger on low or high level.
@ LevelHigh
Trigger on high level.
GpioOutputType
GPIO output type.
Definition gpio.hpp:74
@ HighZ
High-impedance (not driven).
@ OpenDrain
Drive low or float.
@ PushPull
Drive high/low actively.
Base classes to control copy/move semantics.
Configuration structure for input GPIO setup.
Definition gpio.hpp:134
bool operator==(const Config &other) const
GpioInputEvent input_events
Input events to trigger IRQ (default: None).
Definition gpio.hpp:137
bool Validate() const
Validate configuration for basic constraints.
Config(uint32_t pin)
Create config with a pin number.
GpioPullMode pull
Pull mode (default: None).
Definition gpio.hpp:136
uint32_t pin_
GPIO pin number (non-negative integer).
Definition gpio.hpp:135
std::function< void(uint32_t)> irq_handler
Optional IRQ handler callback. The function argument is bit field of events that triggered the IRQ.
Definition gpio.hpp:138
Configuration structure for output GPIO setup.
Definition gpio.hpp:250
bool initial_state
Initial logic state when configured as output.
Definition gpio.hpp:255
GpioDriveStrength drive
Drive strength (default: 4 mA).
Definition gpio.hpp:254
uint32_t pin_
GPIO pin number (non-negative integer).
Definition gpio.hpp:251
GpioOutputType output_type
Output type (default: PushPull).
Definition gpio.hpp:253
bool operator==(const Config &other) const
bool Validate() const
Validate configuration for basic constraints.
GpioPullMode pull
Pull mode (default: None).
Definition gpio.hpp:252
Config(uint32_t pin)
Create config with a pin number.