ESP32-C6 GPIO Comprehensive Test Suite
This directory contains a comprehensive testing suite specifically designed for the EspGpio class on ESP32-C6 DevKit-M-1 hardware using ESP-IDF v5.5+.
Overview
The GPIO test suite provides thorough validation of all GPIO functionalities including:
Core Features
- โ Basic GPIO initialization and configuration
- โ Input/output operations and state management
- โ Pull resistor configuration (floating, pull-up, pull-down)
- โ Pin validation and error handling
Advanced Features (ESP32-C6 Specific)
- โ Interrupt functionality with multiple trigger types
- โ Drive capability testing (5mA to 40mA)
- โ RTC GPIO support for low-power operations
- โ Glitch filter configuration
- โ Sleep and wake-up functionality
- โ Hold functionality for state retention
Performance & Robustness
- โ Stress testing with rapid state changes
- โ Concurrent GPIO operations
- โ Loopback testing (requires physical wire connection)
- โ Power consumption analysis
- โ Comprehensive diagnostics and statistics
Hardware Setup
ESP32-C6 DevKit-M-1 Pin Layout
The test suite uses the following safe pins on ESP32-C6 DevKit-M-1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Safe Test Pins:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Function โ GPIO Pin โ
โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโค
โ LED Output โ GPIO 8 โ
โ Digital Out 1 โ GPIO 10 โ
โ Digital Out 2 โ GPIO 11 โ
โ Digital Input 1 โ GPIO 0 (BOOT) โ
โ Digital Input 2 โ GPIO 1 โ
โ Interrupt Pin โ GPIO 2 โ
โ Pull Test Pin โ GPIO 3 โ
โ Drive Test Pin โ GPIO 16 โ
โ RTC GPIO Pin โ GPIO 7 โ
โ Analog Pin โ GPIO 6 โ
โ Loopback Out โ GPIO 20 โ
โ Loopback In โ GPIO 21 โ
โ Stress Test Pin โ GPIO 23 โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
Pins to Avoid:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GPIO 9 โ Boot strap โ
โ GPIO 15 โ Boot strap โ
โ GPIO 12, 13 โ USB-JTAG โ
โ GPIO 24-30 โ SPI Flash โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
```text
### Optional Physical Connections
For complete loopback testing, connect:
- **GPIO 20** (Loopback Out) โ **GPIO 21** (Loopback In)
## Building and Running
### Build Commands
```bash
## Build GPIO test suite (Release)
idf.py build -DEXAMPLE_TYPE=gpio_test -DBUILD_TYPE=Release
## Build GPIO test suite (Debug)
idf.py build -DEXAMPLE_TYPE=gpio_test -DBUILD_TYPE=Debug
## Flash and monitor
idf.py flash monitor -DEXAMPLE_TYPE=gpio_test
```text
### CI Pipeline
The GPIO test is integrated into the CI pipeline:
```yaml
## In .github/workflows/esp32-component-ci.yml
example_type: [comprehensive, ascii_art, nimble_test, gpio_test]
```text
Build artifacts are available as:
- `fw-gpio_test-release-v5.5-Release`
- `fw-gpio_test-release-v5.5-Debug`
## Test Categories
### 1. Basic Functionality Tests
- GPIO initialization and configuration modes
- Basic input/output operations
- State management and verification
### 2. Configuration Tests
- Pull resistor functionality
- Direction switching
- Output mode configuration
### 3. Advanced Feature Tests
- Interrupt configuration and handling
- Drive capability settings
- Hardware verification functions
### 4. ESP32-C6 Specific Tests
- RTC GPIO operations
- Glitch filter functionality
- Sleep/wake operations
- Hold functionality
### 5. Robustness Tests
- Error handling with invalid pins
- Stress testing with rapid operations
- Concurrent GPIO operations
- Pin validation
### 6. Performance Tests
- Timing analysis
- Power consumption characteristics
- Operation statistics
## Expected Output
```text
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ESP32-C6 GPIO COMPREHENSIVE TEST SUITE โ
โ HardFOC Internal Interface โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ Target: ESP32-C6 DevKit-M-1 โ
โ ESP-IDF: v5.5+ โ
โ Features: GPIO, Interrupts, RTC, Sleep, Advanced Features โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Starting comprehensive GPIO testing...
โ
PASSED: test_basic_gpio_functionality (15.23 ms)
โ
PASSED: test_gpio_initialization_and_configuration (22.45 ms)
โ
PASSED: test_gpio_input_output_operations (18.67 ms)
...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GPIO TEST SUMMARY โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ Total Tests: 18 โ
โ Passed Tests: 18 โ
โ Failed Tests: 0 โ
โ Success Rate: 100.00% โ
โ Total Exec Time: 324.56 ms โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ALL GPIO TESTS PASSED! ๐
```text
## Development Notes
### Adding New Tests
To add a new test function:
1. **Declare the function:**
```cpp
bool test_my_new_functionality();
- Implement the test:
1 2 3 4 5 6 7 8 9 10
bool test_my_new_functionality() { ESP_LOGI(TAG, "=== Testing My New Functionality ==="); try { // Test implementation return true; } catch (const std::exception& e) { ESP_LOGE(TAG, "Exception: %s", e.what()); return false; } }
- Add to test execution:
1
RUN_TEST(test_my_new_functionality);
Test Patterns
The test suite follows these patterns:
- Consistent logging with clear test boundaries
- Exception handling for robust error reporting
- State verification after each operation
- Resource cleanup in destructors
- Timing measurement for performance analysis
Debugging
For debugging individual tests:
- Enable debug build:
1
idf.py build -DEXAMPLE_TYPE=gpio_test -DBUILD_TYPE=Debug
- Add debug prints:
1
ESP_LOGD(TAG, "Debug info: %d", value);
- Use specific pin for debugging:
1
static constexpr hf_pin_num_t DEBUG_PIN = 22;
Integration with Main Project
This GPIO test suite serves as:
- Validation tool for EspGpio implementation
- Regression testing for GPIO functionality
- Performance benchmarking for optimization
- Hardware verification for ESP32-C6 compatibility
- Documentation of GPIO capabilities and usage patterns
Contributing
When modifying the GPIO test suite:
- Maintain pin safety - only use designated safe pins
- Add comprehensive logging for test traceability
- Include error handling for robustness
- Update documentation for new test categories
- Verify CI integration for automated testing
License
Copyright HardFOC - Internal Interface Testing Suite