HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
Loading...
Searching...
No Matches
bldc_comprehensive_test.cpp File Reference

Comprehensive BLDC motor testing suite for ESP32-C6 DevKit-M-1 (noexcept) More...

#include "../../../inc/tmc9660.hpp"
#include "esp32_tmc9660_bus.hpp"
#include "TestFramework.h"
#include <memory>
#include <vector>
#include <algorithm>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Include dependency graph for bldc_comprehensive_test.cpp:

Classes

struct  TestDriverHandle
 

Functions

std::unique_ptr< TestDriverHandlecreate_test_driver (bool use_uart=false, bool use_flash=false) noexcept
 
TMC9660< Esp32Tmc9660SpiBus > * get_spi_driver (TestDriverHandle &handle)
 
TMC9660< Esp32Tmc9660UartBus > * get_uart_driver (TestDriverHandle &handle)
 
template<typename DriverType = TMC9660<Esp32Tmc9660SpiBus>>
DriverTypeget_driver (TestDriverHandle &handle)
 
void log_telemetry_data (TMC9660< Esp32Tmc9660SpiBus > &driver, const char *context) noexcept
 
void log_telemetry_data (TMC9660< Esp32Tmc9660UartBus > &driver, const char *context) noexcept
 
bool test_bldc_bootloader_initialization () noexcept
 
bool test_bldc_driver_enable () noexcept
 
bool test_bldc_motor_type_configuration () noexcept
 
bool test_bldc_hall_sensor_configuration () noexcept
 
bool test_bldc_abn_encoder_configuration () noexcept
 
bool test_bldc_foc_control_configuration () noexcept
 
bool test_bldc_velocity_control () noexcept
 
bool test_bldc_current_control () noexcept
 
bool test_bldc_commutation_modes () noexcept
 
bool test_bldc_telemetry_monitoring () noexcept
 
bool test_bldc_performance_benchmarks () noexcept
 
bool test_bldc_error_handling () noexcept
 
bool test_bldc_edge_cases () noexcept
 
bool test_bldc_startup_shutdown_procedures () noexcept
 
bool test_bldc_motor_runtime_configuration () noexcept
 
template<typename CommType >
bool configureGateDriverForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureCurrentSensingForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureHallSensorForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureABNEncoderForBLDC (TMC9660< CommType > &driver, uint32_t countsPerRev=1024) noexcept
 
template<typename CommType >
bool configureMotorParametersForBLDC (TMC9660< CommType > &driver, uint8_t polePairs, uint32_t pwmFrequency) noexcept
 
template<typename CommType >
bool configureFOCControlForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureProtectionForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureRampForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureBrakeForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureStopEventsForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureHeartbeatForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configurePowerForBLDC (TMC9660< CommType > &driver) noexcept
 
template<typename CommType >
bool configureCompleteBLDCMotor (TMC9660< CommType > &driver, uint8_t polePairs=7, uint32_t pwmFrequency=20000) noexcept
 
void app_main (void)
 

Variables

static const charTAG = "BLDC_Test"
 
static TestResults g_test_results
 
static constexpr bool ENABLE_CORE_TESTS = true
 
static constexpr bool ENABLE_HALL_SENSOR_TESTS = true
 
static constexpr bool ENABLE_ABN_ENCODER_TESTS = true
 
static constexpr bool ENABLE_FOC_CONTROL_TESTS = true
 
static constexpr bool ENABLE_VELOCITY_CONTROL_TESTS = true
 
static constexpr bool ENABLE_CURRENT_CONTROL_TESTS = true
 
static constexpr bool ENABLE_COMMUTATION_TESTS = true
 
static constexpr bool ENABLE_TELEMETRY_TESTS = true
 
static constexpr bool ENABLE_PERFORMANCE_TESTS = true
 
static constexpr bool ENABLE_STRESS_TESTS = true
 
static constexpr uint8_t TEST_POLE_PAIRS = 7
 
static constexpr uint16_t TEST_ENCODER_CPR = 1024
 
static constexpr uint16_t TEST_MAX_TORQUE_CURRENT = 500
 
static constexpr uint16_t TEST_MAX_FLUX_CURRENT = 50
 
static constexpr uint16_t TEST_VELOCITY_TARGET = 1000
 
static constexpr uint16_t TEST_POSITION_TARGET = 500
 

Detailed Description

Comprehensive BLDC motor testing suite for ESP32-C6 DevKit-M-1 (noexcept)

This file contains comprehensive testing for BLDC motor control including:

  • Bootloader initialization and configuration validation
  • Hardware reset sequence (integrated into bootloaderInit)
  • Mode auto-detection (bootloader vs parameter mode)
  • OTP auto-start scenario handling
  • Motor type configuration (BLDC with various pole pairs)
  • Hall sensor feedback configuration and testing
  • ABN encoder feedback configuration and testing
  • FOC control loop configuration (current and velocity)
  • Commutation mode testing (FOC_HALL_SENSOR, FOC_ABN, FOC_OPENLOOP)
  • Velocity control testing with different targets
  • Current control testing with different limits
  • Motor startup and shutdown procedures
  • Error handling and recovery
  • Telemetry monitoring during operation
  • Performance benchmarking
  • Multi-device scenarios
  • Edge cases and fault injection

NEW in v2.0: Integrated Reset & Mode Detection The bootloaderInit() function now includes:

  • Hardware reset sequence (RST pin toggle + FAULTN monitoring)
  • Auto-detection of bootloader vs parameter mode
  • OTP auto-start scenario detection and handling
  • Transition from parameter mode to bootloader if needed

All functions are noexcept - no exception handling used.

Author
Nebiyu Tadesse
Date
2025

Function Documentation

◆ app_main()

void app_main ( void )
Here is the call graph for this function:

◆ configureABNEncoderForBLDC()

template<typename CommType >
bool configureABNEncoderForBLDC ( TMC9660< CommType > & driver,
uint32_t countsPerRev = 1024 )
noexcept

◆ configureBrakeForBLDC()

template<typename CommType >
bool configureBrakeForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureCompleteBLDCMotor()

template<typename CommType >
bool configureCompleteBLDCMotor ( TMC9660< CommType > & driver,
uint8_t polePairs = 7,
uint32_t pwmFrequency = 20000 )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ configureCurrentSensingForBLDC()

template<typename CommType >
bool configureCurrentSensingForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureFOCControlForBLDC()

template<typename CommType >
bool configureFOCControlForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureGateDriverForBLDC()

template<typename CommType >
bool configureGateDriverForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureHallSensorForBLDC()

template<typename CommType >
bool configureHallSensorForBLDC ( TMC9660< CommType > & driver)
noexcept

◆ configureHeartbeatForBLDC()

template<typename CommType >
bool configureHeartbeatForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureMotorParametersForBLDC()

template<typename CommType >
bool configureMotorParametersForBLDC ( TMC9660< CommType > & driver,
uint8_t polePairs,
uint32_t pwmFrequency )
noexcept
Here is the caller graph for this function:

◆ configurePowerForBLDC()

template<typename CommType >
bool configurePowerForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureProtectionForBLDC()

template<typename CommType >
bool configureProtectionForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureRampForBLDC()

template<typename CommType >
bool configureRampForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ configureStopEventsForBLDC()

template<typename CommType >
bool configureStopEventsForBLDC ( TMC9660< CommType > & driver)
noexcept
Here is the caller graph for this function:

◆ create_test_driver()

std::unique_ptr< TestDriverHandle > create_test_driver ( bool use_uart = false,
bool use_flash = false )
noexcept
Here is the call graph for this function:

◆ get_driver()

template<typename DriverType = TMC9660<Esp32Tmc9660SpiBus>>
DriverType * get_driver ( TestDriverHandle & handle)
Here is the call graph for this function:

◆ get_spi_driver()

TMC9660< Esp32Tmc9660SpiBus > * get_spi_driver ( TestDriverHandle & handle)
inline
Here is the caller graph for this function:

◆ get_uart_driver()

TMC9660< Esp32Tmc9660UartBus > * get_uart_driver ( TestDriverHandle & handle)
inline
Here is the caller graph for this function:

◆ log_telemetry_data() [1/2]

void log_telemetry_data ( TMC9660< Esp32Tmc9660SpiBus > & driver,
const char * context )
noexcept
Here is the caller graph for this function:

◆ log_telemetry_data() [2/2]

void log_telemetry_data ( TMC9660< Esp32Tmc9660UartBus > & driver,
const char * context )
noexcept

◆ test_bldc_abn_encoder_configuration()

bool test_bldc_abn_encoder_configuration ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_bootloader_initialization()

bool test_bldc_bootloader_initialization ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_commutation_modes()

bool test_bldc_commutation_modes ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_current_control()

bool test_bldc_current_control ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_driver_enable()

bool test_bldc_driver_enable ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_edge_cases()

bool test_bldc_edge_cases ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_error_handling()

bool test_bldc_error_handling ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_foc_control_configuration()

bool test_bldc_foc_control_configuration ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_hall_sensor_configuration()

bool test_bldc_hall_sensor_configuration ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_motor_runtime_configuration()

bool test_bldc_motor_runtime_configuration ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_motor_type_configuration()

bool test_bldc_motor_type_configuration ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_performance_benchmarks()

bool test_bldc_performance_benchmarks ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_startup_shutdown_procedures()

bool test_bldc_startup_shutdown_procedures ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_telemetry_monitoring()

bool test_bldc_telemetry_monitoring ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bldc_velocity_control()

bool test_bldc_velocity_control ( )
noexcept
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ENABLE_ABN_ENCODER_TESTS

constexpr bool ENABLE_ABN_ENCODER_TESTS = true
staticconstexpr

◆ ENABLE_COMMUTATION_TESTS

constexpr bool ENABLE_COMMUTATION_TESTS = true
staticconstexpr

◆ ENABLE_CORE_TESTS

constexpr bool ENABLE_CORE_TESTS = true
staticconstexpr

◆ ENABLE_CURRENT_CONTROL_TESTS

constexpr bool ENABLE_CURRENT_CONTROL_TESTS = true
staticconstexpr

◆ ENABLE_FOC_CONTROL_TESTS

constexpr bool ENABLE_FOC_CONTROL_TESTS = true
staticconstexpr

◆ ENABLE_HALL_SENSOR_TESTS

constexpr bool ENABLE_HALL_SENSOR_TESTS = true
staticconstexpr

◆ ENABLE_PERFORMANCE_TESTS

constexpr bool ENABLE_PERFORMANCE_TESTS = true
staticconstexpr

◆ ENABLE_STRESS_TESTS

constexpr bool ENABLE_STRESS_TESTS = true
staticconstexpr

◆ ENABLE_TELEMETRY_TESTS

constexpr bool ENABLE_TELEMETRY_TESTS = true
staticconstexpr

◆ ENABLE_VELOCITY_CONTROL_TESTS

constexpr bool ENABLE_VELOCITY_CONTROL_TESTS = true
staticconstexpr

◆ g_test_results

TestResults g_test_results
static

◆ TAG

const char* TAG = "BLDC_Test"
static

◆ TEST_ENCODER_CPR

constexpr uint16_t TEST_ENCODER_CPR = 1024
staticconstexpr

◆ TEST_MAX_FLUX_CURRENT

constexpr uint16_t TEST_MAX_FLUX_CURRENT = 50
staticconstexpr

◆ TEST_MAX_TORQUE_CURRENT

constexpr uint16_t TEST_MAX_TORQUE_CURRENT = 500
staticconstexpr

◆ TEST_POLE_PAIRS

constexpr uint8_t TEST_POLE_PAIRS = 7
staticconstexpr

◆ TEST_POSITION_TARGET

constexpr uint16_t TEST_POSITION_TARGET = 500
staticconstexpr

◆ TEST_VELOCITY_TARGET

constexpr uint16_t TEST_VELOCITY_TARGET = 1000
staticconstexpr