Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
ic_haus_registers.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6#include <nlohmann/json_fwd.hpp>
7#include <span>
8#include <string>
9#include <string_view>
10
11namespace mm::node::somanet {
12
45
47enum class IcHausChip : uint8_t {
48 kIcMu,
49 kIcPvl,
50};
51
53constexpr std::string_view toString(IcHausChip chip) {
54 switch (chip) {
56 return "iC-MU";
58 return "iC-PVL";
59 }
60 return "unknown";
61}
62
65 std::string_view name;
66
73 std::string_view bits;
74
75 std::string_view description;
76};
77
79void to_json(nlohmann::json& j, const IcHausField& field);
80
87inline constexpr size_t kMaxFieldsPerRegister = 8;
88
91 uint8_t address = 0;
92
97 uint8_t lastAddress = 0;
98
99 bool reserved = false;
100
104 bool spiOnly = false;
105
106 std::array<IcHausField, kMaxFieldsPerRegister> fields{};
107 uint8_t fieldCount = 0;
108
110 std::span<const IcHausField> namedFields() const { return {fields.data(), fieldCount}; }
111
114 std::string layout() const;
115};
116
119void to_json(nlohmann::json& j, const IcHausRegister& r);
120
124 std::string_view name;
125
127 std::string_view addressing;
128
129 std::span<const IcHausRegister> registers;
130};
131
133void to_json(nlohmann::json& j, const IcHausRegisterSpace& space);
134
137std::span<const IcHausRegisterSpace> icHausRegisterSpaces();
138
139} // namespace mm::node::somanet
Pure SOMANET (Synapticon manufacturer-specific) vocabulary — object indices, sub-entry numbers and en...
Definition ic_haus_registers.cc:7
void to_json(nlohmann::json &j, const IcHausField &field)
Serialises an IcHausField. Participates in nlohmann ADL.
Definition ic_haus_registers.cc:358
std::span< const IcHausRegisterSpace > icHausRegisterSpaces()
Every register space of both chips, in the order a reader should meet them: the iC-MU's two,...
Definition ic_haus_registers.cc:382
constexpr std::string_view toString(IcHausChip chip)
Name of a chip, as the console and logs should render it. Never returns nullptr.
Definition ic_haus_registers.h:53
IcHausChip
Which chip a register space belongs to.
Definition ic_haus_registers.h:47
@ kIcMu
The position encoder; BiSS-C to the drive.
@ kIcPvl
The battery-buffered multiturn counter, reached over I²C through the iC-MU.
constexpr size_t kMaxFieldsPerRegister
How many fields one register row can name.
Definition ic_haus_registers.h:87
One field of a register — a named piece of it, with what the datasheet calls it.
Definition ic_haus_registers.h:64
std::string_view description
The datasheet's own one-line description of the field.
Definition ic_haus_registers.h:75
std::string_view bits
Definition ic_haus_registers.h:73
std::string_view name
The datasheet's own name, e.g. "GC_M".
Definition ic_haus_registers.h:65
One addressable register space of one chip.
Definition ic_haus_registers.h:122
std::string_view addressing
How the space is reached, since that is what decides whether OS command 0 can read it at all.
Definition ic_haus_registers.h:127
IcHausChip chip
Definition ic_haus_registers.h:123
std::string_view name
The datasheet's own name for the space.
Definition ic_haus_registers.h:124
std::span< const IcHausRegister > registers
Definition ic_haus_registers.h:129
One row of a register map — usually one address, sometimes a printed range.
Definition ic_haus_registers.h:90
uint8_t fieldCount
How many of fields this row actually names.
Definition ic_haus_registers.h:107
uint8_t lastAddress
Definition ic_haus_registers.h:97
std::span< const IcHausField > namedFields() const
The fields this row names, most significant bit first.
Definition ic_haus_registers.h:110
bool reserved
The whole row is reserved and names no fields.
Definition ic_haus_registers.h:99
bool spiOnly
Definition ic_haus_registers.h:104
std::string layout() const
The row as the datasheet prints it — field names with their bit slices, joined with " | "....
Definition ic_haus_registers.cc:339
std::array< IcHausField, kMaxFieldsPerRegister > fields
Only the first fieldCount count.
Definition ic_haus_registers.h:106
uint8_t address
The address, or the first of a range.
Definition ic_haus_registers.h:91