HF-Core Platform 0.1.0-dev
Hardware-Agnostic Handler Layer & RTOS Utilities for HardFOC
Loading...
Searching...
No Matches
tmc5160_handler_comprehensive_test.cpp File Reference

Comprehensive test suite for Tmc5160Handler. More...

#include "TestFramework.h"
#include "esp32_bus_setup.hpp"
#include "esp32_test_config.hpp"
#include "handlers/tmc5160/Tmc5160Handler.h"
#include <cmath>
#include <memory>
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Include dependency graph for tmc5160_handler_comprehensive_test.cpp:

Functions

static bool create_handler () noexcept
 
static bool test_construction () noexcept
 
static bool test_initialize () noexcept
 
static bool test_is_initialized () noexcept
 
static bool test_driver_config_snapshot () noexcept
 
static bool test_enable_motor () noexcept
 
static bool test_is_motor_enabled () noexcept
 
static bool test_disable_motor () noexcept
 
static bool test_set_target_velocity () noexcept
 
static bool test_set_target_position () noexcept
 
static bool test_get_current_position () noexcept
 
static bool test_get_current_velocity () noexcept
 
static bool test_stop () noexcept
 
static bool test_set_current () noexcept
 
static bool test_is_standstill () noexcept
 
static bool test_is_target_reached () noexcept
 
static bool test_is_overtemperature () noexcept
 
static bool test_is_stall_detected () noexcept
 
static bool test_stallguard_result () noexcept
 
static bool test_chip_version () noexcept
 
static bool test_visit_driver_ramp_control () noexcept
 
static bool test_visit_driver_motor_control () noexcept
 
static bool test_visit_driver_encoder () noexcept
 
static bool test_visit_driver_communication () noexcept
 
static bool test_dump_diagnostics () noexcept
 
static bool test_operations_before_init () noexcept
 
static bool test_deinitialize () noexcept
 
void app_main (void)
 

Variables

static const char * TAG = "TMC5160_Handler_Test"
 
static TestResults g_test_results
 
static constexpr bool ENABLE_CONSTRUCTION_TESTS = true
 
static constexpr bool ENABLE_INITIALIZATION_TESTS = true
 
static constexpr bool ENABLE_MOTOR_ENABLE_TESTS = true
 
static constexpr bool ENABLE_MOTION_CONTROL_TESTS = true
 
static constexpr bool ENABLE_STATUS_TESTS = true
 
static constexpr bool ENABLE_VISIT_DRIVER_TESTS = true
 
static constexpr bool ENABLE_DIAGNOSTICS_TESTS = true
 
static constexpr bool ENABLE_ERROR_HANDLING_TESTS = true
 
static std::unique_ptr< EspGpio > g_enable_gpio
 
static std::unique_ptr< EspGpio > g_diag0_gpio
 
static std::unique_ptr< EspGpio > g_diag1_gpio
 
static BaseSpi * g_spi_device = nullptr
 
static std::unique_ptr< Tmc5160Handlerg_handler
 
static bool g_hw_present = false
 

Detailed Description

Comprehensive test suite for Tmc5160Handler.

Tests: CRTP SPI adapter, initialization with DriverConfig, motor enable/ disable, motion control (position/velocity/acceleration/stop), visitDriver() subsystem access (rampControl, motorControl, stallGuard, status, encoder, etc.), StallGuard readback, diagnostics dump, status checks (overtemp, stall, standstill, target reached), driver config snapshot, and pre-init error handling.

Note
This test requires a TMC5160 evaluation board connected via SPI. Without hardware, initialization will fail gracefully and remaining tests will be skipped.
Author
HardFOC Team
Date
2025-2026

Function Documentation

◆ app_main()

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

◆ create_handler()

static bool create_handler ( )
staticnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_chip_version()

static bool test_chip_version ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_construction()

static bool test_construction ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_deinitialize()

static bool test_deinitialize ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_disable_motor()

static bool test_disable_motor ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_driver_config_snapshot()

static bool test_driver_config_snapshot ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_dump_diagnostics()

static bool test_dump_diagnostics ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_enable_motor()

static bool test_enable_motor ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_get_current_position()

static bool test_get_current_position ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_get_current_velocity()

static bool test_get_current_velocity ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_initialize()

static bool test_initialize ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_initialized()

static bool test_is_initialized ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_motor_enabled()

static bool test_is_motor_enabled ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_overtemperature()

static bool test_is_overtemperature ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_stall_detected()

static bool test_is_stall_detected ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_standstill()

static bool test_is_standstill ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_is_target_reached()

static bool test_is_target_reached ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_operations_before_init()

static bool test_operations_before_init ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_set_current()

static bool test_set_current ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_set_target_position()

static bool test_set_target_position ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_set_target_velocity()

static bool test_set_target_velocity ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_stallguard_result()

static bool test_stallguard_result ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_stop()

static bool test_stop ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_visit_driver_communication()

static bool test_visit_driver_communication ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_visit_driver_encoder()

static bool test_visit_driver_encoder ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_visit_driver_motor_control()

static bool test_visit_driver_motor_control ( )
staticnoexcept
Here is the caller graph for this function:

◆ test_visit_driver_ramp_control()

static bool test_visit_driver_ramp_control ( )
staticnoexcept
Here is the caller graph for this function:

Variable Documentation

◆ ENABLE_CONSTRUCTION_TESTS

constexpr bool ENABLE_CONSTRUCTION_TESTS = true
staticconstexpr

◆ ENABLE_DIAGNOSTICS_TESTS

constexpr bool ENABLE_DIAGNOSTICS_TESTS = true
staticconstexpr

◆ ENABLE_ERROR_HANDLING_TESTS

constexpr bool ENABLE_ERROR_HANDLING_TESTS = true
staticconstexpr

◆ ENABLE_INITIALIZATION_TESTS

constexpr bool ENABLE_INITIALIZATION_TESTS = true
staticconstexpr

◆ ENABLE_MOTION_CONTROL_TESTS

constexpr bool ENABLE_MOTION_CONTROL_TESTS = true
staticconstexpr

◆ ENABLE_MOTOR_ENABLE_TESTS

constexpr bool ENABLE_MOTOR_ENABLE_TESTS = true
staticconstexpr

◆ ENABLE_STATUS_TESTS

constexpr bool ENABLE_STATUS_TESTS = true
staticconstexpr

◆ ENABLE_VISIT_DRIVER_TESTS

constexpr bool ENABLE_VISIT_DRIVER_TESTS = true
staticconstexpr

◆ g_diag0_gpio

std::unique_ptr<EspGpio> g_diag0_gpio
static

◆ g_diag1_gpio

std::unique_ptr<EspGpio> g_diag1_gpio
static

◆ g_enable_gpio

std::unique_ptr<EspGpio> g_enable_gpio
static

◆ g_handler

std::unique_ptr<Tmc5160Handler> g_handler
static

◆ g_hw_present

bool g_hw_present = false
static

◆ g_spi_device

BaseSpi* g_spi_device = nullptr
static

◆ g_test_results

TestResults g_test_results
static

◆ TAG

const char* TAG = "TMC5160_Handler_Test"
static