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

BaseGpio adapter for a single PCA9685 channel used as a digital output. More...

#include <Pca9685Handler.h>

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

Public Member Functions

 Pca9685GpioPin (hf_pin_num_t pin, Pca9685Handler *parent_handler, hf_gpio_active_state_t active_state=hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH) noexcept
 Construct a PCA9685 GPIO pin wrapper.
 
 ~Pca9685GpioPin () noexcept override=default
 Default destructor.
 
BaseGpio Interface Implementation
bool Initialize () noexcept override
 Initialize the GPIO pin (sets channel to full-off by default).
 
bool Deinitialize () noexcept override
 Deinitialize (marks as uninitialized; channel state persists).
 
bool IsPinAvailable () const noexcept override
 Check if this channel number is valid (0-15).
 
hf_u8_t GetMaxPins () const noexcept override
 Returns 16 (total channels on the PCA9685).
 
const char * GetDescription () const noexcept override
 Returns a description string like "PCA9685_CH_5".
 

Protected Member Functions

BaseGpio Protected Implementation
hf_gpio_err_t SetDirectionImpl (hf_gpio_direction_t direction) noexcept override
 Set pin direction. Only OUTPUT is supported.
 
hf_gpio_err_t GetDirectionImpl (hf_gpio_direction_t &direction) const noexcept override
 Get direction (always OUTPUT).
 
hf_gpio_err_t SetOutputModeImpl (hf_gpio_output_mode_t mode) noexcept override
 Set output mode. Only push-pull is natively supported (global setting).
 
hf_gpio_err_t GetOutputModeImpl (hf_gpio_output_mode_t &mode) const noexcept override
 Get output mode (tracked internally).
 
hf_gpio_err_t SetPullModeImpl (hf_gpio_pull_mode_t mode) noexcept override
 Not supported – returns GPIO_ERR_UNSUPPORTED_OPERATION.
 
hf_gpio_pull_mode_t GetPullModeImpl () const noexcept override
 Returns FLOATING (no pull resistors on PCA9685).
 
hf_gpio_err_t SetPinLevelImpl (hf_gpio_level_t level) noexcept override
 Write pin level via the PCA9685 driver.
 
hf_gpio_err_t GetPinLevelImpl (hf_gpio_level_t &level) noexcept override
 Read pin level (returns cached state since PCA9685 is output-only).
 

Private Attributes

hf_pin_num_t pin_
 Channel number (0-15).
 
Pca9685Handlerparent_handler_
 Owning handler (not owned).
 
char description_ [32] = {}
 Human-readable description.
 
hf_gpio_level_t cached_level_
 Cached output level.
 

Friends

class Pca9685Handler
 

Detailed Description

BaseGpio adapter for a single PCA9685 channel used as a digital output.

Wraps one of the 16 PCA9685 PWM channels (0-15) as a HardFOC BaseGpio instance. Since the PCA9685 is a PWM output controller (not a GPIO expander), this wrapper operates in output-only mode:

  • HIGH: Sets the channel to full-on (bit 12 of ON register)
  • LOW: Sets the channel to full-off (bit 12 of OFF register)
  • Input: Not supported (PCA9685 cannot read pin states)
  • Pull mode: Not supported
  • Interrupts: Not supported

This is useful for controlling LEDs, relays, or enable pins where simple on/off control is sufficient without PWM.

Note
Pin instances are created via Pca9685Handler::CreateGpioPin() and stored in the handler's pin registry as shared_ptr.

Constructor & Destructor Documentation

◆ Pca9685GpioPin()

Pca9685GpioPin::Pca9685GpioPin ( hf_pin_num_t pin,
Pca9685Handler * parent_handler,
hf_gpio_active_state_t active_state = hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH )
noexcept

Construct a PCA9685 GPIO pin wrapper.

Parameters
pinChannel number (0-15, used as pin number).
parent_handlerPointer to the owning handler (must not be null).
active_stateActive polarity (default: active high).

◆ ~Pca9685GpioPin()

Pca9685GpioPin::~Pca9685GpioPin ( )
overridedefaultnoexcept

Default destructor.

Member Function Documentation

◆ Deinitialize()

bool Pca9685GpioPin::Deinitialize ( )
overridenoexcept

Deinitialize (marks as uninitialized; channel state persists).

◆ GetDescription()

const char * Pca9685GpioPin::GetDescription ( ) const
overridenoexcept

Returns a description string like "PCA9685_CH_5".

◆ GetDirectionImpl()

hf_gpio_err_t Pca9685GpioPin::GetDirectionImpl ( hf_gpio_direction_t & direction) const
overrideprotectednoexcept

Get direction (always OUTPUT).

◆ GetMaxPins()

hf_u8_t Pca9685GpioPin::GetMaxPins ( ) const
inlineoverridenoexcept

Returns 16 (total channels on the PCA9685).

◆ GetOutputModeImpl()

hf_gpio_err_t Pca9685GpioPin::GetOutputModeImpl ( hf_gpio_output_mode_t & mode) const
overrideprotectednoexcept

Get output mode (tracked internally).

◆ GetPinLevelImpl()

hf_gpio_err_t Pca9685GpioPin::GetPinLevelImpl ( hf_gpio_level_t & level)
overrideprotectednoexcept

Read pin level (returns cached state since PCA9685 is output-only).

◆ GetPullModeImpl()

hf_gpio_pull_mode_t Pca9685GpioPin::GetPullModeImpl ( ) const
overrideprotectednoexcept

Returns FLOATING (no pull resistors on PCA9685).

◆ Initialize()

bool Pca9685GpioPin::Initialize ( )
overridenoexcept

Initialize the GPIO pin (sets channel to full-off by default).

Here is the call graph for this function:

◆ IsPinAvailable()

bool Pca9685GpioPin::IsPinAvailable ( ) const
overridenoexcept

Check if this channel number is valid (0-15).

◆ SetDirectionImpl()

hf_gpio_err_t Pca9685GpioPin::SetDirectionImpl ( hf_gpio_direction_t direction)
overrideprotectednoexcept

Set pin direction. Only OUTPUT is supported.

Returns
GPIO_SUCCESS for OUTPUT, GPIO_ERR_UNSUPPORTED_OPERATION for INPUT.

◆ SetOutputModeImpl()

hf_gpio_err_t Pca9685GpioPin::SetOutputModeImpl ( hf_gpio_output_mode_t mode)
overrideprotectednoexcept

Set output mode. Only push-pull is natively supported (global setting).

◆ SetPinLevelImpl()

hf_gpio_err_t Pca9685GpioPin::SetPinLevelImpl ( hf_gpio_level_t level)
overrideprotectednoexcept

Write pin level via the PCA9685 driver.

HIGH = SetChannelFullOn, LOW = SetChannelFullOff.

Here is the call graph for this function:

◆ SetPullModeImpl()

hf_gpio_err_t Pca9685GpioPin::SetPullModeImpl ( hf_gpio_pull_mode_t mode)
overrideprotectednoexcept

Not supported – returns GPIO_ERR_UNSUPPORTED_OPERATION.

Friends And Related Symbol Documentation

◆ Pca9685Handler

friend class Pca9685Handler
friend

Member Data Documentation

◆ cached_level_

hf_gpio_level_t Pca9685GpioPin::cached_level_
private
Initial value:
=
hf_gpio_level_t::HF_GPIO_LEVEL_LOW

Cached output level.

◆ description_

char Pca9685GpioPin::description_[32] = {}
private

Human-readable description.

◆ parent_handler_

Pca9685Handler* Pca9685GpioPin::parent_handler_
private

Owning handler (not owned).

◆ pin_

hf_pin_num_t Pca9685GpioPin::pin_
private

Channel number (0-15).


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