TMC9660 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
tmc9660_types.hpp File Reference

Public types of the TMC9660 driver: errors, Result<T>, the protocol enumerations, Config and its model knobs. More...

#include <cstdint>
#include "tmc9660_detail.hpp"
#include "tmc9660_version.h"

Go to the source code of this file.

Classes

struct  tmc9660::Result< T >
 The value of a call, or why there is none. More...
 
struct  tmc9660::Result< void >
 The result of a call that returns no value. More...
 
struct  tmc9660::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  tmc9660::Config
 Configuration of the driver. The defaults are the chip's. More...
 
class  tmc9660::CheckedConfig
 A configuration proven valid at build time. More...
 

Namespaces

namespace  tmc9660
 The TMC9660 driver: everything it declares lives here; internals in detail.
 

Enumerations

enum class  tmc9660::Error : uint8_t {
  tmc9660::Error::Ok = 0 , tmc9660::Error::NotInitialized = 1 , tmc9660::Error::InvalidArgument = 2 , tmc9660::Error::Bus = 3 ,
  tmc9660::Error::Timeout = 4 , tmc9660::Error::DeviceIdMismatch , tmc9660::Error::Crc = 6 , tmc9660::Error::Busy = 7 ,
  tmc9660::Error::DeviceFault = 8 , tmc9660::Error::Unsupported = 9 , tmc9660::Error::UnexpectedReset , tmc9660::Error::Nack = 17 ,
  tmc9660::Error::WrongMode = 18 , tmc9660::Error::Refused = 19 , tmc9660::Error::VerifyFailed = 20 , tmc9660::Error::BadReply = 21
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  tmc9660::LogLevel : uint8_t { tmc9660::LogLevel::Error = 0 , tmc9660::LogLevel::Warning , tmc9660::LogLevel::Info , tmc9660::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  tmc9660::BusStatus : uint8_t { tmc9660::BusStatus::Ok = 0 , tmc9660::BusStatus::Fault , tmc9660::BusStatus::Timeout }
 What a UART port reports for one exchange. More...
 
enum class  tmc9660::CtrlPin : uint8_t { tmc9660::CtrlPin::Reset = 0 , tmc9660::CtrlPin::DrvEn , tmc9660::CtrlPin::Wake , tmc9660::CtrlPin::Faultn }
 The control pins of the chip that the optional GpioSet() and GpioGet() hooks may drive. More...
 
enum class  tmc9660::GpioSignal : uint8_t { tmc9660::GpioSignal::INACTIVE = 0 , tmc9660::GpioSignal::ACTIVE = 1 }
 Logical level of a control pin; the port maps it to the physical polarity. More...
 
enum class  tmc9660::Mode : uint8_t { tmc9660::Mode::Bootloader = 0 , tmc9660::Mode::Parameter = 1 , tmc9660::Mode::Register = 2 }
 The protocol the chip speaks on its host interface. More...
 
enum class  tmc9660::BootMode : uint8_t { tmc9660::BootMode::Reserved , tmc9660::BootMode::Register = 1 , tmc9660::BootMode::Parameter = 2 , tmc9660::BootMode::Reserved3 = 3 }
 BOOT_MODE of the boot configuration (offset 8, bits 0-1). More...
 
enum class  tmc9660::Bank : uint8_t { tmc9660::Bank::SpiFlash = 1 , tmc9660::Bank::I2cEeprom = 2 , tmc9660::Bank::Otp = 3 , tmc9660::Bank::Config = 5 }
 External memory banks of the bootloader (SET_BANK). More...
 
enum class  tmc9660::BlInfo : uint8_t {
  tmc9660::BlInfo::ChipType = 0 , tmc9660::BlInfo::BlVersion = 1 , tmc9660::BlInfo::Features = 2 , tmc9660::BlInfo::GitInfo = 12 ,
  tmc9660::BlInfo::ChipVersion = 13 , tmc9660::BlInfo::ChipFrequency = 14 , tmc9660::BlInfo::ConfigMemStart = 17 , tmc9660::BlInfo::ConfigMemSize = 18 ,
  tmc9660::BlInfo::OtpMemSize = 19 , tmc9660::BlInfo::I2cMemSize = 20 , tmc9660::BlInfo::SpiMemSize = 21 , tmc9660::BlInfo::PartitionVersion = 22 ,
  tmc9660::BlInfo::SpiMemPartitions = 25 , tmc9660::BlInfo::I2cMemPartitions = 26 , tmc9660::BlInfo::ChipVariant = 28
}
 GET_INFO selectors of the bootloader. More...
 
enum class  tmc9660::BlStatus : uint8_t {
  tmc9660::BlStatus::Ok = 0 , tmc9660::BlStatus::CmdNotFound = 1 , tmc9660::BlStatus::InvalidAddr = 3 , tmc9660::BlStatus::InvalidValue = 4 ,
  tmc9660::BlStatus::InvalidBank = 14 , tmc9660::BlStatus::Busy = 15 , tmc9660::BlStatus::MemUnconfigured = 17 , tmc9660::BlStatus::OtpError = 18 ,
  tmc9660::BlStatus::SessionStart = 19 , tmc9660::BlStatus::CmdNotAvailable = 20 , tmc9660::BlStatus::BootloaderResumed = 21
}
 Bootloader reply status codes (datasheet bootloader chapter). More...
 
enum class  tmc9660::BlCmd : uint8_t {
  tmc9660::BlCmd::GetInfo = 0 , tmc9660::BlCmd::GetBank = 8 , tmc9660::BlCmd::SetBank = 9 , tmc9660::BlCmd::GetAddress = 10 ,
  tmc9660::BlCmd::SetAddress = 11 , tmc9660::BlCmd::Read32 = 12 , tmc9660::BlCmd::Read32Inc = 13 , tmc9660::BlCmd::Read16 = 14 ,
  tmc9660::BlCmd::Read16Inc = 15 , tmc9660::BlCmd::Read8 = 16 , tmc9660::BlCmd::Read8Inc = 17 , tmc9660::BlCmd::Write32 = 18 ,
  tmc9660::BlCmd::Write32Inc = 19 , tmc9660::BlCmd::Write16 = 20 , tmc9660::BlCmd::Write16Inc = 21 , tmc9660::BlCmd::Write8 = 22 ,
  tmc9660::BlCmd::Write8Inc = 23 , tmc9660::BlCmd::NoOp = 29 , tmc9660::BlCmd::OtpLoad = 30 , tmc9660::BlCmd::OtpBurn = 31 ,
  tmc9660::BlCmd::MemIsConfigured = 32 , tmc9660::BlCmd::MemIsConnected = 33 , tmc9660::BlCmd::FlashSendCmd = 36 , tmc9660::BlCmd::FlashEraseSector = 37 ,
  tmc9660::BlCmd::MemIsBusy = 40 , tmc9660::BlCmd::BootstrapRs485 = 255
}
 Bootloader command codes. More...
 
enum class  tmc9660::Tmcl : uint8_t {
  tmc9660::Tmcl::Mst = 3 , tmc9660::Tmcl::Sap = 5 , tmc9660::Tmcl::Gap = 6 , tmc9660::Tmcl::Stap = 7 ,
  tmc9660::Tmcl::Sgp = 9 , tmc9660::Tmcl::Ggp = 10 , tmc9660::Tmcl::Rfs = 13 , tmc9660::Tmcl::Sio = 14 ,
  tmc9660::Tmcl::Gio = 15 , tmc9660::Tmcl::Calc = 19 , tmc9660::Tmcl::Comp = 20 , tmc9660::Tmcl::Jc = 21 ,
  tmc9660::Tmcl::Ja = 22 , tmc9660::Tmcl::Csub = 23 , tmc9660::Tmcl::Rsub = 24 , tmc9660::Tmcl::Ei = 25 ,
  tmc9660::Tmcl::Di = 26 , tmc9660::Tmcl::Wait = 27 , tmc9660::Tmcl::Stop = 28 , tmc9660::Tmcl::Calcx = 33 ,
  tmc9660::Tmcl::Aap = 34 , tmc9660::Tmcl::Agp = 35 , tmc9660::Tmcl::Cle = 36 , tmc9660::Tmcl::Vect = 37 ,
  tmc9660::Tmcl::Reti = 38 , tmc9660::Tmcl::Calcvv = 40 , tmc9660::Tmcl::Calcva = 41 , tmc9660::Tmcl::Calcav = 42 ,
  tmc9660::Tmcl::Calcvx = 43 , tmc9660::Tmcl::Calcxv = 44 , tmc9660::Tmcl::Calcv = 45 , tmc9660::Tmcl::Rst = 48 ,
  tmc9660::Tmcl::Djnz = 49 , tmc9660::Tmcl::Siv = 55 , tmc9660::Tmcl::Giv = 56 , tmc9660::Tmcl::Aiv = 57 ,
  tmc9660::Tmcl::ApplStop = 128 , tmc9660::Tmcl::ApplRun = 129 , tmc9660::Tmcl::ApplStep = 130 , tmc9660::Tmcl::ApplReset = 131 ,
  tmc9660::Tmcl::DownloadStart = 132 , tmc9660::Tmcl::DownloadEnd = 133 , tmc9660::Tmcl::ReadMem = 134 , tmc9660::Tmcl::GetStatus = 135 ,
  tmc9660::Tmcl::GetVersion = 136 , tmc9660::Tmcl::FactoryDefault = 137 , tmc9660::Tmcl::Breakpoint = 141 , tmc9660::Tmcl::RamDebug = 142 ,
  tmc9660::Tmcl::GetInfo = 157 , tmc9660::Tmcl::Boot = 242
}
 TMCL operation codes (Table 18 of the parameter mode manual). More...
 
enum class  tmc9660::TmclStatus : uint8_t {
  tmc9660::TmclStatus::Ok = 100 , tmc9660::TmclStatus::CmdLoaded = 101 , tmc9660::TmclStatus::ChecksumError = 1 , tmc9660::TmclStatus::InvalidCommand = 2 ,
  tmc9660::TmclStatus::WrongType = 3 , tmc9660::TmclStatus::InvalidValue = 4 , tmc9660::TmclStatus::CmdNotAvailable = 6 , tmc9660::TmclStatus::CmdLoadError = 7 ,
  tmc9660::TmclStatus::MaxExceeded = 9 , tmc9660::TmclStatus::DownloadNotPossible = 10
}
 TMCL reply status codes (Table 19). More...
 
enum class  tmc9660::TmclSpiStatus : uint8_t { tmc9660::TmclSpiStatus::Ok = 0xFF , tmc9660::TmclSpiStatus::ChecksumError = 0x00 , tmc9660::TmclSpiStatus::FirstCommand = 0x0C , tmc9660::TmclSpiStatus::NotReady = 0xF0 }
 SPI status byte of a TMCL reply. More...
 
enum class  tmc9660::RamDebugType : uint8_t {
  tmc9660::RamDebugType::Init = 0 , tmc9660::RamDebugType::SampleCount = 1 , tmc9660::RamDebugType::Prescaler = 3 , tmc9660::RamDebugType::SetChannel = 4 ,
  tmc9660::RamDebugType::SetTriggerChannel = 5 , tmc9660::RamDebugType::TriggerMaskShift = 6 , tmc9660::RamDebugType::EnableTrigger = 7 , tmc9660::RamDebugType::GetState = 8 ,
  tmc9660::RamDebugType::ReadSample = 9 , tmc9660::RamDebugType::GetInfo = 10 , tmc9660::RamDebugType::GetChannelType = 11 , tmc9660::RamDebugType::GetChannelAddress = 12 ,
  tmc9660::RamDebugType::SetPretrigger = 13 , tmc9660::RamDebugType::GetPretrigger = 14
}
 RAMDebug types (Table 16). More...
 
enum class  tmc9660::ReferenceSearch : uint8_t { tmc9660::ReferenceSearch::Start = 0 , tmc9660::ReferenceSearch::Stop = 1 , tmc9660::ReferenceSearch::Status = 2 }
 RFS sub-commands. More...
 
enum class  tmc9660::TmclLayout : uint8_t { tmc9660::TmclLayout::Auto = 0 , tmc9660::TmclLayout::MotorHigh , tmc9660::TmclLayout::TypeHigh }
 Where the type and the motor or bank bytes of a TMCL frame put their bits (ambiguity A2). More...
 

Functions

constexpr const char * tmc9660::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr Error tmc9660::Validate (const Config &c) noexcept
 Check a Config without touching the bus.
 
void tmc9660::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 * tmc9660::GetDriverVersion () noexcept
 
constexpr uint32_t tmc9660::GetDriverVersionMajor () noexcept
 
constexpr uint32_t tmc9660::GetDriverVersionMinor () noexcept
 
constexpr uint32_t tmc9660::GetDriverVersionPatch () noexcept
 

Variables

constexpr int32_t tmc9660::kSystemOff = 0
 Value of COMMUTATION_MODE (parameter 4) that leaves the gate driver off.
 
constexpr int32_t tmc9660::kCommutationModeMax = 8
 The largest valid COMMUTATION_MODE value.
 
constexpr uint32_t tmc9660::kChipId = 0x544D0001U
 The chip ID every TMC9660 reports (bootloader CHIP_TYPE, register MCC_INFO_CHIP).
 
constexpr uint32_t tmc9660::kMotorControlClockHz = 40'000'000U
 The system clock motor control needs, in Hz.
 
constexpr uint32_t tmc9660::kBootMagic = 0xA3B4C5D6U
 The magic value of the Boot command.
 

Detailed Description

Public types of the TMC9660 driver: errors, Result<T>, the protocol enumerations, Config and its model knobs.

Everything here is plain data with no platform dependency, so handlers, tests and tools can include it without the driver template. The configuration defaults are the values the datasheet gives (device address 1, host address 255 for the bootloader, 2 for TMCL).