29#ifndef ADS7952_SPI_INTERFACE_HPP
30#define ADS7952_SPI_INTERFACE_HPP
91template <
typename Derived>
117template <typename Port>
119 detail::ExactHook<Port, bool()
noexcept>::Take(&Port::EnsureInitialized);
120 detail::ExactHook<Port, bool(
const uint8_t*, uint8_t*, std::size_t)
noexcept>::Take(
129template <SpiPort Port>
132 explicit FrameBus(Port& port) noexcept : port_(port) {}
134 Port& GetPort() &
noexcept {
140 [[nodiscard]]
Error Frame(uint16_t word, uint16_t& reply)
noexcept {
141 const uint32_t w = word;
142 tx_ = {
static_cast<uint8_t
>(w >> 8U),
static_cast<uint8_t
>(w & 0xFFU)};
144 if (!port_.Transfer(tx_.data(), rx_.data(), tx_.size())) {
148 reply =
static_cast<uint16_t
>((
static_cast<uint32_t
>(rx_[0]) << 8U) |
149 static_cast<uint32_t
>(rx_[1]));
155 std::array<uint8_t, kFrameBytes> tx_{};
156 std::array<uint8_t, kFrameBytes> rx_{};
Compile-time helpers of the ADS7952 driver: exact hook matching and enumeration checks.
ADS795x command and reply words: the bit fields of every frame (datasheet SLAS605C,...
Public types of the ADS7952 driver: errors, Result<T>, variants, ranges, GPIO and alarm settings,...
CRTP base of the platform SPI port.
Definition ads7952_spi_interface.hpp:92
SpiInterface(const SpiInterface &)=delete
Ports are not copied: the driver holds a reference.
SpiInterface() noexcept=default
Only the derived port is constructed.
SpiInterface & operator=(const SpiInterface &)=delete
Ports are not copied: the driver holds a reference.
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exac...
Definition ads7952_spi_interface.hpp:118
constexpr std::size_t kFrameBytes
Bytes per transfer: every frame is 16 bits with CS low throughout (section 8.1).
Definition ads7952_types.hpp:310
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition ads7952_types.hpp:38
The ADS7952 driver: everything it declares lives here; internals in detail.
Definition ads7952.hpp:30
constexpr uint32_t kMaxClockHz
Highest SCLK frequency, f(SCLK) max (sections 7.3 and 7.9).
Definition ads7952_spi_interface.hpp:56
constexpr uint32_t kCsSetupNs
CS low to the first rising SCLK edge, t_su1; the largest minimum, at +VBD = 1.8 V (section 7....
Definition ads7952_spi_interface.hpp:60
constexpr uint32_t kCsHoldNs
Definition ads7952_spi_interface.hpp:63
constexpr bool kContinuousWord
Definition ads7952_spi_interface.hpp:74
constexpr bool kMsbFirst
Each word is clocked most significant bit first (DI15 and DO15 first, Figure 2).
Definition ads7952_spi_interface.hpp:54
constexpr uint32_t kQuietNs
Definition ads7952_spi_interface.hpp:67
constexpr uint32_t kMinCsHighNs
Shortest time CS stays high between two frames, t_w1 (section 7.9).
Definition ads7952_spi_interface.hpp:58
constexpr uint8_t kSpiMode
Definition ads7952_spi_interface.hpp:52
constexpr uint32_t kFrameBits
SCLK cycles per frame: one 16-bit word with CS low throughout (section 8.1).
Definition ads7952_spi_interface.hpp:76
constexpr uint32_t kSdoReleaseNs
Definition ads7952_spi_interface.hpp:70