BaseGpio adapter for a single PCAL95555 GPIO expander pin.
More...
#include <Pcal95555Handler.h>
|
| | Pcal95555GpioPin (hf_pin_num_t pin, Pcal95555Handler *parent_handler, hf_gpio_direction_t direction=hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT, hf_gpio_active_state_t active_state=hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH, hf_gpio_output_mode_t output_mode=hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL, hf_gpio_pull_mode_t pull_mode=hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING) noexcept |
| | Construct a PCAL95555 GPIO pin wrapper.
|
| |
| | ~Pcal95555GpioPin () noexcept override=default |
| | Default destructor.
|
| |
|
| bool | Initialize () noexcept override |
| | Initialize the pin (configures direction and pull mode on the expander).
|
| |
| bool | Deinitialize () noexcept override |
| | Deinitialize (marks pin as uninitialized; expander state persists).
|
| |
| bool | IsPinAvailable () const noexcept override |
| | Check if this pin number is valid (0-15).
|
| |
| hf_u8_t | GetMaxPins () const noexcept override |
| | Returns 16 (total pins on the expander).
|
| |
| const char * | GetDescription () const noexcept override |
| | Returns a description string like "PCAL95555_PIN_5".
|
| |
| hf_gpio_err_t | SupportsInterrupts () const noexcept override |
| | Check if this pin supports interrupt configuration.
|
| |
| hf_gpio_err_t | ConfigureInterrupt (hf_gpio_interrupt_trigger_t trigger, InterruptCallback callback=nullptr, void *user_data=nullptr) noexcept override |
| | Configure interrupt for this pin.
|
| |
|
These features require PCAL9555A. On PCA9555, they return failure.
|
| hf_gpio_err_t | SetPolarityInversion (bool invert) noexcept |
| | Set input polarity inversion for this pin.
|
| |
| hf_gpio_err_t | SetInterruptMask (bool mask) noexcept |
| | Set the interrupt mask for this pin.
|
| |
| hf_gpio_err_t | GetInterruptStatus (bool &status) noexcept |
| | Get the interrupt status for this pin.
|
| |
|
|
| hf_gpio_err_t | SetDirectionImpl (hf_gpio_direction_t direction) noexcept override |
| | Set pin direction via the PCAL95555 driver.
|
| |
| hf_gpio_err_t | SetOutputModeImpl (hf_gpio_output_mode_t mode) noexcept override |
| | Returns GPIO_ERR_UNSUPPORTED_OPERATION (use Pcal95555Handler::SetOutputMode for per-port control).
|
| |
| hf_gpio_err_t | SetPullModeImpl (hf_gpio_pull_mode_t mode) noexcept override |
| | Set pull mode (floating/up/down). PCAL9555A only.
|
| |
| hf_gpio_pull_mode_t | GetPullModeImpl () const noexcept override |
| | Get current pull mode (tracked internally).
|
| |
| hf_gpio_err_t | SetPinLevelImpl (hf_gpio_level_t level) noexcept override |
| | Write pin level via the PCAL95555 driver.
|
| |
| hf_gpio_err_t | GetPinLevelImpl (hf_gpio_level_t &level) noexcept override |
| | Read pin level via the PCAL95555 driver.
|
| |
| hf_gpio_err_t | GetDirectionImpl (hf_gpio_direction_t &direction) const noexcept override |
| | Get pin direction from the PCAL95555 driver.
|
| |
| hf_gpio_err_t | GetOutputModeImpl (hf_gpio_output_mode_t &mode) const noexcept override |
| | Get output mode (tracked internally).
|
| |
BaseGpio adapter for a single PCAL95555 GPIO expander pin.
Wraps one of the 16 GPIO expander pins (0-15) as a HardFOC BaseGpio instance. All hardware operations delegate to the parent Pcal95555Handler, which in turn calls the typed PCAL95555 driver.
Features:
- Direction (input/output)
- Level read/write
- Pull mode (floating, pull-up, pull-down) – PCAL9555A only
- Output mode (push-pull / open-drain) – PCAL9555A only, per-port granularity
- Polarity inversion
- Interrupt configuration (delegates to handler for centralized management)
- Note
- Pin instances are created via Pcal95555Handler::CreateGpioPin() and stored in the handler's pin registry as shared_ptr.
◆ Pcal95555GpioPin()
| Pcal95555GpioPin::Pcal95555GpioPin |
( |
hf_pin_num_t | pin, |
|
|
Pcal95555Handler * | parent_handler, |
|
|
hf_gpio_direction_t | direction = hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT, |
|
|
hf_gpio_active_state_t | active_state = hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH, |
|
|
hf_gpio_output_mode_t | output_mode = hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL, |
|
|
hf_gpio_pull_mode_t | pull_mode = hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING ) |
|
noexcept |
Construct a PCAL95555 GPIO pin wrapper.
- Parameters
-
| pin | Pin number (0-15). |
| parent_handler | Pointer to the owning handler (must not be null). |
| direction | Initial direction (default: input). |
| active_state | Active polarity (default: active high). |
| output_mode | Output mode (default: push-pull). |
| pull_mode | Pull resistor mode (default: floating). |
◆ ~Pcal95555GpioPin()
| Pcal95555GpioPin::~Pcal95555GpioPin |
( |
| ) |
|
|
overridedefaultnoexcept |
◆ ConfigureInterrupt()
| hf_gpio_err_t Pcal95555GpioPin::ConfigureInterrupt |
( |
hf_gpio_interrupt_trigger_t | trigger, |
|
|
InterruptCallback | callback = nullptr, |
|
|
void * | user_data = nullptr ) |
|
overridenoexcept |
Configure interrupt for this pin.
Delegates to the parent handler's RegisterPinInterrupt() for centralized interrupt management.
- Parameters
-
| trigger | Trigger type (rising, falling, both, none). |
| callback | Function to call when interrupt fires. |
| user_data | User data passed to callback. |
- Returns
- GPIO_SUCCESS or error code.
◆ Deinitialize()
| bool Pcal95555GpioPin::Deinitialize |
( |
| ) |
|
|
overridenoexcept |
Deinitialize (marks pin as uninitialized; expander state persists).
◆ GetDescription()
| const char * Pcal95555GpioPin::GetDescription |
( |
| ) |
const |
|
overridenoexcept |
Returns a description string like "PCAL95555_PIN_5".
◆ GetDirectionImpl()
| hf_gpio_err_t Pcal95555GpioPin::GetDirectionImpl |
( |
hf_gpio_direction_t & | direction | ) |
const |
|
overrideprotectednoexcept |
Get pin direction from the PCAL95555 driver.
◆ GetInterruptStatus()
| hf_gpio_err_t Pcal95555GpioPin::GetInterruptStatus |
( |
bool & | status | ) |
|
|
noexcept |
Get the interrupt status for this pin.
- Parameters
-
| [out] | status | true if this pin has a pending interrupt. |
- Returns
- GPIO_SUCCESS or GPIO_ERR_FAILURE.
◆ GetMaxPins()
| hf_u8_t Pcal95555GpioPin::GetMaxPins |
( |
| ) |
const |
|
inlineoverridenoexcept |
Returns 16 (total pins on the expander).
◆ GetOutputModeImpl()
| hf_gpio_err_t Pcal95555GpioPin::GetOutputModeImpl |
( |
hf_gpio_output_mode_t & | mode | ) |
const |
|
overrideprotectednoexcept |
Get output mode (tracked internally).
◆ GetPinLevelImpl()
| hf_gpio_err_t Pcal95555GpioPin::GetPinLevelImpl |
( |
hf_gpio_level_t & | level | ) |
|
|
overrideprotectednoexcept |
Read pin level via the PCAL95555 driver.
◆ GetPullModeImpl()
| hf_gpio_pull_mode_t Pcal95555GpioPin::GetPullModeImpl |
( |
| ) |
const |
|
overrideprotectednoexcept |
Get current pull mode (tracked internally).
◆ Initialize()
| bool Pcal95555GpioPin::Initialize |
( |
| ) |
|
|
overridenoexcept |
Initialize the pin (configures direction and pull mode on the expander).
◆ IsPinAvailable()
| bool Pcal95555GpioPin::IsPinAvailable |
( |
| ) |
const |
|
overridenoexcept |
Check if this pin number is valid (0-15).
◆ SetDirectionImpl()
| hf_gpio_err_t Pcal95555GpioPin::SetDirectionImpl |
( |
hf_gpio_direction_t | direction | ) |
|
|
overrideprotectednoexcept |
Set pin direction via the PCAL95555 driver.
◆ SetInterruptMask()
| hf_gpio_err_t Pcal95555GpioPin::SetInterruptMask |
( |
bool | mask | ) |
|
|
noexcept |
Set the interrupt mask for this pin.
- Parameters
-
| mask | true to mask (disable) interrupt, false to unmask (enable). |
- Returns
- GPIO_SUCCESS or GPIO_ERR_FAILURE.
◆ SetOutputModeImpl()
| hf_gpio_err_t Pcal95555GpioPin::SetOutputModeImpl |
( |
hf_gpio_output_mode_t | mode | ) |
|
|
overrideprotectednoexcept |
◆ SetPinLevelImpl()
| hf_gpio_err_t Pcal95555GpioPin::SetPinLevelImpl |
( |
hf_gpio_level_t | level | ) |
|
|
overrideprotectednoexcept |
Write pin level via the PCAL95555 driver.
◆ SetPolarityInversion()
| hf_gpio_err_t Pcal95555GpioPin::SetPolarityInversion |
( |
bool | invert | ) |
|
|
noexcept |
Set input polarity inversion for this pin.
- Parameters
-
| invert | true to invert, false for normal polarity. |
- Returns
- GPIO_SUCCESS or GPIO_ERR_FAILURE.
◆ SetPullModeImpl()
| hf_gpio_err_t Pcal95555GpioPin::SetPullModeImpl |
( |
hf_gpio_pull_mode_t | mode | ) |
|
|
overrideprotectednoexcept |
Set pull mode (floating/up/down). PCAL9555A only.
◆ SupportsInterrupts()
| hf_gpio_err_t Pcal95555GpioPin::SupportsInterrupts |
( |
| ) |
const |
|
overridenoexcept |
Check if this pin supports interrupt configuration.
- Returns
- GPIO_SUCCESS only when both:
- the detected chip has Agile I/O (PCAL9555A), and
- a hardware INT pin was provided to the handler. Otherwise returns GPIO_ERR_UNSUPPORTED_OPERATION.
◆ Pcal95555Handler
Allow handler to access pin interrupt data directly.
◆ description_
| char Pcal95555GpioPin::description_[32] = {} |
|
private |
Human-readable description.
◆ interrupt_callback_
| InterruptCallback Pcal95555GpioPin::interrupt_callback_ = nullptr |
|
private |
◆ interrupt_enabled_
| bool Pcal95555GpioPin::interrupt_enabled_ = false |
|
private |
◆ interrupt_trigger_
| hf_gpio_interrupt_trigger_t Pcal95555GpioPin::interrupt_trigger_ |
|
private |
Initial value:=
hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_NONE
◆ interrupt_user_data_
| void* Pcal95555GpioPin::interrupt_user_data_ = nullptr |
|
private |
◆ parent_handler_
Owning handler (not owned).
◆ pin_
| hf_pin_num_t Pcal95555GpioPin::pin_ |
|
private |
The documentation for this class was generated from the following files: