|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
GPIO input-only wrapper with pull configuration and optional IRQ. More...
#include <gpio.hpp>


Classes | |
| struct | Config |
| Configuration structure for input GPIO setup. More... | |
Public Member Functions | |
| GpioIn (uint32_t pin) | |
| Create a GPIO input with default configuration. | |
| GpioIn (uint32_t pin, const Config &config) | |
| Create a GPIO input with the given configuration. | |
| virtual | ~GpioIn () |
| Destructor. | |
| void | EnableIrq (GpioInputEvent events, std::function< void(uint32_t)> handler) |
| Enable GPIO IRQs for the given event set and handler. | |
| void | DisableIrq () |
| Disable any IRQs configured for this input. | |
| void | Configure (const Config &config) |
| Apply a new configuration. | |
| bool | Read () const |
| Read the current GPIO level. | |
| uint32_t | GetPin () const |
| Return the GPIO number. | |
| Config | GetConfig () const |
| Return the cached configuration. | |
| bool | HasHandler () const |
| Return true if an IRQ handler is currently registered. | |
| void | CallIrqHandler (uint32_t events) const |
| Invoke the registered IRQ handler (if any). | |
Public Member Functions inherited from c7222::NonCopyable | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable (NonCopyable &&)=default | |
| NonCopyable & | operator= (NonCopyable &&)=default |
Public Member Functions inherited from c7222::NonMovable | |
| NonMovable (const NonMovable &)=default | |
| NonMovable & | operator= (const NonMovable &)=default |
| NonMovable (NonMovable &&)=delete | |
| NonMovable & | operator= (NonMovable &&)=delete |
Protected Member Functions | |
| void | ApplyConfig () |
| Apply internal configuration to the hardware. | |
Protected Member Functions inherited from c7222::NonCopyableNonMovable | |
| NonCopyableNonMovable ()=default | |
| ~NonCopyableNonMovable ()=default | |
Protected Member Functions inherited from c7222::NonCopyable | |
| NonCopyable ()=default | |
| ~NonCopyable ()=default | |
Protected Member Functions inherited from c7222::NonMovable | |
| NonMovable ()=default | |
| ~NonMovable ()=default | |
Protected Attributes | |
| uint32_t | pin_ |
| GPIO pin number managed by this instance. | |
| Config | config_ |
| Cached configuration used to (re)apply platform settings. | |
GPIO input-only wrapper with pull configuration and optional IRQ.
This class owns an input pin configuration and exposes Read() plus IRQ enable/disable helpers. Only pull mode and input events are configurable.
IRQ behavior:
EnableIrq(events, handler) registers a callback and enables GPIO IRQs on the platform backend.events argument is a bitmask of GpioInputEvent values. Multiple events can be OR-ed together to enable several triggers at once.handler whenever an IRQ fires, so the handler can inspect which edge/level caused the interrupt.Event masking:
GpioInputEvent values are bit flags (LevelLow, LevelHigh, FallingEdge, RisingEdge). The platform maps these directly to the underlying Pico SDK IRQ masks.EnableIrq(GpioInputEvent::FallingEdge | GpioInputEvent::RisingEdge, cb) enables both edges on the same pin.
|
inlineexplicit |
Create a GPIO input with default configuration.
|
explicit |
Create a GPIO input with the given configuration.
| pin | GPIO number. |
| config | Initial configuration. |
|
virtual |
Destructor.
Platform backends may use this to unregister the pin from internal maps.
|
protected |
Apply internal configuration to the hardware.
Implemented by the platform backend.
| void c7222::GpioIn::CallIrqHandler | ( | uint32_t | events | ) | const |
Invoke the registered IRQ handler (if any).
Used by platform IRQ dispatchers.
| void c7222::GpioIn::Configure | ( | const Config & | config | ) |
Apply a new configuration.
| config | New configuration. |
| void c7222::GpioIn::DisableIrq | ( | ) |
Disable any IRQs configured for this input.

| void c7222::GpioIn::EnableIrq | ( | GpioInputEvent | events, |
| std::function< void(uint32_t)> | handler | ||
| ) |
Enable GPIO IRQs for the given event set and handler.
| events | Bitmask of input events to enable. |
| handler | Callback invoked from IRQ context. |

|
inline |
Return the cached configuration.
|
inline |
Return the GPIO number.
|
inline |
Return true if an IRQ handler is currently registered.
| bool c7222::GpioIn::Read | ( | ) | const |
Read the current GPIO level.
|
protected |
Cached configuration used to (re)apply platform settings.
|
protected |
GPIO pin number managed by this instance.