|
TMC9660 Driver 0.1.0
API reference
|
The TMC9660 driver: everything it declares lives here; internals in detail.
More...
Namespaces | |
| namespace | fields |
Bit fields, one lower-case namespace per register: fields::mcc_pwm_config::EnableX. | |
| namespace | global0 |
| Bank 0 numbers. | |
| namespace | regs |
| The registers by name. | |
| namespace | value |
Classes | |
| struct | BlWriteOptions |
Options of TMC9660::BlWriteConfig(). More... | |
| class | BootConfig |
| The 64-byte configuration memory of the bootloader, as 16 little-endian 32-bit words. More... | |
| class | CheckedConfig |
| A configuration proven valid at build time. More... | |
| struct | Config |
| Configuration of the driver. The defaults are the chip's. More... | |
| struct | GateDriverRegConfig |
| Gate-driver start-up of register mode: the words of the manual's start sequence. More... | |
| struct | GlobalInfo |
| One global parameter: its bank, number, access and range. More... | |
| struct | LastReply |
The last parameter-mode reply as received (see TMC9660::GetLastReply()). More... | |
| struct | ParamInfo |
| One row of Table 57. More... | |
| struct | PartitionEntry |
| One entry of an external-memory partition table. More... | |
| struct | Quirks |
| Model knobs: where the documents disagree, the driver reads one way by default and a flag selects the other (docs/ambiguities.md). More... | |
| struct | RegAddr |
| Address of a register: its block and its offset in the block. More... | |
| struct | RegInfo |
| One row of the register map. More... | |
| struct | Result |
| The value of a call, or why there is none. More... | |
| struct | Result< void > |
| The result of a call that returns no value. More... | |
| class | SpiInterface |
| CRTP base of the platform SPI port. More... | |
| class | TMC9660 |
| Driver for one TMC9660 on a platform port. More... | |
| struct | TmclInstruction |
| One instruction of a script download. More... | |
| class | UartInterface |
| CRTP base of the platform UART port. More... | |
Concepts | |
| concept | AnyPort |
Satisfied by a port that derives from exactly one of SpiInterface and UartInterface. | |
| concept | SpiPort |
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool. | |
| concept | UartPort |
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exactly the types above. | |
Functions | |
| constexpr Result< std::size_t > | BuildPartitionTable (std::span< const PartitionEntry > entries, uint8_t size_index, uint8_t sector_index, std::span< uint8_t > out) noexcept |
| Build a partition table (datasheet Tables 21 and 22): header, entries, CRC-32 over the bytes from the magic number on. | |
| constexpr const GlobalInfo * | FindGlobal (uint8_t bank, uint32_t number) noexcept |
| The row of a global parameter. | |
| constexpr Config | KconfigDefaults () noexcept |
The configuration menuconfig selected, on top of the Config{} defaults. | |
| constexpr const ParamInfo * | FindParam (uint32_t id) noexcept |
| The table row of an axis parameter. | |
| constexpr const RegInfo * | FindRegister (RegAddr addr) noexcept |
| The map row of a register. | |
| constexpr const char * | ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr Error | Validate (const Config &c) noexcept |
Check a Config without touching the bus. | |
| void | ConfigIsInvalid () noexcept |
Reached only when a CheckedConfig is built from an invalid configuration: it is never defined, so the build fails and names it (KB-CPP20-013). | |
| constexpr const char * | GetDriverVersion () noexcept |
| constexpr uint32_t | GetDriverVersionMajor () noexcept |
| constexpr uint32_t | GetDriverVersionMinor () noexcept |
| constexpr uint32_t | GetDriverVersionPatch () noexcept |
Variables | |
| constexpr uint32_t | kConfigMemAddress = 0x0002'0000U |
| Address of the configuration memory in the bootloader's address space. | |
| constexpr std::size_t | kClockWordIndex = 6 |
| Word index of the clock configuration (byte offset 24). | |
| constexpr std::size_t | kBootModeWordIndex = 2 |
| Word index of the BOOT_MODE word (byte offset 8): written last. | |
| constexpr std::size_t | kLdoWordIndex = 0 |
| Word index of the LDO configuration (byte offset 0). | |
| constexpr std::size_t | kPartitionHeaderBytes = 16 |
| Header size of a partition table. | |
| constexpr std::size_t | kPartitionEntryBytes = 24 |
| Size of one partition entry. | |
| constexpr std::array< GlobalInfo, 55 > | kGlobals = detail::MakeGlobals() |
| Tables 61 to 63, sorted by bank and number. | |
| constexpr std::array< int32_t, 513 > | kAllowedValues |
| Every value a coded parameter accepts, concatenated. | |
| constexpr std::array< ParamInfo, 289 > | kParams |
| Table 57, sorted by number. | |
| constexpr std::array< RegInfo, 163 > | kRegisters |
| The register map, sorted by block and offset. | |
| constexpr int32_t | kSystemOff = 0 |
| Value of COMMUTATION_MODE (parameter 4) that leaves the gate driver off. | |
| constexpr int32_t | kCommutationModeMax = 8 |
| The largest valid COMMUTATION_MODE value. | |
| constexpr uint32_t | kChipId = 0x544D0001U |
| The chip ID every TMC9660 reports (bootloader CHIP_TYPE, register MCC_INFO_CHIP). | |
| constexpr uint32_t | kMotorControlClockHz = 40'000'000U |
| The system clock motor control needs, in Hz. | |
| constexpr uint32_t | kBootMagic = 0xA3B4C5D6U |
The magic value of the Boot command. | |
Bus requirements | |
What the TMC9660 needs from the UART. | |
| constexpr uint8_t | kSpiMode = 3 |
| SPI mode: CPOL 1, CPHA 1 (the default of the chip's SPI peripheral). | |
| constexpr bool | kMsbFirst = true |
| Each byte is clocked most significant bit first; multi-byte values are big endian. | |
| constexpr uint32_t | kMaxClockHz = 10'000'000 |
| Highest SCK frequency. | |
| constexpr uint32_t | kCsSetupNs = 100 |
| CS low to the first SCK edge, t_CSS. | |
| constexpr uint32_t | kCsHoldNs = 100 |
| SCK edge to CS change, t_CC (data sheet p. 27: one SCK period, 100 ns at 10 MHz). | |
| constexpr bool | kContinuousWord = true |
true: a datagram is clocked in one CS low period, without a CS pulse between its bytes. | |
| constexpr uint32_t | kMinCsHighNs = 100 |
| Shortest time CS stays high between two datagrams, t_CSH (4 system clocks at 40 MHz). | |
| constexpr uint32_t | kClockPhaseNs = 20 |
| SCK low and high time, t_CL and t_CH. | |
| constexpr uint32_t | kDataSetupNs = 20 |
| Data setup and hold time, t_DU and t_DH. | |
| constexpr std::size_t | kBootloaderDatagramBytes = 5 |
| Bootloader datagram length in bytes. | |
| constexpr std::size_t | kParameterDatagramBytes = 8 |
| Parameter-mode (TMCL) datagram length in bytes. | |
| constexpr std::size_t | kRegisterDatagramBytes = 6 |
| Register-mode datagram length in bytes. | |
| constexpr uint8_t | kUartDataBits = 8 |
| Data bits of a frame: 8N1, one start bit and one stop bit. | |
| constexpr uint32_t | kMaxBaudRate = 5'000'000 |
| Highest baud rate. | |
| constexpr uint32_t | kTurnaroundUs = 1'000 |
| constexpr uint32_t | kMinAutobaudRate = 9'600 |
| Lowest standard baud rate the chip detects automatically. | |
| constexpr uint32_t | kMaxAutobaudRate = 250'000 |
| Highest standard baud rate the chip detects automatically at a 40 MHz system clock. | |
The TMC9660 driver: everything it declares lives here; internals in detail.
|
strong |
|
strong |
|
strong |
Named fields of the configuration memory.
|
strong |
|
strong |
|
strong |
The axis parameters, by name; the value is the number sent as the TMCL type.
|
strong |
Power-down durations of TMC9660::PowerDown() (global parameter 11).
| Enumerator | |
|---|---|
| Ms250 | 250 ms. |
| Ms500 | 500 ms. |
| S1 | 1 s. |
| S2 | 2 s. |
| S4 | 4 s. |
| S8 | 8 s. |
| S16 | 16 s. |
| S32 | 32 s. |
|
constexprnoexcept |
Build a partition table (datasheet Tables 21 and 22): header, entries, CRC-32 over the bytes from the magic number on.
| entries | The partitions. |
| size_index | Memory size is 2^size_index bytes, 0 if unknown (at most 31). |
| sector_index | Erase sector size is 2^sector_index bytes, 0 if unknown (at most 31). |
| out | Receives the table; must hold 16 + 24 * entries.size() bytes. |
Error::InvalidArgument when an entry is invalid (type not 2 or 4, size not a multiple of the sector size, parameter partition under 0x400 bytes, offset or size not sector aligned, overlap) or out is too small. Nothing is written on error.
|
constexprnoexcept |
The row of a global parameter.
| bank | The bank number (0, 2 or 3). |
| number | The parameter number in the bank. |
nullptr when the manual lists none.
|
constexprnoexcept |
The table row of an axis parameter.
| id | The parameter number. |
nullptr when the manual lists no such parameter. The map row of a register.
| addr | The register. |
nullptr when the manual lists none at that address.
|
constexprnoexcept |
|
inlineconstexpr |
Every value a coded parameter accepts, concatenated.
|
inlineconstexpr |
Assumed longest time from the last request byte to the first reply byte, in microseconds. The manuals give no bound (ambiguity A19); the chip adds UART_TXEN_PRE_DELAY only when UART_TXEN is used. A port sets its reply timeout above this value plus the frame time.