HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
Loading...
Searching...
No Matches
spi_daisy_chain_comprehensive_test.cpp File Reference

Comprehensive SPI Daisy Chain testing suite for TMC51x0. More...

#include "tmc51x0.hpp"
#include "test_config/esp32_tmc51x0_bus.hpp"
#include "test_config/esp32_tmc51x0_test_config.hpp"
#include "test_config/TestFramework.h"
#include <memory>
#include <vector>
Include dependency graph for spi_daisy_chain_comprehensive_test.cpp:

Classes

struct  TestDriverHandle
 Test driver handle containing SPI interface and driver instance. More...
 

Functions

bool test_daisy_chain_setup () noexcept
 Test SPI daisy chain setup and initialization.
 
bool test_daisy_chain_position_management () noexcept
 Test daisy chain position management and addressing.
 
bool test_multi_motor_coordination () noexcept
 Test multi-motor coordination in daisy chain configuration.
 
std::unique_ptr< TestDriverHandlecreate_daisy_chain_drivers () noexcept
 Create and initialize daisy chain driver instances.
 
void app_main (void)
 

Variables

static const char * TAG = "SPI_DaisyChain_Test"
 
static TestResults g_test_results
 
static constexpr tmc51x0_test_config::TestRigType SELECTED_TEST_RIG
 
static constexpr bool ENABLE_DAISY_CHAIN_SETUP_TESTS = true
 
static constexpr bool ENABLE_POSITION_MANAGEMENT_TESTS = true
 
static constexpr bool ENABLE_MULTI_MOTOR_COORDINATION_TESTS = true
 
static constexpr uint8_t TEST_CHAIN_LENGTH = 2
 
static constexpr uint8_t TEST_IRUN = 20
 
static constexpr uint8_t TEST_IHOLD = 10
 
static constexpr uint8_t TEST_GLOBAL_SCALER = 32
 
static constexpr uint8_t TEST_TOFF = 5
 
static constexpr tmc51x0::MicrostepResolution TEST_MRES = tmc51x0::MicrostepResolution::MRES_256
 

Detailed Description

Comprehensive SPI Daisy Chain testing suite for TMC51x0.

Supports 1 or more TMC51x0 drivers. Set TEST_CHAIN_LENGTH to match your hardware (default: 2). With TEST_CHAIN_LENGTH=1, standard single-driver SPI operation is tested (position 0, chain length 1).

This file contains comprehensive testing for TMC51x0 SPI daisy chain features:

  • SPI daisy chain setup and configuration
  • Daisy-chain position management
  • Multi-motor coordination
  • Chain length configuration
  • Sequential positioning

Hardware Requirements:

  • ESP32 development board
  • 2+ TMC51x0 stepper motor drivers (daisy-chained via SPI)
  • Stepper motors connected to each TMC51x0
  • SPI connection: All chips share CSN, SCK, MOSI; MISO daisy-chained

Pin Configuration (modify as needed):

  • SPI: MOSI=23, MISO=19, SCLK=18, CS=5 (shared by all chips)
  • Control: EN=2, DIR=4, STEP=15 (shared or separate per chip)

Daisy-Chain Wiring:

  • MCU MISO ──> Chip 1 SDO ──> Chip 2 SDI Chip 1 SDI <── MCU MOSI Chip 2 SDO ──> MCU MISO (if 2 chips) or Chip 3 SDI (if 3 chips)
  • All chips: CSN, SCK, MOSI (SDI) tied together
Author
Nebiyu Tadesse
Date
2025

Function Documentation

◆ app_main()

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

◆ create_daisy_chain_drivers()

std::unique_ptr< TestDriverHandle > create_daisy_chain_drivers ( )
noexcept

Create and initialize daisy chain driver instances.

Creates a shared SPI interface and multiple driver instances configured for daisy chain operation. Each driver is assigned a unique chain position.

Returns
Unique pointer to TestDriverHandle, or nullptr on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_daisy_chain_position_management()

bool test_daisy_chain_position_management ( )
noexcept

Test daisy chain position management and addressing.

Returns
true if test passed, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_daisy_chain_setup()

bool test_daisy_chain_setup ( )
noexcept

Test SPI daisy chain setup and initialization.

Returns
true if test passed, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_multi_motor_coordination()

bool test_multi_motor_coordination ( )
noexcept

Test multi-motor coordination in daisy chain configuration.

Returns
true if test passed, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ENABLE_DAISY_CHAIN_SETUP_TESTS

constexpr bool ENABLE_DAISY_CHAIN_SETUP_TESTS = true
staticconstexpr

◆ ENABLE_MULTI_MOTOR_COORDINATION_TESTS

constexpr bool ENABLE_MULTI_MOTOR_COORDINATION_TESTS = true
staticconstexpr

◆ ENABLE_POSITION_MANAGEMENT_TESTS

constexpr bool ENABLE_POSITION_MANAGEMENT_TESTS = true
staticconstexpr

◆ g_test_results

TestResults g_test_results
static

◆ SELECTED_TEST_RIG

constexpr tmc51x0_test_config::TestRigType SELECTED_TEST_RIG
staticconstexpr
Initial value:
=
@ TEST_RIG_CORE_DRIVER
Core driver test rig (17HS4401S motor, TMC51x0 EVAL board, reference switches, encoder)

◆ TAG

const char* TAG = "SPI_DaisyChain_Test"
static

◆ TEST_CHAIN_LENGTH

constexpr uint8_t TEST_CHAIN_LENGTH = 2
staticconstexpr

◆ TEST_GLOBAL_SCALER

constexpr uint8_t TEST_GLOBAL_SCALER = 32
staticconstexpr

◆ TEST_IHOLD

constexpr uint8_t TEST_IHOLD = 10
staticconstexpr

◆ TEST_IRUN

constexpr uint8_t TEST_IRUN = 20
staticconstexpr

◆ TEST_MRES

◆ TEST_TOFF

constexpr uint8_t TEST_TOFF = 5
staticconstexpr