TMC9660 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
tmc9660_globals.hpp
Go to the documentation of this file.
1
6#ifndef TMC9660_GLOBALS_HPP
7#define TMC9660_GLOBALS_HPP
8
9#include <array>
10#include <cstddef>
11#include <cstdint>
12
13#include "tmc9660_params.hpp"
14
15namespace tmc9660 {
16
18struct GlobalInfo {
19 uint8_t bank;
20 uint16_t number;
22 int64_t min;
23 int64_t max;
24 bool odd_only;
25};
26
28enum class GlobalBank : uint8_t {
29 System = 0,
30 UserVars = 2,
31 Interrupts = 3
32};
33
35namespace global0 {
36inline constexpr uint16_t SERIAL_ADDRESS = 1;
37inline constexpr uint16_t SERIAL_HOST_ADDRESS = 2;
38inline constexpr uint16_t HEARTBEAT_MONITORING_CONFIG = 3;
39inline constexpr uint16_t HEARTBEAT_MONITORING_TIMEOUT = 4;
40inline constexpr uint16_t IO_DIRECTION_MASK = 5;
41inline constexpr uint16_t IO_INPUT_PULLUP_PULLDOWN_ENABLE_MASK = 6;
42inline constexpr uint16_t IO_INPUT_PULLUP_PULLDOWN_DIRECTION_MASK = 7;
43inline constexpr uint16_t WAKE_PIN_CONTROL_ENABLE = 10;
44inline constexpr uint16_t GO_TO_TIMEOUT_POWER_DOWN_STATE =
45 11;
46inline constexpr uint16_t MAIN_LOOPS = 12;
47inline constexpr uint16_t TORQUE_LOOPS = 13;
48inline constexpr uint16_t VELOCITY_LOOPS = 14;
49inline constexpr uint16_t AUTO_START_ENABLE = 77;
50inline constexpr uint16_t CLEAR_USER_VARIABLES = 85;
51} // namespace global0
52
53namespace detail {
54
56constexpr std::array<GlobalInfo, 55> MakeGlobals() noexcept {
57 std::array<GlobalInfo, 55> t{};
58 std::size_t n = 0U;
59 const auto add = [&t, &n](uint8_t bank, uint16_t number, Access access, int64_t lo, int64_t hi,
60 bool odd) noexcept {
61 t[n++] = GlobalInfo{
62 .bank = bank, .number = number, .access = access, .min = lo, .max = hi, .odd_only = odd};
63 };
64 add(0, 1, Access::ReadWriteStored, 1, 255, true);
65 add(0, 2, Access::ReadWriteStored, 1, 255, false);
66 add(0, 3, Access::ReadWriteStored, 0, 3, false);
67 add(0, 4, Access::ReadWriteStored, 1, 4294967295LL, false);
68 add(0, 5, Access::ReadWriteStored, 0, 524287, false);
69 add(0, 6, Access::ReadWriteStored, 0, 524287, false);
70 add(0, 7, Access::ReadWriteStored, 0, 524287, false);
71 add(0, 10, Access::ReadWriteStored, 0, 1, false);
72 add(0, 11, Access::WriteOnly, 0, 7, false);
73 add(0, 12, Access::ReadOnly, 0, 4294967295LL, false);
74 add(0, 13, Access::ReadOnly, 0, 4294967295LL, false);
75 add(0, 14, Access::ReadOnly, 0, 4294967295LL, false);
76 add(0, 77, Access::ReadWriteStored, 0, 1, false);
77 add(0, 85, Access::ReadWriteStored, 0, 1, false);
78 for (uint16_t i = 0U; i < 16U; ++i) {
79 add(2, i, Access::ReadWriteStored, -2147483648LL, 2147483647LL, false);
80 }
81 for (uint16_t i = 0U; i < 3U; ++i) {
82 add(3, i, Access::ReadWrite, 0, 2147483647LL, false);
83 }
84 for (uint16_t i = 10U; i < 32U; ++i) {
85 add(3, i, Access::ReadWrite, 0, 3, false);
86 }
87 return t;
88}
89
90} // namespace detail
91
93inline constexpr std::array<GlobalInfo, 55> kGlobals = detail::MakeGlobals();
94
101[[nodiscard]] constexpr const GlobalInfo* FindGlobal(uint8_t bank, uint32_t number) noexcept {
102 for (const GlobalInfo& g : kGlobals) {
103 if ((g.bank == bank) && (g.number == number)) {
104 return &g;
105 }
106 }
107 return nullptr;
108}
109
110} // namespace tmc9660
111
112#endif // TMC9660_GLOBALS_HPP
constexpr uint16_t IO_DIRECTION_MASK
GPIO direction mask.
Definition tmc9660_globals.hpp:40
constexpr uint16_t AUTO_START_ENABLE
Start the script after power-up.
Definition tmc9660_globals.hpp:49
constexpr uint16_t CLEAR_USER_VARIABLES
Clear the user variables at start-up.
Definition tmc9660_globals.hpp:50
constexpr uint16_t IO_INPUT_PULLUP_PULLDOWN_DIRECTION_MASK
Pull direction mask.
Definition tmc9660_globals.hpp:42
constexpr uint16_t WAKE_PIN_CONTROL_ENABLE
Enable the WAKE pin function.
Definition tmc9660_globals.hpp:43
constexpr uint16_t HEARTBEAT_MONITORING_TIMEOUT
Timeout in ms.
Definition tmc9660_globals.hpp:39
constexpr uint16_t VELOCITY_LOOPS
Read only: velocity loops per second.
Definition tmc9660_globals.hpp:48
constexpr uint16_t SERIAL_ADDRESS
Module address, odd values only.
Definition tmc9660_globals.hpp:36
constexpr uint16_t IO_INPUT_PULLUP_PULLDOWN_ENABLE_MASK
Pull resistor enable mask.
Definition tmc9660_globals.hpp:41
constexpr uint16_t TORQUE_LOOPS
Read only: torque loops per second.
Definition tmc9660_globals.hpp:47
constexpr uint16_t SERIAL_HOST_ADDRESS
Host address.
Definition tmc9660_globals.hpp:37
constexpr uint16_t GO_TO_TIMEOUT_POWER_DOWN_STATE
Write only: power down for 250 ms to 32 s.
Definition tmc9660_globals.hpp:44
constexpr uint16_t HEARTBEAT_MONITORING_CONFIG
0 off, 1 UART, 2 SPI, 3 both.
Definition tmc9660_globals.hpp:38
constexpr uint16_t MAIN_LOOPS
Read only: main loops per second.
Definition tmc9660_globals.hpp:46
The TMC9660 driver: everything it declares lives here; internals in detail.
Definition tmc9660.hpp:37
constexpr std::array< GlobalInfo, 55 > kGlobals
Tables 61 to 63, sorted by bank and number.
Definition tmc9660_globals.hpp:93
constexpr const GlobalInfo * FindGlobal(uint8_t bank, uint32_t number) noexcept
The row of a global parameter.
Definition tmc9660_globals.hpp:101
Access
Access class of a parameter (the R/W column of Table 57).
Definition tmc9660_params.hpp:19
@ ReadOnly
R: GAP only.
@ ReadWriteStored
RWE: SAP and GAP, STAP stores it.
@ WriteOnly
W: SAP only.
@ ReadWrite
RW: SAP and GAP, not stored by STAP.
GlobalBank
Banks of global parameters.
Definition tmc9660_globals.hpp:28
@ System
Bank 0: communication, I/O masks, heartbeat, power-down, auto start.
@ UserVars
Bank 2: 16 user variables of the scripting feature.
@ Interrupts
Bank 3: timers and trigger transitions.
One global parameter: its bank, number, access and range.
Definition tmc9660_globals.hpp:18
Access access
Access class.
Definition tmc9660_globals.hpp:21
int64_t min
Smallest value.
Definition tmc9660_globals.hpp:22
uint8_t bank
Bank 0 (system), 2 (user variables) or 3 (interrupt configuration).
Definition tmc9660_globals.hpp:19
int64_t max
Largest value.
Definition tmc9660_globals.hpp:23
uint16_t number
Parameter number in the bank.
Definition tmc9660_globals.hpp:20
bool odd_only
Only odd values are valid (SERIAL_ADDRESS).
Definition tmc9660_globals.hpp:24
The axis parameters of parameter mode (SAP, GAP, STAP, AAP): number, range, default and access of eve...