Comprehensive PWM testing suite for ESP32 family (noexcept)
This comprehensive test suite validates all functionality of the EspPwm class across different ESP32 variants, with particular focus on LEDC peripheral capabilities and constraints:
Test Coverage:
- Lifecycle Management: Constructor/Destructor, Initialize/Deinitialize
- Configuration: Modes, clock sources, unit configuration
- Channel Management: Configure, enable/disable, validation
- PWM Control: Duty cycle, frequency, resolution control
- Advanced Features: Synchronized operations, complementary outputs
- ESP32-Specific: Hardware fade, idle levels, timer management
- LEDC Validation: Clock source constraints, frequency/resolution limits
- Resource Management: Timer allocation, eviction policies, health checks
- Status & Diagnostics: Statistics, error reporting, capability detection
- Callbacks: Fade callback mechanisms (ESP-IDF LEDC native support only)
- Edge Cases & Stress: Boundary conditions, resource exhaustion, recovery
Hardware Requirements:
- ESP32 development board (any variant: ESP32, ESP32-S2/S3, ESP32-C3/C6, ESP32-H2)
- GPIO pins for PWM output testing (configurable)
- Optional: Logic analyzer or oscilloscope for signal verification
Test Progression Indicator:
GPIO14 toggles HIGH/LOW after each test completion for visual feedback. This allows monitoring test progress without serial output.
- Note
- This test suite is designed to be variant-agnostic and will adapt to the specific LEDC capabilities of the target ESP32 variant.
| bool test_enhanced_validation_system |
( |
| ) |
|
|
noexcept |
Test enhanced validation system with clock source awareness (NEW)
- Returns
- true if all validation system tests pass, false otherwise
Comprehensive validation of the LEDC peripheral constraint system:
Phase 1: Clock Source Validation
- Tests APB clock (80MHz) with various frequency/resolution combinations
- Validates hardware constraint formula: freq × (2^resolution) ≤ clock_freq
- Verifies proper error reporting for invalid combinations
Phase 2: Dynamic Resolution Calculation
- Tests maximum achievable resolution for given frequencies
- Validates theoretical vs. practical resolution limits
- Confirms hardware constraint calculations
Phase 3: Enhanced Duty Cycle Validation
- Tests overflow protection for different resolutions
- Validates automatic clamping of out-of-range values
- Confirms resolution-specific duty cycle ranges
Phase 4: Auto-Fallback Functionality
- Tests automatic resolution adjustment for problematic combinations
- Validates fallback resolution selection algorithms
- Confirms graceful handling of impossible combinations
- Note
- This test validates the core LEDC peripheral constraint system
- Warning
- Tests may fail on ESP32 variants with different LEDC capabilities
- See also
- test_frequency_resolution_validation() for basic constraint testing
-
SetFrequencyWithAutoFallback() for automatic resolution adjustment
| bool test_timer_management |
( |
| ) |
|
|
noexcept |
Test comprehensive LEDC timer resource management.
- Returns
- true if all timer management tests pass, false otherwise
Validates advanced timer allocation and management features:
Phase 1: Basic Timer Allocation
- Tests automatic timer assignment for different frequency/resolution combinations
- Validates timer sharing optimization for compatible frequencies
- Confirms proper timer resource tracking
Phase 2: Timer Exhaustion Scenarios
- Tests behavior when all timers are allocated with incompatible combinations
- Validates proper error reporting (TIMER_CONFLICT)
- Confirms system stability under resource pressure
Phase 3: Compatible Frequency Reuse
- Tests timer sharing for frequencies within tolerance (±5%)
- Validates resource optimization and efficiency
Phase 4: Timer Recovery
- Tests timer resource recovery after channel release
- Validates automatic cleanup and reallocation
Phase 5: Forced Timer Assignment
- Tests manual timer assignment with ForceTimerAssignment()
- Validates override of automatic allocation
Phase 6: Diagnostics Validation
- Tests statistics and diagnostics reporting accuracy
- Validates resource usage tracking
- Note
- This test exercises the core LEDC timer management algorithms
- Warning
- Timer allocation behavior may vary between ESP32 variants
- See also
- FindOrAllocateTimer() for Timer Module allocation implementation
-
ForceTimerAssignment() for manual Timer Module control