HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
Pcal95555GpioPin Class Reference

BaseGpio adapter for a single PCAL95555 GPIO expander pin. More...

#include <Pcal95555Handler.h>

Inheritance diagram for Pcal95555GpioPin:
[legend]
Collaboration diagram for Pcal95555GpioPin:
[legend]

Public Member Functions

 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.
 
BaseGpio Interface Implementation
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.
 
PCAL9555A Advanced Features

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.
 

Protected Member Functions

BaseGpio Protected Implementation
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).
 

Private Attributes

hf_pin_num_t pin_
 Pin number (0-15).
 
Pcal95555Handlerparent_handler_
 Owning handler (not owned).
 
char description_ [32] = {}
 Human-readable description.
 
Per-Pin Interrupt State
InterruptCallback interrupt_callback_ = nullptr
 
void * interrupt_user_data_ = nullptr
 
hf_gpio_interrupt_trigger_t interrupt_trigger_
 
bool interrupt_enabled_ = false
 

Friends

class Pcal95555Handler
 Allow handler to access pin interrupt data directly.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
pinPin number (0-15).
parent_handlerPointer to the owning handler (must not be null).
directionInitial direction (default: input).
active_stateActive polarity (default: active high).
output_modeOutput mode (default: push-pull).
pull_modePull resistor mode (default: floating).

◆ ~Pcal95555GpioPin()

Pcal95555GpioPin::~Pcal95555GpioPin ( )
overridedefaultnoexcept

Default destructor.

Member Function Documentation

◆ 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
triggerTrigger type (rising, falling, both, none).
callbackFunction to call when interrupt fires.
user_dataUser data passed to callback.
Returns
GPIO_SUCCESS or error code.
Here is the call graph for this function:

◆ 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]statustrue 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).

Here is the call graph for this function:

◆ Initialize()

bool Pcal95555GpioPin::Initialize ( )
overridenoexcept

Initialize the pin (configures direction and pull mode on the expander).

Here is the call graph for this function:

◆ 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
masktrue 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

Returns GPIO_ERR_UNSUPPORTED_OPERATION (use Pcal95555Handler::SetOutputMode for per-port control).

◆ 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
inverttrue 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.
Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ Pcal95555Handler

friend class Pcal95555Handler
friend

Allow handler to access pin interrupt data directly.

Member Data Documentation

◆ 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_

Pcal95555Handler* Pcal95555GpioPin::parent_handler_
private

Owning handler (not owned).

◆ pin_

hf_pin_num_t Pcal95555GpioPin::pin_
private

Pin number (0-15).


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