Driver
TMC9660 Driver¶
A C++20 driver for the TMC9660 servo controller and gate driver: the bootloader, parameter mode and register mode, over SPI or UART, with guards so that nothing energises a motor by accident. It runs on any MCU.
The driver has no platform code. You give it a small class that brings the bus up and moves bytes; it does the rest: the frames of three protocols, the checks of every reply, the parameter and register tables, and the rules that keep the power stage off until the chip and your request say otherwise.
Figure description and sources
Top to bottom, each arrow is a call. Your application calls one object, whose public calls are listed from the umbrella header in inc/. The core turns each call into register reads and writes and hands them to the port contract (the CRTP base in inc/*_interface.hpp), which forwards them, at compile time, to the hooks of the port class you write; your port moves the bytes on the bus. The notes on the right say which layers stay the same on every MCU and which one you write. A library without a port contract has only the first two layers.
Drawn from: inc/tmc9660.hpp public calls; inc/tmc9660_spi_interface.hpp SpiInterface; inc/tmc9660_uart_interface.hpp UartInterface; figure module docs/diagrams/figures/driver-layers.py.
What you get¶
- Three modes in one class.
Mode::Bootloader,Mode::ParameterandMode::Register; a call that belongs to another mode returnsWrongModeand sends nothing. See Bootloader, Parameter mode and Register mode. - Checked tables. All 289 parameters and 163 registers of the reference manuals, with access, range and coded values; a bad value is refused before a byte leaves.
- Safe to start and to stop.
EnableDrive()reads the flags and raises DRV_EN before it sets the commutation mode;DisableDrive()is never refused. See Safety. - Reset-aware. The driver watches each transport for evidence that the chip restarted and sends no write after it.
- Explicit where the documents disagree. Twenty-four ambiguities (A1 to A24), most with a knob. See Ambiguities.
- No heap, no exceptions, no RTTI. The host tests build with
-fno-exceptions -fno-rtti. See Contract. - Tested without hardware. Host tests run the driver against an independent model of the chip, a fuzz target attacks it, and one-edit mutants of every guard must be caught. See Testing and CI.
Not yet run on a real chip
Everything is verified against a model built from the documents. The ambiguities page lists what a bench check should settle first.
Datasheet¶
| Document | Revision | Get it |
|---|---|---|
| Datasheet: TMC9660 70V Smart Gate Driver with Servo (FOC) Controller in HW and Buck Converter (Analog Devices (Trinamic) 19-101926) | 1, 2024-11 | vendor page |
| Datasheet: TMC9660 Parameter Mode Reference Manual (Analog Devices (Trinamic) n/a) | 0, 2025-02 | vendor page |
| Datasheet: TMC9660 Register Mode Reference Manual (Analog Devices (Trinamic) n/a) | 0, 2025-04 | vendor page |
| Datasheet: TMC9660 Configuration and Bootstrapping (Analog Devices (Trinamic) AN-2601) | 0, 2025-01-08 | vendor page |
Written against these revisions; the SHA-256 of each file is in docs/datasheets.yml. Where each part
of the driver is in the datasheet: Datasheet map.
Where to go next¶
-
Wire the chip, write the port, read a parameter in about 15 lines.
-
Pins, bus settings, timing and power.
-
What keeps the power stage off, and what the driver does not cover.
-
What the driver promises, what it needs, threading and errors.
-
Start, configure the bootloader, set parameters, drive, handle errors, task by task.
-
Implement the port for your MCU, on SPI or UART.