TMC9660 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
tmc9660.hpp
Go to the documentation of this file.
1
12#ifndef TMC9660_HPP
13#define TMC9660_HPP
14
15#include <algorithm>
16#include <array>
17#include <bit>
18#include <concepts>
19#include <cstddef>
20#include <cstdint>
21#include <limits>
22#include <span>
23#include <type_traits>
24#include <utility>
25
27#include "tmc9660_detail.hpp"
28#include "tmc9660_frames.hpp"
29#include "tmc9660_globals.hpp"
30#include "tmc9660_params.hpp"
31#include "tmc9660_registers.hpp"
33#include "tmc9660_types.hpp"
35#include "tmc9660_version.h"
36
37namespace tmc9660 {
38
39namespace detail {
40
41// Optional hooks: a `Declares*` concept only tests the name, the `Has*` concept the exact
42// signature, `noexcept` and the result type; the driver rejects a hook that is declared but does
43// not match (KB-CPP20-007).
44
46template <typename Port>
47concept DeclaresGpioSet =
48 requires(Port& port) { port.GpioSet(CtrlPin::Reset, GpioSignal::ACTIVE); };
49
51template <typename Port>
52concept HasGpioSet =
53 requires { ExactHook<Port, bool(CtrlPin, GpioSignal) noexcept>::Take(&Port::GpioSet); };
54
56template <typename Port>
57concept DeclaresGpioGet =
58 requires(Port& port, bool& level) { port.GpioGet(CtrlPin::Faultn, level); };
59
61template <typename Port>
62concept HasGpioGet =
63 requires { ExactHook<Port, bool(CtrlPin, bool&) noexcept>::Take(&Port::GpioGet); };
64
66template <typename Port>
67concept DeclaresDelayUs = requires(Port& port) { port.DelayUs(static_cast<uint32_t>(1)); };
68
71template <typename Port>
72concept HasDelayUs = requires { ExactHook<Port, void(uint32_t) noexcept>::Take(&Port::DelayUs); };
73
75template <typename Port>
76concept DeclaresLog = requires(Port& port) { port.Log(LogLevel::Info, ""); };
77
79template <typename Port>
80concept HasLog =
81 requires { ExactHook<Port, void(LogLevel, const char*) noexcept>::Take(&Port::Log); };
82
85template <typename Port>
86void DelayUs(Port& port, uint32_t us) noexcept {
87 if constexpr (HasDelayUs<Port>) {
88 port.DelayUs(us);
89 } else {
90 static_assert(kAlwaysFalse<Port>,
91 "tmc9660: the port must implement `void DelayUs(uint32_t us) noexcept`");
92 }
93}
94
96template <typename Port>
97void Log(Port& port, LogLevel level, const char* message) noexcept {
98 if constexpr (HasLog<Port>) {
99 port.Log(level, message);
100 } else {
101 // No Log() hook: every parameter is used in this branch too (MISRA C++:2023 Rule 0.2.2).
102 static_cast<void>(port);
103 static_cast<void>(level);
104 static_cast<void>(message);
105 }
106}
107
108} // namespace detail
109
113 false};
114};
115
117enum class MemQuery : uint8_t {
118 Configured = 0,
119 Connected,
120 Busy,
121};
122
124enum class PowerDownTime : uint8_t {
125 Ms250 = 0,
126 Ms500,
127 S1,
128 S2,
129 S4,
130 S8,
131 S16,
132 S32,
133};
134
138 uint16_t type{0};
139 uint8_t motor{0};
140 int32_t value{0};
141};
142
145 uint32_t pwm_enable{
146 0x0000'0F00U};
147 uint32_t gdrv_cfg{0};
148 uint32_t gdrv_timing{0};
149 uint32_t gdrv_bbm{0};
150 uint32_t gdrv_hw{
151 0x0300'0FFFU};
152 uint8_t chop_run{
153 7};
155 uint32_t gdrv_prot{0};
159 uint32_t gdrv_ocp_uvw{0};
160 uint32_t gdrv_ocp_y2{0};
161 uint32_t status_en{
162 0xEFFF'FFFFU};
163 uint32_t prot_en{0xAFFF'FFFFU};
165};
166
169template <typename Port>
171
173struct LastReply {
174 uint8_t status{0};
175 uint8_t op{0};
176 uint32_t value{0};
177};
178
207template <AnyPort Port>
208class TMC9660 {
209 static_assert(!detail::DeclaresGpioSet<Port> || detail::HasGpioSet<Port>,
210 "tmc9660: the optional GpioSet hook must be `bool GpioSet(CtrlPin, GpioSignal) "
211 "noexcept`, so that a "
212 "failed pin write is reported");
213 static_assert(
214 !detail::DeclaresGpioGet<Port> || detail::HasGpioGet<Port>,
215 "tmc9660: the optional GpioGet hook must be `bool GpioGet(CtrlPin, bool& high) noexcept`");
216 static_assert(
217 !detail::DeclaresDelayUs<Port> || detail::HasDelayUs<Port>,
218 "tmc9660: the DelayUs hook must be `void DelayUs(uint32_t us) noexcept`, so that no wait is "
219 "truncated");
220 static_assert(
221 !detail::DeclaresLog<Port> || detail::HasLog<Port>,
222 "tmc9660: the optional Log hook must be `void Log(LogLevel, const char* message) noexcept`");
223
224public:
230 explicit TMC9660(Port& port, const Config& config = {}) noexcept
231 : port_(port), config_(config), mode_(config.mode), bl_app_mode_(config.mode) {}
232
234 TMC9660(const TMC9660&) = delete;
236 TMC9660& operator=(const TMC9660&) = delete;
237
240
249
258 Result<void> Deinitialize() noexcept;
259
262 [[nodiscard]] bool IsInitialized() const noexcept {
263 return initialized_;
264 }
270 [[nodiscard]] Mode GetMode() const noexcept {
271 return mode_;
272 }
275 [[nodiscard]] uint8_t LastStatus() const noexcept {
276 return last_status_;
277 }
281 [[nodiscard]] LastReply GetLastReply() const noexcept {
282 return {.status = last_status_tmcl_, .op = last_op_, .value = last_value_};
283 }
285 [[nodiscard]] const Config& GetConfig() const noexcept {
286 return config_;
287 }
288
297
299
302
322 Result<void> DisableDrive() noexcept;
323
336 Result<void> EnableDrive(uint8_t commutation_mode) noexcept;
337
343 Result<void> MotorStop() noexcept;
344
346
349
351 Result<uint32_t> BlGetInfo(BlInfo info) noexcept;
357 Result<uint32_t> BlRead32(Bank bank, uint32_t address) noexcept;
365 Result<void> BlWrite32(Bank bank, uint32_t address, uint32_t value) noexcept;
384 Result<void> BlWriteConfig(const BootConfig& config, const BlWriteOptions& options = {}) noexcept;
407 Result<void> BlEraseFlashSector(uint32_t address, bool allow_partition_table = false) noexcept;
412 Result<void> BlOtpLoad() noexcept;
413
415
418
423 Result<uint32_t> GetChipId() noexcept;
428 Result<uint32_t> GetVersion() noexcept;
435 Result<int64_t> GetParam(Param param, uint8_t motor = 0) noexcept;
444 Result<uint32_t> ReadRawParam(uint16_t type, uint8_t motor = 0) noexcept;
455 Result<void> SetParam(Param param, int64_t value, uint8_t motor = 0) noexcept;
462 Result<void> ClearFlags(Param flags, uint32_t mask) noexcept;
467 Result<void> StoreParams() noexcept;
474 Result<void> FactoryDefault(bool confirm) noexcept;
476 Result<int64_t> GetGlobal(GlobalBank bank, uint16_t number) noexcept;
484 Result<void> SetGlobal(GlobalBank bank, uint16_t number, int64_t value) noexcept;
490 Result<void> SetTargetTorque(int32_t value) noexcept {
491 return SetParam(Param::TARGET_TORQUE, value);
492 }
498 Result<void> SetTargetVelocity(int32_t value) noexcept {
499 return SetParam(Param::TARGET_VELOCITY, value);
500 }
506 Result<void> SetTargetPosition(int32_t value) noexcept {
507 return SetParam(Param::TARGET_POSITION, value);
508 }
518 Result<void> SetIo(uint8_t pin, bool high) noexcept;
521 Result<int32_t> GetIo(uint8_t pin, bool analog) noexcept;
529 Result<int32_t> RamDebug(RamDebugType type, uint8_t motor_bank, int32_t value) noexcept;
539 Result<void> ScriptRun(bool from_address, uint32_t address) noexcept;
549 Result<void> ScriptStep() noexcept;
554 Result<void> ScriptReset() noexcept;
559 Result<int32_t> ScriptStatus() noexcept;
565 Result<uint32_t> ScriptReadMem(uint32_t address) noexcept;
576 Result<void> ScriptDownload(std::span<const TmclInstruction> script) noexcept;
583 Result<void> PowerDown(PowerDownTime time) noexcept;
590 Result<void> ReturnToBootloader() noexcept;
596 Result<void> DisableSpi1Slave() noexcept;
597
599
602
608 Result<uint32_t> ReadReg(RegAddr addr) noexcept;
617 Result<void> WriteReg(RegAddr addr, uint32_t value) noexcept;
626 Result<void> UpdateReg(RegAddr addr, uint32_t mask, uint32_t value) noexcept;
633 template <typename F>
634 Result<uint32_t> ReadField(RegAddr addr) noexcept {
635 const Result<uint32_t> r = ReadReg(addr);
636 return r.ok() ? Result<uint32_t>::Success(F::Extract(r.value)) : r;
637 }
645 template <typename F>
646 Result<void> WriteField(RegAddr addr, uint32_t value) noexcept {
647 if (value > F::kMax) {
649 }
650 return UpdateReg(addr, F::kMask, F::Insert(0U, value));
651 }
660 Result<uint32_t> RegRamDebug(uint8_t subcommand, uint8_t index, bool write,
661 uint32_t value) noexcept;
674
676
677private:
678 static constexpr bool kSpi = SpiPort<Port>;
679
680 // Transports.
681 Result<detail::BlReply> blExchange(BlCmd cmd, uint32_t value, bool write) noexcept;
682 Result<detail::BlReply> blSpiTransfer(BlCmd cmd, uint32_t value) noexcept;
683 Error blTransport(BlCmd cmd, uint32_t value, bool write, detail::BlReply& reply) noexcept;
684 Error tmclTransport(const detail::TmclCommand& c, bool probe, detail::TmclReply& reply) noexcept;
685 Error blExchangeSpi(BlCmd cmd, uint32_t value, bool write, detail::BlReply& reply) noexcept;
686 Error blExchangeUart(BlCmd cmd, uint32_t value, detail::BlReply& reply) noexcept;
687 Error tmclRawSpi(const detail::TmclCommand& c, bool probe, detail::TmclReply& reply) noexcept;
688 Error tmclRawUart(const detail::TmclCommand& c, detail::TmclReply& reply) noexcept;
689 Error tmclSpiFetch(detail::TmclReply& reply) noexcept;
690 Error spiFirstCommand() noexcept;
691 Result<uint32_t> regSpiExchange(uint8_t block, uint16_t offset, bool write, uint32_t data,
692 bool probe) noexcept;
693 Result<uint32_t> regUartExchange(uint8_t command, uint8_t block, uint16_t offset, uint32_t data,
694 bool probe) noexcept;
695 Error regSpiDatagram(const std::array<uint8_t, detail::kRegSpiLen>& req,
696 detail::RegSpiReply& out) noexcept;
697 Result<detail::TmclReply> tmcl(uint8_t op, uint16_t type, uint8_t motor, uint32_t value,
698 bool write, bool accept_loaded) noexcept;
699 Result<detail::TmclReply> tmclRaw(const detail::TmclCommand& c, bool probe,
700 bool accept_loaded) noexcept;
701 Result<uint32_t> regExchange(bool write, RegAddr addr, uint32_t data) noexcept;
702 Result<uint32_t> regExchangeRaw(uint8_t command, uint8_t block, uint16_t offset, bool write,
703 uint32_t data, bool probe) noexcept;
704 Error checkRegSpiReply(const detail::RegSpiReply& r) noexcept;
705 Error spiTransfer(std::size_t len) noexcept;
706 Error uartExchange(std::size_t tx_len, std::size_t rx_len) noexcept;
707 Error mapBusStatus(BusStatus s) const noexcept;
708
709 // Helpers.
710 Result<void> fail(Error e, const char* message) noexcept;
711 Error need(Mode m) const noexcept;
712 void markReset() noexcept;
713 Result<void> verifyIdentity() noexcept;
714 Result<void> waitForIdentity() noexcept;
715 Result<void> regBaseline() noexcept;
716 Result<void> setDrvEn(GpioSignal s) noexcept;
717 Result<void> blSetup(Bank bank, uint32_t address) noexcept;
718 Result<uint32_t> blReadWord(uint32_t address) noexcept;
719 Result<void> blWriteWord(uint32_t address, uint32_t value) noexcept;
720 Result<void> disableDriveParameter() noexcept;
721 Result<void> startParameterMode() noexcept;
722 Result<void> verifyTmclLayout() noexcept;
723 Result<bool> probeTmclLayout(TmclLayout layout) noexcept;
724 Error uartResync() noexcept;
725 Error faultnGuard() noexcept;
726 Result<void> blSetBank(Bank bank) noexcept;
727 Result<void> blLiveness(uint32_t value) noexcept;
728 Result<void> disableDriveRegister() noexcept;
729 Result<void> idleSafe(const detail::TmclCommand& stop) noexcept;
730 Result<void> startPreconditions() noexcept;
731 Result<void> hardwareReset() noexcept;
732 Result<void> blWaitPll(const BootConfig& config, std::size_t index) noexcept;
733 Result<void> blWriteChanged(const BootConfig& old, const BootConfig& config) noexcept;
734 Result<void> blVerifyConfig(const BootConfig& config, bool start) noexcept;
735 Result<void> blFollowStart(const BootConfig& config) noexcept;
736 Result<void> blStartWrite(const BootConfig& config) noexcept;
737 void blStopUnknownApplication() noexcept;
738 Result<void> blWriteBootMode(const BootConfig& config, bool start) noexcept;
739 Result<void> regPut(RegAddr addr, uint32_t value) noexcept;
740 Result<bool> gdrvLatched() noexcept;
741 Result<void> gdrvSetup(const GateDriverRegConfig& config) noexcept;
742 Result<void> gdrvEnergise(const GateDriverRegConfig& config) noexcept;
743 Result<void> gdrvProtect(const GateDriverRegConfig& config) noexcept;
744 Result<void> armCanary() noexcept;
745 Result<int64_t> readParamRaw(Param p, uint8_t motor) noexcept;
746 Error energisingGuard(RegAddr addr, uint32_t value) const noexcept;
747
748 Port& port_;
749 Config config_;
750 Mode mode_{Mode::Bootloader};
751 bool initialized_{false};
752 bool canary_armed_{false};
753 bool reg_started_{false};
754 bool defer_resync_{false};
755 bool uart_dirty_{false};
756 bool watchdog_at_start_{false};
758 Mode bl_app_mode_{
761 Bank bl_bank_{Bank::Config};
762 uint8_t reg_counter_{0};
763 uint8_t last_status_{0};
764 uint8_t last_status_tmcl_{0};
765 uint8_t last_op_{0};
766 uint32_t last_value_{0};
767 std::array<uint8_t, 9> tx_{};
768 std::array<uint8_t, 9> rx_{};
769};
770
771} // namespace tmc9660
772
773// codeql::misra_deviation_next_line(MD-CPP-009)
774#include "../src/tmc9660.ipp" // IWYU pragma: export
775
776#endif // TMC9660_HPP
The 64-byte configuration memory of the bootloader, as 16 little-endian 32-bit words.
Definition tmc9660_bootconfig.hpp:175
Driver for one TMC9660 on a platform port.
Definition tmc9660.hpp:208
Result< void > ScriptStop() noexcept
ApplStop.
LastReply GetLastReply() const noexcept
The last parameter-mode reply, as the chip sent it (no bus traffic).
Definition tmc9660.hpp:281
Result< uint32_t > GetChipId() noexcept
GetInfo type 0: the chip ID.
Result< void > Deinitialize() noexcept
Switch the gate driver off and mark the driver uninitialised. The chip is left as it is.
Result< void > BlOtpLoad() noexcept
OTP_LOAD: load the OTP configuration. (OTP_BURN is not exposed: it is permanent.)
Mode GetMode() const noexcept
Definition tmc9660.hpp:270
Result< void > SetTargetTorque(int32_t value) noexcept
SetParam of TARGET_TORQUE.
Definition tmc9660.hpp:490
Result< void > GateDriverStart(const GateDriverRegConfig &config) noexcept
Energise the gate driver in register mode, in the order of the register manual, with the guards compl...
Result< void > PowerDown(PowerDownTime time) noexcept
Put the chip into the power-down state for a time (global parameter 11). The gate driver is switched ...
Result< void > DisableSpi1Slave() noexcept
Erratum 5 workaround: disable the SPI1 slave (op 146, type 4, bank 9, value 0). Only call it when the...
Result< void > SetParam(Param param, int64_t value, uint8_t motor=0) noexcept
SAP: write an axis parameter, after checking access, range and coded set against Table 57.
Result< void > Service() noexcept
Poll the things that need no request: FAULTN when the port reads it, and in parameter mode a read of ...
Result< void > StoreParams() noexcept
STAP: store all storable parameters to the external memory.
Result< void > ReturnToBootloader() noexcept
Return to the bootloader (Boot command). The gate driver is switched off and COMMUTATION_MODE is read...
Result< uint32_t > ReadReg(RegAddr addr) noexcept
Read a register of the register map.
Result< int64_t > GetParam(Param param, uint8_t motor=0) noexcept
GAP: read an axis parameter.
Result< uint32_t > BlGetInfo(BlInfo info) noexcept
GET_INFO.
Result< BootConfig > BlReadConfig() noexcept
Read the 64-byte configuration memory.
Result< void > SetIo(uint8_t pin, bool high) noexcept
SIO: set a digital output.
Result< void > ScriptStep() noexcept
ApplStep.
Result< void > EnsureInitialized() noexcept
Start the driver, once: bus up, optional hardware reset, identity check in Config::mode.
bool IsInitialized() const noexcept
Definition tmc9660.hpp:262
Result< uint32_t > ReadField(RegAddr addr) noexcept
The value of one field.
Definition tmc9660.hpp:634
Result< void > WriteField(RegAddr addr, uint32_t value) noexcept
Set one field.
Definition tmc9660.hpp:646
Result< uint32_t > ReadRawParam(uint16_t type, uint8_t motor=0) noexcept
Single-shot raw read: one GAP with a parameter number taken as given (not looked up in the table,...
Result< void > EnableDrive(uint8_t commutation_mode) noexcept
Energise the gate driver in parameter mode, after the start-up guards.
TMC9660(Port &port, const Config &config={}) noexcept
Bind the driver to a port and store the configuration. No I/O, cannot fail.
Definition tmc9660.hpp:230
Result< void > MotorStop() noexcept
Stop the motor (MST). Parameter mode. Sent before a UART resync, and once more (after the resync) whe...
Result< int64_t > GetGlobal(GlobalBank bank, uint16_t number) noexcept
GGP.
uint8_t LastStatus() const noexcept
Definition tmc9660.hpp:275
Result< void > BlEraseFlashSector(uint32_t address, bool allow_partition_table=false) noexcept
Erase one 4 KiB sector of the SPI flash (SECTOR_ERASE 0x20). Refused unless the flash is configured a...
Result< int32_t > GetIo(uint8_t pin, bool analog) noexcept
GIO.
Result< bool > BlMemoryStatus(Bank bank, MemQuery query) noexcept
Ask about an external memory.
Result< uint32_t > RegRamDebug(uint8_t subcommand, uint8_t index, bool write, uint32_t value) noexcept
RAMDebug access in register mode.
Result< void > ScriptReset() noexcept
ApplReset.
Result< void > DisableDrive() noexcept
Switch the gate driver off. Never refused: whatever the mode, state or earlier error,...
TMC9660(const TMC9660 &)=delete
One driver object per chip.
Result< int32_t > ScriptStatus() noexcept
GetStatus of the script.
Result< void > UpdateReg(RegAddr addr, uint32_t mask, uint32_t value) noexcept
Read-modify-write of the bits in mask; the mask must lie within the register's writable bits.
const Config & GetConfig() const noexcept
Definition tmc9660.hpp:285
Result< void > SetTargetPosition(int32_t value) noexcept
SetParam of TARGET_POSITION.
Definition tmc9660.hpp:506
Result< void > ScriptDownload(std::span< const TmclInstruction > script) noexcept
Download a script: DownloadStart, every instruction (each acknowledged with CMD_LOADED),...
Result< void > BlWriteConfig(const BootConfig &config, const BlWriteOptions &options={}) noexcept
Write a configuration and verify it.
Result< void > SetTargetVelocity(int32_t value) noexcept
SetParam of TARGET_VELOCITY.
Definition tmc9660.hpp:498
Result< int32_t > RamDebug(RamDebugType type, uint8_t motor_bank, int32_t value) noexcept
RAMDebug command.
Result< int32_t > ReferenceSearchCommand(ReferenceSearch action) noexcept
RFS.
Result< void > WriteReg(RegAddr addr, uint32_t value) noexcept
Write a register. Refused (nothing sent): read-only registers (InvalidArgument) and any write that se...
Result< uint32_t > ScriptReadMem(uint32_t address) noexcept
ReadMem: the script instruction word at address.
TMC9660 & operator=(const TMC9660 &)=delete
One driver object per chip.
Result< void > ScriptRun(bool from_address, uint32_t address) noexcept
ApplRun: run the script. The chip executes what is in its script memory, a script stored earlier or o...
Result< void > ClearFlags(Param flags, uint32_t mask) noexcept
SAP of a flag word: write 1 to the bits to clear.
Result< uint32_t > GetVersion() noexcept
GetInfo type 1: the version word.
Result< void > BlWrite32(Bank bank, uint32_t address, uint32_t value) noexcept
Write a 32-bit word of an external memory bank (SPI flash or I2C EEPROM).
Result< uint32_t > BlRead32(Bank bank, uint32_t address) noexcept
Read a 32-bit word of a bootloader memory bank.
Result< void > SetGlobal(GlobalBank bank, uint16_t number, int64_t value) noexcept
SGP, checked against Tables 61 to 63.
Result< void > BlStartApplication(BootMode target) noexcept
Read the configuration, set BOOT_MODE and START_MOTOR_CTRL and write it (BlWriteConfig).
Satisfied by a port that derives from exactly one of SpiInterface and UartInterface.
Definition tmc9660.hpp:170
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exac...
Definition tmc9660_spi_interface.hpp:105
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exa...
Definition tmc9660_uart_interface.hpp:82
BlCmd
Bootloader command codes.
Definition tmc9660_types.hpp:269
RamDebugType
RAMDebug types (Table 16).
Definition tmc9660_types.hpp:375
CtrlPin
The control pins of the chip that the optional GpioSet() and GpioGet() hooks may drive.
Definition tmc9660_types.hpp:188
LogLevel
Severity passed to the optional Log() hook.
Definition tmc9660_types.hpp:172
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition tmc9660_types.hpp:35
BootMode
BOOT_MODE of the boot configuration (offset 8, bits 0-1).
Definition tmc9660_types.hpp:218
TmclLayout
Where the type and the motor or bank bytes of a TMCL frame put their bits (ambiguity A2).
Definition tmc9660_types.hpp:428
ReferenceSearch
RFS sub-commands.
Definition tmc9660_types.hpp:393
BlInfo
GET_INFO selectors of the bootloader.
Definition tmc9660_types.hpp:235
Mode
The protocol the chip speaks on its host interface.
Definition tmc9660_types.hpp:202
BusStatus
What a UART port reports for one exchange.
Definition tmc9660_types.hpp:180
Tmcl
TMCL operation codes (Table 18 of the parameter mode manual).
Definition tmc9660_types.hpp:299
Bank
External memory banks of the bootloader (SET_BANK).
Definition tmc9660_types.hpp:227
GpioSignal
Logical level of a control pin; the port maps it to the physical polarity.
Definition tmc9660_types.hpp:196
@ Reset
RSTN, active low on the package pin; ACTIVE holds the chip in reset.
@ Faultn
FAULTN, an input; GpioGet reports the pin level (low: asserted).
@ Info
Lifecycle events: initialised, mode changes.
@ InvalidArgument
An argument or a Config field is out of range; nothing was sent.
@ MotorHigh
Byte 3 (SPI byte 2): motor << 4 | type[11:8]; the byte before holds type[7:0].
@ Bootloader
The bootloader: GET_INFO, memory access, configuration.
@ Stop
Stop the script.
@ FactoryDefault
Restore the factory defaults.
@ Config
The 64-byte configuration memory at 0x00020000.
@ ACTIVE
The pin function is asserted.
The TMC9660 driver: everything it declares lives here; internals in detail.
Definition tmc9660.hpp:37
Param
The axis parameters, by name; the value is the number sent as the TMCL type.
Definition tmc9660_params.hpp:40
@ TARGET_VELOCITY
Target velocity value.
@ TARGET_POSITION
Target position value.
@ TARGET_TORQUE
Target torque value.
MemQuery
Queries about the external memory of the bootloader.
Definition tmc9660.hpp:117
@ Connected
MEM_IS_CONNECTED.
@ Configured
MEM_IS_CONFIGURED.
@ Busy
MEM_IS_BUSY.
PowerDownTime
Power-down durations of TMC9660::PowerDown() (global parameter 11).
Definition tmc9660.hpp:124
GlobalBank
Banks of global parameters.
Definition tmc9660_globals.hpp:28
Options of TMC9660::BlWriteConfig().
Definition tmc9660.hpp:111
bool allow_ldo_change
Allow a change of the LDO word: it changes VEXT1 and VEXT2 at once.
Definition tmc9660.hpp:112
Configuration of the driver. The defaults are the chip's.
Definition tmc9660_types.hpp:461
Gate-driver start-up of register mode: the words of the manual's start sequence.
Definition tmc9660.hpp:144
uint32_t gdrv_hw
MCC_GDRV_HW: bias, charge pump, comparators and bridge enables.
Definition tmc9660.hpp:150
uint32_t prot_en
MCC_GDRV_PROT_EN after the start: protection handling (all on). 0 runs the stage unprotected: say so ...
Definition tmc9660.hpp:163
uint32_t gdrv_ocp_uvw
Definition tmc9660.hpp:159
uint32_t gdrv_prot
Definition tmc9660.hpp:155
uint32_t status_en
MCC_GDRV_STATUS_EN after the start: fault reporting (reset value: all on).
Definition tmc9660.hpp:161
uint32_t gdrv_ocp_y2
MCC_GDRV_OCP_Y2, as gdrv_ocp_uvw.
Definition tmc9660.hpp:160
uint32_t pwm_enable
MCC_PWM_CONFIG written first: ENABLE_UX1/VX2/WY1/Y2 and CHOP 1 are added.
Definition tmc9660.hpp:145
uint32_t gdrv_bbm
MCC_GDRV_BBM: break-before-make times.
Definition tmc9660.hpp:149
uint32_t gdrv_timing
MCC_GDRV_TIMING.
Definition tmc9660.hpp:148
uint32_t gdrv_cfg
MCC_GDRV_CFG: gate current and adaptive mode.
Definition tmc9660.hpp:147
uint8_t chop_run
Definition tmc9660.hpp:152
The last parameter-mode reply as received (see TMC9660::GetLastReply()).
Definition tmc9660.hpp:173
uint8_t op
Echoed command number.
Definition tmc9660.hpp:175
uint8_t status
TMCL status code.
Definition tmc9660.hpp:174
uint32_t value
Reply value.
Definition tmc9660.hpp:176
Address of a register: its block and its offset in the block.
Definition tmc9660_registers.hpp:28
The value of a call, or why there is none.
Definition tmc9660_types.hpp:112
constexpr bool ok() const noexcept
Definition tmc9660_types.hpp:117
static constexpr Result Success(T v) noexcept
A successful result.
Definition tmc9660_types.hpp:130
T value
The value; T{} when the call failed.
Definition tmc9660_types.hpp:113
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition tmc9660_types.hpp:138
One instruction of a script download.
Definition tmc9660.hpp:136
uint8_t motor
Motor or bank (4 bits).
Definition tmc9660.hpp:139
int32_t value
Value.
Definition tmc9660.hpp:140
uint16_t type
Type or parameter number (12 bits).
Definition tmc9660.hpp:138
Tmcl op
Command number.
Definition tmc9660.hpp:137
The bootloader's configuration memory (64 bytes, datasheet "Bootloader Configuration") as a typed Boo...
Compile-time helpers of the TMC9660 driver: byte copy, exact hook matching, typed register fields and...
Pure frame encoders and decoders of the three TMC9660 protocols: bootloader, parameter mode (TMCL) an...
The global parameters of parameter mode (SGP, GGP): banks 0, 2 and 3 (Tables 61 to 63).
The axis parameters of parameter mode (SAP, GAP, STAP, AAP): number, range, default and access of eve...
The registers of register mode: block, offset, reset value and access masks of every register of the ...
The SPI port of the TMC9660 driver: the CRTP base, the SpiPort concept and the bus requirements.
Public types of the TMC9660 driver: errors, Result<T>, the protocol enumerations, Config and its mode...
The UART port of the TMC9660 driver: the CRTP base, the UartPort concept and the bus requirements.