ADS7952 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts
ads7952_spi_interface.hpp File Reference

The SPI port of the ADS7952 driver: the CRTP base, the SpiPort concept and the 16-bit frame. More...

#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include "ads7952_detail.hpp"
#include "ads7952_registers.hpp"
#include "ads7952_types.hpp"

Go to the source code of this file.

Classes

class  ads7952::SpiInterface< Derived >
 CRTP base of the platform SPI port. More...
 

Namespaces

namespace  ads7952
 The ADS7952 driver: everything it declares lives here; internals in detail.
 

Concepts

concept  ads7952::SpiPort
 Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool.
 

Variables

Bus requirements

What the ADS795x needs from the SPI bus (datasheet SLAS605C, sections 7.3, 7.9 and 8.1; the values hold for every +VBD from 1.7 V to 5.25 V). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123).

constexpr uint8_t ads7952::kSpiMode = 0
 
constexpr bool ads7952::kMsbFirst = true
 Each word is clocked most significant bit first (DI15 and DO15 first, Figure 2).
 
constexpr uint32_t ads7952::kMaxClockHz = 20'000'000
 Highest SCLK frequency, f(SCLK) max (sections 7.3 and 7.9).
 
constexpr uint32_t ads7952::kMinCsHighNs = 20
 Shortest time CS stays high between two frames, t_w1 (section 7.9).
 
constexpr uint32_t ads7952::kCsSetupNs = 8
 CS low to the first rising SCLK edge, t_su1; the largest minimum, at +VBD = 1.8 V (section 7.9).
 
constexpr uint32_t ads7952::kCsHoldNs = 0
 
constexpr uint32_t ads7952::kQuietNs = 40
 
constexpr uint32_t ads7952::kSdoReleaseNs = 26
 
constexpr bool ads7952::kContinuousWord = true
 
constexpr uint32_t ads7952::kFrameBits = 16
 SCLK cycles per frame: one 16-bit word with CS low throughout (section 8.1).
 

Detailed Description

The SPI port of the ADS7952 driver: the CRTP base, the SpiPort concept and the 16-bit frame.

The driver never calls an SDK. It calls hooks on a class you derive from ads7952::SpiInterface<Self>:

Hook Contract
bool EnsureInitialized() noexcept Bring the bus up on the first call; true at once afterwards
bool Transfer(const uint8_t* tx, uint8_t* rx, std::size_t len) noexcept One full-duplex transfer of len = 2 bytes with CS low throughout and high after
void DelayUs(uint32_t us) noexcept Wait at least us microseconds (once, at start-up: the power-up time)

Every frame is one 16-bit word, MSB first, and the chip starts a conversion on each CS falling edge, so CS must go high between two frames and stay low for exactly 16 SCLK cycles: the driver calls Transfer() once per frame, always with 2 bytes and both buffers. What the chip needs from the bus is below as constexpr values (kSpiMode to kContinuousWord, datasheet sections 7.3, 7.9 and 8.1); a port checks its settings against them with static_assert. The SCLK rate and the CS high time set how long the next channel acquires (from the 14th rising edge to the next CS falling edge, section 8.1), so choose the rate for your input network. The port moves raw bytes: it never retries, never interprets the frame and never configures the chip. The optional Log() hook is described in ads7952.hpp.