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

ESP32C6 RMT-based Programmable IO Channel implementation with advanced ESP-IDF v5.5+ features. More...

#include <EspPio.h>

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

Classes

struct  ChannelState
 

Public Member Functions

 EspPio () noexcept
 Constructor.
 
 ~EspPio () noexcept override
 Destructor.
 
 EspPio (const EspPio &)=delete
 
EspPiooperator= (const EspPio &)=delete
 
 EspPio (EspPio &&) noexcept=default
 
EspPiooperator= (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)
 
- Public Member Functions inherited from BasePio
virtual ~BasePio () noexcept=default
 Virtual destructor.
 
 BasePio (const BasePio &)=delete
 
BasePiooperator= (const BasePio &)=delete
 
 BasePio (BasePio &&) noexcept=default
 
BasePiooperator= (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.
 

Private Member Functions

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.
 

Static Private Member Functions

static hf_u32_t GetClockSourceFrequency (rmt_clock_source_t clk_src) noexcept
 Map an RMT clock source to its nominal frequency in Hz.
 
static hf_u32_t ResolveClockSourceHz (rmt_clock_source_t clk_src) noexcept
 

Private Attributes

std::array< ChannelState, MAX_CHANNELSchannels_
 
PlatformMutex state_mutex_
 
hf_pio_statistics_t global_statistics_
 
hf_pio_diagnostics_t global_diagnostics_
 

Static Private Attributes

static constexpr hf_u8_t MAX_CHANNELS = HF_RMT_MAX_CHANNELS
 
static constexpr size_t MAX_SYMBOLS_PER_TRANSMISSION = 256
 
static constexpr uint32_t DEFAULT_RESOLUTION_NS = 1000
 
static constexpr uint32_t RMT_CLK_SRC_FREQ = 80000000
 
static constexpr const char * TAG = "EspPio"
 Logging tag.
 

Additional Inherited Members

- Protected Member Functions inherited from BasePio
 BasePio () noexcept
 Protected constructor.
 
- Protected Attributes inherited from BasePio
bool initialized_
 Initialization state tracking.
 
hf_pio_statistics_t statistics_
 PIO operation statistics.
 
hf_pio_diagnostics_t diagnostics_
 PIO diagnostic information.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ EspPio() [1/3]

EspPio::EspPio ( )
noexcept

Constructor.

◆ ~EspPio()

EspPio::~EspPio ( )
overridenoexcept

Destructor.

◆ EspPio() [2/3]

EspPio::EspPio ( const EspPio & )
delete

◆ EspPio() [3/3]

EspPio::EspPio ( EspPio && )
defaultnoexcept

Member Function Documentation

◆ CalculateClockDivider()

uint32_t EspPio::CalculateClockDivider ( uint32_t resolution_ns,
uint32_t & actual_resolution_ns,
uint32_t source_clock_hz ) const
privatenoexcept

Calculate RMT clock divider for desired resolution.

Parameters
resolution_nsDesired resolution in nanoseconds
actual_resolution_ns[out] Actual resolution that will be achieved
source_clock_hzSource clock frequency in Hz for the selected clk_src
Returns
Clock divider value (1-255)
Note
This method handles the 8-bit divider constraint and calculates the closest achievable resolution

◆ CalculateResolutionHz()

hf_u32_t EspPio::CalculateResolutionHz ( hf_u32_t resolution_ns,
hf_u32_t & actual_resolution_ns,
hf_u32_t source_clock_hz ) const
privatenoexcept

Calculate the best possible resolution_hz from requested resolution_ns.

Parameters
resolution_nsRequested resolution in nanoseconds
actual_resolution_ns[out] Actual resolution that will be achieved
source_clock_hzSource clock frequency in Hz for the selected clk_src
Returns
Calculated resolution_hz for RMT peripheral
Note
This handles the 8-bit divider constraint (1-255) and returns the closest achievable resolution

◆ ClearCallbacks()

void EspPio::ClearCallbacks ( )
overridevirtualnoexcept

Clear all callbacks.

Implements BasePio.

◆ ClearChannelCallbacks()

void EspPio::ClearChannelCallbacks ( hf_u8_t channel_id)
overridevirtualnoexcept

Clear all callbacks for a specific channel.

Parameters
channel_idChannel identifier

Implements BasePio.

◆ ConfigureAdvancedRmt()

hf_pio_err_t EspPio::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.

Parameters
channel_idChannel identifier
memory_blocksNumber of memory blocks (symbols) to allocate
enable_dmaEnable DMA mode for large transfers
queue_depthTransmit queue depth
Returns
Error code indicating success or failure

◆ ConfigureCarrier()

hf_pio_err_t EspPio::ConfigureCarrier ( hf_u8_t channel_id,
uint32_t carrier_freq_hz,
float duty_cycle )
noexcept

Configure carrier modulation for IR protocols.

Parameters
channel_idChannel identifier
carrier_freq_hzCarrier frequency in Hz (0 to disable)
duty_cycleCarrier duty cycle (0.0 to 1.0)
Returns
Error code indicating success or failure

◆ ConfigureChannel()

hf_pio_err_t EspPio::ConfigureChannel ( hf_u8_t channel_id,
const hf_pio_channel_config_t & config )
overridevirtualnoexcept

Configure a PIO channel.

Parameters
channel_idChannel identifier
configChannel configuration
Returns
Error code indicating success or failure

Implements BasePio.

◆ ConfigureEncoder()

hf_pio_err_t EspPio::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.

Parameters
channel_idChannel identifier
bit0_configConfiguration for bit 0 encoding
bit1_configConfiguration for bit 1 encoding
Returns
Error code indicating success or failure

◆ ConvertFromRmtSymbols()

hf_pio_err_t EspPio::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 )
privatenoexcept

Convert RMT symbols back to hf_pio_symbol_t format.

Parameters
rmt_symbolsInput RMT symbols to convert
rmt_symbol_countNumber of RMT symbols to convert
symbolsOutput buffer for converted PIO symbols
max_symbolsMaximum number of PIO symbols that can be stored in the buffer
symbols_converted[out] Actual number of PIO symbols converted

◆ ConvertToRmtSymbols()

hf_pio_err_t EspPio::ConvertToRmtSymbols ( const hf_pio_symbol_t * symbols,
size_t symbol_count,
rmt_symbol_word_t * rmt_symbols,
size_t & rmt_symbol_count )
privatenoexcept

Convert hf_pio_symbol_t array to RMT symbol format.

◆ Deinitialize()

hf_pio_err_t EspPio::Deinitialize ( )
overridevirtualnoexcept

Deinitialize the PIO peripheral.

Returns
Error code indicating success or failure

Implements BasePio.

◆ DeinitializeChannel()

hf_pio_err_t EspPio::DeinitializeChannel ( hf_u8_t channel_id)
privatenoexcept

Deinitialize a specific channel.

◆ EnableLoopback()

hf_pio_err_t EspPio::EnableLoopback ( hf_u8_t channel_id,
bool enable )
noexcept

Enable/disable loopback mode for testing.

Parameters
channel_idChannel identifier
enabletrue to enable loopback, false to disable
Returns
Error code indicating success or failure

◆ GetActualResolution()

hf_pio_err_t EspPio::GetActualResolution ( hf_u8_t channel_id,
hf_u32_t & achieved_resolution_ns ) const
noexcept

Get the actual achieved resolution for a channel in nanoseconds.

Parameters
channel_idChannel identifier
achieved_resolution_ns[out] Actual resolution achieved by hardware
Returns
Error code indicating success or failure
Note
Due to 8-bit clock divider limitations (1-255), the actual resolution may differ from the requested resolution_ns in the configuration

◆ GetCapabilities()

hf_pio_err_t EspPio::GetCapabilities ( hf_pio_capabilities_t & capabilities) const
overridevirtualnoexcept

Get PIO capabilities.

Parameters
capabilities[out] Capability information
Returns
Error code indicating success or failure

Implements BasePio.

◆ GetChannelStatistics()

hf_pio_err_t EspPio::GetChannelStatistics ( hf_u8_t channel_id,
hf_pio_channel_statistics_t & stats ) const
noexcept

Get current RMT channel statistics.

Parameters
channel_idChannel identifier
stats[out] Channel statistics structure
Returns
Error code indicating success or failure

◆ GetChannelStatus()

hf_pio_err_t EspPio::GetChannelStatus ( hf_u8_t channel_id,
hf_pio_channel_status_t & status ) const
overridevirtualnoexcept

Get channel status information.

Parameters
channel_idChannel identifier
status[out] Status information
Returns
Error code indicating success or failure

Implements BasePio.

◆ GetClockSource()

hf_pio_err_t EspPio::GetClockSource ( hf_u8_t channel_id,
rmt_clock_source_t & clk_src ) const
noexcept

Get the currently selected RMT clock source for a channel.

◆ GetClockSourceFrequency()

static hf_u32_t EspPio::GetClockSourceFrequency ( rmt_clock_source_t clk_src)
inlinestaticprivatenoexcept

Map an RMT clock source to its nominal frequency in Hz.

◆ GetDiagnostics()

hf_pio_err_t EspPio::GetDiagnostics ( hf_u8_t channel_id,
hf_pio_diagnostics_t & diagnostics ) const
overridevirtualnoexcept

Get PIO diagnostic information.

Parameters
channel_idChannel identifier
diagnosticsReference to diagnostics structure to fill
Returns
hf_pio_err_t::PIO_SUCCESS if successful, error code otherwise

Reimplemented from BasePio.

◆ GetEffectiveClockFrequency()

uint32_t EspPio::GetEffectiveClockFrequency ( uint32_t clock_divider,
uint32_t source_clock_hz ) const
privatenoexcept

Get effective RMT clock frequency for a given divider.

Parameters
clock_dividerClock divider value
source_clock_hzSource clock frequency in Hz for the selected clk_src
Returns
Effective clock frequency in Hz

◆ GetMaxSymbolCount()

size_t EspPio::GetMaxSymbolCount ( ) const
noexcept

Get the maximum number of symbols that can be transmitted in one operation.

Returns
Maximum symbol count

◆ GetResolutionConstraints() [1/2]

hf_pio_err_t EspPio::GetResolutionConstraints ( hf_u32_t & min_resolution_ns,
hf_u32_t & max_resolution_ns,
hf_u32_t & clock_freq_hz ) const
privatenoexcept

Get information about resolution constraints for current ESP32 variant.

Parameters
min_resolution_ns[out] Minimum achievable resolution in nanoseconds
max_resolution_ns[out] Maximum achievable resolution in nanoseconds
clock_freq_hz[out] Source clock frequency in Hz
Returns
Error code indicating success or failure

◆ GetResolutionConstraints() [2/2]

hf_pio_err_t EspPio::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
privatenoexcept

Get resolution constraints for a specific channel's selected clock source.

◆ GetSourceClockHz()

hf_pio_err_t EspPio::GetSourceClockHz ( hf_u8_t channel_id,
hf_u32_t & clock_hz ) const
noexcept

Get the current source clock frequency for a channel (Hz)

◆ GetStatistics()

hf_pio_err_t EspPio::GetStatistics ( hf_u8_t channel_id,
hf_pio_statistics_t & statistics ) const
overridevirtualnoexcept

Get PIO operation statistics.

Parameters
channel_idChannel identifier
statisticsReference to statistics structure to fill
Returns
hf_pio_err_t::PIO_SUCCESS if successful, error code otherwise

Reimplemented from BasePio.

◆ Initialize()

hf_pio_err_t EspPio::Initialize ( )
overridevirtualnoexcept

Initialize the PIO peripheral.

Returns
Error code indicating success or failure

Implements BasePio.

◆ InitializeChannel()

hf_pio_err_t EspPio::InitializeChannel ( hf_u8_t channel_id)
privatenoexcept

Initialize a specific channel.

◆ InvokeChannelErrorCallback()

void EspPio::InvokeChannelErrorCallback ( hf_u8_t channel_id,
hf_pio_err_t error )
privatenoexcept

Invoke channel-specific error callback.

Parameters
channel_idChannel identifier
errorError that occurred

◆ IsChannelBusy()

bool EspPio::IsChannelBusy ( hf_u8_t channel_id) const
overridevirtualnoexcept

Check if a channel is currently busy.

Parameters
channel_idChannel identifier
Returns
true if channel is busy, false otherwise

Implements BasePio.

◆ IsValidChannelId()

bool EspPio::IsValidChannelId ( hf_u8_t channel_id) const
privatenoexcept

Validate channel ID.

◆ operator=() [1/2]

EspPio & EspPio::operator= ( const EspPio & )
delete

◆ operator=() [2/2]

EspPio & EspPio::operator= ( EspPio && )
defaultnoexcept

◆ ReceiveRawRmtSymbols()

hf_pio_err_t EspPio::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)

Parameters
channel_idChannel identifier
rmt_bufferBuffer to store raw RMT symbols
buffer_sizeSize of buffer in RMT symbols
symbols_received[out] Number of symbols actually received
timeout_usTimeout in microseconds
Returns
Error code indicating success or failure
Note
This provides direct RMT access similar to rmt_wrapper.hpp

◆ ResetChannelStatistics()

hf_pio_err_t EspPio::ResetChannelStatistics ( hf_u8_t channel_id)
noexcept

Reset channel statistics counters.

Parameters
channel_idChannel identifier
Returns
Error code indicating success or failure

◆ ResolveClockSourceHz()

static hf_u32_t EspPio::ResolveClockSourceHz ( rmt_clock_source_t clk_src)
inlinestaticprivatenoexcept

◆ SetClockSource()

hf_pio_err_t EspPio::SetClockSource ( hf_u8_t channel_id,
rmt_clock_source_t clk_src )
noexcept

Allow caller to choose the RMT clock source per channel.

Parameters
channel_idChannel identifier
clk_srcRMT clock source (e.g. RMT_CLK_SRC_PLL_F80M, RMT_CLK_SRC_XTAL, RMT_CLK_SRC_RC_FAST)
Returns
Error code indicating success or failure
Note
Must be called before ConfigureChannel() to take effect for initial install. Reconfiguration via ConfigureAdvancedRmt() also respects this selection.

◆ SetErrorCallback()

void EspPio::SetErrorCallback ( hf_u8_t channel_id,
hf_pio_error_callback_t callback,
void * user_data = nullptr )
overridevirtualnoexcept

Set callback for error events.

Parameters
channel_idChannel identifier
callbackCallback function
user_dataUser data to pass to callback

Implements BasePio.

◆ SetIdleLevel()

hf_pio_err_t EspPio::SetIdleLevel ( hf_u8_t channel_id,
bool idle_level )
noexcept

Set RMT channel idle output level.

Parameters
channel_idChannel identifier
idle_leveltrue for high, false for low
Returns
Error code indicating success or failure

◆ SetReceiveCallback()

void EspPio::SetReceiveCallback ( hf_u8_t channel_id,
hf_pio_receive_callback_t callback,
void * user_data = nullptr )
overridevirtualnoexcept

Set callback for reception complete events.

Parameters
channel_idChannel identifier
callbackCallback function
user_dataUser data to pass to callback

Implements BasePio.

◆ SetTransmitCallback()

void EspPio::SetTransmitCallback ( hf_u8_t channel_id,
hf_pio_transmit_callback_t callback,
void * user_data = nullptr )
overridevirtualnoexcept

Set callback for transmission complete events.

Parameters
channel_idChannel identifier
callbackCallback function
user_dataUser data to pass to callback

Implements BasePio.

◆ StartReceive()

hf_pio_err_t EspPio::StartReceive ( hf_u8_t channel_id,
hf_pio_symbol_t * buffer,
size_t buffer_size,
uint32_t timeout_us = 0 )
overridevirtualnoexcept

Start receiving symbols.

Parameters
channel_idChannel identifier
bufferBuffer to store received symbols
buffer_sizeSize of the buffer
timeout_usTimeout in microseconds (0 = no timeout)
Returns
Error code indicating success or failure

Implements BasePio.

◆ StopReceive()

hf_pio_err_t EspPio::StopReceive ( hf_u8_t channel_id,
size_t & symbols_received )
overridevirtualnoexcept

Stop receiving and get the number of symbols received.

Parameters
channel_idChannel identifier
symbols_received[out] Number of symbols actually received
Returns
Error code indicating success or failure

Implements BasePio.

◆ Transmit()

hf_pio_err_t EspPio::Transmit ( hf_u8_t channel_id,
const hf_pio_symbol_t * symbols,
size_t symbol_count,
bool wait_completion = false )
overridevirtualnoexcept

Transmit a sequence of symbols.

Parameters
channel_idChannel identifier
symbolsArray of symbols to transmit
symbol_countNumber of symbols in the array
wait_completionIf true, block until transmission is complete
Returns
Error code indicating success or failure

Implements BasePio.

◆ TransmitRawRmtSymbols()

hf_pio_err_t EspPio::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)

Parameters
channel_idChannel identifier
rmt_symbolsArray of raw RMT symbols
symbol_countNumber of RMT symbols
wait_completionIf true, block until transmission is complete
Returns
Error code indicating success or failure
Note
This provides direct RMT access similar to rmt_wrapper.hpp

◆ ValidateChannelConfiguration()

hf_pio_err_t EspPio::ValidateChannelConfiguration ( hf_u8_t channel_id,
const hf_pio_channel_config_t & config ) const
privatenoexcept

Validate channel configuration for current ESP32 variant.

Parameters
channel_idChannel identifier
configChannel configuration to validate
Returns
Error code indicating validation result

◆ ValidatePioSystem()

bool EspPio::ValidatePioSystem ( )
noexcept

Comprehensive PIO system validation and performance test.

Returns
true if all systems pass validation, false otherwise

◆ ValidateSymbols()

hf_pio_err_t EspPio::ValidateSymbols ( const hf_pio_symbol_t * symbols,
size_t symbol_count ) const
privatenoexcept

Validate symbol array.

Member Data Documentation

◆ channels_

std::array<ChannelState, MAX_CHANNELS> EspPio::channels_
private

◆ DEFAULT_RESOLUTION_NS

constexpr uint32_t EspPio::DEFAULT_RESOLUTION_NS = 1000
staticconstexprprivate

◆ global_diagnostics_

hf_pio_diagnostics_t EspPio::global_diagnostics_
private

◆ global_statistics_

hf_pio_statistics_t EspPio::global_statistics_
private

◆ MAX_CHANNELS

constexpr hf_u8_t EspPio::MAX_CHANNELS = HF_RMT_MAX_CHANNELS
staticconstexprprivate

◆ MAX_SYMBOLS_PER_TRANSMISSION

constexpr size_t EspPio::MAX_SYMBOLS_PER_TRANSMISSION = 256
staticconstexprprivate

◆ RMT_CLK_SRC_FREQ

constexpr uint32_t EspPio::RMT_CLK_SRC_FREQ = 80000000
staticconstexprprivate

◆ state_mutex_

PlatformMutex EspPio::state_mutex_
mutableprivate

◆ TAG

constexpr const char* EspPio::TAG = "EspPio"
staticconstexprprivate

Logging tag.


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