18#ifndef ADS7952_REGISTERS_HPP
19#define ADS7952_REGISTERS_HPP
38inline constexpr uint16_t
kManual = 0x1000U;
39inline constexpr uint16_t
kAuto1 = 0x2000U;
40inline constexpr uint16_t
kAuto2 = 0x3000U;
90[[nodiscard]]
constexpr uint8_t
ReplyAddress(uint16_t reply)
noexcept {
91 return static_cast<uint8_t
>((
static_cast<uint32_t
>(reply) >>
kReplyAddressShift) & 0x0FU);
99[[nodiscard]]
constexpr uint16_t
ReplyCode(uint16_t reply)
noexcept {
100 return static_cast<uint16_t
>(
static_cast<uint32_t
>(reply) &
kReplyCodeMask);
109[[nodiscard]]
constexpr uint16_t
ManualWord(uint8_t channel, uint16_t control)
noexcept {
122[[nodiscard]]
constexpr uint16_t
AutoWord(uint16_t mode,
bool restart, uint16_t control)
noexcept {
124 (restart ?
static_cast<uint32_t
>(
kAutoReset) : 0U) |
134 return static_cast<uint16_t
>(
static_cast<uint32_t
>(
kAuto2Program) |
157 uint16_t threshold)
noexcept {
158 return static_cast<uint16_t
>(
160 (high ?
static_cast<uint32_t
>(
kAlarmHigh) : 0U) |
161 (exit ?
static_cast<uint32_t
>(
kAlarmExit) : 0U) |
167using detail::operator
""_u8;
168using detail::operator
""_u16;
170static_assert(
ManualWord(3_u8, 0_u16) == 0x1980U);
173 (
ManualWord(0x14_u8, 0xFFFF_u16) == 0x1A7FU));
Compile-time helpers of the ADS7952 driver: exact hook matching and enumeration checks.
constexpr uint16_t kGpio3PowerDown
DI08: GPIO3 is the power-down input.
Definition ads7952_registers.hpp:61
constexpr uint16_t kAutoReset
DI10, Auto modes: restart the sequence.
Definition ads7952_registers.hpp:48
constexpr uint16_t kAuto2
0011: Auto-2 mode (Table 5).
Definition ads7952_registers.hpp:40
constexpr uint16_t kContinue
0000: keep the mode, ignore DI11:00.
Definition ads7952_registers.hpp:37
constexpr uint16_t kPowerDown
DI05: power down at the next frame's end.
Definition ads7952_registers.hpp:51
constexpr uint16_t kRangeTwoVref
DI06: 0 to 2 x VREF (Range 2).
Definition ads7952_registers.hpp:50
constexpr uint16_t kAlarmExit
DI12: leave the sequence after this frame.
Definition ads7952_registers.hpp:69
constexpr uint32_t kAlarmChannelShift
DI15:14: channel within the group.
Definition ads7952_registers.hpp:67
constexpr uint16_t kAlarmLowReset
Low threshold after reset: all zeros.
Definition ads7952_registers.hpp:72
constexpr uint16_t kManual
0001: Manual mode (Table 1).
Definition ads7952_registers.hpp:38
constexpr uint16_t kReplyCodeMask
DO11:00: the 12-bit result, straight binary.
Definition ads7952_registers.hpp:77
constexpr uint16_t AlarmGroupWord(uint8_t group) noexcept
The first frame of an alarm group's programming sequence.
Definition ads7952_registers.hpp:143
constexpr uint16_t kAlarmProgramGroup0
11bb: alarm group bb (Table 13).
Definition ads7952_registers.hpp:44
constexpr uint16_t kAuto1Program
1000: Auto-1 mask in the next frame.
Definition ads7952_registers.hpp:42
constexpr uint16_t ManualWord(uint8_t channel, uint16_t control) noexcept
A Manual mode word with DI11 = 1: select channel for the next frame and set DI06:00.
Definition ads7952_registers.hpp:109
constexpr uint16_t kControlMask
DI06:00: the bits a mode word programs.
Definition ads7952_registers.hpp:54
constexpr uint16_t kAlarmHigh
DI13: 1 high threshold, 0 low.
Definition ads7952_registers.hpp:68
constexpr uint32_t kChannelsPerAlarmGroup
Table 12: four channels per group.
Definition ads7952_registers.hpp:73
constexpr uint16_t kAlarmThresholdMask
DI09:00: the upper 10 result bits.
Definition ads7952_registers.hpp:70
constexpr uint32_t kCommandShift
DI15:12 hold the command.
Definition ads7952_registers.hpp:35
constexpr uint16_t kAuto2Program
1001: Auto-2 last channel (Table 6).
Definition ads7952_registers.hpp:43
constexpr uint16_t kGpioProgram
0100: GPIO program register (Table 11).
Definition ads7952_registers.hpp:41
constexpr uint8_t ReplyAddress(uint16_t reply) noexcept
The 4-bit field DO15:12 of a reply: the channel the result belongs to (DI04 = 0 in the frame before),...
Definition ads7952_registers.hpp:90
constexpr uint16_t AlarmThresholdWord(uint8_t channel_in_group, bool high, bool exit, uint16_t threshold) noexcept
One alarm threshold frame of a group's programming sequence.
Definition ads7952_registers.hpp:156
constexpr uint16_t kGpioReadout
DI04: next reply carries GPIO3:0 in DO15:12.
Definition ads7952_registers.hpp:52
constexpr uint16_t kGpioDirectionMask
DI03:00: 1 = output.
Definition ads7952_registers.hpp:64
constexpr uint16_t AutoWord(uint16_t mode, bool restart, uint16_t control) noexcept
An Auto-1 or Auto-2 mode word with DI11 = 1.
Definition ads7952_registers.hpp:122
constexpr uint16_t kAlarmHighReset
High threshold after reset: all ones.
Definition ads7952_registers.hpp:71
constexpr uint32_t kGpioAlarmShift
DI06:04: GPIO0/GPIO1 alarm outputs.
Definition ads7952_registers.hpp:63
constexpr uint16_t Auto2ProgramWord(uint8_t last) noexcept
The Auto-2 program word: last becomes the last channel of the Auto-2 sequence.
Definition ads7952_registers.hpp:133
constexpr uint16_t kGpioResetAll
DI09: reset every register next frame.
Definition ads7952_registers.hpp:60
constexpr uint32_t kAuto2LastShift
DI09:06: the last channel of the sequence.
Definition ads7952_registers.hpp:57
constexpr uint16_t kCommandMask
DI15:12.
Definition ads7952_registers.hpp:36
constexpr uint32_t kManualChannelShift
DI10:07, Manual: the next channel.
Definition ads7952_registers.hpp:49
constexpr uint16_t kGpioDataMask
DI03:00: GPIO output levels.
Definition ads7952_registers.hpp:53
constexpr uint16_t kGpio2Range
DI07: GPIO2 is the range input.
Definition ads7952_registers.hpp:62
constexpr uint32_t kReplyAddressShift
DO15:12: channel address or GPIO3:0.
Definition ads7952_registers.hpp:76
constexpr uint16_t kAuto1
0010: Auto-1 mode (Table 2).
Definition ads7952_registers.hpp:39
constexpr uint16_t kProgramEnable
DI11: take DI10:00 (Manual: DI06:00).
Definition ads7952_registers.hpp:47
constexpr uint16_t ReplyCode(uint16_t reply) noexcept
The 12-bit conversion result of a reply, DO11:00.
Definition ads7952_registers.hpp:99
The ADS795x frame format.
Definition ads7952_registers.hpp:26