|
HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
|
TMC5160 UART command/response frame structure with built-in CRC8. More...
#include <tmc51x0_comm_interface.hpp>
Classes | |
| union | Frame |
| Union for accessing UART frames in different ways. More... | |
Public Member Functions | |
| size_t | GetSize () const noexcept |
| Get frame size in bytes based on type. | |
| uint8_t | GetAddress () const noexcept |
| Get register address from frame. | |
| bool | IsWrite () const noexcept |
| Check if this is a write frame. | |
| uint32_t | GetValue () const noexcept |
| Get 32-bit data value from frame. | |
| void | CalculateCrc () noexcept |
| Calculate and set CRC8 checksum for the frame CRC8 is calculated over all bytes except the CRC byte itself. | |
| bool | VerifyCrc () const noexcept |
| Verify CRC8 checksum of the frame. | |
| void | SetFrame (const uint8_t *bytes, UartFrameType frame_type) noexcept |
| Set the frame from raw bytes. | |
| void | GetFrame (uint8_t *bytes) const noexcept |
| Get the frame as raw bytes. | |
| bool | IsValid () const noexcept |
| Check if frame is valid. | |
Static Public Member Functions | |
| static UartFrame | Write (uint8_t node_addr, uint8_t reg_addr, uint32_t value) noexcept |
| Construct a write access frame (8 bytes) | |
| static UartFrame | ReadRequest (uint8_t node_addr, uint8_t reg_addr) noexcept |
| Construct a read request frame (4 bytes) | |
| static UartFrame | ReadReply (const uint8_t *bytes) noexcept |
| Construct a read reply frame from received bytes (8 bytes) | |
Public Attributes | |
| union tmc51x0::UartFrame::Frame | frame |
| UartFrameType | type |
| Frame type. | |
TMC5160 UART command/response frame structure with built-in CRC8.
Represents a TMC5160 UART frame per datasheet section 5.1. Supports write access (8 bytes), read request (4 bytes), and read reply (8 bytes). Automatically calculates and verifies CRC8 checksum.
Frame Structure (per datasheet section 5.1):
Sync nibble: 0x05 (Bits 0-3 = 1,0,1,0 transmitted LSB first)
|
inlinenoexcept |
Calculate and set CRC8 checksum for the frame CRC8 is calculated over all bytes except the CRC byte itself.
|
inlinenoexcept |
Get register address from frame.
|
inlinenoexcept |
Get the frame as raw bytes.
| bytes | Output buffer (must be at least GetSize() bytes) |
|
inlinenoexcept |
Get frame size in bytes based on type.
|
inlinenoexcept |
Get 32-bit data value from frame.
|
inlinenoexcept |
Check if frame is valid.
|
inlinenoexcept |
Check if this is a write frame.
|
inlinestaticnoexcept |
Construct a read reply frame from received bytes (8 bytes)
| bytes | Pointer to received frame bytes |
|
inlinestaticnoexcept |
Construct a read request frame (4 bytes)
| node_addr | 8-bit node address (0-127) |
| reg_addr | Register address to read (0x00-0x73) |
|
inlinenoexcept |
Set the frame from raw bytes.
| bytes | Pointer to frame bytes |
| frame_type | Type of frame (determines size) |
|
inlinenoexcept |
Verify CRC8 checksum of the frame.
|
inlinestaticnoexcept |
Construct a write access frame (8 bytes)
| node_addr | 8-bit node address (0-127) |
| reg_addr | Register address to write (0x00-0x73) |
| value | 32-bit value to write |
| union tmc51x0::UartFrame::Frame tmc51x0::UartFrame::frame |
| UartFrameType tmc51x0::UartFrame::type |
Frame type.