HF-TMC9660 Driver
Hardware Agnostic C++ Driver for the TMC9660
Loading...
Searching...
No Matches
TMC9660CommInterface.hpp File Reference

Communication interfaces for TMC9660 Parameter Mode devices using TMCL protocol over SPI and UART. More...

#include <array>
#include <cstdint>
#include <cstdlib>
#include <span>
Include dependency graph for TMC9660CommInterface.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TMCLReply
 Reply structure returned by sendCommand() More...
 
struct  TMCLFrame
 Frame structure for TMCL commands and replies. More...
 
class  TMC9660CommInterface
 SPI status codes as per TMC9660 Parameter Mode. More...
 
class  SPITMC9660CommInterface
 SPI implementation of TMC9660CommInterface. More...
 
class  UARTTMC9660CommInterface
 UART implementation of TMC9660CommInterface. More...
 

Enumerations

enum class  CommMode { SPI , UART }
 Supported physical communication modes. More...
 
enum class  SPIStatus : uint8_t { OK = 0xFF , CHECKSUM_ERROR = 0x00 , FIRST_CMD = 0x0C , NOT_READY = 0xF0 }
 SPI status codes as per TMC9660 Parameter Mode. More...
 

Functions

static constexpr uint8_t tmclChecksum (const uint8_t *bytes, size_t n) noexcept
 Calculate 8-bit checksum (sum of bytes)
 

Detailed Description

Communication interfaces for TMC9660 Parameter Mode devices using TMCL protocol over SPI and UART.

For parameter read/write access, either UART or SPI may be used. Both interfaces share the same TMCL command structure and follow a strict command/reply order.

SPI Command Format

Table 3: Command format for parameter read/write access through SPI

BYTE 0 1-2 3 4-6 7
Bits 0-7 8-19 20-23 24-55 56-63
Desc Operation Type Motor/Bank Data Checksum

SPI Reply Format

Table 4: Reply format for parameter read/write access through SPI

BYTE 0 1 2 3-6 7
Bits 0-7 8-15 16-23 24-55 56-63
Desc SPI Status TMCL Status Operation Data Checksum

UART Command Format

BYTE 0 1 2-3 4 5-8 9
Desc Sync+Address Command Type Motor/Bank Data Checksum

UART Reply Format

BYTE 0 1 2 3 4-7 8
Desc Host Address Sync+Address TMCL Status Operation Data Checksum

Enumeration Type Documentation

◆ CommMode

enum class CommMode
strong

Supported physical communication modes.

Enumerator
SPI 
UART 

◆ SPIStatus

enum class SPIStatus : uint8_t
strong

SPI status codes as per TMC9660 Parameter Mode.

Enumerator
OK 
CHECKSUM_ERROR 
FIRST_CMD 
NOT_READY 

Function Documentation

◆ tmclChecksum()

static constexpr uint8_t tmclChecksum ( const uint8_t *  bytes,
size_t  n 
)
staticconstexprnoexcept

Calculate 8-bit checksum (sum of bytes)