|
HF-TMC9660 Driver
Hardware Agnostic C++ Driver for the TMC9660
|
To keep the driver portable it does not ship with any hardware specific code. Instead you plug in your own class that knows how to talk over SPI or UART. The steps below show how to write that class and hook it up to the library.
The library itself does not contain any hardware specific transfer code. Instead you provide a class derived from TMC9660CommInterface that delivers the 8 byte datagrams over SPI or UART.
This document explains the required functions and provides a skeleton implementation you can adapt for your platform.
Create a new C++ class that inherits from either SPITMC9660CommInterface or UARTTMC9660CommInterface. The choice depends on whether your hardware uses SPI or UART for communication.
Only a single method must be implemented. It should transmit the contents of tx and fill rx with the reply from the device. Return true on success and false if any error occurred. If communication fails you can use this return value to trigger a retry or error message in your application.
Inside spiTransfer() perform the actual byte exchange. For example on an embedded MCU you might toggle chip select, call into your SPI driver and then return the received bytes.
For UART interfaces implement uartTransfer() instead. The method signatures are documented in TMC9660CommInterface.hpp.
Instantiate your interface and pass it to the driver:
All library calls now communicate through your implementation.
After implementing the interface you can build any of the example programs or integrate the driver into your own application:
TMC9660 object into your existing control loop or RTOS task.