TMC9660 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts
tmc9660_spi_interface.hpp File Reference

The SPI port of the TMC9660 driver: the CRTP base, the SpiPort concept and the bus requirements. More...

#include <concepts>
#include <cstddef>
#include <cstdint>
#include "tmc9660_detail.hpp"
#include "tmc9660_types.hpp"

Go to the source code of this file.

Classes

class  tmc9660::SpiInterface< Derived >
 CRTP base of the platform SPI port. More...
 

Namespaces

namespace  tmc9660
 The TMC9660 driver: everything it declares lives here; internals in detail.
 

Concepts

concept  tmc9660::SpiPort
 Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool.
 

Variables

Bus requirements

What the TMC9660 needs from the UART.

constexpr uint8_t tmc9660::kSpiMode = 3
 SPI mode: CPOL 1, CPHA 1 (the default of the chip's SPI peripheral).
 
constexpr bool tmc9660::kMsbFirst = true
 Each byte is clocked most significant bit first; multi-byte values are big endian.
 
constexpr uint32_t tmc9660::kMaxClockHz = 10'000'000
 Highest SCK frequency.
 
constexpr uint32_t tmc9660::kCsSetupNs = 100
 CS low to the first SCK edge, t_CSS.
 
constexpr uint32_t tmc9660::kCsHoldNs = 100
 SCK edge to CS change, t_CC (data sheet p. 27: one SCK period, 100 ns at 10 MHz).
 
constexpr bool tmc9660::kContinuousWord = true
 true: a datagram is clocked in one CS low period, without a CS pulse between its bytes.
 
constexpr uint32_t tmc9660::kMinCsHighNs = 100
 Shortest time CS stays high between two datagrams, t_CSH (4 system clocks at 40 MHz).
 
constexpr uint32_t tmc9660::kClockPhaseNs = 20
 SCK low and high time, t_CL and t_CH.
 
constexpr uint32_t tmc9660::kDataSetupNs = 20
 Data setup and hold time, t_DU and t_DH.
 
constexpr std::size_t tmc9660::kBootloaderDatagramBytes = 5
 Bootloader datagram length in bytes.
 
constexpr std::size_t tmc9660::kParameterDatagramBytes = 8
 Parameter-mode (TMCL) datagram length in bytes.
 
constexpr std::size_t tmc9660::kRegisterDatagramBytes = 6
 Register-mode datagram length in bytes.
 

Detailed Description

The SPI port of the TMC9660 driver: the CRTP base, the SpiPort concept and the bus requirements.

The driver never calls an SDK. It calls hooks on a class you derive from tmc9660::SpiInterface<Self>:

The same SPI port carries the bootloader (5-byte datagrams), parameter mode (8 bytes) and register mode (6 bytes): the port moves raw bytes, never retries, never interprets a frame. What the chip needs from the bus is below as constexpr values (datasheet "SPI Interface", electrical characteristics); a port checks its settings against them with static_assert. The optional hooks (GpioSet, GpioGet, SckHz, Log) are described in tmc9660.hpp.