HardFOC driver
TMC9660 Driver¶
A C++20 driver for the Analog Devices (Trinamic) TMC9660 smart motor controller. It boots the chip into parameter mode, configures BLDC, stepper and DC motors, runs field-oriented control and reads telemetry, on any MCU with SPI or UART.
The driver has no platform code. You give it a small class that moves bytes over SPI or UART and toggles four pins; it does the rest: the bootloader handshake, TMCL framing, retries, unit conversion and fault decoding.
- Motors
- 3-phase BLDC / PMSM, 2-phase stepper, brushed DC
- Control
- Field-oriented control on chip: torque / flux, velocity and position loops, ramps
- Feedback
- Digital Hall, ABN incremental encoder (two), SPI absolute encoder
- Host interface
- SPI mode 3 up to 10 MHz (64-bit TMCL datagrams) or UART (72-bit frames)
- Control pins
- RST, DRV_EN, WAKE (inputs), FAULTN (open-drain output)
- Driver modes
- Parameter mode (TMCL), which this driver uses; register-mode headers are included
Datasheet · Parameter-mode reference · Register-mode reference · Configuration and bootstrapping
What you get¶
- One object per chip.
TMC9660<YourPort>exposes the chip as named subsystems:motorConfig,feedbackSense,velocityControl,positionControl,torqueFluxControl,telemetry,protection,diagnosticsand more. - Boot handled.
bootloaderInit()resets the chip, writes the bootloader configuration and starts motor control in parameter mode. See Bootloader. - Engineering units. RPM, degrees, rad/s and amperes in and out, converted with the motor's real pole pairs and sensor settings. See Units and diagnostics.
- A fast, correct SPI transport. NOT_READY polling instead of fixed delays, and pipelined batches: N parameter reads cost N + 1 datagrams. See Timing and throughput.
- Zero-overhead portability. The port is a CRTP class: no virtual calls, no heap, no RTOS dependency. See Porting.
- Tested without hardware. Host unit tests run the driver against a model of the chip's SPI and UART behaviour. See Testing and CI.
Where to go next¶
-
Wire the chip, write the port, spin a motor in about 15 lines.
-
Pins, bus settings, control-pin levels and the evaluation kits.
-
The three layers and what each one owns.
-
Configure, command, read and handle errors, task by task.
-
Implement the communication interface for your MCU.
-
Every class and member, generated from the headers.