|
TMC9660 Driver 0.1.0
API reference
|
The UART port of the TMC9660 driver: the CRTP base, the UartPort 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::UartInterface< Derived > |
| CRTP base of the platform UART port. More... | |
Namespaces | |
| namespace | tmc9660 |
The TMC9660 driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | tmc9660::UartPort |
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exactly the types above. | |
Variables | |
Bus requirements | |
What the TMC9660 needs from the UART. | |
| constexpr uint8_t | tmc9660::kUartDataBits = 8 |
| Data bits of a frame: 8N1, one start bit and one stop bit. | |
| constexpr uint32_t | tmc9660::kMaxBaudRate = 5'000'000 |
| Highest baud rate. | |
| constexpr uint32_t | tmc9660::kTurnaroundUs = 1'000 |
| constexpr uint32_t | tmc9660::kMinAutobaudRate = 9'600 |
| Lowest standard baud rate the chip detects automatically. | |
| constexpr uint32_t | tmc9660::kMaxAutobaudRate = 250'000 |
| Highest standard baud rate the chip detects automatically at a 40 MHz system clock. | |
The UART port of the TMC9660 driver: the CRTP base, the UartPort concept and the bus requirements.
The chip's host UART is 8N1, least significant bit first, and detects the baud rate from the sync bit of each request (standard rates from 9600 to 250000 at a 40 MHz system clock; up to 5 Mbit/s when the rate is configured). Derive from tmc9660::UartInterface<Self> and implement:
bool EnsureInitialized() noexcept: bring the UART up on the first call; true at once afterwards.BusStatus Exchange(const uint8_t* tx, std::size_t tx_len, uint8_t* rx, std::size_t rx_len,
uint32_t timeout_us) noexcept: send tx_len bytes without gaps between bytes, then receive exactly rx_len bytes (0 when no reply is expected). The port discards stale received bytes before it sends and removes the echo of its own bytes on a shared wire, and handles transceiver direction. A call with tx_len == 0 sends nothing: it only discards what is waiting on the line, reading up to rx_len bytes within timeout_us (the driver does this to drain a late reply after a failed exchange).void DelayUs(uint32_t us) noexcept: wait (required: a port without it does not compile).Two documents disagree on how long a gap inside a request may be before the chip discards the partial message (about 100 ms in one chapter, 10 ms in another, ambiguity A6): a port sends each request without gaps, so the question does not arise.