HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
Pcal95555Handler.h
Go to the documentation of this file.
1
82#ifndef COMPONENT_HANDLER_PCAL95555_HANDLER_H_
83#define COMPONENT_HANDLER_PCAL95555_HANDLER_H_
84
85#include <atomic>
86#include <cstdint>
87#include <memory>
88#include <array>
89#include <functional>
90#include "base/BaseGpio.h"
91#include "base/BaseI2c.h"
92#include "core/hf-core-drivers/external/hf-pcal95555-driver/inc/pcal95555.hpp"
93#include "RtosMutex.h"
94
95// Forward declarations
97
103
126class HalI2cPcal95555Comm : public pcal95555::I2cInterface<HalI2cPcal95555Comm> {
127public:
133 explicit HalI2cPcal95555Comm(BaseI2c& i2c_device) noexcept;
134
138
151 bool Write(uint8_t addr, uint8_t reg, const uint8_t* data, size_t len) noexcept;
152
164 bool Read(uint8_t addr, uint8_t reg, uint8_t* data, size_t len) noexcept;
165
170 bool EnsureInitialized() noexcept;
171
182 bool RegisterInterruptHandler(std::function<void()> handler) noexcept;
183
185
190 const std::function<void()>& GetInterruptHandler() const noexcept { return interrupt_handler_; }
191
192private:
193 BaseI2c& i2c_device_;
194 mutable RtosMutex i2c_mutex_;
195 std::function<void()> interrupt_handler_;
196};
197
199
205
226class Pcal95555GpioPin : public BaseGpio {
227public:
237 Pcal95555GpioPin(hf_pin_num_t pin,
238 Pcal95555Handler* parent_handler,
239 hf_gpio_direction_t direction = hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT,
240 hf_gpio_active_state_t active_state = hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH,
241 hf_gpio_output_mode_t output_mode = hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL,
242 hf_gpio_pull_mode_t pull_mode = hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING) noexcept;
243
245 ~Pcal95555GpioPin() noexcept override = default;
246
249
251 bool Initialize() noexcept override;
252
254 bool Deinitialize() noexcept override;
255
257 bool IsPinAvailable() const noexcept override;
258
260 hf_u8_t GetMaxPins() const noexcept override { return 16; }
261
263 const char* GetDescription() const noexcept override;
264
272 hf_gpio_err_t SupportsInterrupts() const noexcept override;
273
285 hf_gpio_err_t ConfigureInterrupt(hf_gpio_interrupt_trigger_t trigger,
286 InterruptCallback callback = nullptr,
287 void* user_data = nullptr) noexcept override;
288
290
294
300 hf_gpio_err_t SetPolarityInversion(bool invert) noexcept;
301
307 hf_gpio_err_t SetInterruptMask(bool mask) noexcept;
308
310 using BaseGpio::GetInterruptStatus;
311
317 hf_gpio_err_t GetInterruptStatus(bool& status) noexcept;
318
320
321protected:
324
326 hf_gpio_err_t SetDirectionImpl(hf_gpio_direction_t direction) noexcept override;
327
329 hf_gpio_err_t SetOutputModeImpl(hf_gpio_output_mode_t mode) noexcept override;
330
332 hf_gpio_err_t SetPullModeImpl(hf_gpio_pull_mode_t mode) noexcept override;
333
335 hf_gpio_pull_mode_t GetPullModeImpl() const noexcept override;
336
338 hf_gpio_err_t SetPinLevelImpl(hf_gpio_level_t level) noexcept override;
339
341 hf_gpio_err_t GetPinLevelImpl(hf_gpio_level_t& level) noexcept override;
342
344 hf_gpio_err_t GetDirectionImpl(hf_gpio_direction_t& direction) const noexcept override;
345
347 hf_gpio_err_t GetOutputModeImpl(hf_gpio_output_mode_t& mode) const noexcept override;
348
350
352 friend class Pcal95555Handler;
353
354private:
355 hf_pin_num_t pin_;
357 char description_[32] = {};
358
361 InterruptCallback interrupt_callback_ = nullptr;
362 void* interrupt_user_data_ = nullptr;
363 hf_gpio_interrupt_trigger_t interrupt_trigger_ =
364 hf_gpio_interrupt_trigger_t::HF_GPIO_INTERRUPT_TRIGGER_NONE;
365 bool interrupt_enabled_ = false;
367};
368
370
376
411public:
412 //==========================================================================
415 //==========================================================================
416
418 using Pcal95555Driver = pcal95555::PCAL95555<HalI2cPcal95555Comm>;
419
421
422 //==========================================================================
425 //==========================================================================
426
438 explicit Pcal95555Handler(BaseI2c& i2c_device, BaseGpio* interrupt_pin = nullptr) noexcept;
439
441 ~Pcal95555Handler() noexcept = default;
442
446 Pcal95555Handler& operator=(const Pcal95555Handler&) = delete;
447
451 Pcal95555Handler& operator=(Pcal95555Handler&&) = delete;
452
454
455 //==========================================================================
458 //==========================================================================
459
469 bool EnsureInitialized() noexcept;
470
479 bool EnsureDeinitialized() noexcept;
480
485 bool IsInitialized() const noexcept { return initialized_; }
486
488
489 //==========================================================================
493 //==========================================================================
494
501 hf_gpio_err_t SetDirection(uint8_t pin, hf_gpio_direction_t direction) noexcept;
502
509 hf_gpio_err_t SetOutput(uint8_t pin, bool active) noexcept;
510
517 hf_gpio_err_t ReadInput(uint8_t pin, bool& active) noexcept;
518
524 hf_gpio_err_t Toggle(uint8_t pin) noexcept;
525
540 hf_gpio_err_t SetPullMode(uint8_t pin, hf_gpio_pull_mode_t pull_mode) noexcept;
541
548 hf_gpio_err_t GetPullMode(uint8_t pin, hf_gpio_pull_mode_t& pull_mode) noexcept;
549
551
552 //==========================================================================
556 //==========================================================================
557
564 hf_gpio_err_t SetDirections(uint16_t pin_mask, hf_gpio_direction_t direction) noexcept;
565
572 hf_gpio_err_t SetOutputs(uint16_t pin_mask, bool active) noexcept;
573
581 hf_gpio_err_t SetPullModes(uint16_t pin_mask, hf_gpio_pull_mode_t pull_mode) noexcept;
582
584
585 //==========================================================================
588 //==========================================================================
589
594 bool HasInterruptSupport() const noexcept { return interrupt_pin_ != nullptr; }
595
600 bool IsInterruptConfigured() const noexcept { return interrupt_configured_; }
601
611 bool DrainPendingInterrupts() noexcept;
612
619 hf_gpio_err_t GetAllInterruptMasks(uint16_t& mask) noexcept;
620
630 hf_gpio_err_t GetAllInterruptStatus(uint16_t& status) noexcept;
631
633
634 //==========================================================================
638 //==========================================================================
639
641 static constexpr uint8_t PinCount() noexcept { return 16; }
642
647 uint8_t GetI2cAddress() const noexcept;
648
664 std::shared_ptr<BaseGpio> CreateGpioPin(
665 hf_pin_num_t pin,
666 hf_gpio_direction_t direction = hf_gpio_direction_t::HF_GPIO_DIRECTION_INPUT,
667 hf_gpio_active_state_t active_state = hf_gpio_active_state_t::HF_GPIO_ACTIVE_HIGH,
668 hf_gpio_output_mode_t output_mode = hf_gpio_output_mode_t::HF_GPIO_OUTPUT_MODE_PUSH_PULL,
669 hf_gpio_pull_mode_t pull_mode = hf_gpio_pull_mode_t::HF_GPIO_PULL_MODE_FLOATING,
670 bool allow_existing = true) noexcept;
671
677 std::shared_ptr<BaseGpio> GetGpioPin(hf_pin_num_t pin) noexcept;
678
684 bool IsPinCreated(hf_pin_num_t pin) const noexcept;
685
690 uint16_t GetCreatedPinMask() const noexcept;
691
693
694 //==========================================================================
698 //==========================================================================
699
705 bool HasAgileIO() const noexcept;
706
711 pcal95555::ChipVariant GetChipVariant() const noexcept;
712
719 hf_gpio_err_t SetPolarityInversion(hf_pin_num_t pin, bool invert) noexcept;
720
728 hf_gpio_err_t SetInterruptMask(hf_pin_num_t pin, bool mask) noexcept;
729
737 hf_gpio_err_t GetInterruptStatus(hf_pin_num_t pin, bool& status) noexcept;
738
746 hf_gpio_err_t SetDriveStrength(hf_pin_num_t pin, DriveStrength level) noexcept;
747
755 hf_gpio_err_t EnableInputLatch(hf_pin_num_t pin, bool enable) noexcept;
756
764 hf_gpio_err_t SetOutputMode(bool port0_open_drain, bool port1_open_drain) noexcept;
765
770 hf_gpio_err_t ResetToDefault() noexcept;
771
773
774 //==========================================================================
777 //==========================================================================
778
783 uint16_t GetErrorFlags() const noexcept;
784
789 void ClearErrorFlags(uint16_t mask = 0xFFFF) noexcept;
790
792
793 //==========================================================================
796 //==========================================================================
797
804 void DumpDiagnostics() const noexcept;
805
807
809 friend class Pcal95555GpioPin;
810
811private:
812 //==========================================================================
813 // Private Methods
814 //==========================================================================
815
820 bool EnsureInitializedLocked() noexcept;
821
826 hf_gpio_err_t Initialize() noexcept;
827
832 hf_gpio_err_t Deinitialize() noexcept;
833
835 bool ValidatePin(uint8_t pin) const noexcept { return pin < 16; }
836
845 hf_gpio_err_t RegisterPinInterrupt(hf_pin_num_t pin,
846 hf_gpio_interrupt_trigger_t trigger,
847 InterruptCallback callback,
848 void* user_data) noexcept;
849
855 hf_gpio_err_t UnregisterPinInterrupt(hf_pin_num_t pin) noexcept;
856
861 hf_gpio_err_t ConfigureHardwareInterrupt() noexcept;
862
869 static void HardwareInterruptCallback(BaseGpio* gpio,
870 hf_gpio_interrupt_trigger_t trigger,
871 void* user_data) noexcept;
872
876 void ProcessInterrupts() noexcept;
877
878 //==========================================================================
881 //==========================================================================
882
887 [[nodiscard]] Pcal95555Driver* GetDriver() noexcept;
888 [[nodiscard]] const Pcal95555Driver* GetDriver() const noexcept;
889
891
892 //==========================================================================
893 // Private Members
894 //==========================================================================
895
898 BaseI2c& i2c_device_;
901 bool initialized_ = false;
902 mutable RtosMutex handler_mutex_;
904
907 std::array<std::shared_ptr<Pcal95555GpioPin>, 16> pin_registry_;
909
912 BaseGpio* interrupt_pin_;
914 std::atomic<bool> interrupt_pending_{false};
916
920 std::array<hf_gpio_pull_mode_t, 16> pull_mode_cache_;
922
926 uint16_t prev_input_state_ = 0;
928};
929
931
932#endif // COMPONENT_HANDLER_PCAL95555_HANDLER_H_
Concrete I2C communication adapter for PCAL95555 using BaseI2c.
Definition Pcal95555Handler.h:126
bool Read(uint8_t addr, uint8_t reg, uint8_t *data, size_t len) noexcept
Read data from a device register.
Definition Pcal95555Handler.cpp:56
bool Write(uint8_t addr, uint8_t reg, const uint8_t *data, size_t len) noexcept
Write data to a device register.
Definition Pcal95555Handler.cpp:34
std::function< void()> interrupt_handler_
Stored interrupt handler from driver.
Definition Pcal95555Handler.h:195
bool RegisterInterruptHandler(std::function< void()> handler) noexcept
Register an interrupt handler to be called when the INT pin fires.
Definition Pcal95555Handler.cpp:71
RtosMutex i2c_mutex_
Thread safety for I2C operations.
Definition Pcal95555Handler.h:194
HalI2cPcal95555Comm(BaseI2c &i2c_device) noexcept
Construct the I2C communication adapter.
Definition Pcal95555Handler.cpp:31
BaseI2c & i2c_device_
I2C device interface (not owned).
Definition Pcal95555Handler.h:193
bool EnsureInitialized() noexcept
Ensure the I2C bus is initialized and ready.
Definition Pcal95555Handler.cpp:67
const std::function< void()> & GetInterruptHandler() const noexcept
Get the stored interrupt handler (if any).
Definition Pcal95555Handler.h:190
BaseGpio adapter for a single PCAL95555 GPIO expander pin.
Definition Pcal95555Handler.h:226
hf_gpio_err_t SetPullModeImpl(hf_gpio_pull_mode_t mode) noexcept override
Set pull mode (floating/up/down). PCAL9555A only.
Definition Pcal95555Handler.cpp:970
hf_gpio_err_t SetPolarityInversion(bool invert) noexcept
Set input polarity inversion for this pin.
Definition Pcal95555Handler.cpp:939
~Pcal95555GpioPin() noexcept override=default
Default destructor.
bool Deinitialize() noexcept override
Deinitialize (marks pin as uninitialized; expander state persists).
Definition Pcal95555Handler.cpp:909
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).
Definition Pcal95555Handler.cpp:962
void * interrupt_user_data_
Definition Pcal95555Handler.h:362
hf_gpio_err_t SetPinLevelImpl(hf_gpio_level_t level) noexcept override
Write pin level via the PCAL95555 driver.
Definition Pcal95555Handler.cpp:988
InterruptCallback interrupt_callback_
Definition Pcal95555Handler.h:361
bool IsPinAvailable() const noexcept override
Check if this pin number is valid (0-15).
Definition Pcal95555Handler.cpp:914
bool Initialize() noexcept override
Initialize the pin (configures direction and pull mode on the expander).
Definition Pcal95555Handler.cpp:888
hf_pin_num_t pin_
Pin number (0-15).
Definition Pcal95555Handler.h:355
hf_gpio_err_t SupportsInterrupts() const noexcept override
Check if this pin supports interrupt configuration.
Definition Pcal95555Handler.cpp:918
char description_[32]
Human-readable description.
Definition Pcal95555Handler.h:357
hf_gpio_err_t GetInterruptStatus(bool &status) noexcept
Get the interrupt status for this pin.
Definition Pcal95555Handler.cpp:949
hf_gpio_pull_mode_t GetPullModeImpl() const noexcept override
Get current pull mode (tracked internally).
Definition Pcal95555Handler.cpp:976
bool interrupt_enabled_
Definition Pcal95555Handler.h:365
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.
Definition Pcal95555Handler.cpp:874
hf_gpio_err_t SetInterruptMask(bool mask) noexcept
Set the interrupt mask for this pin.
Definition Pcal95555Handler.cpp:944
hf_gpio_err_t GetDirectionImpl(hf_gpio_direction_t &direction) const noexcept override
Get pin direction from the PCAL95555 driver.
Definition Pcal95555Handler.cpp:1007
Pcal95555Handler * parent_handler_
Owning handler (not owned).
Definition Pcal95555Handler.h:356
hf_gpio_err_t SetDirectionImpl(hf_gpio_direction_t direction) noexcept override
Set pin direction via the PCAL95555 driver.
Definition Pcal95555Handler.cpp:956
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.
Definition Pcal95555Handler.cpp:929
const char * GetDescription() const noexcept override
Returns a description string like "PCAL95555_PIN_5".
Definition Pcal95555Handler.cpp:925
hf_gpio_err_t GetOutputModeImpl(hf_gpio_output_mode_t &mode) const noexcept override
Get output mode (tracked internally).
Definition Pcal95555Handler.cpp:1014
hf_gpio_interrupt_trigger_t interrupt_trigger_
Definition Pcal95555Handler.h:363
hf_gpio_err_t GetPinLevelImpl(hf_gpio_level_t &level) noexcept override
Read pin level via the PCAL95555 driver.
Definition Pcal95555Handler.cpp:995
hf_u8_t GetMaxPins() const noexcept override
Returns 16 (total pins on the expander).
Definition Pcal95555Handler.h:260
Unified, non-templated handler for a single PCA9555 / PCAL9555A device.
Definition Pcal95555Handler.h:410
uint8_t GetI2cAddress() const noexcept
Get the I2C address of the underlying device.
Definition Pcal95555Handler.cpp:608
hf_gpio_err_t GetInterruptStatus(hf_pin_num_t pin, bool &status) noexcept
Get interrupt status for a single pin.
Definition Pcal95555Handler.cpp:702
hf_gpio_err_t GetPullMode(uint8_t pin, hf_gpio_pull_mode_t &pull_mode) noexcept
Get the pull resistor mode for a single pin (tracked internally).
Definition Pcal95555Handler.cpp:300
std::unique_ptr< Pcal95555Driver > pcal95555_driver_
Typed driver (created in Initialize).
Definition Pcal95555Handler.h:900
uint16_t GetCreatedPinMask() const noexcept
Get a bitmask of all created pin numbers.
Definition Pcal95555Handler.cpp:655
pcal95555::ChipVariant GetChipVariant() const noexcept
Get the detected chip variant.
Definition Pcal95555Handler.cpp:674
hf_gpio_err_t Deinitialize() noexcept
Internal deinitialization.
Definition Pcal95555Handler.cpp:184
bool EnsureInitialized() noexcept
Ensure the handler is initialized (lazy initialization).
Definition Pcal95555Handler.cpp:93
std::unique_ptr< HalI2cPcal95555Comm > i2c_adapter_
I2C adapter (created in Initialize).
Definition Pcal95555Handler.h:899
bool IsPinCreated(hf_pin_num_t pin) const noexcept
Check if a pin wrapper has been created.
Definition Pcal95555Handler.cpp:649
bool DrainPendingInterrupts() noexcept
Drain any pending interrupt that was deferred from ISR context.
Definition Pcal95555Handler.cpp:526
bool EnsureDeinitialized() noexcept
Deinitialize the handler and release resources.
Definition Pcal95555Handler.cpp:101
hf_gpio_err_t SetPolarityInversion(hf_pin_num_t pin, bool invert) noexcept
Set input polarity inversion for a pin.
Definition Pcal95555Handler.cpp:680
hf_gpio_err_t ReadInput(uint8_t pin, bool &active) noexcept
Read the logical level of an input pin.
Definition Pcal95555Handler.cpp:236
hf_gpio_err_t SetDriveStrength(hf_pin_num_t pin, DriveStrength level) noexcept
Set output drive strength for a pin.
Definition Pcal95555Handler.cpp:712
BaseI2c & i2c_device_
I2C device reference (not owned).
Definition Pcal95555Handler.h:898
bool interrupt_configured_
Whether hardware interrupt is active.
Definition Pcal95555Handler.h:913
uint16_t prev_input_state_
Last-read pin input levels (bitmask).
Definition Pcal95555Handler.h:926
hf_gpio_err_t SetOutput(uint8_t pin, bool active) noexcept
Write a logical level to an output pin.
Definition Pcal95555Handler.cpp:226
hf_gpio_err_t EnableInputLatch(hf_pin_num_t pin, bool enable) noexcept
Enable or disable input latch for a pin.
Definition Pcal95555Handler.cpp:723
hf_gpio_err_t UnregisterPinInterrupt(hf_pin_num_t pin) noexcept
Unregister a per-pin interrupt callback.
Definition Pcal95555Handler.cpp:473
uint16_t GetErrorFlags() const noexcept
Get the driver's error flags.
Definition Pcal95555Handler.cpp:756
bool HasInterruptSupport() const noexcept
Check if hardware interrupt support is available.
Definition Pcal95555Handler.h:594
hf_gpio_err_t RegisterPinInterrupt(hf_pin_num_t pin, hf_gpio_interrupt_trigger_t trigger, InterruptCallback callback, void *user_data) noexcept
Register a per-pin interrupt callback (called by Pcal95555GpioPin).
Definition Pcal95555Handler.cpp:416
hf_gpio_err_t Initialize() noexcept
Internal initialization (called by EnsureInitialized under mutex).
Definition Pcal95555Handler.cpp:115
hf_gpio_err_t SetDirection(uint8_t pin, hf_gpio_direction_t direction) noexcept
Set the direction of a single pin.
Definition Pcal95555Handler.cpp:212
std::shared_ptr< BaseGpio > CreateGpioPin(hf_pin_num_t pin, 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, bool allow_existing=true) noexcept
Create or retrieve an existing BaseGpio pin wrapper.
Definition Pcal95555Handler.cpp:612
BaseGpio * interrupt_pin_
Hardware INT pin (optional, not owned).
Definition Pcal95555Handler.h:912
hf_gpio_err_t GetAllInterruptMasks(uint16_t &mask) noexcept
Get the interrupt mask for all 16 pins.
Definition Pcal95555Handler.cpp:386
hf_gpio_err_t SetDirections(uint16_t pin_mask, hf_gpio_direction_t direction) noexcept
Set direction for multiple pins at once.
Definition Pcal95555Handler.cpp:314
Pcal95555Driver * GetDriver() noexcept
Get the underlying PCAL95555 driver for advanced register-level operations.
Definition Pcal95555Handler.cpp:593
bool IsInitialized() const noexcept
Check if the handler has been initialized.
Definition Pcal95555Handler.h:485
hf_gpio_err_t SetInterruptMask(hf_pin_num_t pin, bool mask) noexcept
Set the per-pin interrupt mask.
Definition Pcal95555Handler.cpp:691
hf_gpio_err_t SetOutputs(uint16_t pin_mask, bool active) noexcept
Write output level for multiple pins at once.
Definition Pcal95555Handler.cpp:327
hf_gpio_err_t SetPullModes(uint16_t pin_mask, hf_gpio_pull_mode_t pull_mode) noexcept
Set pull mode for multiple pins at once.
Definition Pcal95555Handler.cpp:341
std::array< std::shared_ptr< Pcal95555GpioPin >, 16 > pin_registry_
Created pin wrappers.
Definition Pcal95555Handler.h:907
pcal95555::PCAL95555< HalI2cPcal95555Comm > Pcal95555Driver
Typed PCAL95555 driver using our I2C adapter.
Definition Pcal95555Handler.h:418
void ProcessInterrupts() noexcept
Process pending interrupts by reading status and dispatching callbacks.
Definition Pcal95555Handler.cpp:536
bool EnsureInitializedLocked() noexcept
Check init state under already-held handler_mutex_.
Definition Pcal95555Handler.cpp:110
void DumpDiagnostics() const noexcept
Dump comprehensive diagnostics to the system log.
Definition Pcal95555Handler.cpp:770
bool ValidatePin(uint8_t pin) const noexcept
Validate pin number is in range 0-15.
Definition Pcal95555Handler.h:835
static constexpr uint8_t PinCount() noexcept
Total number of GPIO pins on the expander.
Definition Pcal95555Handler.h:641
static void HardwareInterruptCallback(BaseGpio *gpio, hf_gpio_interrupt_trigger_t trigger, void *user_data) noexcept
Static ISR callback for the hardware interrupt pin.
Definition Pcal95555Handler.cpp:515
bool HasAgileIO() const noexcept
Check if the detected chip supports Agile I/O features.
Definition Pcal95555Handler.cpp:670
std::atomic< bool > interrupt_pending_
Deferred interrupt flag (set in ISR, cleared in task context).
Definition Pcal95555Handler.h:914
std::array< hf_gpio_pull_mode_t, 16 > pull_mode_cache_
Definition Pcal95555Handler.h:920
hf_gpio_err_t SetPullMode(uint8_t pin, hf_gpio_pull_mode_t pull_mode) noexcept
Set the pull resistor mode for a single pin.
Definition Pcal95555Handler.cpp:261
hf_gpio_err_t SetOutputMode(bool port0_open_drain, bool port1_open_drain) noexcept
Configure per-port output mode (push-pull or open-drain).
Definition Pcal95555Handler.cpp:733
hf_gpio_err_t ResetToDefault() noexcept
Reset all registers to power-on default state.
Definition Pcal95555Handler.cpp:743
RtosMutex handler_mutex_
Thread safety for handler operations.
Definition Pcal95555Handler.h:902
hf_gpio_err_t Toggle(uint8_t pin) noexcept
Toggle the output state of a pin.
Definition Pcal95555Handler.cpp:251
bool IsInterruptConfigured() const noexcept
Check if hardware interrupt is configured and enabled.
Definition Pcal95555Handler.h:600
hf_gpio_err_t ConfigureHardwareInterrupt() noexcept
Configure the hardware interrupt pin (falling edge, active-low).
Definition Pcal95555Handler.cpp:500
std::shared_ptr< BaseGpio > GetGpioPin(hf_pin_num_t pin) noexcept
Get an existing GPIO pin wrapper by number.
Definition Pcal95555Handler.cpp:643
hf_gpio_err_t GetAllInterruptStatus(uint16_t &status) noexcept
Get the interrupt status for all 16 pins.
Definition Pcal95555Handler.cpp:403
Pcal95555Handler(BaseI2c &i2c_device, BaseGpio *interrupt_pin=nullptr) noexcept
Construct a handler for a PCAL95555 device.
Definition Pcal95555Handler.cpp:81
bool initialized_
Initialization state.
Definition Pcal95555Handler.h:901
void ClearErrorFlags(uint16_t mask=0xFFFF) noexcept
Clear driver error flags.
Definition Pcal95555Handler.cpp:760