25#include "driver/gpio.h"
89 hf_gpio_drive_cap_t drive_capability =
90 hf_gpio_drive_cap_t::HF_GPIO_DRIVE_CAP_MEDIUM)
noexcept;
155 void* user_data =
nullptr) noexcept override;
335 hf_gpio_glitch_filter_type_t filter_type,
336 const hf_gpio_flex_filter_config_t* flex_config =
nullptr) noexcept;
411 [[nodiscard]]
bool IsHeld() const noexcept;
Unified GPIO base class for all digital GPIO implementations.
ESP32 GPIO type definitions for hardware abstraction.
uint32_t hf_u32_t
Platform-agnostic 32-bit unsigned integer type.
Definition HardwareTypes.h:52
uint8_t hf_u8_t
Platform-agnostic 8-bit unsigned integer type.
Definition HardwareTypes.h:40
hf_i32_t hf_pin_num_t
Platform-agnostic GPIO pin number type.
Definition HardwareTypes.h:99
Unified GPIO base class for all digital GPIO implementations.
Definition BaseGpio.h:294
bool IsInitialized() const noexcept
Check if the pin is initialized.
Definition BaseGpio.h:786
Advanced MCU-specific implementation of unified BaseGpio with ESP32C6/ESP-IDF v5.5+ features.
Definition EspGpio.h:65
static bool IsStrappingPin(hf_pin_num_t pin_num) noexcept
Check if pin is a strapping pin requiring caution.
hf_gpio_err_t ConfigureSleep(const hf_gpio_sleep_config_t &config) noexcept
Configure GPIO sleep behavior.
bool pin_glitch_filter_enabled_
Pin glitch filter enabled.
Definition EspGpio.h:535
static bool IsValidPin(hf_pin_num_t pin_num) noexcept
Validate if a pin number is valid for the target platform.
bool hold_enabled_
Hold function enabled.
Definition EspGpio.h:539
hf_gpio_err_t GetPinCapabilities(hf_gpio_pin_capabilities_t &capabilities) const noexcept
Get pin capabilities for comprehensive feature detection.
hf_gpio_err_t DisableInterrupt() noexcept override
Disable GPIO interrupt.
hf_gpio_err_t ConfigurePinGlitchFilter(bool enable) noexcept
Configure pin glitch filter (fixed 2 clock cycles).
bool isr_handler_added_
Whether ISR handler was added for this pin.
Definition EspGpio.h:530
hf_gpio_err_t GetStatistics(hf_gpio_statistics_t &statistics) const noexcept override
Get GPIO operation statistics.
hf_gpio_err_t ConfigureFlexGlitchFilter(const hf_gpio_flex_filter_config_t &config) noexcept
Configure flexible glitch filter with custom timing.
hf_gpio_sleep_config_t sleep_config_
Sleep configuration.
Definition EspGpio.h:538
void CleanupAdvancedFeatures() noexcept
Cleanup advanced feature resources.
bool interrupt_enabled_
Interrupt currently enabled.
Definition EspGpio.h:527
hf_gpio_err_t ClearInterruptStats() noexcept override
Clear interrupt statistics/counters.
bool SupportsRtcGpio() const noexcept
Check if pin supports RTC GPIO functionality.
hf_gpio_err_t GetStatusInfo(hf_gpio_status_info_t &status) const noexcept
Get detailed status information for diagnostics.
hf_gpio_err_t ReadImpl(hf_gpio_state_t &state) noexcept
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_drive_cap_t drive_capability_
Current drive capability setting.
Definition EspGpio.h:533
void CleanupInterruptSemaphore() noexcept
Cleanup interrupt semaphore (called from destructor).
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 EnableInterrupt() noexcept override
Enable GPIO interrupt.
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_drive_cap_t GetDriveCapability() const noexcept
Get current drive capability setting.
Definition EspGpio.h:299
gpio_int_type_t MapInterruptTrigger(hf_gpio_interrupt_trigger_t trigger) const noexcept
Convert BaseGpio::InterruptTrigger to platform-specific interrupt type.
hf_gpio_err_t SetPinLevelImpl(hf_gpio_level_t level) noexcept override
Platform-specific implementation for setting pin electrical level.
bool IsHeld() const noexcept
Check if pin is currently held.
bool Initialize() noexcept override
Initialize the MCU GPIO pin with current configuration.
void * platform_semaphore_
Platform-specific semaphore for WaitForInterrupt.
Definition EspGpio.h:529
hf_gpio_interrupt_trigger_t interrupt_trigger_
Current interrupt trigger type.
Definition EspGpio.h:524
hf_gpio_err_t ConfigureHold(bool enable) noexcept
Enable GPIO hold function.
void * rtc_gpio_handle_
Platform-specific RTC GPIO handle.
Definition EspGpio.h:545
bool IsPinAvailable() const noexcept override
Check if the pin is available for GPIO operations.
hf_gpio_err_t GetPinLevelImpl(hf_gpio_level_t &level) noexcept override
Platform-specific implementation for reading pin electrical level.
bool IsInitialized() const noexcept
Check if the GPIO pin has been initialized.
Definition EspGpio.h:199
hf_gpio_wakeup_config_t wakeup_config_
Wake-up configuration.
Definition EspGpio.h:541
InterruptCallback interrupt_callback_
User interrupt callback.
Definition EspGpio.h:525
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.
hf_gpio_err_t GetOutputModeImpl(hf_gpio_output_mode_t &mode) const noexcept override
Platform-specific implementation for reading output mode from hardware.
hf_gpio_err_t SetDriveCapability(hf_gpio_drive_cap_t capability) noexcept
Set GPIO drive capability.
hf_gpio_status_info_t GetConfigurationDump() const noexcept
Get comprehensive GPIO configuration information.
static hf_u32_t GetTotalInterruptCount() noexcept
Get total interrupt count across all GPIO instances.
std::atomic< hf_u32_t > interrupt_count_
Number of interrupts occurred (thread-safe)
Definition EspGpio.h:528
hf_gpio_flex_filter_config_t flex_filter_config_
Flexible filter configuration.
Definition EspGpio.h:537
void IRAM_ATTR HandleInterrupt()
Handle interrupt in instance context.
void * interrupt_user_data_
User data for callback.
Definition EspGpio.h:526
static bool gpio_isr_handler_installed_
Track if ISR service is installed.
Definition EspGpio.h:548
hf_u8_t GetMaxPins() const noexcept override
Get the maximum number of pins supported by this MCU.
bool SupportsGlitchFilter() const noexcept
Check if glitch filters are supported.
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_pull_mode_t GetPullModeImpl() const noexcept override
Platform-specific implementation for reading pull resistor mode.
static bool IsRtcGpio(hf_pin_num_t pin_num) noexcept
Check if pin supports RTC GPIO functionality.
hf_gpio_glitch_filter_type_t glitch_filter_type_
Type of glitch filter configured.
Definition EspGpio.h:534
hf_gpio_err_t ConfigureWakeUp(const hf_gpio_wakeup_config_t &config) noexcept
Configure GPIO as wake-up source.
hf_gpio_err_t DisableGlitchFilters() noexcept
Disable all glitch filters.
hf_gpio_err_t WriteImpl(hf_gpio_state_t state) noexcept
static void IRAM_ATTR StaticInterruptHandler(void *arg)
Static interrupt service routine handler.
hf_gpio_err_t GetDiagnostics(hf_gpio_diagnostics_t &diagnostics) const noexcept override
Get GPIO diagnostics information.
hf_gpio_err_t EnableGlitchFilters() noexcept
Enable all configured glitch filters.
bool Deinitialize() noexcept override
Deinitialize the MCU GPIO pin.
void * glitch_filter_handle_
Platform-specific glitch filter handle.
Definition EspGpio.h:544
hf_gpio_err_t GetInterruptStatus(InterruptStatus &status) noexcept override
Get current interrupt status and statistics.
bool InitializeAdvancedFeatures() noexcept
Initialize advanced features during GPIO initialization.
void CleanupGlitchFilters() noexcept
Cleanup glitch filter resources.
bool rtc_gpio_enabled_
RTC GPIO functionality enabled.
Definition EspGpio.h:540
~EspGpio() override
Destructor - ensures proper cleanup including interrupt resources.
hf_gpio_err_t WaitForInterrupt(hf_u32_t timeout_ms=0) noexcept override
Wait for GPIO interrupt with timeout.
hf_gpio_err_t SetPullModeImpl(hf_gpio_pull_mode_t mode) noexcept override
Platform-specific implementation for setting pull resistor mode.
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.
static hf_u32_t GetActiveGpioCount() noexcept
Get count of currently active GPIO instances.
bool flex_glitch_filter_enabled_
Flexible glitch filter enabled.
Definition EspGpio.h:536
hf_gpio_level_t
GPIO pin electrical levels.
Definition BaseGpio.h:148
hf_gpio_err_t
HardFOC GPIO error codes.
Definition BaseGpio.h:108
hf_gpio_state_t
GPIO pin logical states.
Definition BaseGpio.h:138
hf_gpio_direction_t
GPIO pin direction/mode configuration.
Definition BaseGpio.h:168
hf_gpio_interrupt_trigger_t
GPIO interrupt trigger types.
Definition BaseGpio.h:200
hf_gpio_pull_mode_t
GPIO pull resistor configuration.
Definition BaseGpio.h:188
hf_gpio_output_mode_t
GPIO output drive modes.
Definition BaseGpio.h:178
void(*)(BaseGpio *gpio, hf_gpio_interrupt_trigger_t trigger, void *user_data) InterruptCallback
GPIO interrupt callback function type.
Definition BaseGpio.h:220
hf_gpio_active_state_t
GPIO active state polarity configuration.
Definition BaseGpio.h:158
@ HF_GPIO_DIRECTION_INPUT
Pin configured as input.
@ HF_GPIO_PULL_MODE_FLOATING
No pull resistor (floating/high-impedance)
@ HF_GPIO_OUTPUT_MODE_PUSH_PULL
Push-pull output (strong high and low)
@ HF_GPIO_ACTIVE_HIGH
Active state is electrical high.
GPIO interrupt status structure.
Definition BaseGpio.h:227
GPIO diagnostic information.
Definition BaseGpio.h:259
GPIO operation statistics.
Definition BaseGpio.h:238