|
HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
|
Unified GPIO base class for all digital GPIO implementations. More...
#include <BaseGpio.h>
Public Member Functions | |
| BaseGpio (const BaseGpio ©)=delete | |
| Copy constructor is deleted to avoid copying instances. | |
| BaseGpio & | operator= (const BaseGpio ©)=delete |
| Assignment operator is deleted to avoid copying instances. | |
| virtual | ~BaseGpio () noexcept=default |
| Virtual destructor for proper cleanup of derived classes. | |
| bool | IsInitialized () const noexcept |
| Check if the pin is initialized. | |
| bool | EnsureInitialized () noexcept |
| Ensures the pin is initialized (lazy initialization). | |
| bool | EnsureDeinitialized () noexcept |
| Ensures the pin is deinitialized (lazy deinitialization). | |
| hf_pin_num_t | GetPin () const noexcept |
| Get the GPIO pin number/identifier. | |
| hf_gpio_direction_t | GetDirection () const noexcept |
| Get the current pin direction. | |
| hf_gpio_err_t | SetDirection (hf_gpio_direction_t direction) noexcept |
| Set the pin direction (input or output). | |
| bool | IsInput () const noexcept |
| Check if the pin is currently configured as input. | |
| bool | IsOutput () const noexcept |
| Check if the pin is currently configured as output. | |
| hf_gpio_output_mode_t | GetOutputMode () const noexcept |
| Get the output drive mode. | |
| hf_gpio_err_t | SetOutputMode (hf_gpio_output_mode_t mode) noexcept |
| Set the output drive mode. | |
| hf_gpio_pull_mode_t | GetPullMode () const noexcept |
| Get the current pull resistor mode. | |
| hf_gpio_err_t | SetPullMode (hf_gpio_pull_mode_t mode) noexcept |
| Set the pull resistor mode. | |
| hf_gpio_state_t | GetCurrentState () const noexcept |
| Get the current logical state of the pin. | |
| hf_gpio_err_t | SetState (hf_gpio_state_t state) noexcept |
| Set the pin to a specific logical state. | |
| hf_gpio_active_state_t | GetActiveState () const noexcept |
| Get the active state polarity configuration. | |
| void | SetActiveState (hf_gpio_active_state_t active_state) noexcept |
| Set the active state polarity configuration. | |
| hf_gpio_err_t | SetActive () noexcept |
| Set the GPIO to active state. | |
| hf_gpio_err_t | SetInactive () noexcept |
| Set the GPIO to inactive state. | |
| hf_gpio_err_t | Toggle () noexcept |
| Toggle the GPIO state. | |
| hf_gpio_err_t | IsActive (bool &is_active) noexcept |
| Check if the GPIO is currently active. | |
| hf_gpio_err_t | VerifyDirection (hf_gpio_direction_t &direction) const noexcept |
| Verify current direction setting by reading from hardware registers. | |
| hf_gpio_err_t | VerifyOutputMode (hf_gpio_output_mode_t &mode) const noexcept |
| Verify current output mode setting by reading from hardware registers. | |
| hf_gpio_err_t | VerifyHardwareConfiguration () const noexcept |
| Perform comprehensive hardware verification of all pin settings. | |
| virtual bool | IsPinAvailable () const noexcept=0 |
| Check if the pin is available for GPIO operations. | |
| virtual hf_u8_t | GetMaxPins () const noexcept=0 |
| Get the maximum number of pins supported by this GPIO instance. | |
| virtual const char * | GetDescription () const noexcept=0 |
| Get human-readable description of this GPIO instance. | |
| virtual hf_gpio_err_t | SupportsInterrupts () const noexcept |
| Check if this GPIO implementation supports interrupts. | |
| virtual hf_gpio_err_t | ConfigureInterrupt (hf_gpio_interrupt_trigger_t trigger, InterruptCallback callback=nullptr, void *user_data=nullptr) noexcept |
| Configure GPIO interrupt settings. | |
| virtual hf_gpio_err_t | EnableInterrupt () noexcept |
| Enable GPIO interrupt. | |
| virtual hf_gpio_err_t | DisableInterrupt () noexcept |
| Disable GPIO interrupt. | |
| virtual hf_gpio_err_t | WaitForInterrupt (hf_u32_t timeout_ms=0) noexcept |
| Wait for GPIO interrupt to occur. | |
| virtual hf_gpio_err_t | GetInterruptStatus (InterruptStatus &status) noexcept |
| Get interrupt status information. | |
| virtual hf_gpio_err_t | ClearInterruptStats () noexcept |
| Clear interrupt statistics. | |
| virtual hf_gpio_err_t | ResetStatistics () noexcept |
| Reset GPIO operation statistics. | |
| virtual hf_gpio_err_t | ResetDiagnostics () noexcept |
| Reset GPIO diagnostic information. | |
| virtual hf_gpio_err_t | GetStatistics (hf_gpio_statistics_t &statistics) const noexcept |
| Get GPIO operation statistics. | |
| virtual hf_gpio_err_t | GetDiagnostics (hf_gpio_diagnostics_t &diagnostics) const noexcept |
| Get GPIO diagnostic information. | |
| virtual bool | Initialize () noexcept=0 |
| Initialize the GPIO pin with current configuration. | |
| virtual bool | Deinitialize () noexcept |
| Deinitialize the GPIO pin. | |
Static Public Member Functions | |
| static const char * | ToString (hf_gpio_state_t state) noexcept |
| static const char * | ToString (hf_gpio_level_t level) noexcept |
| static const char * | ToString (hf_gpio_active_state_t active_state) noexcept |
| static const char * | ToString (hf_gpio_direction_t direction) noexcept |
| static const char * | ToString (hf_gpio_output_mode_t output_mode) noexcept |
| static const char * | ToString (hf_gpio_pull_mode_t pull_mode) noexcept |
| static const char * | ToString (hf_gpio_interrupt_trigger_t trigger) noexcept |
Protected Member Functions | |
| virtual hf_gpio_err_t | SetDirectionImpl (hf_gpio_direction_t direction) noexcept=0 |
| Platform-specific implementation for setting pin direction. | |
| virtual hf_gpio_err_t | GetDirectionImpl (hf_gpio_direction_t &direction) const noexcept=0 |
| Hardware read-back of current pin direction from registers. | |
| virtual hf_gpio_err_t | SetOutputModeImpl (hf_gpio_output_mode_t mode) noexcept=0 |
| Platform-specific implementation for setting output mode. | |
| virtual hf_gpio_err_t | GetOutputModeImpl (hf_gpio_output_mode_t &mode) const noexcept=0 |
| Hardware read-back of current output mode from registers. | |
| virtual hf_gpio_err_t | SetPullModeImpl (hf_gpio_pull_mode_t mode) noexcept=0 |
| Platform-specific implementation for setting pull resistor mode. | |
| virtual hf_gpio_pull_mode_t | GetPullModeImpl () const noexcept=0 |
| Hardware read-back of current pull resistor mode from registers. | |
| virtual hf_gpio_err_t | SetPinLevelImpl (hf_gpio_level_t level) noexcept=0 |
| Platform-specific implementation for setting pin electrical level. | |
| virtual hf_gpio_err_t | GetPinLevelImpl (hf_gpio_level_t &level) noexcept=0 |
| Platform-specific implementation for getting pin electrical level. | |
| hf_gpio_err_t | ValidateBasicOperation () const noexcept |
| Validate basic parameters before GPIO operations. | |
| hf_gpio_level_t | StateToLevel (hf_gpio_state_t state) const noexcept |
| Convert logical state to electrical level based on polarity. | |
| hf_gpio_state_t | LevelToState (hf_gpio_level_t level) const noexcept |
| Convert electrical level to logical state based on polarity. | |
| BaseGpio (hf_pin_num_t pin_num, 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 | |
| Protected constructor with configuration. | |
Protected Attributes | |
| const hf_pin_num_t | pin_ |
| GPIO pin number/identifier. | |
| bool | initialized_ |
| Initialization state flag. | |
| hf_gpio_direction_t | current_direction_ |
| Current pin direction. | |
| hf_gpio_active_state_t | active_state_ |
| Active state polarity. | |
| hf_gpio_output_mode_t | output_mode_ |
| Output drive mode. | |
| hf_gpio_pull_mode_t | pull_mode_ |
| Pull resistor configuration. | |
| hf_gpio_state_t | current_state_ |
| Current logical state. | |
| hf_gpio_statistics_t | statistics_ |
| GPIO operation statistics. | |
| hf_gpio_diagnostics_t | diagnostics_ |
| GPIO diagnostic information. | |
Unified GPIO base class for all digital GPIO implementations.
This class provides a comprehensive digital GPIO implementation that serves as the base for all GPIO hardware in the HardFOC system. It supports:
Derived classes implement platform-specific details for:
|
delete |
Copy constructor is deleted to avoid copying instances.
|
virtualdefaultnoexcept |
Virtual destructor for proper cleanup of derived classes.
|
inlineexplicitprotectednoexcept |
Protected constructor with configuration.
| pin_num | GPIO pin number |
| direction | GPIO direction (input/output) |
| active_state | Active state polarity (high/low) |
| output_mode | Output drive mode (push-pull/open-drain) |
| pull_mode | Pull resistor configuration (Floating, PullUp, or PullDown) |
Initializes the GPIO with specified configuration. The pin is not physically configured until Initialize() is called.
|
inlinevirtualnoexcept |
Clear interrupt statistics.
Reimplemented in EspGpio.
|
inlinevirtualnoexcept |
Configure GPIO interrupt settings.
| trigger | Interrupt trigger type |
| callback | Callback function to invoke on interrupt (optional) |
| user_data | User data passed to callback (optional) |
Reimplemented in EspGpio.
|
inlinevirtualnoexcept |
Deinitialize the GPIO pin.
Reimplemented in EspGpio.
|
inlinevirtualnoexcept |
Disable GPIO interrupt.
Reimplemented in EspGpio.
|
inlinevirtualnoexcept |
Enable GPIO interrupt.
Reimplemented in EspGpio.
|
inlinenoexcept |
Ensures the pin is deinitialized (lazy deinitialization).
|
inlinenoexcept |
Ensures the pin is initialized (lazy initialization).
|
inlinenoexcept |
Get the active state polarity configuration.
|
inlinenoexcept |
Get the current logical state of the pin.
|
pure virtualnoexcept |
|
inlinevirtualnoexcept |
Get GPIO diagnostic information.
| diagnostics | Reference to store diagnostics data |
Reimplemented in EspGpio.
|
inlinenoexcept |
Get the current pin direction.
|
protectedpure virtualnoexcept |
Hardware read-back of current pin direction from registers.
| direction | Output parameter: actual hardware pin direction |
Reads the actual direction configuration from hardware registers. Useful for fault detection and hardware verification.
|
inlinevirtualnoexcept |
Get interrupt status information.
| status | Reference to store status information |
Reimplemented in EspGpio.
|
pure virtualnoexcept |
|
inlinenoexcept |
Get the output drive mode.
|
protectedpure virtualnoexcept |
Hardware read-back of current output mode from registers.
| mode | Output parameter: actual hardware output mode |
Reads the actual output mode configuration from hardware registers. Useful for fault detection and hardware verification.
|
inlinenoexcept |
Get the GPIO pin number/identifier.
|
protectedpure virtualnoexcept |
Platform-specific implementation for getting pin electrical level.
| level | Output parameter: current electrical level (Low or High) |
|
inlinenoexcept |
Get the current pull resistor mode.
|
protectedpure virtualnoexcept |
Hardware read-back of current pull resistor mode from registers.
Reads the actual pull resistor configuration from hardware registers. Useful for fault detection and hardware verification.
|
inlinevirtualnoexcept |
Get GPIO operation statistics.
| statistics | Reference to store statistics data |
Reimplemented in EspGpio.
|
pure virtualnoexcept |
|
inlinenoexcept |
Check if the GPIO is currently active.
| is_active | Reference to store the result |
|
inlinenoexcept |
Check if the pin is initialized.
|
inlinenoexcept |
Check if the pin is currently configured as input.
|
inlinenoexcept |
Check if the pin is currently configured as output.
|
pure virtualnoexcept |
|
inlineprotectednoexcept |
Convert electrical level to logical state based on polarity.
| level | Electrical level (High or Low) |
Assignment operator is deleted to avoid copying instances.
|
inlinevirtualnoexcept |
Reset GPIO diagnostic information.
|
inlinevirtualnoexcept |
Reset GPIO operation statistics.
|
inlinenoexcept |
Set the GPIO to active state.
|
inlinenoexcept |
Set the active state polarity configuration.
| active_state | New ActiveState setting (High or Low) |
|
inlinenoexcept |
Set the pin direction (input or output).
| direction | New Direction setting (Input or Output) |
|
protectedpure virtualnoexcept |
Platform-specific implementation for setting pin direction.
| direction | New pin direction (Input or Output) |
|
inlinenoexcept |
Set the GPIO to inactive state.
|
inlinenoexcept |
Set the output drive mode.
| mode | New OutputMode setting (PushPull or OpenDrain) |
|
protectedpure virtualnoexcept |
Platform-specific implementation for setting output mode.
| mode | New output mode (PushPull or OpenDrain) |
|
protectedpure virtualnoexcept |
Platform-specific implementation for setting pin electrical level.
| level | New electrical level (Low or High) |
|
inlinenoexcept |
Set the pull resistor mode.
| mode | New PullMode setting (Floating, PullUp, or PullDown) |
|
protectedpure virtualnoexcept |
Platform-specific implementation for setting pull resistor mode.
| mode | New pull resistor mode (Floating, PullUp, PullDown) |
|
inlinenoexcept |
Set the pin to a specific logical state.
| state | New logical state to set (Active or Inactive) |
|
inlineprotectednoexcept |
Convert logical state to electrical level based on polarity.
| state | Logical state (Active or Inactive) |
|
inlinevirtualnoexcept |
Check if this GPIO implementation supports interrupts.
Reimplemented in EspGpio.
|
inlinenoexcept |
Toggle the GPIO state.
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlineprotectednoexcept |
Validate basic parameters before GPIO operations.
|
inlinenoexcept |
Verify current direction setting by reading from hardware registers.
| direction | Output parameter: actual hardware direction setting |
Reads the actual direction configuration from hardware registers for fault detection and verification. Compares against cached value.
|
inlinenoexcept |
Perform comprehensive hardware verification of all pin settings.
Verifies that all hardware registers match the expected cached values. Useful for detecting hardware faults, register corruption, or power management issues. Updates diagnostics on mismatch.
|
inlinenoexcept |
Verify current output mode setting by reading from hardware registers.
| mode | Output parameter: actual hardware output mode setting |
Reads the actual output mode configuration from hardware registers for fault detection and verification. Compares against cached value.
|
inlinevirtualnoexcept |
Wait for GPIO interrupt to occur.
| timeout_ms | Timeout in milliseconds (0 = wait forever) |
Reimplemented in EspGpio.
|
protected |
Active state polarity.
|
protected |
Current pin direction.
|
protected |
Current logical state.
|
protected |
GPIO diagnostic information.
|
protected |
Initialization state flag.
|
protected |
Output drive mode.
|
protected |
GPIO pin number/identifier.
|
protected |
Pull resistor configuration.
|
protected |
GPIO operation statistics.