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

Comprehensive UART communication 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 uart_multi_node_comprehensive_test.cpp:

Classes

struct  UartTestHandle
 

Functions

std::unique_ptr< UartTestHandlecreate_uart_drivers () noexcept
 Create UART interface and driver instances.
 
bool test_uart_basic_communication () noexcept
 Verify basic UART register read/write communication.
 
bool test_uart_node_address_configuration () noexcept
 Test UART node address configuration via NODECONF register.
 
bool test_send_delay_configuration () noexcept
 Test send delay configuration.
 
bool test_uart_motor_control () noexcept
 Test motor control operations over UART.
 
void app_main (void)
 

Variables

static const char * TAG = "UART_MultiNode_Test"
 
static TestResults g_test_results
 
static constexpr bool ENABLE_BASIC_COMM_TESTS = true
 
static constexpr bool ENABLE_NODE_ADDRESS_TESTS = true
 
static constexpr bool ENABLE_SEND_DELAY_TESTS = true
 
static constexpr bool ENABLE_MOTOR_CONTROL_TESTS = true
 
static constexpr uint8_t TEST_NODE_COUNT = 1
 Number of TMC51x0 nodes on the UART bus. Set to 1 for single-driver setups.
 
static constexpr uart_port_t UART_PORT = UART_NUM_1
 UART port (avoid UART_NUM_0 which is typically used for the USB console)
 
static constexpr uint32_t UART_BAUD = 115200
 UART baud rate – TMC5160 auto-detects from sync frame.
 
static constexpr int UART_TX_PIN = 17
 UART pin configuration.
 
static constexpr int UART_RX_PIN = 16
 
static constexpr int EN_PIN = 11
 
static constexpr tmc51x0_test_config::TestRigType SELECTED_TEST_RIG
 Test rig selection for motor configuration.
 

Detailed Description

Comprehensive UART communication testing suite for TMC51x0.

Tests UART single-wire communication with 1 or more TMC51x0 drivers. Set TEST_NODE_COUNT to match your hardware (default: 1).

Features tested:

  • UART interface initialization and basic register access
  • Node address configuration (NODECONF register)
  • Send delay configuration
  • Multi-node coordination (when TEST_NODE_COUNT > 1)

Hardware Requirements:

  • ESP32 development board
  • 1+ TMC51x0 stepper motor drivers in UART mode (SD_MODE=LOW, SPI_MODE=LOW)
  • UART wiring: ESP32 TX -> TMC5160 SWN, ESP32 RX <- TMC5160 SWP
  • For multi-node: NAI/NAO daisy chain (first chip NAI to GND)

Pin Configuration (modify as needed):

  • UART TX: GPIO 17
  • UART RX: GPIO 16
  • EN: GPIO 11
Author
Nebiyu Tadesse
Date
2025

Function Documentation

◆ app_main()

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

◆ create_uart_drivers()

std::unique_ptr< UartTestHandle > create_uart_drivers ( )
noexcept

Create UART interface and driver instances.

Creates one Esp32UART interface shared by all drivers, and one TMC51x0 instance per node. Each driver is assigned node address 0 initially (sequential programming would assign unique addresses).

Here is the caller graph for this function:

◆ test_send_delay_configuration()

bool test_send_delay_configuration ( )
noexcept

Test send delay configuration.

SENDDELAY (NODECONF bits 11:8) controls the number of bit-times the TMC5160 waits before replying to a read request. For multi-node systems, this must be >= 2 to avoid bus contention.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_uart_basic_communication()

bool test_uart_basic_communication ( )
noexcept

Verify basic UART register read/write communication.

Reads the IOIN register (0x04) which contains chip version and pin states. A successful read confirms the UART link, baud rate detection, and CRC are all working.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_uart_motor_control()

bool test_uart_motor_control ( )
noexcept

Test motor control operations over UART.

Initializes the driver, configures ramp parameters, enables the motor, commands a small move, and polls for completion. This proves the full driver API works over UART, not just register access.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_uart_node_address_configuration()

bool test_uart_node_address_configuration ( )
noexcept

Test UART node address configuration via NODECONF register.

Writes a new node address via ConfigureUartNodeAddress(), then verifies the driver tracks it by checking GetUartNodeAddress(). Since NODECONF is write-only, we verify by reading IOIN on the new address to confirm the chip responds.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ EN_PIN

constexpr int EN_PIN = 11
staticconstexpr

◆ ENABLE_BASIC_COMM_TESTS

constexpr bool ENABLE_BASIC_COMM_TESTS = true
staticconstexpr

◆ ENABLE_MOTOR_CONTROL_TESTS

constexpr bool ENABLE_MOTOR_CONTROL_TESTS = true
staticconstexpr

◆ ENABLE_NODE_ADDRESS_TESTS

constexpr bool ENABLE_NODE_ADDRESS_TESTS = true
staticconstexpr

◆ ENABLE_SEND_DELAY_TESTS

constexpr bool ENABLE_SEND_DELAY_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)

Test rig selection for motor configuration.

◆ TAG

const char* TAG = "UART_MultiNode_Test"
static

◆ TEST_NODE_COUNT

constexpr uint8_t TEST_NODE_COUNT = 1
staticconstexpr

Number of TMC51x0 nodes on the UART bus. Set to 1 for single-driver setups.

◆ UART_BAUD

constexpr uint32_t UART_BAUD = 115200
staticconstexpr

UART baud rate – TMC5160 auto-detects from sync frame.

◆ UART_PORT

constexpr uart_port_t UART_PORT = UART_NUM_1
staticconstexpr

UART port (avoid UART_NUM_0 which is typically used for the USB console)

◆ UART_RX_PIN

constexpr int UART_RX_PIN = 16
staticconstexpr

◆ UART_TX_PIN

constexpr int UART_TX_PIN = 17
staticconstexpr

UART pin configuration.