|
HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
|
Frame structure for TMCL commands. More...
#include <tmc9660_comm_interface.hpp>
Public Member Functions | |
| void | toSpi (std::span< uint8_t, 8 > out) const noexcept |
| Serialize frame into 8-byte SPI buffer. | |
| void | toUart (uint8_t addr, std::span< uint8_t, 9 > out) const noexcept |
| Serialize frame into 9-byte UART buffer, including sync bit and checksum. | |
Static Public Member Functions | |
| static TMCLFrame | fromSpi (std::span< const uint8_t, 8 > in) noexcept |
| Deserialize an SPI buffer into a TMCLFrame without status check. | |
| static bool | fromSpiChecked (std::span< const uint8_t, 8 > in, TMCLFrame &out_frame) noexcept |
| Deserialize an SPI buffer with status and checksum validation. | |
| static bool | fromUart (std::span< const uint8_t, 9 > in, uint8_t expected_addr, TMCLFrame &out_frame) noexcept |
| Deserialize a UART buffer with address and checksum validation. | |
| static constexpr uint8_t | calculateChecksum (const uint8_t *bytes, size_t n) noexcept |
| Calculate 8-bit checksum (sum of bytes). | |
Public Attributes | |
| uint8_t | opcode = 0 |
| Operation code field (BYTE 0, bits 0-7). | |
| uint16_t | type = 0 |
| Parameter or command type (BYTE 1-2, bits 8-19). | |
| uint8_t | motor = 0 |
| Motor or bank identifier (BYTE 2, bits 20-23). | |
| uint32_t | value = 0 |
| 32-bit data value (BYTE 3-6, bits 24-55). | |
Frame structure for TMCL commands.
Supports conversion to/from SPI (8 bytes) and UART (9 bytes) formats.
|
inlinestaticconstexprnoexcept |
Calculate 8-bit checksum (sum of bytes).
| bytes | Pointer to data bytes to sum. |
| n | Number of bytes to include in sum. |
|
inlinestaticnoexcept |
Deserialize an SPI buffer with status and checksum validation.
| in | Span of 8 received bytes. |
| out_frame | Reference to store the valid frame. |
|
inlinestaticnoexcept |
Deserialize a UART buffer with address and checksum validation.
| in | Span of 9 received bytes. |
| expected_addr | 7-bit expected address of host. |
| out_frame | Reference to store the valid frame. |
Serialize frame into 8-byte SPI buffer.
| out | Span of 8 bytes to fill: opcode, type (2), motor, value (4). |
Serialize frame into 9-byte UART buffer, including sync bit and checksum.
| addr | 7-bit module address; MSB (sync bit) set automatically. |
| out | Span of 9 bytes to fill: sync+addr, fields, checksum. |
| uint8_t tmc9660::TMCLFrame::motor = 0 |
Motor or bank identifier (BYTE 2, bits 20-23).
| uint8_t tmc9660::TMCLFrame::opcode = 0 |
Operation code field (BYTE 0, bits 0-7).
| uint16_t tmc9660::TMCLFrame::type = 0 |
Parameter or command type (BYTE 1-2, bits 8-19).
| uint32_t tmc9660::TMCLFrame::value = 0 |
32-bit data value (BYTE 3-6, bits 24-55).