Basic Usage Test Suite - TLE92466ED ESP32-C6
Overview
The Basic Usage example is a comprehensive test suite that demonstrates fundamental TLE92466ED operations on ESP32-C6 using a professional FreeRTOS-based test framework. This suite provides structured validation of driver functionality with automatic result tracking, GPIO14 progress indicators, and detailed execution timing.
π― Purpose
- Validate TLE92466ED driver functionality on ESP32-C6
- Demonstrate best practices for driver integration
- Provide professional test infrastructure for development
- Enable CI/CD integration with structured output
- Document expected behavior and performance
π§ͺ Test Framework Architecture
Professional Test Infrastructure
The example uses the TLE92466ED Test Framework (TLE92466ED_TestFramework.hpp), which provides:
β FreeRTOS Task-Based Execution
- Each test runs in isolated FreeRTOS task
- Custom stack size per test (8KB default)
- Automatic semaphore synchronization
- 30-second timeout protection
- Fallback to inline execution on failure
β GPIO14 Progress Indicator
- Visual feedback on oscilloscope/logic analyzer
- Toggle: HIGH/LOW on each test completion
- Blink Pattern: 5 blinks at section start/end
- Hardware-level test progression tracking
β Automatic Result Tracking
- Pass/fail counting
- Microsecond-precision execution timing
- Success rate calculation
- Professional summary reports
β Test Section Management
- Compile-time section enable/disable
- Section-based organization
- Custom blink patterns per section
- Structured output formatting
π Test Suite Structure
Test Sections
1. INITIALIZATION_TESTS (#define ENABLE_INITIALIZATION_TESTS 1)
Tests fundamental setup and communication:
test_hal_initialization- ESP32-C6 HAL setup and SPI configurationtest_driver_initialization- TLE92466ED driver instance creationtest_chip_id- SPI communication verification via chip ID
2. BASIC_OPERATION_TESTS (#define ENABLE_BASIC_OPERATION_TESTS 1)
Tests core driver operations:
test_channel_enable_disable- Channel control operationstest_current_setting- Current configuration (100mA, 500mA, 1000mA, 1500mA)test_diagnostics- Real-time diagnostics reading
3. CURRENT_CONTROL_TESTS (#define ENABLE_CURRENT_CONTROL_TESTS 1)
Tests advanced current control:
test_current_ramping- Smooth 0β1000mAβ0mA transitions
Test Function Signatures
All test functions follow this pattern:
cpp
static bool test_function_name() noexcept;
text
Key Characteristics:
- Return
bool(true = passed, false = failed) - Declared
noexceptfor embedded safety - Self-contained and isolated
- Descriptive ESP_LOG output
- Proper error handling with
std::expected
π§ Hardware Setup
Required Components
- ESP32-C6-DevKitC-1 development board
- TLE92466ED evaluation board or custom PCB
- 12-24V power supply for VBAT (2A minimum)
- Test load: Solenoid, resistor (6-120Ξ©), or LED with current limiting
- Oscilloscope/Logic Analyzer (optional, for GPIO14 monitoring)
- Connecting wires
Wiring Diagram
```text ESP32-C6 TLE92466ED Function βββ βββ- βββ GPIO2 ββ-> MISO SPI Data In GPIO7 ββ-> MOSI SPI Data Out GPIO6 ββ-> SCLK SPI Clock GPIO10 ββ-> CS Chip Select (active low) GPIO14 ββ-> [LED/Scope] Test Progress Indicator 3.3V ββ-> VDD Logic Supply GND ββ-> GND Common Ground
External Supply TLE92466ED βββββ βββ- 12-24V ββ> VBAT Power Supply GND ββ> GND Power Ground
Test Load TLE92466ED βββ βββ- Load+ ββ> OUT0 Channel 0 Output Load- ββ> GND (via sense) Return Path ```text
Complete Pin Configuration
| Function | ESP32-C6 GPIO | TLE92466ED Pin | Configuration | Notes |
|---|---|---|---|---|
| SPI MISO | GPIO2 | MISO | Input | Data from TLE92466ED |
| SPI MOSI | GPIO7 | MOSI | Output | Data to TLE92466ED |
| SPI SCLK | GPIO6 | SCLK | Output | 1MHz SPI Clock |
| SPI CS | GPIO10 | CS | Output | Active Low |
| Test Indicator | GPIO14 | - | Output | Progress indicator |
| Logic Supply | 3.3V | VDD | Power | 3.3V Β±10% |
| Power Supply | External | VBAT | Power | 8-28V, 2A+ |
| Ground | GND | GND | Ground | Common reference |
GPIO14 Test Indicator Setup
text
ESP32-C6 GPIO14 βββ¬ββ LED (Anode)
β βββ LED (Cathode) ββ 220Ξ© ββ GND
β
βββ Oscilloscope/Logic Analyzer Probe
text
Purpose: Visual and measurable feedback showing test progression
βοΈ Configuration
Hardware Configuration (main/TLE92466ED_Config.hpp)
All hardware-specific settings are centralized:
```cpp namespace TLE92466ED_Config {
struct SPIPins { static constexpr int MISO = 2; // GPIO2 static constexpr int MOSI = 7; // GPIO7 static constexpr int SCLK = 6; // GPIO6 static constexpr int CS = 10; // GPIO10 };
struct SPIParams { static constexpr int FREQUENCY = 1000000; // 1MHz static constexpr int MODE = 0; // SPI Mode 0 static constexpr int QUEUE_SIZE = 7; };
struct CurrentLimits { static constexpr uint16_t SINGLE_CHANNEL_MAX = 2000; // 2A static constexpr uint16_t PARALLEL_CHANNEL_MAX = 4000; // 4A };
struct HardwareSpecs { static constexpr float SUPPLY_VOLTAGE_MIN = 8.0f; // 8V static constexpr float SUPPLY_VOLTAGE_MAX = 28.0f; // 28V static constexpr int TEMPERATURE_MAX = 150; // 150Β°C };
} // namespace TLE92466ED_Config ```text
To modify hardware settings: Edit main/TLE92466ED_Config.hpp
Test Configuration (main/BasicUsageExample.cpp)
Enable/disable test sections at compile time:
cpp
#define ENABLE_INITIALIZATION_TESTS 1 // HAL, driver, chip ID
#define ENABLE_BASIC_OPERATION_TESTS 1 // Enable, current, diagnostics
#define ENABLE_CURRENT_CONTROL_TESTS 1 // Ramping tests
text
To disable a section: Set to 0 and rebuild
Build Configuration (app_config.yml)
Application metadata and build settings:
yaml
apps:
basic_usage:
description: "Basic usage example for TLE92466ED"
source_file: "BasicUsageExample.cpp"
category: "demo"
idf_versions: ["release/v5.5"]
build_types: ["Debug", "Release"]
ci_enabled: true
featured: true
text
Note: This is for build metadata only. Hardware config is in TLE92466ED_Config.hpp.
π Building and Running
Quick Start
```bash cd examples/esp32
Build the basic usage example
./scripts/build_app.sh basic_usage Debug
Flash to ESP32-C6
./scripts/flash_app.sh basic_usage Debug
Monitor output
./scripts/monitor_app.sh basic_usage ```text
Manual Build
```bash cd examples/esp32
Set target
idf.py set-target esp32c6
Configure (optional)
idf.py menuconfig
Build with APP_TYPE=basic_usage
idf.py -DAPP_TYPE=basic_usage build
Flash
idf.py -p /dev/ttyUSB0 flash
Monitor
idf.py -p /dev/ttyUSB0 monitor ```text
Build Targets
```bash
Debug build (optimized for debugging)
idf.py -DAPP_TYPE=basic_usage -DCMAKE_BUILD_TYPE=Debug build
Release build (optimized for performance)
idf.py -DAPP_TYPE=basic_usage -DCMAKE_BUILD_TYPE=Release build ```text
π Expected Output
Professional Test Header
```text ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β TLE92466ED BASIC USAGE TEST SUITE - ESP32-C6 β β HardFOC Core Drivers β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Target: esp32c6 ESP-IDF Version: v5.5.0
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TLE92466ED TEST CONFIGURATION
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β Test sections will execute based on compile-time configuration β
β GPIO14 test progression indicator: ENABLED β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```text
Test Execution
```text ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β SECTION: INITIALIZATION TESTS β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ [GPIO14: Blink pattern - 5 blinks]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Running (task): hal_initialization β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ I (1234) TLE92466ED_Basic: Creating HAL instanceβ¦ I (1235) ESP32C6_HAL: ESP32C6_HAL created with SPI config I (1236) ESP32C6_HAL: MISO: GPIO2, MOSI: GPIO7, SCLK: GPIO6, CS: GPIO10 I (1237) ESP32C6_HAL: Frequency: 1000000 Hz, Mode: 0 I (1238) TLE92466ED_Basic: Initializing HALβ¦ I (1240) ESP32C6_HAL: ESP32C6_HAL initialized successfully I (1241) TLE92466ED_Basic: β HAL initialized successfully [SUCCESS] PASSED (task): hal_initialization (12.34 ms) Test task completed: hal_initialization [GPIO14: Toggle HIGH]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Running (task): driver_initialization β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ I (1250) TLE92466ED_Basic: Creating TLE92466ED driver instanceβ¦ I (1251) TLE92466ED_Basic: Initializing TLE92466ED driverβ¦ I (1275) TLE92466ED_Basic: β TLE92466ED driver initialized successfully [SUCCESS] PASSED (task): driver_initialization (25.67 ms) Test task completed: driver_initialization [GPIO14: Toggle LOW]
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Running (task): chip_id β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ I (1280) TLE92466ED_Basic: Reading chip identificationβ¦ I (1285) TLE92466ED_Basic: β Chip ID: 0x123456789ABC [SUCCESS] PASSED (task): chip_id (5.23 ms) Test task completed: chip_id [GPIO14: Toggle HIGH] ```text
Test Results Summary
```text ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β TEST RESULTS SUMMARY β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£ β Total Tests: 7 β β Passed: 7 β β Failed: 0 β β Success Rate: 100.00% β β Total Time: 234.56 ms β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
I (5000) TLE92466ED_Basic: β ALL TESTS PASSED! System will restart in 10 secondsβ¦ ```text
GPIO14 Signal Pattern
text
Time β GPIO14 β Event
βββββββββΌβββββββββΌββββββββββββββββββββββββββββββ
0ms β LOW β Boot
100ms β BLINK β Section start (5 blinks)
β ββ β
200ms β HIGH β Test 1 complete
300ms β LOW β Test 2 complete
400ms β HIGH β Test 3 complete
500ms β BLINK β Section 2 start (5 blinks)
600ms β LOW β Test 4 complete
...
text
π§ͺ Individual Test Details
1. test_hal_initialization()
Purpose: Validate ESP32-C6 HAL creation and SPI initialization
Operations:
- Create ESP32C6_HAL instance with configuration from
TLE92466ED_Config.hpp - Initialize SPI peripheral (SPI2_HOST)
- Configure GPIO pins for SPI
- Set up SPI parameters (1MHz, Mode 0)
Expected Result: β PASS
- HAL instance created successfully
- SPI bus initialized
- GPIO pins configured
- Ready for communication
Failure Modes:
- SPI bus already initialized
- GPIO pins in use
- Invalid SPI configuration
- Hardware fault
2. test_driver_initialization()
Purpose: Create TLE92466ED driver instance and initialize IC
Operations:
- Create TLE92466ED driver instance with HAL reference
- Execute driver initialization sequence
- Configure TLE92466ED registers
- Set up default parameters
Expected Result: β PASS
- Driver instance created
- IC initialized successfully
- Registers configured
- Ready for operations
Failure Modes:
- HAL not initialized
- SPI communication failure
- TLE92466ED not powered
- IC initialization timeout
3. test_chip_id()
Purpose: Verify SPI communication by reading 48-bit chip ID
Operations:
- Read chip identification register
- Verify CRC-8 (SAE J1850)
- Validate chip ID format
Expected Result: β PASS
- Chip ID read successfully
- 48-bit value displayed (e.g.,
0x123456789ABC) - CRC verified
Failure Modes:
- SPI communication error
- CRC mismatch
- Invalid chip ID
- TLE92466ED not responding
4. test_channel_enable_disable()
Purpose: Validate channel control operations
Operations:
- Enable channel 0
- Wait 1 second
- Disable channel 0
- Verify register writes
Expected Result: β PASS
- Channel enabled successfully
- Channel disabled successfully
- No communication errors
Failure Modes:
- Register write failure
- SPI timeout
- Invalid channel number
5. test_current_setting()
Purpose: Test current configuration at multiple setpoints
Operations: Test current settings at:
- 100mA
- 500mA
- 1000mA
- 1500mA
Expected Result: β PASS
- All current values set successfully
- No register errors
- 500ms delay between steps
Failure Modes:
- Current out of range (0-2000mA)
- Register write failure
- Invalid channel
6. test_diagnostics()
Purpose: Verify diagnostics reading and fault detection
Operations:
- Read diagnostics registers
- Check for faults:
- Overcurrent
- Overtemperature
- Open load
- Short circuit
- Report status
Expected Result: β PASS (no faults expected)
- Diagnostics read successfully
- βAll systems normalβ (assuming proper load)
Possible Warnings (not test failures):
- β οΈ Overcurrent detected (load too high)
- π‘οΈ Overtemperature detected (thermal issue)
- π Open load (no load connected)
- β‘ Short circuit (load shorted)
Failure Modes:
- Cannot read diagnostics
- SPI communication error
7. test_current_ramping()
Purpose: Demonstrate smooth current transitions
Operations:
- Enable channel 0
- Ramp UP: 0mA β 1000mA (100mA steps, 300ms each)
- Ramp DOWN: 1000mA β 0mA (100mA steps, 300ms each)
- Disable channel 0
Expected Result: β PASS
- Smooth ramping completed
- All current values set successfully
- Channel disabled at end
Failure Modes:
- Current setting failure
- Channel enable/disable failure
- Timeout during ramping
π Troubleshooting
Common Issues
1. All Tests Fail β
Symptom: Every test returns FAILED
Root Causes:
- TLE92466ED not powered (check VBAT: 12-24V)
- SPI wiring incorrect
- Common ground missing
- ESP32-C6 not programmed correctly
Solutions: ```bash
Check wiring
- VBAT: 12-24V present
- VDD: 3.3V present
- GND: Common ground between ESP32-C6, TLE92466ED, and power supply
- SPI pins: MISO, MOSI, SCLK, CS connected correctly
Re-flash
idf.py -p /dev/ttyUSB0 erase-flash idf.py -p /dev/ttyUSB0 flash ```text
2. HAL Initialization Fails β
Symptom: test_hal_initialization fails
Root Causes:
- SPI2 bus already in use
- GPIO pins conflicting
- Invalid SPI configuration
Solutions:
- Check
sdkconfigfor SPI conflicts - Verify GPIO pins are not used elsewhere
- Try different GPIO pins (modify
TLE92466ED_Config.hpp) - Check ESP32-C6 hardware
3. Driver Initialization Fails β
Symptom: test_driver_initialization fails
Root Causes:
- SPI communication not working
- TLE92466ED not responding
- Power supply issue
Solutions:
- Verify SPI with logic analyzer/oscilloscope
- Check VBAT voltage (must be 8-28V)
- Check VDD voltage (must be 3.3V Β±10%)
- Verify TLE92466ED is not damaged
4. Chip ID Read Fails β
Symptom: test_chip_id fails, βFailed to read chip IDβ
Root Causes:
- SPI communication error
- TLE92466ED not powered
- CS pin not working
Solutions:
- Measure SPI signals with oscilloscope:
- SCLK: Should show 1MHz clock during transactions
- MOSI: Should show data output
- MISO: Should show data input
- CS: Should go LOW during transactions
- Check power supply voltages
- Verify chip is not in reset or fault state
5. Diagnostics Show Faults β οΈ
Symptom: Tests pass but diagnostics show warnings
Overcurrent β οΈ:
- Load drawing too much current
- Check load resistance (should be β₯6Ξ© for 2A max)
- Verify VBAT voltage
Overtemperature π‘οΈ:
- IC too hot (>150Β°C junction temp)
- Add heatsink
- Reduce duty cycle
- Lower ambient temperature
Open Load π:
- No load connected (expected if testing without load)
- Loose connection
- Load resistance too high
Short Circuit β‘:
- Load or wiring shorted to ground
- Check continuity
- Inspect for solder bridges
6. Current Ramping Fails β
Symptom: test_current_ramping fails midway
Root Causes:
- Load specification issue
- Power supply canβt deliver current
- Thermal shutdown during ramp
Solutions:
- Use proper test load (resistor: 6-120Ξ©, 5W+)
- Ensure power supply can deliver 2A+
- Monitor diagnostics during ramp
- Add cooling if needed
Debug Configuration
Enable Verbose Logging
In sdkconfig:
ini
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y
text
Or via menuconfig: ```bash idf.py menuconfig
Component config -> Log output -> Default log verbosity -> Debug
```text
SPI Signal Analysis
Use logic analyzer to verify:
- SCLK: 1MHz square wave during transactions
- CS: Active LOW during transactions
- MOSI/MISO: Data patterns visible
- Timing: Mode 0 (CPOL=0, CPHA=0)
GPIO14 Monitoring
Attach oscilloscope to GPIO14:
- Should toggle after each test
- Should show blink patterns at section boundaries
- Indicates test progression even if serial output fails
π Performance Characteristics
Typical Execution Times
| Test | Expected Time | Max Time |
|---|---|---|
| HAL Initialization | 10-15 ms | 50 ms |
| Driver Initialization | 20-30 ms | 100 ms |
| Chip ID Read | 5-10 ms | 20 ms |
| Channel Enable/Disable | 15-25 ms | 50 ms |
| Current Setting (4 values) | 40-60 ms | 100 ms |
| Diagnostics Read | 10-15 ms | 30 ms |
| Current Ramping | 60-80 ms | 150 ms |
| Total Suite | 200-250 ms | 500 ms |
Memory Usage
| Resource | Usage | Notes |
|---|---|---|
| Flash | ~55KB | Driver + HAL + test framework |
| RAM (static) | ~12KB | Driver instance + buffers |
| Stack (per task) | 8KB | Configurable in RUN_TEST_IN_TASK |
| Heap (dynamic) | ~4KB | HAL instance + std::unique_ptr |
SPI Performance
- Clock Frequency: 1MHz (configurable 100kHz - 8MHz)
- Transaction Time: ~32ΞΌs per 32-bit frame
- Register Read: ~100ΞΌs (including overhead)
- Register Write: ~80ΞΌs (including overhead)
π Related Documentation
ESP32 Examples
- Multi-Channel Test Suite - Multiple channel control tests
- Test Framework Reference - Framework API
- Hardware Configuration - Pin and parameter config
- ESP32-C6 HAL - HAL implementation details
Driver Documentation
- Driver API Reference - Complete API documentation
- HAL Implementation Guide - Porting to new platforms
- Register Map - TLE92466ED register details
- Diagnostics - Fault detection and handling
Build System
- App Configuration - Build metadata
- CMake Setup - Build system configuration
- Component Structure - ESP-IDF component
π Learning Path
Beginner
- β Start Here: Basic Usage Test Suite
- Run tests and observe GPIO14 indicators
- Modify test current values
- Try with different loads
Intermediate
- Modify
TLE92466ED_Config.hppfor custom hardware - Add new test functions
- Configure test sections
- Analyze SPI signals with oscilloscope
Advanced
- Implement custom HAL for different MCU
- Extend test framework for CI/CD
- Create application-specific tests
- Optimize performance and memory
π CI/CD Integration
Structured Output
The test suite produces structured output suitable for parsing:
text
[SUCCESS] PASSED (task): test_name (12.34 ms)
[FAILED] FAILED (task): test_name (45.67 ms)
text
Exit Codes
- 0: All tests passed
- Non-zero: Tests failed (after restart)
Parsing Results
```bash
Extract pass/fail count
grep βTotal Tests:β output.log grep βSuccess Rate:β output.log
Check for failures
grep β[FAILED]β output.log && echo βTests failed!β || echo βAll passed!β ```text
Example: Basic Usage Test Suite
Platform: ESP32-C6
Framework: FreeRTOS + Test Framework
Complexity: βββββ
Status: β
Production Ready