ESP32C6 RMT-based Programmable IO Channel implementation with advanced ESP-IDF v5.5+ features.
More...
|
| | EspPio () noexcept |
| | Constructor.
|
| |
| | ~EspPio () noexcept override |
| | Destructor.
|
| |
| | EspPio (const EspPio &)=delete |
| |
| EspPio & | operator= (const EspPio &)=delete |
| |
| | EspPio (EspPio &&) noexcept=default |
| |
| EspPio & | operator= (EspPio &&) noexcept=default |
| |
| hf_pio_err_t | Initialize () noexcept override |
| | Initialize the PIO peripheral.
|
| |
| hf_pio_err_t | Deinitialize () noexcept override |
| | Deinitialize the PIO peripheral.
|
| |
| hf_pio_err_t | ConfigureChannel (hf_u8_t channel_id, const hf_pio_channel_config_t &config) noexcept override |
| | Configure a PIO channel.
|
| |
| hf_pio_err_t | Transmit (hf_u8_t channel_id, const hf_pio_symbol_t *symbols, size_t symbol_count, bool wait_completion=false) noexcept override |
| | Transmit a sequence of symbols.
|
| |
| hf_pio_err_t | StartReceive (hf_u8_t channel_id, hf_pio_symbol_t *buffer, size_t buffer_size, uint32_t timeout_us=0) noexcept override |
| | Start receiving symbols.
|
| |
| hf_pio_err_t | StopReceive (hf_u8_t channel_id, size_t &symbols_received) noexcept override |
| | Stop receiving and get the number of symbols received.
|
| |
| bool | IsChannelBusy (hf_u8_t channel_id) const noexcept override |
| | Check if a channel is currently busy.
|
| |
| hf_pio_err_t | GetChannelStatus (hf_u8_t channel_id, hf_pio_channel_status_t &status) const noexcept override |
| | Get channel status information.
|
| |
| hf_pio_err_t | GetCapabilities (hf_pio_capabilities_t &capabilities) const noexcept override |
| | Get PIO capabilities.
|
| |
| void | SetTransmitCallback (hf_u8_t channel_id, hf_pio_transmit_callback_t callback, void *user_data=nullptr) noexcept override |
| | Set callback for transmission complete events.
|
| |
| void | SetReceiveCallback (hf_u8_t channel_id, hf_pio_receive_callback_t callback, void *user_data=nullptr) noexcept override |
| | Set callback for reception complete events.
|
| |
| void | SetErrorCallback (hf_u8_t channel_id, hf_pio_error_callback_t callback, void *user_data=nullptr) noexcept override |
| | Set callback for error events.
|
| |
| void | ClearChannelCallbacks (hf_u8_t channel_id) noexcept override |
| | Clear all callbacks for a specific channel.
|
| |
| void | ClearCallbacks () noexcept override |
| | Clear all callbacks.
|
| |
| hf_pio_err_t | GetStatistics (hf_u8_t channel_id, hf_pio_statistics_t &statistics) const noexcept override |
| | Get PIO operation statistics.
|
| |
| hf_pio_err_t | GetDiagnostics (hf_u8_t channel_id, hf_pio_diagnostics_t &diagnostics) const noexcept override |
| | Get PIO diagnostic information.
|
| |
| hf_pio_err_t | TransmitRawRmtSymbols (hf_u8_t channel_id, const rmt_symbol_word_t *rmt_symbols, size_t symbol_count, bool wait_completion=false) noexcept |
| | Transmit raw RMT symbols directly (bypassing hf_pio_symbol_t conversion)
|
| |
| hf_pio_err_t | ReceiveRawRmtSymbols (hf_u8_t channel_id, rmt_symbol_word_t *rmt_buffer, size_t buffer_size, size_t &symbols_received, uint32_t timeout_us=10000) noexcept |
| | Receive raw RMT symbols directly (bypassing hf_pio_symbol_t conversion)
|
| |
| hf_pio_err_t | ConfigureAdvancedRmt (hf_u8_t channel_id, size_t memory_blocks=64, bool enable_dma=false, uint32_t queue_depth=4) noexcept |
| | Configure advanced RMT channel settings.
|
| |
| hf_pio_err_t | ConfigureCarrier (hf_u8_t channel_id, uint32_t carrier_freq_hz, float duty_cycle) noexcept |
| | Configure carrier modulation for IR protocols.
|
| |
| hf_pio_err_t | EnableLoopback (hf_u8_t channel_id, bool enable) noexcept |
| | Enable/disable loopback mode for testing.
|
| |
| size_t | GetMaxSymbolCount () const noexcept |
| | Get the maximum number of symbols that can be transmitted in one operation.
|
| |
| bool | ValidatePioSystem () noexcept |
| | Comprehensive PIO system validation and performance test.
|
| |
| hf_pio_err_t | ConfigureEncoder (hf_u8_t channel_id, const hf_pio_symbol_t &bit0_config, const hf_pio_symbol_t &bit1_config) noexcept |
| | Configure RMT encoder for specific protocol.
|
| |
| hf_pio_err_t | SetIdleLevel (hf_u8_t channel_id, bool idle_level) noexcept |
| | Set RMT channel idle output level.
|
| |
| hf_pio_err_t | GetChannelStatistics (hf_u8_t channel_id, hf_pio_channel_statistics_t &stats) const noexcept |
| | Get current RMT channel statistics.
|
| |
| hf_pio_err_t | ResetChannelStatistics (hf_u8_t channel_id) noexcept |
| | Reset channel statistics counters.
|
| |
| hf_pio_err_t | GetActualResolution (hf_u8_t channel_id, hf_u32_t &achieved_resolution_ns) const noexcept |
| | Get the actual achieved resolution for a channel in nanoseconds.
|
| |
| hf_pio_err_t | SetClockSource (hf_u8_t channel_id, rmt_clock_source_t clk_src) noexcept |
| | Allow caller to choose the RMT clock source per channel.
|
| |
| hf_pio_err_t | GetClockSource (hf_u8_t channel_id, rmt_clock_source_t &clk_src) const noexcept |
| | Get the currently selected RMT clock source for a channel.
|
| |
| hf_pio_err_t | GetSourceClockHz (hf_u8_t channel_id, hf_u32_t &clock_hz) const noexcept |
| | Get the current source clock frequency for a channel (Hz)
|
| |
| virtual | ~BasePio () noexcept=default |
| | Virtual destructor.
|
| |
| | BasePio (const BasePio &)=delete |
| |
| BasePio & | operator= (const BasePio &)=delete |
| |
| | BasePio (BasePio &&) noexcept=default |
| |
| BasePio & | operator= (BasePio &&) noexcept=default |
| |
| bool | IsInitialized () const noexcept |
| | Check if the PIO is initialized.
|
| |
| bool | EnsureInitialized () noexcept |
| | Ensures that the PIO is initialized (lazy initialization).
|
| |
| bool | EnsureDeinitialized () noexcept |
| | Ensures that the PIO is deinitialized (lazy deinitialization).
|
| |
| virtual hf_pio_err_t | ResetStatistics () noexcept |
| | Reset PIO operation statistics.
|
| |
| virtual hf_pio_err_t | ResetDiagnostics () noexcept |
| | Reset PIO diagnostic information.
|
| |
|
| bool | IsValidChannelId (hf_u8_t channel_id) const noexcept |
| | Validate channel ID.
|
| |
| hf_pio_err_t | ConvertToRmtSymbols (const hf_pio_symbol_t *symbols, size_t symbol_count, rmt_symbol_word_t *rmt_symbols, size_t &rmt_symbol_count) noexcept |
| | Convert hf_pio_symbol_t array to RMT symbol format.
|
| |
| hf_pio_err_t | ConvertFromRmtSymbols (const rmt_symbol_word_t *rmt_symbols, size_t rmt_symbol_count, hf_pio_symbol_t *symbols, size_t max_symbols, size_t &symbols_converted) noexcept |
| | Convert RMT symbols back to hf_pio_symbol_t format.
|
| |
| hf_pio_err_t | InitializeChannel (hf_u8_t channel_id) noexcept |
| | Initialize a specific channel.
|
| |
| hf_pio_err_t | DeinitializeChannel (hf_u8_t channel_id) noexcept |
| | Deinitialize a specific channel.
|
| |
| hf_pio_err_t | ValidateSymbols (const hf_pio_symbol_t *symbols, size_t symbol_count) const noexcept |
| | Validate symbol array.
|
| |
| hf_u32_t | CalculateResolutionHz (hf_u32_t resolution_ns, hf_u32_t &actual_resolution_ns, hf_u32_t source_clock_hz) const noexcept |
| | Calculate the best possible resolution_hz from requested resolution_ns.
|
| |
| uint32_t | CalculateClockDivider (uint32_t resolution_ns, uint32_t &actual_resolution_ns, uint32_t source_clock_hz) const noexcept |
| | Calculate RMT clock divider for desired resolution.
|
| |
| uint32_t | GetEffectiveClockFrequency (uint32_t clock_divider, uint32_t source_clock_hz) const noexcept |
| | Get effective RMT clock frequency for a given divider.
|
| |
| hf_pio_err_t | GetResolutionConstraints (hf_u32_t &min_resolution_ns, hf_u32_t &max_resolution_ns, hf_u32_t &clock_freq_hz) const noexcept |
| | Get information about resolution constraints for current ESP32 variant.
|
| |
| hf_pio_err_t | GetResolutionConstraints (hf_u8_t channel_id, hf_u32_t &min_resolution_ns, hf_u32_t &max_resolution_ns, hf_u32_t &clock_freq_hz) const noexcept |
| | Get resolution constraints for a specific channel's selected clock source.
|
| |
| hf_pio_err_t | ValidateChannelConfiguration (hf_u8_t channel_id, const hf_pio_channel_config_t &config) const noexcept |
| | Validate channel configuration for current ESP32 variant.
|
| |
| void | InvokeChannelErrorCallback (hf_u8_t channel_id, hf_pio_err_t error) noexcept |
| | Invoke channel-specific error callback.
|
| |
ESP32C6 RMT-based Programmable IO Channel implementation with advanced ESP-IDF v5.5+ features.
This class implements the BasePio interface using the ESP32C6's advanced RMT peripheral with full ESP-IDF v5.5+ feature support. The RMT peripheral is specifically designed for generating and receiving infrared remote control signals, but it's versatile enough to handle many types of precisely-timed digital protocols with hardware acceleration.
Key ESP32C6 RMT features utilized:
- Hardware symbol encoding with configurable timing and DMA support
- Built-in carrier generation for IR protocols with precise frequency control
- Configurable idle levels and end markers with hardware validation
- Interrupt-driven operation with minimal CPU overhead and advanced callbacks
- Support for both transmission and reception with hardware filtering
- Advanced power management and ULP integration capabilities
- Hardware oversampling and digital filtering for noise reduction
- Multi-channel synchronization and triggered sampling support
Advanced ESP-IDF v5.5+ Features:
- DMA-accelerated transfers for high-throughput applications
- Hardware-based digital filters for signal conditioning
- Advanced calibration and drift compensation mechanisms
- Real-time threshold monitoring with interrupt notifications
- Zero-crossing detection for AC signal analysis
- Adaptive power management for battery-powered applications
Robustness Features:
- True lazy initialization (no hardware access until needed)
- Comprehensive error handling and diagnostics
- Thread-safe operation with mutex protection
- Resource leak prevention with RAII principles
- Extensive validation and bounds checking
Limitations:
- Maximum symbol duration depends on RMT clock configuration
- Symbol buffer size is limited by available memory
- Some advanced features may not be available on all ESP32 variants
- DMA mode requires continuous memory allocation
- Note
- This implementation prioritizes performance, accuracy, and resource efficiency.
-
All advanced features are gracefully degraded on older ESP-IDF versions.