|
TMC5160 Driver 0.1.0
API reference
|
The SPI port of the TMC5160 driver: the CRTP base, the SpiPort concept and the bus requirements.
More...
#include <concepts>#include <cstddef>#include <cstdint>#include "tmc5160_detail.hpp"#include "tmc5160_types.hpp"Go to the source code of this file.
Classes | |
| class | tmc5160::SpiInterface< Derived > |
| CRTP base of the platform SPI port. More... | |
Namespaces | |
| namespace | tmc5160 |
The TMC5160 driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | tmc5160::SpiPort |
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept (KB-CPP20-006). | |
Variables | |
Bus requirements | |
What the TMC5160 needs from the UART (section 5, page 26). | |
| constexpr uint8_t | tmc5160::kSpiMode = 3 |
| SPI mode: SCK idles high, data is latched on the rising edge ("usually referred to as mode 3"). | |
| constexpr bool | tmc5160::kMsbFirst = true |
| Each byte is clocked most significant bit first. | |
| constexpr uint32_t | tmc5160::kMaxClockHz = 4'000'000 |
| constexpr uint32_t | tmc5160::kDatagramBytes = 5 |
| A datagram is 40 bits; the whole datagram (5 bytes per chip in a chain) is one CSN low period. | |
| constexpr uint32_t | tmc5160::kMinCsHighNs = 200 |
| CSN high time between datagrams is more than 2 clocks + 10 ns: 200 ns covers the slowest clock. | |
| constexpr uint32_t | tmc5160::kCsHoldNs = 100 |
| constexpr uint32_t | tmc5160::kCsSetupNs = 10 |
| CSN low to the first SCK edge, t_CC, minimum. | |
| constexpr bool | tmc5160::kContinuousWord = true |
true: the chip needs the 40 bits of a datagram without a CSN pulse in between. | |
The SPI port of the TMC5160 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 tmc5160::SpiInterface<Self>:
| Hook | Contract |
|---|---|
bool EnsureInitialized() noexcept | Bring the bus up on the first call; true at once afterwards |
bool Transfer(const uint8_t* tx, uint8_t* rx, std::size_t len) noexcept | One full-duplex transfer, CSN low for all len bytes, SPI mode 3, MSB first; len is 5 x the chain length; both buffers are given |
The port moves raw bytes: it never retries, never interprets a datagram and never configures the chip. DelayUs, GpioSet, GpioGet, SckHz and Log are optional hooks described in tmc5160.hpp.