Concrete UART communication adapter for TMC9660 using BaseUart and BaseGpio.
More...
#include <Tmc9660Handler.h>
|
| | HalUartTmc9660Comm (BaseUart &uart, BaseGpio &rst, BaseGpio &drv_en, BaseGpio &faultn, BaseGpio &wake, bool rst_active_high=true, bool drv_en_active_high=true, bool faultn_active_low=false, bool wake_active_low=false) noexcept |
| | Construct the UART communication adapter.
|
| |
|
| bool | uartSendTMCL (const std::array< uint8_t, 9 > &data) noexcept |
| | Send a 9-byte TMCL datagram over UART.
|
| |
| bool | uartReceiveTMCL (std::array< uint8_t, 9 > &data) noexcept |
| | Receive a 9-byte TMCL reply datagram over UART.
|
| |
| bool | uartTransferBootloader (const std::array< uint8_t, 8 > &tx, std::array< uint8_t, 8 > &rx) noexcept |
| | Perform an 8-byte UART bootloader transfer (send + receive).
|
| |
| bool | gpioSet (tmc9660::TMC9660CtrlPin pin, tmc9660::GpioSignal signal) noexcept |
| | Set a TMC9660 control pin to a given logical signal state.
|
| |
| bool | gpioRead (tmc9660::TMC9660CtrlPin pin, tmc9660::GpioSignal &signal) noexcept |
| | Read a TMC9660 control pin's current logical signal state.
|
| |
| void | debugLog (int level, const char *tag, const char *format, va_list args) noexcept |
| | Route TMC9660 driver debug output to the HardFOC Logger.
|
| |
| void | delayMs (uint32_t ms) noexcept |
| | Delay execution for the specified number of milliseconds.
|
| |
| void | delayUs (uint32_t us) noexcept |
| | Delay execution for the specified number of microseconds.
|
| |
Concrete UART communication adapter for TMC9660 using BaseUart and BaseGpio.
Implements all methods required by tmc9660::UartCommInterface<HalUartTmc9660Comm> through the CRTP pattern. Handles:
- TMCL transfers: 9-byte send/receive for parameter mode
- Bootloader transfers: 8-byte send/receive for bootloader mode
- GPIO control: Same four control pins as HalSpiTmc9660Comm
- Timing and logging: Same platform-aware implementations
- Note
- This class does NOT own the BaseUart or BaseGpio instances; they must remain valid for the lifetime of this object.
- See also
- tmc9660::UartCommInterface CRTP base class from the TMC9660 driver
-
HalSpiTmc9660Comm SPI equivalent of this class
◆ HalUartTmc9660Comm()
| HalUartTmc9660Comm::HalUartTmc9660Comm |
( |
BaseUart & | uart, |
|
|
BaseGpio & | rst, |
|
|
BaseGpio & | drv_en, |
|
|
BaseGpio & | faultn, |
|
|
BaseGpio & | wake, |
|
|
bool | rst_active_high = true, |
|
|
bool | drv_en_active_high = true, |
|
|
bool | faultn_active_low = false, |
|
|
bool | wake_active_low = false ) |
|
noexcept |
Construct the UART communication adapter.
- Parameters
-
| uart | Reference to a pre-configured BaseUart implementation. |
| rst | BaseGpio connected to TMC9660 RST (pin 22, output). |
| drv_en | BaseGpio connected to TMC9660 DRV_EN (pin 21, output). |
| faultn | BaseGpio connected to TMC9660 FAULTN (pin 20, input). |
| wake | BaseGpio connected to TMC9660 WAKE (pin 19, output). |
| rst_active_high | Physical level for RST ACTIVE state (default: true). |
| drv_en_active_high | Physical level for DRV_EN ACTIVE state (default: true). |
| faultn_active_low | Physical level for FAULTN ACTIVE state (default: false). |
| wake_active_low | Physical level for WAKE ACTIVE state (default: false). |
◆ debugLog()
| void HalUartTmc9660Comm::debugLog |
( |
int | level, |
|
|
const char * | tag, |
|
|
const char * | format, |
|
|
va_list | args ) |
|
noexcept |
Route TMC9660 driver debug output to the HardFOC Logger.
- Parameters
-
| level | Log level (0=Error, 1=Warning, 2=Info, 3=Debug). |
| tag | Log tag string for categorization. |
| format | printf-style format string. |
| args | Variable argument list. |
◆ delayMs()
| void HalUartTmc9660Comm::delayMs |
( |
uint32_t | ms | ) |
|
|
noexcept |
Delay execution for the specified number of milliseconds.
- Parameters
-
| ms | Milliseconds to delay (delegates to os_delay_msec). |
◆ delayUs()
| void HalUartTmc9660Comm::delayUs |
( |
uint32_t | us | ) |
|
|
noexcept |
Delay execution for the specified number of microseconds.
On ESP32, uses esp_rom_delay_us() for accurate sub-millisecond timing. On other platforms, uses a busy-wait loop based on the processor cycle counter.
- Parameters
-
◆ gpioRead()
| bool HalUartTmc9660Comm::gpioRead |
( |
tmc9660::TMC9660CtrlPin | pin, |
|
|
tmc9660::GpioSignal & | signal ) |
|
noexcept |
Read a TMC9660 control pin's current logical signal state.
Reads the physical GPIO level via BaseGpio, then translates to ACTIVE/INACTIVE based on the pin's configured active-level polarity.
- Parameters
-
| pin | Which control pin to read (typically FAULTN for fault status). |
| [out] | signal | Current logical signal state. |
- Returns
- true if the GPIO read succeeded.
◆ gpioSet()
| bool HalUartTmc9660Comm::gpioSet |
( |
tmc9660::TMC9660CtrlPin | pin, |
|
|
tmc9660::GpioSignal | signal ) |
|
noexcept |
Set a TMC9660 control pin to a given logical signal state.
Translates the logical ACTIVE/INACTIVE signal to a physical HIGH/LOW level based on the pin's configured active-level polarity, then writes via BaseGpio.
- Parameters
-
| pin | Which control pin to set (RST, DRV_EN, FAULTN, WAKE). |
| signal | Desired logical signal state. |
- Returns
- true if the GPIO write succeeded.
◆ uartReceiveTMCL()
| bool HalUartTmc9660Comm::uartReceiveTMCL |
( |
std::array< uint8_t, 9 > & | data | ) |
|
|
noexcept |
Receive a 9-byte TMCL reply datagram over UART.
- Parameters
-
| [out] | data | 9-byte array to store the received reply. |
- Returns
- true if BaseUart::Read() succeeded within timeout.
◆ uartSendTMCL()
| bool HalUartTmc9660Comm::uartSendTMCL |
( |
const std::array< uint8_t, 9 > & | data | ) |
|
|
noexcept |
Send a 9-byte TMCL datagram over UART.
- Parameters
-
| data | 9-byte array: [sync+addr, opcode, type, motor, value(4), checksum]. |
- Returns
- true if BaseUart::Write() succeeded.
◆ uartTransferBootloader()
| bool HalUartTmc9660Comm::uartTransferBootloader |
( |
const std::array< uint8_t, 8 > & | tx, |
|
|
std::array< uint8_t, 8 > & | rx ) |
|
noexcept |
Perform an 8-byte UART bootloader transfer (send + receive).
- Parameters
-
| tx | 8-byte transmit buffer (bootloader command). |
| [out] | rx | 8-byte receive buffer (bootloader reply). |
- Returns
- true if both write and read succeeded.
◆ ctrl_pins_
Host-side control pin references.
◆ uart_
| BaseUart& HalUartTmc9660Comm::uart_ |
|
private |
UART bus interface (not owned).
The documentation for this class was generated from the following files: