|
HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
|
Reply structure returned by TMCL command operations. More...
#include <tmc9660_comm_interface.hpp>
Public Member Functions | |
| bool | isOK () const noexcept |
| uint32_t | extractRawValue (size_t offset) const noexcept |
| Extract 32-bit value from raw bytes at specified offset (MSB-first) | |
| std::string | getVersionString () const noexcept |
| Extract version string from GetVersion reply (Command 136, Type 0) | |
Static Public Member Functions | |
| static bool | fromSpi (std::span< const uint8_t, 8 > in, TMCLReply &r, uint8_t sent_opcode=0, uint16_t sent_type=0) noexcept |
| Decode and validate reply from SPI TMCL datagram. | |
| static bool | fromUart (std::span< const uint8_t, 9 > in, uint8_t addr, TMCLReply &r, uint8_t sent_opcode=0, uint16_t sent_type=0) noexcept |
| Decode and validate reply from UART TMCL datagram. | |
Public Attributes | |
| SPIStatus | spi_status = SPIStatus::OK |
| SPI status byte. | |
| uint8_t | status = 0 |
| TMCL status code (100=OK, 101=LOADED) | |
| uint8_t | opcode = 0 |
| Echoed operation code. | |
| uint32_t | value = 0 |
| Optional returned value. | |
| std::array< uint8_t, 8 > | rawBytes |
| Raw SPI bytes (8-byte) or UART bytes mapped to 8-byte format. | |
Reply structure returned by TMCL command operations.
This structure contains the decoded reply from a TMCL command, including SPI status, TMCL status, operation code, and the returned value. The structure also stores raw bytes for advanced parsing and provides helper methods for extracting version strings and handling protocol mismatches.
Extract 32-bit value from raw bytes at specified offset (MSB-first)
| offset | Starting byte offset (0-4 for 32-bit value) |
Useful for extracting misaligned data when protocol mismatch occurs (e.g., bootloader 5-byte SESSION_START parsed as 8-byte TMCL).
|
inlinestaticnoexcept |
Decode and validate reply from SPI TMCL datagram.
Parses an 8-byte SPI reply, validates checksum, and handles special reply formats such as SESSION_START and GetVersion string replies. Raw bytes are always stored for advanced parsing even if initial parsing fails.
| in | Input buffer containing 8 bytes from SPI |
| r | Output parameter to receive decoded reply |
| sent_opcode | Optional opcode of command that was sent (for handling special replies) |
| sent_type | Optional type field of command that was sent (for handling special replies) |
|
inlinestaticnoexcept |
Decode and validate reply from UART TMCL datagram.
Parses a 9-byte UART reply, validates module address and checksum, and handles special reply formats. UART replies include host address and sync bits not present in SPI format.
| in | Input buffer containing 9 bytes from UART |
| addr | Expected 7-bit module address for address validation |
| r | Output parameter to receive decoded reply |
| sent_opcode | Optional opcode of command that was sent (for handling special replies) |
| sent_type | Optional type field of command that was sent (for handling special replies) |
|
inlinenoexcept |
Extract version string from GetVersion reply (Command 136, Type 0)
GetVersion with Type=0 returns: [Host Address][Version String 8 chars] This method extracts the version string portion
|
inlinenoexcept |
| uint8_t tmc9660::TMCLReply::opcode = 0 |
Echoed operation code.
| std::array<uint8_t, 8> tmc9660::TMCLReply::rawBytes |
Raw SPI bytes (8-byte) or UART bytes mapped to 8-byte format.
| SPIStatus tmc9660::TMCLReply::spi_status = SPIStatus::OK |
SPI status byte.
| uint8_t tmc9660::TMCLReply::status = 0 |
TMCL status code (100=OK, 101=LOADED)
| uint32_t tmc9660::TMCLReply::value = 0 |
Optional returned value.