HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
Loading...
Searching...
No Matches
esp32_tmc9660_test_config.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <cstdint>
14
15//==============================================================================
16// COMPILE-TIME CONFIGURATION FLAGS
17//==============================================================================
18
33#ifndef ESP32_TMC9660_ENABLE_DETAILED_LOGGING
34#define ESP32_TMC9660_ENABLE_DETAILED_LOGGING 0
35#endif
36
38
45struct SPIPins {
46 static constexpr uint8_t MISO = 2;
47 static constexpr uint8_t MOSI = 7;
48 static constexpr uint8_t SCLK = 6;
49 static constexpr uint8_t CS = 18;
50};
51
57struct UARTPins {
58 static constexpr uint8_t TX = 5;
59 static constexpr uint8_t RX = 4;
60};
61
68 static constexpr uint8_t RST = 22;
69 static constexpr uint8_t DRV_EN = 20;
70 static constexpr uint8_t FAULTN = 19;
71 static constexpr uint8_t WAKE = 21;
72};
73
84struct SPIParams {
85 static constexpr uint32_t FREQUENCY = 1000000;
86 static constexpr uint8_t MODE = 3;
87 static constexpr uint8_t QUEUE_SIZE = 1;
88 static constexpr uint8_t SPI_HOST_ID = 2;
89};
90
96struct UARTParams {
97 static constexpr uint32_t BAUD_RATE = 115200;
98 static constexpr uint8_t ADDRESS = 0;
99 static constexpr uint8_t UART_PORT = 1;
100};
101
108 static constexpr float MAX_SUPPLY_VOLTAGE = 60.0f;
109 static constexpr float MAX_CURRENT_A = 3.0f;
110 static constexpr uint32_t PWM_FREQUENCY_HZ = 25000;
111};
112
120 static constexpr float VS_MIN = 8.0f;
121 static constexpr float VS_NOM = 24.0f;
122 static constexpr float VS_MAX = 60.0f;
123 static constexpr float VDD_NOM = 3.3f;
124};
125
132 static constexpr int16_t OPERATING_MIN = -40;
133 static constexpr int16_t OPERATING_MAX = 125;
134 static constexpr int16_t JUNCTION_MAX = 150;
135 static constexpr int16_t WARNING_THRESHOLD = 110;
136};
137
143struct Timing {
144 static constexpr uint16_t POWER_ON_DELAY_MS = 100;
145 static constexpr uint16_t RESET_DELAY_MS = 50;
146 static constexpr uint16_t BOOT_DELAY_MS = 500;
147 static constexpr uint16_t INTER_FRAME_US = 10;
148};
149
156 static constexpr uint16_t POLL_INTERVAL_MS = 100;
157 static constexpr uint8_t MAX_RETRY_COUNT = 3;
158 static constexpr uint8_t MAX_FAULT_COUNT = 5;
159};
160
167 static constexpr uint16_t TEST_DURATION_MS = 5000;
168 static constexpr uint16_t RAMP_STEP_DELAY_MS = 100;
169 static constexpr int32_t DEFAULT_VELOCITY = 1000;
170 static constexpr uint16_t REGISTER_READ_COUNT = 100;
171};
172
178struct AppConfig {
179 // Logging
180 static constexpr bool ENABLE_DEBUG_LOGGING = true;
181 static constexpr bool ENABLE_BUS_LOGGING = false;
182
183 // Performance
184 static constexpr bool ENABLE_PERFORMANCE_MONITORING = true;
185 static constexpr uint16_t STATS_REPORT_INTERVAL_MS = 10000;
186
187 // Error handling
188 static constexpr bool ENABLE_AUTO_RECOVERY = true;
189 static constexpr uint8_t MAX_ERROR_COUNT = 10;
190};
191
192} // namespace TMC9660_TestConfig
193
199static_assert(TMC9660_TestConfig::SPIParams::FREQUENCY <= 10000000,
200 "SPI frequency exceeds TMC9660 maximum of 10MHz");
201
202static_assert(TMC9660_TestConfig::SPIParams::MODE == 3,
203 "TMC9660 requires SPI Mode 3 (CPOL=1, CPHA=1)");
204
205static_assert(TMC9660_TestConfig::UARTParams::BAUD_RATE >= 9600 &&
207 "UART baud rate must be between 9600 and 921600");
208
212#define TMC9660_VALIDATE_GPIO(pin) \
213 static_assert((pin) >= 0 && (pin) < 30, "Invalid GPIO pin number for ESP32-C6")
Definition esp32_tmc9660_test_config.hpp:37
Application-specific Configuration.
Definition esp32_tmc9660_test_config.hpp:178
static constexpr bool ENABLE_PERFORMANCE_MONITORING
Enable performance metrics.
Definition esp32_tmc9660_test_config.hpp:184
static constexpr bool ENABLE_BUS_LOGGING
Enable SPI/UART transaction logs.
Definition esp32_tmc9660_test_config.hpp:181
static constexpr bool ENABLE_AUTO_RECOVERY
Enable automatic error recovery.
Definition esp32_tmc9660_test_config.hpp:188
static constexpr bool ENABLE_DEBUG_LOGGING
Enable detailed debug logs.
Definition esp32_tmc9660_test_config.hpp:180
static constexpr uint8_t MAX_ERROR_COUNT
Maximum errors before failsafe.
Definition esp32_tmc9660_test_config.hpp:189
static constexpr uint16_t STATS_REPORT_INTERVAL_MS
Statistics reporting interval.
Definition esp32_tmc9660_test_config.hpp:185
Control GPIO Pins for TMC9660.
Definition esp32_tmc9660_test_config.hpp:67
static constexpr uint8_t FAULTN
GPIO19 - Fault indicator (active LOW, open-drain)
Definition esp32_tmc9660_test_config.hpp:70
static constexpr uint8_t WAKE
GPIO21 - Wake control (active LOW)
Definition esp32_tmc9660_test_config.hpp:71
static constexpr uint8_t RST
GPIO22 - Reset pin (active HIGH)
Definition esp32_tmc9660_test_config.hpp:68
static constexpr uint8_t DRV_EN
GPIO20 - Driver enable (active HIGH)
Definition esp32_tmc9660_test_config.hpp:69
Motor Controller Specifications.
Definition esp32_tmc9660_test_config.hpp:107
static constexpr uint32_t PWM_FREQUENCY_HZ
Default PWM frequency (Hz)
Definition esp32_tmc9660_test_config.hpp:110
static constexpr float MAX_CURRENT_A
Maximum phase current (A)
Definition esp32_tmc9660_test_config.hpp:109
static constexpr float MAX_SUPPLY_VOLTAGE
Maximum supply voltage (V)
Definition esp32_tmc9660_test_config.hpp:108
Diagnostic Thresholds.
Definition esp32_tmc9660_test_config.hpp:155
static constexpr uint8_t MAX_RETRY_COUNT
Maximum communication retries.
Definition esp32_tmc9660_test_config.hpp:157
static constexpr uint16_t POLL_INTERVAL_MS
Diagnostic polling interval (ms)
Definition esp32_tmc9660_test_config.hpp:156
static constexpr uint8_t MAX_FAULT_COUNT
Faults before failsafe.
Definition esp32_tmc9660_test_config.hpp:158
SPI Communication Parameters.
Definition esp32_tmc9660_test_config.hpp:84
static constexpr uint8_t MODE
SPI Mode 3 (CPOL=1, CPHA=1) ⚠️ CRITICAL.
Definition esp32_tmc9660_test_config.hpp:86
static constexpr uint8_t QUEUE_SIZE
Transaction queue size.
Definition esp32_tmc9660_test_config.hpp:87
static constexpr uint8_t SPI_HOST_ID
SPI2_HOST.
Definition esp32_tmc9660_test_config.hpp:88
static constexpr uint32_t FREQUENCY
1MHz SPI frequency
Definition esp32_tmc9660_test_config.hpp:85
SPI Pin Configuration for ESP32-C6.
Definition esp32_tmc9660_test_config.hpp:45
static constexpr uint8_t CS
GPIO18 - Chip Select (active low)
Definition esp32_tmc9660_test_config.hpp:49
static constexpr uint8_t MOSI
GPIO7 - SPI MOSI (Master Out Slave In)
Definition esp32_tmc9660_test_config.hpp:47
static constexpr uint8_t MISO
GPIO2 - SPI MISO (Master In Slave Out)
Definition esp32_tmc9660_test_config.hpp:46
static constexpr uint8_t SCLK
GPIO6 - SPI Clock.
Definition esp32_tmc9660_test_config.hpp:48
Supply Voltage Specifications (volts)
Definition esp32_tmc9660_test_config.hpp:119
static constexpr float VS_MAX
Maximum motor supply voltage (V)
Definition esp32_tmc9660_test_config.hpp:122
static constexpr float VS_MIN
Minimum motor supply voltage (V)
Definition esp32_tmc9660_test_config.hpp:120
static constexpr float VS_NOM
Nominal motor supply voltage (V)
Definition esp32_tmc9660_test_config.hpp:121
static constexpr float VDD_NOM
Logic supply voltage (V)
Definition esp32_tmc9660_test_config.hpp:123
Temperature Specifications (celsius)
Definition esp32_tmc9660_test_config.hpp:131
static constexpr int16_t OPERATING_MIN
Minimum operating temperature (°C)
Definition esp32_tmc9660_test_config.hpp:132
static constexpr int16_t JUNCTION_MAX
Maximum junction temperature (°C)
Definition esp32_tmc9660_test_config.hpp:134
static constexpr int16_t WARNING_THRESHOLD
Temperature warning threshold (°C)
Definition esp32_tmc9660_test_config.hpp:135
static constexpr int16_t OPERATING_MAX
Maximum operating temperature (°C)
Definition esp32_tmc9660_test_config.hpp:133
Test Configuration.
Definition esp32_tmc9660_test_config.hpp:166
static constexpr uint16_t REGISTER_READ_COUNT
Register reads per test.
Definition esp32_tmc9660_test_config.hpp:170
static constexpr uint16_t TEST_DURATION_MS
Test duration (ms)
Definition esp32_tmc9660_test_config.hpp:167
static constexpr uint16_t RAMP_STEP_DELAY_MS
Velocity ramp step delay (ms)
Definition esp32_tmc9660_test_config.hpp:168
static constexpr int32_t DEFAULT_VELOCITY
Default test velocity (RPM)
Definition esp32_tmc9660_test_config.hpp:169
Timing Parameters.
Definition esp32_tmc9660_test_config.hpp:143
static constexpr uint16_t INTER_FRAME_US
Minimum time between frames (μs)
Definition esp32_tmc9660_test_config.hpp:147
static constexpr uint16_t POWER_ON_DELAY_MS
Power-on initialization delay (ms)
Definition esp32_tmc9660_test_config.hpp:144
static constexpr uint16_t BOOT_DELAY_MS
Bootloader startup delay (ms)
Definition esp32_tmc9660_test_config.hpp:146
static constexpr uint16_t RESET_DELAY_MS
Reset recovery delay (ms)
Definition esp32_tmc9660_test_config.hpp:145
UART Communication Parameters.
Definition esp32_tmc9660_test_config.hpp:96
static constexpr uint8_t ADDRESS
TMCL module address.
Definition esp32_tmc9660_test_config.hpp:98
static constexpr uint8_t UART_PORT
UART_NUM_1.
Definition esp32_tmc9660_test_config.hpp:99
static constexpr uint32_t BAUD_RATE
UART baud rate.
Definition esp32_tmc9660_test_config.hpp:97
UART Pin Configuration for ESP32-C6.
Definition esp32_tmc9660_test_config.hpp:57
static constexpr uint8_t TX
GPIO5 - UART TX.
Definition esp32_tmc9660_test_config.hpp:58
static constexpr uint8_t RX
GPIO4 - UART RX.
Definition esp32_tmc9660_test_config.hpp:59