HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
PioComprehensiveTest.cpp File Reference

Comprehensive PIO testing suite for ESP32-C6 DevKit-M-1 with RMT peripheral (noexcept) More...

Include dependency graph for PioComprehensiveTest.cpp:

Classes

struct  CallbackTestData
 

Functions

void TestTransmitCallback (hf_u8_t channel_id, size_t symbols_sent, void *user_data)
 
void TestReceiveCallback (hf_u8_t channel_id, const hf_pio_symbol_t *symbols, size_t symbol_count, void *user_data)
 
void TestErrorCallback (hf_u8_t channel_id, hf_pio_err_t error, void *user_data)
 
hf_pio_channel_config_t create_test_channel_config (hf_gpio_num_t gpio_pin, hf_pio_direction_t direction=hf_pio_direction_t::Transmit) noexcept
 Create a default PIO channel configuration for testing using resolution_ns ESP32-C6 specific configuration for RMT compatibility with latest improvements.
 
void create_ws2812_rgb_symbols (uint8_t r, uint8_t g, uint8_t b, hf_pio_symbol_t *symbols, uint32_t resolution_ns) noexcept
 Create WS2812 symbols for RGB data using resolution_ns timing.
 
hf_pio_symbol_t create_ws2812_reset_symbol (uint32_t resolution_ns) noexcept
 Create WS2812 reset symbol using resolution_ns timing.
 
void create_logic_analyzer_test_pattern (hf_pio_symbol_t *symbols, size_t &symbol_count, uint32_t resolution_ns) noexcept
 Create test pattern for logic analyzer verification using resolution_ns timing.
 
void ensure_minimum_tick_duration (hf_pio_symbol_t *symbols, size_t symbol_count, uint32_t min_ticks=1) noexcept
 Ensure minimum tick duration for symbols to prevent "Duration too short" errors.
 
bool test_esp32_variant_detection () noexcept
 
bool test_channel_allocation_helpers () noexcept
 
bool test_channel_direction_validation () noexcept
 
bool test_resolution_ns_usage () noexcept
 
bool test_constructor_default () noexcept
 
bool test_destructor_cleanup () noexcept
 
bool test_initialization_states () noexcept
 
bool test_lazy_initialization () noexcept
 
bool test_channel_configuration () noexcept
 
bool test_multiple_channel_configuration () noexcept
 
bool test_basic_symbol_transmission () noexcept
 
bool test_transmission_edge_cases () noexcept
 
bool test_ws2812_single_led () noexcept
 
bool test_ws2812_multiple_leds () noexcept
 
bool test_ws2812_color_cycle () noexcept
 
bool test_ws2812_brightness_sweep () noexcept
 
bool test_ws2812_pattern_validation () noexcept
 
bool test_ws2812_rainbow_transition () noexcept
 
bool test_logic_analyzer_patterns () noexcept
 
bool test_frequency_sweep () noexcept
 
bool test_rmt_encoder_configuration () noexcept
 
bool test_rmt_carrier_modulation () noexcept
 
bool test_rmt_advanced_configuration () noexcept
 
bool test_loopback_functionality () noexcept
 
bool test_hardware_loopback_gpio8_to_gpio18 () noexcept
 
bool test_callback_functionality () noexcept
 
bool test_statistics_and_diagnostics () noexcept
 
bool test_stress_transmission () noexcept
 
bool test_pio_system_validation () noexcept
 
void app_main ()
 

Variables

static const char * TAG = "PIO_Test"
 
static TestResults g_test_results
 
static constexpr bool ENABLE_CORE_TESTS = true
 
static constexpr bool ENABLE_VARIANT_TESTS = true
 
static constexpr bool ENABLE_CHANNEL_TESTS = true
 
static constexpr bool ENABLE_TRANSMISSION_TESTS = true
 
static constexpr bool ENABLE_WS2812_TESTS = true
 
static constexpr bool ENABLE_ANALYZER_TESTS = true
 
static constexpr bool ENABLE_ADVANCED_TESTS = true
 
static constexpr bool ENABLE_LOOPBACK_TESTS = true
 
static constexpr bool ENABLE_CALLBACK_TESTS = true
 
static constexpr bool ENABLE_DIAGNOSTIC_TESTS = true
 
static constexpr bool ENABLE_STRESS_TESTS = true
 
static constexpr uint32_t WS2812_T0H = 350
 
static constexpr uint32_t WS2812_T0L = 900
 
static constexpr uint32_t WS2812_T1H = 700
 
static constexpr uint32_t WS2812_T1L = 600
 
static constexpr uint32_t WS2812_RESET = 50000
 
static constexpr hf_gpio_num_t TEST_GPIO_TX = 8
 
static constexpr hf_gpio_num_t TEST_GPIO_RX = 18
 
static constexpr uint32_t TEST_RESOLUTION_WS2812_NS = 125
 
static constexpr uint32_t TEST_RESOLUTION_STANDARD_NS = 500
 
static constexpr uint32_t TEST_RESOLUTION_LOW_NS = 10000
 
static CallbackTestData g_callback_data [HF_RMT_MAX_CHANNELS] = {}
 

Detailed Description

Comprehensive PIO testing suite for ESP32-C6 DevKit-M-1 with RMT peripheral (noexcept)

This comprehensive test suite validates all functionality of the EspPio class using ESP-IDF v5.5 RMT with the latest improvements including:

  • Channel-specific callback system with proper user data handling
  • Resolution_ns user interface with internal conversion to resolution_hz
  • ESP32 variant-specific channel validation (TX/RX allocation per variant)
  • Enhanced clock divider calculation with overflow protection
  • Constructor/Destructor behavior
  • Lifecycle management (Initialize/Deinitialize)
  • Channel configuration and management
  • Symbol transmission and reception
  • RMT-specific features (carrier modulation, loopback, encoder configuration)
  • WS2812 LED protocol timing validation with comprehensive color testing (GPIO8) • Primary colors (R/G/B) at maximum brightness for timing stress testing • Secondary colors (Yellow/Magenta/Cyan) and white variations • Brightness sweep tests (0-255) for each color channel • Bit pattern validation (alternating, edge cases, specific patterns) • Rainbow color wheel transitions with HSV to RGB conversion • Rapid color change sequences for protocol stress testing
  • Automated loopback testing (GPIO8 TX -> GPIO18 RX)
  • Logic analyzer test scenarios
  • Advanced RMT features (DMA, memory blocks, queue depth)
  • Status and diagnostics (statistics, error reporting)
  • Channel-specific callbacks (transmit, receive, error)
  • Edge cases and stress testing
  • ASCII Art test result decoration
Note
This test suite is designed for ESP32-C6 DevKitM-1 with ESP-IDF v5.5+ RMT driver
Uses built-in RGB LED on GPIO8 for WS2812 testing and automated loopback
Automated testing: Connect GPIO8 (TX) to GPIO18 (RX) with jumper wire
Incorporates latest PIO improvements: channel-specific callbacks, resolution_hz, variant validation

Function Documentation

◆ app_main()

void app_main ( void )

◆ create_logic_analyzer_test_pattern()

void create_logic_analyzer_test_pattern ( hf_pio_symbol_t * symbols,
size_t & symbol_count,
uint32_t resolution_ns )
noexcept

Create test pattern for logic analyzer verification using resolution_ns timing.

◆ create_test_channel_config()

hf_pio_channel_config_t create_test_channel_config ( hf_gpio_num_t gpio_pin,
hf_pio_direction_t direction = hf_pio_direction_t::Transmit )
noexcept

Create a default PIO channel configuration for testing using resolution_ns ESP32-C6 specific configuration for RMT compatibility with latest improvements.

◆ create_ws2812_reset_symbol()

hf_pio_symbol_t create_ws2812_reset_symbol ( uint32_t resolution_ns)
noexcept

Create WS2812 reset symbol using resolution_ns timing.

◆ create_ws2812_rgb_symbols()

void create_ws2812_rgb_symbols ( uint8_t r,
uint8_t g,
uint8_t b,
hf_pio_symbol_t * symbols,
uint32_t resolution_ns )
noexcept

Create WS2812 symbols for RGB data using resolution_ns timing.

Parameters
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)
symbolsOutput array (must have space for 48 symbols - 24 bits * 2 symbols per bit)
resolution_nsThe resolution in nanoseconds for timing calculations

◆ ensure_minimum_tick_duration()

void ensure_minimum_tick_duration ( hf_pio_symbol_t * symbols,
size_t symbol_count,
uint32_t min_ticks = 1 )
noexcept

Ensure minimum tick duration for symbols to prevent "Duration too short" errors.

Parameters
symbolsArray of symbols to validate
symbol_countNumber of symbols in the array
min_ticksMinimum number of ticks required (default: 1)

◆ test_basic_symbol_transmission()

bool test_basic_symbol_transmission ( )
noexcept

◆ test_callback_functionality()

bool test_callback_functionality ( )
noexcept

◆ test_channel_allocation_helpers()

bool test_channel_allocation_helpers ( )
noexcept

◆ test_channel_configuration()

bool test_channel_configuration ( )
noexcept

◆ test_channel_direction_validation()

bool test_channel_direction_validation ( )
noexcept

◆ test_constructor_default()

bool test_constructor_default ( )
noexcept

◆ test_destructor_cleanup()

bool test_destructor_cleanup ( )
noexcept

◆ test_esp32_variant_detection()

bool test_esp32_variant_detection ( )
noexcept

◆ test_frequency_sweep()

bool test_frequency_sweep ( )
noexcept

◆ test_hardware_loopback_gpio8_to_gpio18()

bool test_hardware_loopback_gpio8_to_gpio18 ( )
noexcept

◆ test_initialization_states()

bool test_initialization_states ( )
noexcept

◆ test_lazy_initialization()

bool test_lazy_initialization ( )
noexcept

◆ test_logic_analyzer_patterns()

bool test_logic_analyzer_patterns ( )
noexcept

◆ test_loopback_functionality()

bool test_loopback_functionality ( )
noexcept

◆ test_multiple_channel_configuration()

bool test_multiple_channel_configuration ( )
noexcept

◆ test_pio_system_validation()

bool test_pio_system_validation ( )
noexcept

◆ test_resolution_ns_usage()

bool test_resolution_ns_usage ( )
noexcept

◆ test_rmt_advanced_configuration()

bool test_rmt_advanced_configuration ( )
noexcept

◆ test_rmt_carrier_modulation()

bool test_rmt_carrier_modulation ( )
noexcept

◆ test_rmt_encoder_configuration()

bool test_rmt_encoder_configuration ( )
noexcept

◆ test_statistics_and_diagnostics()

bool test_statistics_and_diagnostics ( )
noexcept

◆ test_stress_transmission()

bool test_stress_transmission ( )
noexcept

◆ test_transmission_edge_cases()

bool test_transmission_edge_cases ( )
noexcept

◆ test_ws2812_brightness_sweep()

bool test_ws2812_brightness_sweep ( )
noexcept

◆ test_ws2812_color_cycle()

bool test_ws2812_color_cycle ( )
noexcept

◆ test_ws2812_multiple_leds()

bool test_ws2812_multiple_leds ( )
noexcept

◆ test_ws2812_pattern_validation()

bool test_ws2812_pattern_validation ( )
noexcept

◆ test_ws2812_rainbow_transition()

bool test_ws2812_rainbow_transition ( )
noexcept

◆ test_ws2812_single_led()

bool test_ws2812_single_led ( )
noexcept

◆ TestErrorCallback()

void TestErrorCallback ( hf_u8_t channel_id,
hf_pio_err_t error,
void * user_data )

◆ TestReceiveCallback()

void TestReceiveCallback ( hf_u8_t channel_id,
const hf_pio_symbol_t * symbols,
size_t symbol_count,
void * user_data )

◆ TestTransmitCallback()

void TestTransmitCallback ( hf_u8_t channel_id,
size_t symbols_sent,
void * user_data )

Variable Documentation

◆ ENABLE_ADVANCED_TESTS

constexpr bool ENABLE_ADVANCED_TESTS = true
staticconstexpr

◆ ENABLE_ANALYZER_TESTS

constexpr bool ENABLE_ANALYZER_TESTS = true
staticconstexpr

◆ ENABLE_CALLBACK_TESTS

constexpr bool ENABLE_CALLBACK_TESTS = true
staticconstexpr

◆ ENABLE_CHANNEL_TESTS

constexpr bool ENABLE_CHANNEL_TESTS = true
staticconstexpr

◆ ENABLE_CORE_TESTS

constexpr bool ENABLE_CORE_TESTS = true
staticconstexpr

◆ ENABLE_DIAGNOSTIC_TESTS

constexpr bool ENABLE_DIAGNOSTIC_TESTS = true
staticconstexpr

◆ ENABLE_LOOPBACK_TESTS

constexpr bool ENABLE_LOOPBACK_TESTS = true
staticconstexpr

◆ ENABLE_STRESS_TESTS

constexpr bool ENABLE_STRESS_TESTS = true
staticconstexpr

◆ ENABLE_TRANSMISSION_TESTS

constexpr bool ENABLE_TRANSMISSION_TESTS = true
staticconstexpr

◆ ENABLE_VARIANT_TESTS

constexpr bool ENABLE_VARIANT_TESTS = true
staticconstexpr

◆ ENABLE_WS2812_TESTS

constexpr bool ENABLE_WS2812_TESTS = true
staticconstexpr

◆ g_callback_data

CallbackTestData g_callback_data[HF_RMT_MAX_CHANNELS] = {}
static

◆ g_test_results

TestResults g_test_results
static

◆ TAG

const char* TAG = "PIO_Test"
static

◆ TEST_GPIO_RX

constexpr hf_gpio_num_t TEST_GPIO_RX = 18
staticconstexpr

◆ TEST_GPIO_TX

constexpr hf_gpio_num_t TEST_GPIO_TX = 8
staticconstexpr

◆ TEST_RESOLUTION_LOW_NS

constexpr uint32_t TEST_RESOLUTION_LOW_NS = 10000
staticconstexpr

◆ TEST_RESOLUTION_STANDARD_NS

constexpr uint32_t TEST_RESOLUTION_STANDARD_NS = 500
staticconstexpr

◆ TEST_RESOLUTION_WS2812_NS

constexpr uint32_t TEST_RESOLUTION_WS2812_NS = 125
staticconstexpr

◆ WS2812_RESET

constexpr uint32_t WS2812_RESET = 50000
staticconstexpr

◆ WS2812_T0H

constexpr uint32_t WS2812_T0H = 350
staticconstexpr

◆ WS2812_T0L

constexpr uint32_t WS2812_T0L = 900
staticconstexpr

◆ WS2812_T1H

constexpr uint32_t WS2812_T1H = 700
staticconstexpr

◆ WS2812_T1L

constexpr uint32_t WS2812_T1L = 600
staticconstexpr