BaseGpio adapter for a single PCA9685 channel used as a digital output.
More...
#include <Pca9685Handler.h>
|
| | 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.
|
| |
|
| 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".
|
| |
|
|
| 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).
|
| |
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.
◆ 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
-
| pin | Channel number (0-15, used as pin number). |
| parent_handler | Pointer to the owning handler (must not be null). |
| active_state | Active polarity (default: active high). |
◆ ~Pca9685GpioPin()
| Pca9685GpioPin::~Pca9685GpioPin |
( |
| ) |
|
|
overridedefaultnoexcept |
◆ 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).
◆ 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.
◆ SetPullModeImpl()
| hf_gpio_err_t Pca9685GpioPin::SetPullModeImpl |
( |
hf_gpio_pull_mode_t | mode | ) |
|
|
overrideprotectednoexcept |
Not supported – returns GPIO_ERR_UNSUPPORTED_OPERATION.
◆ Pca9685Handler
◆ 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_
Owning handler (not owned).
◆ pin_
| hf_pin_num_t Pca9685GpioPin::pin_ |
|
private |
The documentation for this class was generated from the following files: