HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
EspGpio Class Reference

Advanced MCU-specific implementation of unified BaseGpio with ESP32C6/ESP-IDF v5.5+ features. More...

#include <EspGpio.h>

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

Public Member Functions

 EspGpio (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, hf_gpio_drive_cap_t drive_capability=hf_gpio_drive_cap_t::HF_GPIO_DRIVE_CAP_MEDIUM) noexcept
 Constructor for EspGpio with full configuration including advanced features.
 
 ~EspGpio () override
 Destructor - ensures proper cleanup including interrupt resources.
 
bool Initialize () noexcept override
 Initialize the MCU GPIO pin with current configuration.
 
bool Deinitialize () noexcept override
 Deinitialize the MCU GPIO pin.
 
bool IsPinAvailable () const noexcept override
 Check if the pin is available for GPIO operations.
 
hf_u8_t GetMaxPins () const noexcept override
 Get the maximum number of pins supported by this MCU.
 
const char * GetDescription () const noexcept override
 Get human-readable description of this GPIO instance.
 
hf_gpio_err_t SupportsInterrupts () const noexcept override
 MCU GPIO supports interrupts.
 
hf_gpio_err_t ConfigureInterrupt (hf_gpio_interrupt_trigger_t trigger, InterruptCallback callback=nullptr, void *user_data=nullptr) noexcept override
 Configure GPIO interrupt settings.
 
hf_gpio_err_t EnableInterrupt () noexcept override
 Enable GPIO interrupt.
 
hf_gpio_err_t DisableInterrupt () noexcept override
 Disable GPIO interrupt.
 
hf_gpio_err_t WaitForInterrupt (hf_u32_t timeout_ms=0) noexcept override
 Wait for GPIO interrupt with timeout.
 
hf_gpio_err_t GetInterruptStatus (InterruptStatus &status) noexcept override
 Get current interrupt status and statistics.
 
hf_gpio_err_t ClearInterruptStats () noexcept override
 Clear interrupt statistics/counters.
 
bool IsInitialized () const noexcept
 Check if the GPIO pin has been initialized.
 
hf_gpio_err_t GetStatistics (hf_gpio_statistics_t &statistics) const noexcept override
 Get GPIO operation statistics.
 
hf_gpio_err_t GetDiagnostics (hf_gpio_diagnostics_t &diagnostics) const noexcept override
 Get GPIO diagnostics information.
 
hf_gpio_drive_cap_t GetDriveCapability () const noexcept
 Get current drive capability setting.
 
hf_gpio_err_t SetDriveCapability (hf_gpio_drive_cap_t capability) noexcept
 Set GPIO drive capability.
 
bool SupportsGlitchFilter () const noexcept
 Check if glitch filters are supported.
 
hf_gpio_err_t ConfigurePinGlitchFilter (bool enable) noexcept
 Configure pin glitch filter (fixed 2 clock cycles).
 
hf_gpio_err_t ConfigureGlitchFilter (hf_gpio_glitch_filter_type_t filter_type, const hf_gpio_flex_filter_config_t *flex_config=nullptr) noexcept
 Configure advanced glitch filter (pin/flex) for ESP32C6.
 
hf_gpio_err_t ConfigureSleepMode (const hf_gpio_sleep_config_t &sleep_config) noexcept
 Configure sleep mode for ESP32C6 GPIO.
 
hf_gpio_err_t ConfigureFlexGlitchFilter (const hf_gpio_flex_filter_config_t &config) noexcept
 Configure flexible glitch filter with custom timing.
 
hf_gpio_err_t EnableGlitchFilters () noexcept
 Enable all configured glitch filters.
 
hf_gpio_err_t DisableGlitchFilters () noexcept
 Disable all glitch filters.
 
bool SupportsRtcGpio () const noexcept
 Check if pin supports RTC GPIO functionality.
 
hf_gpio_err_t ConfigureSleep (const hf_gpio_sleep_config_t &config) noexcept
 Configure GPIO sleep behavior.
 
hf_gpio_err_t ConfigureHold (bool enable) noexcept
 Enable GPIO hold function.
 
hf_gpio_err_t ConfigureWakeUp (const hf_gpio_wakeup_config_t &config) noexcept
 Configure GPIO as wake-up source.
 
hf_gpio_status_info_t GetConfigurationDump () const noexcept
 Get comprehensive GPIO configuration information.
 
bool IsHeld () const noexcept
 Check if pin is currently held.
 
hf_gpio_err_t GetPinCapabilities (hf_gpio_pin_capabilities_t &capabilities) const noexcept
 Get pin capabilities for comprehensive feature detection.
 
hf_gpio_err_t GetStatusInfo (hf_gpio_status_info_t &status) const noexcept
 Get detailed status information for diagnostics.
 
- Public Member Functions inherited from BaseGpio
 BaseGpio (const BaseGpio &copy)=delete
 Copy constructor is deleted to avoid copying instances.
 
BaseGpiooperator= (const BaseGpio &copy)=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 hf_gpio_err_t ResetStatistics () noexcept
 Reset GPIO operation statistics.
 
virtual hf_gpio_err_t ResetDiagnostics () noexcept
 Reset GPIO diagnostic information.
 

Static Public Member Functions

static hf_u32_t GetTotalInterruptCount () noexcept
 Get total interrupt count across all GPIO instances.
 
static hf_u32_t GetActiveGpioCount () noexcept
 Get count of currently active GPIO instances.
 
static bool IsValidPin (hf_pin_num_t pin_num) noexcept
 Validate if a pin number is valid for the target platform.
 
static bool IsRtcGpio (hf_pin_num_t pin_num) noexcept
 Check if pin supports RTC GPIO functionality.
 
static bool IsStrappingPin (hf_pin_num_t pin_num) noexcept
 Check if pin is a strapping pin requiring caution.
 
- Static Public Member Functions inherited from BaseGpio
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

hf_gpio_err_t SetDirectionImpl (hf_gpio_direction_t direction) noexcept override
 Platform-specific implementation for setting pin direction.
 
hf_gpio_err_t SetOutputModeImpl (hf_gpio_output_mode_t mode) noexcept override
 Platform-specific implementation for setting output mode.
 
hf_gpio_err_t SetPinLevelImpl (hf_gpio_level_t level) noexcept override
 Platform-specific implementation for setting pin electrical level.
 
hf_gpio_err_t GetPinLevelImpl (hf_gpio_level_t &level) noexcept override
 Platform-specific implementation for reading pin electrical level.
 
hf_gpio_err_t SetPullModeImpl (hf_gpio_pull_mode_t mode) noexcept override
 Platform-specific implementation for setting pull resistor mode.
 
hf_gpio_pull_mode_t GetPullModeImpl () const noexcept override
 Platform-specific implementation for reading pull resistor mode.
 
hf_gpio_err_t GetDirectionImpl (hf_gpio_direction_t &direction) const noexcept override
 Platform-specific implementation for reading pin direction from hardware.
 
hf_gpio_err_t GetOutputModeImpl (hf_gpio_output_mode_t &mode) const noexcept override
 Platform-specific implementation for reading output mode from hardware.
 
- Protected Member Functions inherited from BaseGpio
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.
 

Private Member Functions

gpio_int_type_t MapInterruptTrigger (hf_gpio_interrupt_trigger_t trigger) const noexcept
 Convert BaseGpio::InterruptTrigger to platform-specific interrupt type.
 
void IRAM_ATTR HandleInterrupt ()
 Handle interrupt in instance context.
 
bool InitializeAdvancedFeatures () noexcept
 Initialize advanced features during GPIO initialization.
 
void CleanupAdvancedFeatures () noexcept
 Cleanup advanced feature resources.
 
void CleanupGlitchFilters () noexcept
 Cleanup glitch filter resources.
 
void CleanupInterruptSemaphore () noexcept
 Cleanup interrupt semaphore (called from destructor).
 
hf_gpio_err_t WriteImpl (hf_gpio_state_t state) noexcept
 
hf_gpio_err_t ReadImpl (hf_gpio_state_t &state) noexcept
 

Static Private Member Functions

static void IRAM_ATTR StaticInterruptHandler (void *arg)
 Static interrupt service routine handler.
 

Private Attributes

hf_gpio_interrupt_trigger_t interrupt_trigger_
 Current interrupt trigger type.
 
InterruptCallback interrupt_callback_
 User interrupt callback.
 
void * interrupt_user_data_
 User data for callback.
 
bool interrupt_enabled_
 Interrupt currently enabled.
 
std::atomic< hf_u32_tinterrupt_count_
 Number of interrupts occurred (thread-safe)
 
void * platform_semaphore_
 Platform-specific semaphore for WaitForInterrupt.
 
bool isr_handler_added_
 Whether ISR handler was added for this pin.
 
hf_gpio_drive_cap_t drive_capability_
 Current drive capability setting.
 
hf_gpio_glitch_filter_type_t glitch_filter_type_
 Type of glitch filter configured.
 
bool pin_glitch_filter_enabled_
 Pin glitch filter enabled.
 
bool flex_glitch_filter_enabled_
 Flexible glitch filter enabled.
 
hf_gpio_flex_filter_config_t flex_filter_config_
 Flexible filter configuration.
 
hf_gpio_sleep_config_t sleep_config_
 Sleep configuration.
 
bool hold_enabled_
 Hold function enabled.
 
bool rtc_gpio_enabled_
 RTC GPIO functionality enabled.
 
hf_gpio_wakeup_config_t wakeup_config_
 Wake-up configuration.
 
void * glitch_filter_handle_
 Platform-specific glitch filter handle.
 
void * rtc_gpio_handle_
 Platform-specific RTC GPIO handle.
 

Static Private Attributes

static bool gpio_isr_handler_installed_
 Track if ISR service is installed.
 

Additional Inherited Members

- Protected Attributes inherited from BaseGpio
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.
 

Detailed Description

Advanced MCU-specific implementation of unified BaseGpio with ESP32C6/ESP-IDF v5.5+ features.

This class provides a comprehensive implementation of BaseGpio for MCU-based GPIO pins with support for both basic and advanced features including:

Basic Features:

  • Dynamic switching between input and output modes
  • Active-high/active-low polarity configuration
  • Pull resistor configuration (floating, pull-up, pull-down)
  • Output drive modes (push-pull, open-drain)
  • Thread-safe state management

Advanced Features (ESP32C6/ESP-IDF v5.5+):

  • Glitch filtering (pin and flexible filters)
  • RTC GPIO support for ultra-low power operations
  • Sleep configuration and state retention
  • Hold functions to maintain state during sleep
  • Deep sleep wake-up configuration
  • Precise drive capability control (5mA to 40mA)
  • Advanced debugging and configuration dump
Note
This class is designed to be platform-agnostic within the MCU domain. Platform-specific details are handled through conditional compilation.
Advanced features require ESP32C6 with ESP-IDF v5.5+ for full functionality.

Constructor & Destructor Documentation

◆ EspGpio()

EspGpio::EspGpio ( 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,
hf_gpio_drive_cap_t drive_capability = hf_gpio_drive_cap_t::HF_GPIO_DRIVE_CAP_MEDIUM )
explicitnoexcept

Constructor for EspGpio with full configuration including advanced features.

Parameters
pin_numPlatform-agnostic GPIO pin number
directionInitial pin direction (Input or Output)
active_statePolarity configuration (High or Low active)
output_modeOutput drive mode (PushPull or OpenDrain)
pull_modePull resistor configuration (Floating, PullUp, or PullDown)
drive_capabilityDrive strength capability (Weak to Strongest)

Creates an MCU GPIO instance with the specified configuration. LAZY INITIALIZATION: The pin is NOT physically configured until the first call to EnsureInitialized(), Initialize(), or any GPIO operation. This allows creating GPIO objects without immediate hardware access.

◆ ~EspGpio()

EspGpio::~EspGpio ( )
override

Destructor - ensures proper cleanup including interrupt resources.

Member Function Documentation

◆ CleanupAdvancedFeatures()

void EspGpio::CleanupAdvancedFeatures ( )
privatenoexcept

Cleanup advanced feature resources.

◆ CleanupGlitchFilters()

void EspGpio::CleanupGlitchFilters ( )
privatenoexcept

Cleanup glitch filter resources.

◆ CleanupInterruptSemaphore()

void EspGpio::CleanupInterruptSemaphore ( )
privatenoexcept

Cleanup interrupt semaphore (called from destructor).

◆ ClearInterruptStats()

hf_gpio_err_t EspGpio::ClearInterruptStats ( )
overridevirtualnoexcept

Clear interrupt statistics/counters.

Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ ConfigureFlexGlitchFilter()

hf_gpio_err_t EspGpio::ConfigureFlexGlitchFilter ( const hf_gpio_flex_filter_config_t & config)
noexcept

Configure flexible glitch filter with custom timing.

Parameters
configFlexible glitch filter configuration
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Flexible glitch filter allows precise control over filtering parameters. Pulses shorter than window_threshold_ns within window_width_ns are filtered.

◆ ConfigureGlitchFilter()

hf_gpio_err_t EspGpio::ConfigureGlitchFilter ( hf_gpio_glitch_filter_type_t filter_type,
const hf_gpio_flex_filter_config_t * flex_config = nullptr )
noexcept

Configure advanced glitch filter (pin/flex) for ESP32C6.

Parameters
filter_typeGlitch filter type (none, pin, flex, both)
flex_configOptional pointer to flexible filter config
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

◆ ConfigureHold()

hf_gpio_err_t EspGpio::ConfigureHold ( bool enable)
noexcept

Enable GPIO hold function.

Parameters
enableEnable or disable hold function
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Hold function maintains GPIO state during sleep and reset. Useful for maintaining critical pin states during power transitions.

◆ ConfigureInterrupt()

hf_gpio_err_t EspGpio::ConfigureInterrupt ( hf_gpio_interrupt_trigger_t trigger,
InterruptCallback callback = nullptr,
void * user_data = nullptr )
overridevirtualnoexcept

Configure GPIO interrupt settings.

Parameters
triggerInterrupt trigger type
callbackCallback function to invoke on interrupt (optional)
user_dataUser data passed to callback (optional)
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ ConfigurePinGlitchFilter()

hf_gpio_err_t EspGpio::ConfigurePinGlitchFilter ( bool enable)
noexcept

Configure pin glitch filter (fixed 2 clock cycles).

Parameters
enableEnable or disable the pin glitch filter
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Pin glitch filter removes pulses shorter than 2 IO_MUX clock cycles. This is a simple, low-overhead filter suitable for basic noise rejection.

◆ ConfigureSleep()

hf_gpio_err_t EspGpio::ConfigureSleep ( const hf_gpio_sleep_config_t & config)
noexcept

Configure GPIO sleep behavior.

Parameters
configSleep configuration parameters
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Configures how the GPIO behaves during sleep modes. Essential for power-optimized applications.

◆ ConfigureSleepMode()

hf_gpio_err_t EspGpio::ConfigureSleepMode ( const hf_gpio_sleep_config_t & sleep_config)
noexcept

Configure sleep mode for ESP32C6 GPIO.

Parameters
sleep_configSleep configuration struct
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

◆ ConfigureWakeUp()

hf_gpio_err_t EspGpio::ConfigureWakeUp ( const hf_gpio_wakeup_config_t & config)
noexcept

Configure GPIO as wake-up source.

Parameters
configWake-up configuration parameters
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Enables GPIO to wake the system from deep sleep. Essential for battery-powered applications.

◆ Deinitialize()

bool EspGpio::Deinitialize ( )
overridevirtualnoexcept

Deinitialize the MCU GPIO pin.

Returns
true if deinitialization successful, false otherwise

Resets the pin to a safe default state and marks it as uninitialized.

Reimplemented from BaseGpio.

◆ DisableGlitchFilters()

hf_gpio_err_t EspGpio::DisableGlitchFilters ( )
noexcept

Disable all glitch filters.

Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

◆ DisableInterrupt()

hf_gpio_err_t EspGpio::DisableInterrupt ( )
overridevirtualnoexcept

Disable GPIO interrupt.

Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ EnableGlitchFilters()

hf_gpio_err_t EspGpio::EnableGlitchFilters ( )
noexcept

Enable all configured glitch filters.

Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

◆ EnableInterrupt()

hf_gpio_err_t EspGpio::EnableInterrupt ( )
overridevirtualnoexcept

Enable GPIO interrupt.

Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ GetActiveGpioCount()

static hf_u32_t EspGpio::GetActiveGpioCount ( )
staticnoexcept

Get count of currently active GPIO instances.

Returns
Number of GPIO instances currently initialized and active

Thread-safe counter for resource monitoring.

◆ GetConfigurationDump()

hf_gpio_status_info_t EspGpio::GetConfigurationDump ( ) const
noexcept

Get comprehensive GPIO configuration information.

Returns
Complete configuration dump structure

Provides detailed information about current GPIO configuration. Useful for debugging and system validation.

◆ GetDescription()

const char * EspGpio::GetDescription ( ) const
overridevirtualnoexcept

Get human-readable description of this GPIO instance.

Returns
String view describing the MCU GPIO

Implements BaseGpio.

◆ GetDiagnostics()

hf_gpio_err_t EspGpio::GetDiagnostics ( hf_gpio_diagnostics_t & diagnostics) const
overridevirtualnoexcept

Get GPIO diagnostics information.

Parameters
diagnosticsReference to store current diagnostics
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ GetDirectionImpl()

hf_gpio_err_t EspGpio::GetDirectionImpl ( hf_gpio_direction_t & direction) const
overrideprotectedvirtualnoexcept

Platform-specific implementation for reading pin direction from hardware.

Parameters
directionOutput parameter: current hardware pin direction
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reads the actual direction configuration from ESP32 GPIO registers.

Implements BaseGpio.

◆ GetDriveCapability()

hf_gpio_drive_cap_t EspGpio::GetDriveCapability ( ) const
inlinenoexcept

Get current drive capability setting.

Returns
Current drive capability level

◆ GetInterruptStatus()

hf_gpio_err_t EspGpio::GetInterruptStatus ( InterruptStatus & status)
overridevirtualnoexcept

Get current interrupt status and statistics.

Parameters
statusReference to store interrupt status
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ GetMaxPins()

hf_u8_t EspGpio::GetMaxPins ( ) const
overridevirtualnoexcept

Get the maximum number of pins supported by this MCU.

Returns
Maximum pin count for this MCU platform

Implements BaseGpio.

◆ GetOutputModeImpl()

hf_gpio_err_t EspGpio::GetOutputModeImpl ( hf_gpio_output_mode_t & mode) const
overrideprotectedvirtualnoexcept

Platform-specific implementation for reading output mode from hardware.

Parameters
modeOutput parameter: current hardware output mode
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reads the actual output mode configuration from ESP32 GPIO registers.

Implements BaseGpio.

◆ GetPinCapabilities()

hf_gpio_err_t EspGpio::GetPinCapabilities ( hf_gpio_pin_capabilities_t & capabilities) const
noexcept

Get pin capabilities for comprehensive feature detection.

Parameters
capabilitiesOutput structure to store pin capabilities
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Provides comprehensive information about pin capabilities including ADC, RTC, touch, strapping, and special function support.

◆ GetPinLevelImpl()

hf_gpio_err_t EspGpio::GetPinLevelImpl ( hf_gpio_level_t & level)
overrideprotectedvirtualnoexcept

Platform-specific implementation for reading pin electrical level.

Parameters
levelOutput parameter: current electrical level (HIGH or LOW)
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reads the current MCU pin electrical level.

Implements BaseGpio.

◆ GetPullModeImpl()

hf_gpio_pull_mode_t EspGpio::GetPullModeImpl ( ) const
overrideprotectedvirtualnoexcept

Platform-specific implementation for reading pull resistor mode.

Returns
Current PullMode configuration

Queries the current pull resistor configuration from MCU registers.

Implements BaseGpio.

◆ GetStatistics()

hf_gpio_err_t EspGpio::GetStatistics ( hf_gpio_statistics_t & statistics) const
overridevirtualnoexcept

Get GPIO operation statistics.

Parameters
statisticsReference to store current statistics
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reimplemented from BaseGpio.

◆ GetStatusInfo()

hf_gpio_err_t EspGpio::GetStatusInfo ( hf_gpio_status_info_t & status) const
noexcept

Get detailed status information for diagnostics.

Parameters
statusOutput structure to store status information
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Provides comprehensive status information for debugging and monitoring.

◆ GetTotalInterruptCount()

static hf_u32_t EspGpio::GetTotalInterruptCount ( )
staticnoexcept

Get total interrupt count across all GPIO instances.

Returns
Total number of GPIO interrupts that have occurred

Thread-safe global interrupt counter for system monitoring.

◆ HandleInterrupt()

void IRAM_ATTR EspGpio::HandleInterrupt ( )
private

Handle interrupt in instance context.

◆ Initialize()

bool EspGpio::Initialize ( )
overridevirtualnoexcept

Initialize the MCU GPIO pin with current configuration.

Returns
true if initialization successful, false otherwise

Configures the physical MCU pin according to the current direction, pull mode, and output mode settings.

Implements BaseGpio.

◆ InitializeAdvancedFeatures()

bool EspGpio::InitializeAdvancedFeatures ( )
privatenoexcept

Initialize advanced features during GPIO initialization.

Returns
true if all advanced features initialized successfully

◆ IsHeld()

bool EspGpio::IsHeld ( ) const
noexcept

Check if pin is currently held.

Returns
true if pin is in hold state

◆ IsInitialized()

bool EspGpio::IsInitialized ( ) const
inlinenoexcept

Check if the GPIO pin has been initialized.

Returns
true if initialized, false otherwise

◆ IsPinAvailable()

bool EspGpio::IsPinAvailable ( ) const
overridevirtualnoexcept

Check if the pin is available for GPIO operations.

Returns
true if pin is available, false if reserved for other functions

Validates that the pin number is valid and not reserved for special functions like SPI, I2C, etc.

Implements BaseGpio.

◆ IsRtcGpio()

static bool EspGpio::IsRtcGpio ( hf_pin_num_t pin_num)
staticnoexcept

Check if pin supports RTC GPIO functionality.

Parameters
pin_numPin number to check
Returns
true if pin supports RTC GPIO (deep sleep, analog functions)

ESP32C6: GPIO0-7 support RTC functionality.

◆ IsStrappingPin()

static bool EspGpio::IsStrappingPin ( hf_pin_num_t pin_num)
staticnoexcept

Check if pin is a strapping pin requiring caution.

Parameters
pin_numPin number to check
Returns
true if pin is a strapping pin

ESP32C6 strapping pins: GPIO4, GPIO5, GPIO8, GPIO9, GPIO15.

◆ IsValidPin()

static bool EspGpio::IsValidPin ( hf_pin_num_t pin_num)
staticnoexcept

Validate if a pin number is valid for the target platform.

Parameters
pin_numPin number to validate
Returns
true if pin is valid for GPIO use, false otherwise

Platform-specific validation using centralized constants.

◆ MapInterruptTrigger()

gpio_int_type_t EspGpio::MapInterruptTrigger ( hf_gpio_interrupt_trigger_t trigger) const
privatenoexcept

Convert BaseGpio::InterruptTrigger to platform-specific interrupt type.

Parameters
triggerBaseGpio interrupt trigger enum
Returns
Platform-specific interrupt type value

◆ ReadImpl()

hf_gpio_err_t EspGpio::ReadImpl ( hf_gpio_state_t & state)
privatenoexcept

◆ SetDirectionImpl()

hf_gpio_err_t EspGpio::SetDirectionImpl ( hf_gpio_direction_t direction)
overrideprotectedvirtualnoexcept

Platform-specific implementation for setting pin direction.

Parameters
directionDesired pin direction (Input or Output)
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Reconfigures the MCU pin as input or output with appropriate pull resistor and drive mode settings.

Implements BaseGpio.

◆ SetDriveCapability()

hf_gpio_err_t EspGpio::SetDriveCapability ( hf_gpio_drive_cap_t capability)
noexcept

Set GPIO drive capability.

Parameters
capabilityNew drive capability level
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Controls the output drive strength from ~5mA (Weak) to ~40mA (Strongest). Higher drive capability allows for faster switching and driving larger loads but increases power consumption and EMI.

◆ SetOutputModeImpl()

hf_gpio_err_t EspGpio::SetOutputModeImpl ( hf_gpio_output_mode_t mode)
overrideprotectedvirtualnoexcept

Platform-specific implementation for setting output mode.

Parameters
modeDesired output mode (PushPull or OpenDrain)
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Changes the output drive characteristics of the MCU pin.

Implements BaseGpio.

◆ SetPinLevelImpl()

hf_gpio_err_t EspGpio::SetPinLevelImpl ( hf_gpio_level_t level)
overrideprotectedvirtualnoexcept

Platform-specific implementation for setting pin electrical level.

Parameters
levelDesired electrical level (HIGH or LOW)
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Sets the MCU pin to the specified electrical level.

Implements BaseGpio.

◆ SetPullModeImpl()

hf_gpio_err_t EspGpio::SetPullModeImpl ( hf_gpio_pull_mode_t mode)
overrideprotectedvirtualnoexcept

Platform-specific implementation for setting pull resistor mode.

Parameters
modeDesired PullMode configuration (Floating, PullUp, or PullDown)
Returns
hf_gpio_err_t::GPIO_SUCCESS if successful, error code otherwise

Configures the MCU's internal pull resistors.

Implements BaseGpio.

◆ StaticInterruptHandler()

static void IRAM_ATTR EspGpio::StaticInterruptHandler ( void * arg)
staticprivate

Static interrupt service routine handler.

Parameters
argPointer to EspGpio instance

◆ SupportsGlitchFilter()

bool EspGpio::SupportsGlitchFilter ( ) const
noexcept

Check if glitch filters are supported.

Returns
true if glitch filters are available

◆ SupportsInterrupts()

hf_gpio_err_t EspGpio::SupportsInterrupts ( ) const
overridevirtualnoexcept

MCU GPIO supports interrupts.

Returns
GPIO_SUCCESS (all MCU GPIOs support interrupts)

Reimplemented from BaseGpio.

◆ SupportsRtcGpio()

bool EspGpio::SupportsRtcGpio ( ) const
noexcept

Check if pin supports RTC GPIO functionality.

Returns
true if pin supports RTC GPIO

◆ WaitForInterrupt()

hf_gpio_err_t EspGpio::WaitForInterrupt ( hf_u32_t timeout_ms = 0)
overridevirtualnoexcept

Wait for GPIO interrupt with timeout.

Parameters
timeout_msTimeout in milliseconds (0 = no timeout)
Returns
hf_gpio_err_t::GPIO_SUCCESS if interrupt occurred, error code otherwise

Reimplemented from BaseGpio.

◆ WriteImpl()

hf_gpio_err_t EspGpio::WriteImpl ( hf_gpio_state_t state)
privatenoexcept

Member Data Documentation

◆ drive_capability_

hf_gpio_drive_cap_t EspGpio::drive_capability_
private

Current drive capability setting.

◆ flex_filter_config_

hf_gpio_flex_filter_config_t EspGpio::flex_filter_config_
private

Flexible filter configuration.

◆ flex_glitch_filter_enabled_

bool EspGpio::flex_glitch_filter_enabled_
private

Flexible glitch filter enabled.

◆ glitch_filter_handle_

void* EspGpio::glitch_filter_handle_
private

Platform-specific glitch filter handle.

◆ glitch_filter_type_

hf_gpio_glitch_filter_type_t EspGpio::glitch_filter_type_
private

Type of glitch filter configured.

◆ gpio_isr_handler_installed_

bool EspGpio::gpio_isr_handler_installed_
staticprivate

Track if ISR service is installed.

◆ hold_enabled_

bool EspGpio::hold_enabled_
private

Hold function enabled.

◆ interrupt_callback_

InterruptCallback EspGpio::interrupt_callback_
private

User interrupt callback.

◆ interrupt_count_

std::atomic<hf_u32_t> EspGpio::interrupt_count_
private

Number of interrupts occurred (thread-safe)

◆ interrupt_enabled_

bool EspGpio::interrupt_enabled_
private

Interrupt currently enabled.

◆ interrupt_trigger_

hf_gpio_interrupt_trigger_t EspGpio::interrupt_trigger_
private

Current interrupt trigger type.

◆ interrupt_user_data_

void* EspGpio::interrupt_user_data_
private

User data for callback.

◆ isr_handler_added_

bool EspGpio::isr_handler_added_
private

Whether ISR handler was added for this pin.

◆ pin_glitch_filter_enabled_

bool EspGpio::pin_glitch_filter_enabled_
private

Pin glitch filter enabled.

◆ platform_semaphore_

void* EspGpio::platform_semaphore_
private

Platform-specific semaphore for WaitForInterrupt.

◆ rtc_gpio_enabled_

bool EspGpio::rtc_gpio_enabled_
private

RTC GPIO functionality enabled.

◆ rtc_gpio_handle_

void* EspGpio::rtc_gpio_handle_
private

Platform-specific RTC GPIO handle.

◆ sleep_config_

hf_gpio_sleep_config_t EspGpio::sleep_config_
private

Sleep configuration.

◆ wakeup_config_

hf_gpio_wakeup_config_t EspGpio::wakeup_config_
private

Wake-up configuration.


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