ADS9324 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables | Friends
Driver types

Errors, results, enumerations, configuration and frame decoding. More...

Classes

struct  ads9324::Result< T >
 The value of a call, or why there is none. More...
 
struct  ads9324::Result< void >
 The result of a call that returns no value. More...
 
struct  ads9324::Window
 The digital window comparator of one channel (section 7.3.12). More...
 
struct  ads9324::Input
 The configuration of one input channel. More...
 
struct  ads9324::Interface
 The data interface (GEN_CFG3, XOR_BITS_CTL, GEN_CFG4, DIG_DELAY_CFG1/2). More...
 
struct  ads9324::ChannelSelect
 Which channels the data frame carries (ANA_CFG2). More...
 
struct  ads9324::Filter
 The digital filter in the data path (DIG_FILTER, GEN_CFG5). More...
 
struct  ads9324::Alarm
 The DRDY/ALARM pin (DRDY_ALARM_SEL, GEN_CFG4). More...
 
struct  ads9324::Sampling
 CONVST timing and the ready wait (section 5.6). More...
 
struct  ads9324::Correction
 System offset and gain correction stages (GEN_CFG5 of the channel banks). More...
 
struct  ads9324::Calibration
 Calibration at start-up and the mode RunAdcCalibration() uses. More...
 
struct  ads9324::TestPattern
 A test pattern of one channel group (TP_CFG, TP_AIN). More...
 
struct  ads9324::DaisyChain
 Daisy chain settings: out of scope in this version, Validate() refuses enabled. More...
 
struct  ads9324::Supply
 Supplies in millivolts for the range checks; 0 means "not stated". More...
 
struct  ads9324::Config
 Everything EnsureInitialized() and ApplyConfig() write to the chip. More...
 
struct  ads9324::WindowFlags
 The latched digital window comparator flags, one bit per channel (bit 0 is AIN1). More...
 
class  ads9324::CheckedConfig
 A configuration proven valid when the program is built. An invalid one does not compile. More...
 
struct  ads9324::Frame
 One decoded data frame. More...
 

Enumerations

enum class  ads9324::Error : uint8_t {
  ads9324::Error::Ok = 0 , ads9324::Error::NotInitialized = 1 , ads9324::Error::InvalidArgument = 2 , ads9324::Error::Bus = 3 ,
  ads9324::Error::Timeout = 4 , ads9324::Error::DeviceIdMismatch = 5 , ads9324::Error::Crc = 6 , ads9324::Error::Busy = 7 ,
  ads9324::Error::DeviceFault = 8 , ads9324::Error::Unsupported = 9 , ads9324::Error::UnexpectedReset = 16 , ads9324::Error::VerifyFailed = 17 ,
  ads9324::Error::Refused = 18 , ads9324::Error::DataMismatch = 19
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  ads9324::LogLevel : uint8_t { ads9324::LogLevel::Error = 0 , ads9324::LogLevel::Warning , ads9324::LogLevel::Info , ads9324::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  ads9324::Verify : uint8_t { ads9324::Verify::None = 0 , ads9324::Verify::ReadBack = 1 }
 Whether a setter reads back what it wrote (costs one two-frame read per register). More...
 
enum class  ads9324::ResetKind : uint8_t { ads9324::ResetKind::Software = 0 , ads9324::ResetKind::Hardware = 1 }
 How Reset() resets the chip. More...
 
enum class  ads9324::InputType : uint8_t { ads9324::InputType::Differential = 0 , ads9324::InputType::SingleEnded = 5 , ads9324::InputType::SingleEndedOpenWireSafe = 6 }
 Input type of a channel (CM_RANGE_AINn, Table 7-1). More...
 
enum class  ads9324::InputRange : uint8_t {
  ads9324::InputRange::V5 = 0 , ads9324::InputRange::V2_5 = 2 , ads9324::InputRange::V6_25 = 3 , ads9324::InputRange::V10 = 4 ,
  ads9324::InputRange::V12_5 = 5
}
 Input range of a channel (INPUT_RANGE_AINn, Table 7-1). More...
 
enum class  ads9324::Bandwidth : uint8_t { ads9324::Bandwidth::Low = 0 , ads9324::Bandwidth::Wide = 1 }
 Analog low-pass filter of a channel (PGA_BW_SEL_AINn, Table 7-2). More...
 
enum class  ads9324::Lanes : uint8_t { ads9324::Lanes::Eight = 0 , ads9324::Lanes::Four = 1 , ads9324::Lanes::Two = 2 , ads9324::Lanes::One = 3 }
 Number of data lanes (DOUT_LANE_SEL, Table 7-11). More...
 
enum class  ads9324::WordLength : uint8_t { ads9324::WordLength::Bits16 = 0 , ads9324::WordLength::Bits24 = 2 }
 Bits per conversion result on the data interface (DOUT_LENGTH). More...
 
enum class  ads9324::DataFormat : uint8_t { ads9324::DataFormat::TwosComplement = 0 , ads9324::DataFormat::OffsetBinary = 1 }
 Coding of the conversion result (EN_OFS_BINARY). More...
 
enum class  ads9324::DriveStrength : uint8_t { ads9324::DriveStrength::Normal = 0 , ads9324::DriveStrength::Half = 1 , ads9324::DriveStrength::Double = 2 , ads9324::DriveStrength::OneAndHalf = 3 }
 Drive strength of the digital outputs (DRIVE_STRENGTH, Table 7-15). More...
 
enum class  ads9324::ReferenceSource : uint8_t { ads9324::ReferenceSource::Pin = 0 , ads9324::ReferenceSource::Internal = 1 , ads9324::ReferenceSource::External = 2 }
 Where the ADC reference comes from (Table 7-3). More...
 
enum class  ads9324::ChannelCount : uint8_t { ads9324::ChannelCount::All16 = 0 , ads9324::ChannelCount::Eight = 1 , ads9324::ChannelCount::Four = 2 , ads9324::ChannelCount::Two = 3 }
 How many channels the data frame carries (ADC_NUM_SEL, Table 7-12). More...
 
enum class  ads9324::AlarmFunction : uint8_t { ads9324::AlarmFunction::Drdy = 0 , ads9324::AlarmFunction::WindowAlert = 1 , ads9324::AlarmFunction::CalDone = 6 , ads9324::AlarmFunction::OrMasked = 8 }
 What the DRDY/ALARM pin shows (DRDY_ALRM_SEL, Table 7-10). More...
 
enum class  ads9324::AverageLength : uint8_t {
  None = 0 , X2 , X4 , X6 ,
  X8 , X10 , X12 , X16 ,
  X20 , X32 , X64 , X128
}
 Length of a block or moving average (BLK_AVG_OSR, MVG_AVG_LEN).
 
enum class  ads9324::FirFilter : uint8_t {
  ads9324::FirFilter::Fir1 = 1 , ads9324::FirFilter::Fir2 = 2 , ads9324::FirFilter::Fir3 = 3 , ads9324::FirFilter::Fir4 = 4 ,
  ads9324::FirFilter::Fir5 = 5 , ads9324::FirFilter::Fir7 = 7
}
 The FIR low-pass filters (FIR_FILT_SEL, Table 7-9). FIR6 is reserved and absent. More...
 
enum class  ads9324::FilterKind : uint8_t { ads9324::FilterKind::None = 0 , ads9324::FilterKind::BlockAverage = 1 , ads9324::FilterKind::MovingAverage = 2 , ads9324::FilterKind::Fir = 3 }
 Which one digital filter is in the data path (section 7.3.11). More...
 
enum class  ads9324::PatternKind : uint8_t { ads9324::PatternKind::Constant = 0 , ads9324::PatternKind::Ramp = 2 }
 Kind of a test pattern (TP_MODE, Table 7-14). More...
 
enum class  ads9324::ReadySource : uint8_t { ads9324::ReadySource::Time = 0 , ads9324::ReadySource::Pin = 1 }
 How WaitDataReady() learns that a result is ready. More...
 
enum class  ads9324::CalibrationMode : uint8_t { ads9324::CalibrationMode::Offset = 1 , ads9324::CalibrationMode::Gain = 2 , ads9324::CalibrationMode::OffsetAndGain = 3 }
 Which errors ADC_CAL removes (ADC_CAL_MODE). More...
 
enum class  ads9324::CalibrationTrigger : uint8_t { ads9324::CalibrationTrigger::SingleShot = 0 , ads9324::CalibrationTrigger::Continuous = 1 }
 How the CONVST clock behaves during ADC calibration (section 7.3.10). More...
 

Functions

constexpr const char * ads9324::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr bool ads9324::Result< T >::ok () const noexcept
 
constexpr ads9324::Result< T >::operator bool () const noexcept
 
static constexpr Result ads9324::Result< T >::Success (T v) noexcept
 A successful result.
 
static constexpr Result ads9324::Result< T >::Failure (Error e) noexcept
 A failed result.
 
constexpr bool ads9324::Result< void >::ok () const noexcept
 
constexpr ads9324::Result< void >::operator bool () const noexcept
 
static constexpr Result ads9324::Result< void >::Success () noexcept
 
static constexpr Result ads9324::Result< void >::Failure (Error e) noexcept
 A failed result.
 
constexpr bool ads9324::IsValid (InputType v) noexcept
 Whether an input type holds a documented code.
 
constexpr bool ads9324::IsValid (InputRange v) noexcept
 Whether an input range holds a documented code.
 
constexpr bool ads9324::IsValid (WordLength v) noexcept
 Whether a word length holds a documented code (01b is reserved).
 
constexpr bool ads9324::IsValid (AlarmFunction v) noexcept
 Whether an alarm function holds a documented code.
 
constexpr bool ads9324::IsValid (FirFilter v) noexcept
 Whether a FIR filter holds a documented code (110b is reserved).
 
constexpr bool ads9324::IsValid (PatternKind v) noexcept
 Whether a test pattern kind holds a documented code (only 0 and 2 are reachable).
 
constexpr bool ads9324::IsValid (CalibrationMode v) noexcept
 Whether a calibration mode holds a documented code.
 
constexpr std::array< Input, 16 > ads9324::DefaultInputs () noexcept
 The default settings of the 16 inputs, spelled out because GCC skips nested member initialisers in inputs{}.
 
constexpr Config ads9324::ChipResetConfig () noexcept
 The chip's reset state as a Config: eight lanes on D7 to D0, everything else as Config{}.
 
constexpr Error ads9324::Validate (const Config &c) noexcept
 Check a configuration against the documented ranges and combinations, with no I/O.
 
consteval ads9324::CheckedConfig::CheckedConfig (const Config &config)
 
constexpr const Config & ads9324::CheckedConfig::Get () const &noexcept
 
void ads9324::CheckedConfig::Get () const &&=delete
 Not on a temporary: the reference would dangle (KB-CPP20-044).
 
constexpr int ads9324::GetDriverVersionMajor () noexcept
 
constexpr int ads9324::GetDriverVersionMinor () noexcept
 
constexpr int ads9324::GetDriverVersionPatch () noexcept
 
constexpr const char * ads9324::GetDriverVersion () noexcept
 
constexpr uint32_t ads9324::AverageFactor (AverageLength length) noexcept
 The averaging factor of a length code: 1, 2, 4, 6, 8, 10, 12, 16, 20, 32, 64, 128.
 
constexpr uint32_t ads9324::FirDecimation (FirFilter fir) noexcept
 The decimation of a FIR filter (Table 7-9).
 
constexpr uint32_t ads9324::ResultsPerOutput (const Filter &filter) noexcept
 Samples that make one result of the digital filter in the data path.
 
constexpr uint32_t ads9324::PulsesPerResult (const Filter &filter) noexcept
 CONVST falling edges the chip needs for one result.
 
constexpr uint32_t ads9324::OutputRateHz (const Config &config) noexcept
 Result rate of the data interface in hertz.
 
constexpr uint32_t ads9324::ConversionTimeUs (const Config &config) noexcept
 Time from the start of a conversion to a ready result, rounded up to microseconds, at least 2.
 
constexpr int16_t ads9324::OffsetCorrectionFor (int32_t expected_code, int32_t measured_code) noexcept
 The OFS value that removes a measured offset (equation 1, section 7.3.9).
 
constexpr int16_t ads9324::GainCorrectionFor (int32_t expected_code, int32_t measured_code) noexcept
 The GAN value that removes a measured gain error (equations 2 to 4, section 7.3.9).
 
constexpr int32_t ads9324::RangeMillivolts (InputRange range) noexcept
 Full-scale voltage of a range in millivolts.
 
constexpr int32_t ads9324::CodeToMicrovolts (int32_t code, InputRange range) noexcept
 Microvolts of a signed code: code x full scale / 32768, rounded half away from zero.
 
constexpr int16_t ads9324::ToSigned16 (uint16_t raw) noexcept
 Reinterpret a 16-bit wire value as a signed code (two's complement).
 
constexpr int16_t ads9324::WireToCode (uint16_t raw, DataFormat format) noexcept
 The signed code of a wire value.
 
constexpr uint16_t ads9324::DerandomizeMask (uint8_t prbs) noexcept
 The XOR mask of the randomizer (equations 7 and 8, section 7.3.14.4).
 
constexpr uint32_t ads9324::FrameChannels (const ChannelSelect &select) noexcept
 Number of channels in a frame.
 
constexpr uint8_t ads9324::FrameSlotChannel (const ChannelSelect &select, uint32_t slot) noexcept
 Which channel a slot of the frame carries (Table 7-12).
 
constexpr bool ads9324::HasDiagByte (const Interface &interface) noexcept
 Whether the frame ends with a DIAG byte: asked for, or implied by the randomizer (the datasheet shows the PRBS byte only together with the DIAG byte, assumption A14).
 
constexpr std::size_t ads9324::FrameBytes (const Interface &interface, const ChannelSelect &select) noexcept
 Bytes of one data frame (section 7.3.14).
 
constexpr bool ads9324::IsStuckFrame (std::span< const uint8_t > bytes) noexcept
 Whether a data frame could come from a stuck or floating line: every byte 0x00 or every byte 0xFF (hardware lessons, KB-CPP-116).
 

Variables

T ads9324::Result< T >::value {}
 The value; T{} when the call failed.
 
Error ads9324::Result< T >::error {Error::Ok}
 Error::Ok on success.
 
Error ads9324::Result< void >::error {Error::Ok}
 Error::Ok on success.
 
constexpr uint8_t ads9324::kAlarmSourceDrdy = 0x01
 Sources of the OR output; bit n of Alarm::sources is the source with code n.
 
constexpr uint8_t ads9324::kAlarmSourceWindow = 0x02
 Source code 1, window alert.
 
constexpr uint8_t ads9324::kAlarmSourceCalDone = 0x40
 Source code 6, ADC calibration done.
 
bool ads9324::Window::enabled {false}
 DWC_EN: the digital window comparator watches this channel.
 
int8_t ads9324::Window::high_code {127}
 High threshold on the top byte of the code (two's complement).
 
int8_t ads9324::Window::low_code {-128}
 Low threshold on the top byte of the code.
 
uint8_t ads9324::Window::hysteresis {0}
 Hysteresis on both thresholds, in top-byte counts.
 
InputType ads9324::Input::type {InputType::Differential}
 Differential, single ended, open-wire safe.
 
InputRange ads9324::Input::range {InputRange::V5}
 Full-scale range.
 
Bandwidth ads9324::Input::bandwidth {Bandwidth::Low}
 Analog low-pass filter.
 
bool ads9324::Input::cm_correction {false}
 Common mode error correction (CME_CORR_EN).
 
int16_t ads9324::Input::offset_quarter_lsb {0}
 OFS: -512 to 511 quarter LSBs, added first.
 
int16_t ads9324::Input::gain {0}
 GAN: -8192 to 8191, result x (1 + gain / 65536).
 
uint8_t ads9324::Input::phase_delay {0}
 Sample delay in CONVST periods, 0 to 255.
 
Window ads9324::Input::window {}
 The window comparator of this channel.
 
Lanes ads9324::Interface::lanes {Lanes::One}
 Lane count; Config{} uses one lane.
 
bool ads9324::Interface::data_on_sdout {true}
 One lane on SDOUT (true) or D7 (false).
 
WordLength ads9324::Interface::length {WordLength::Bits16}
 16 or 24 bits per channel.
 
DataFormat ads9324::Interface::format {DataFormat::TwosComplement}
 Coding.
 
bool ads9324::Interface::append_diag {false}
 Append the DIAG byte (EN_DIAG_FLAG).
 
bool ads9324::Interface::randomize {false}
 XOR the data with PRBS, append the PRBS byte.
 
DriveStrength ads9324::Interface::drive {DriveStrength::Normal}
 Output drive strength.
 
std::array< uint8_t, 9 > ads9324::Interface::delay_ns {}
 Output delay 0 to 5 ns: SDOUT, then D0 to D7.
 
ChannelCount ads9324::ChannelSelect::count {ChannelCount::All16}
 How many channels.
 
uint8_t ads9324::ChannelSelect::group {0}
 Which group of that size (ADC_CH_SEL).
 
FilterKind ads9324::Filter::kind {FilterKind::None}
 Which filter.
 
AverageLength ads9324::Filter::length {AverageLength::None}
 For the two average kinds.
 
FirFilter ads9324::Filter::fir {FirFilter::Fir1}
 For FilterKind::Fir.
 
bool ads9324::Filter::internal_clock {false}
 Block average: internal oversampling clock.
 
AlarmFunction ads9324::Alarm::function {AlarmFunction::Drdy}
 What the pin shows.
 
bool ads9324::Alarm::active_low {false}
 ALRM_POL, applies to every function.
 
bool ads9324::Alarm::pulse {false}
 ALRM_TYPE: pulse instead of level (window).
 
bool ads9324::Alarm::disabled {false}
 ALRM_DIS: the alarm function is off.
 
uint8_t ads9324::Alarm::sources {0}
 For OrMasked: the sources in the OR.
 
bool ads9324::Alarm::or_mask_acknowledged {false}
 The caller accepts that the mask sense is unverified.
 
uint32_t ads9324::Sampling::convst_hz {100'000}
 CONVST frequency, 100 kHz to 1 MHz.
 
ReadySource ads9324::Sampling::ready {ReadySource::Time}
 How a result is known to be ready.
 
uint32_t ads9324::Sampling::ready_timeout_us {10'000}
 Longest pin wait, 1 to kReadyTimeoutMaxUs.
 
bool ads9324::Sampling::reject_stuck_frames {true}
 ReadFrame() refuses an all-0x00 or all-0xFF frame.
 
bool ads9324::Correction::offset_enabled {true}
 OFS stage in the data path.
 
bool ads9324::Correction::gain_enabled {true}
 GAN stage in the data path.
 
bool ads9324::Calibration::run_at_start {false}
 Run ADC_CAL in EnsureInitialized().
 
CalibrationMode ads9324::Calibration::mode {CalibrationMode::OffsetAndGain}
 Which errors.
 
CalibrationTrigger ads9324::Calibration::trigger {CalibrationTrigger::SingleShot}
 CONVST behaviour.
 
bool ads9324::TestPattern::enabled {false}
 TP_EN.
 
PatternKind ads9324::TestPattern::kind {PatternKind::Constant}
 Constant or ramp.
 
bool ads9324::TestPattern::index_insertion {true}
 Add the channel index in the top nibble (TP_DIS_IDX = 0).
 
bool ads9324::TestPattern::step_every_convst {false}
 Ramp: step at every CONVST (TP_UPD_MODE).
 
std::array< uint16_t, 8 > ads9324::TestPattern::value {}
 Pattern per channel; the first is the ramp step.
 
bool ads9324::DaisyChain::enabled {false}
 Refused with Unsupported.
 
uint8_t ads9324::DaisyChain::location {0}
 Position in the chain (unused).
 
uint8_t ads9324::DaisyChain::devices {0}
 Devices in the chain (unused).
 
uint32_t ads9324::Supply::avdd_5v_mv {0}
 AVDD_5V, 4750 to 5250.
 
uint32_t ads9324::Supply::avdd_1v8_mv {0}
 AVDD_1V8, 1700 to 1900.
 
uint32_t ads9324::Supply::iovdd_mv {0}
 
Interface ads9324::Config::interface {}
 Data interface.
 
ReferenceSource ads9324::Config::reference {ReferenceSource::Pin}
 Reference selection.
 
std::array< Input, 16 > ads9324::Config::inputs {DefaultInputs()}
 AIN1 to AIN16.
 
Filter ads9324::Config::filter {}
 Digital filter.
 
ChannelSelect ads9324::Config::channels {}
 Channels in the frame.
 
bool ads9324::Config::low_speed_crosstalk {false}
 CH_XTALK_LOW_SPEED, for under 100 kSPS per channel.
 
Alarm ads9324::Config::alarm {}
 DRDY/ALARM pin.
 
Sampling ads9324::Config::sampling {}
 CONVST and ready wait.
 
Correction ads9324::Config::correction {}
 Offset and gain stages.
 
Calibration ads9324::Config::calibration {}
 ADC calibration.
 
std::array< TestPattern, 2 > ads9324::Config::test_pattern {}
 Group 0 is AIN1 to AIN8, group 1 AIN9 to AIN16.
 
std::array< uint8_t, 2 > ads9324::Config::window_glitch {}
 DWC glitch filter per group, 0 to 15.
 
DaisyChain ads9324::Config::daisy {}
 Out of scope.
 
Supply ads9324::Config::supply {}
 Supply voltages for the range check.
 
bool ads9324::Config::hardware_reset {false}
 Use the RESET pin at start-up (needs GpioSet()).
 
uint16_t ads9324::WindowFlags::high {0}
 Channel n went above its high threshold.
 
uint16_t ads9324::WindowFlags::low {0}
 Channel n went below its low threshold.
 
constexpr uint16_t ads9324::kDeviceId = 0x0004
 DEVICE_ID value of every ADS9324.
 
constexpr uint32_t ads9324::kPowerUpMs = 30
 Power-up wait before the first access, tPU (section 5.7).
 
constexpr uint32_t ads9324::kResetMs = 30
 Wait after a reset before the first access (tPU, A3).
 
constexpr uint32_t ads9324::kResetPulseUs = 1000
 Shortest RESET low pulse the driver drives (a design choice, section 7.4.1).
 
constexpr uint32_t ads9324::kConvstMinHz = 100'000
 Lowest CONVST frequency, fCONVST (section 5.6).
 
constexpr uint32_t ads9324::kConvstMaxHz = 1'000'000
 Highest CONVST frequency, fCONVST.
 
constexpr uint32_t ads9324::kConvstHighMinNs = 50
 Shortest CONVST high time.
 
constexpr uint32_t ads9324::kConvstLowMinNs = 50
 Shortest CONVST low time.
 
constexpr uint32_t ads9324::kDrdyLowDelayNs = 350
 Delay from the CONVST falling edge to the DRDY falling edge.
 
constexpr uint32_t ads9324::kConversionNs = 1250
 Conversion time without oversampling, tCONV.
 
constexpr uint32_t ads9324::kSclkMaxHz = 60'000'000
 Highest SCLK frequency (section 5.6).
 
constexpr uint32_t ads9324::kSingleShotCalMs = 125
 The single-shot ADC calibration time, TWAIT (Table 7-7).
 
constexpr uint32_t ads9324::kCalMarginMs = 25
 Extra time the driver polls CALIB_BUSY after the single-shot wait.
 
constexpr uint32_t ads9324::kContinuousCalConvst = 100'000
 The free-running ADC calibration time in CONVST periods (Table 7-7).
 
constexpr uint32_t ads9324::kReadyTimeoutMaxUs = 200'000
 Longest Sampling::ready_timeout_us.
 
constexpr uint32_t ads9324::kInternalVrefMv = 4096
 Internal reference voltage in millivolts (section 5.5).
 
constexpr uint32_t ads9324::kInputResistanceOhm = 1'000'000
 Input resistance of each AINnP and AINnM pin in ohms (section 7.3.3).
 
constexpr std::size_t ads9324::kMaxFrameBytes = 50
 Longest data frame in bytes: 16 channels of 24 bits, DIAG and PRBS.
 
constexpr uint8_t ads9324::kGlitchMax = 15
 Highest DWC glitch filter count (DWC_GLITCH_FILT, 4 bits).
 
constexpr uint8_t ads9324::kDelayMaxNs = 5
 Largest output delay in nanoseconds (3 bits, section 8.1.10).
 
constexpr int32_t ads9324::kOffsetMin = -512
 OFS range in quarter LSBs (10 bits, two's complement).
 
constexpr int32_t ads9324::kOffsetMax = 511
 OFS range in quarter LSBs.
 
constexpr int32_t ads9324::kGainMin = -8192
 GAN range (14 bits, two's complement).
 
constexpr int32_t ads9324::kGainMax = 8191
 GAN range.
 
std::array< uint16_t, 16 > ads9324::Frame::raw {}
 Wire values after derandomizing; 0 for absent channels.
 
std::array< int16_t, 16 > ads9324::Frame::codes {}
 Signed codes.
 
std::array< uint8_t, 16 > ads9324::Frame::low_byte {}
 The extra byte of a 24-bit word, unprocessed.
 
std::array< int32_t, 16 > ads9324::Frame::microvolts {}
 Input voltage per channel.
 
uint16_t ads9324::Frame::present_mask {0}
 Bit n: channel n is in this frame.
 
uint16_t ads9324::Frame::clipped_mask {0}
 Bit n: channel n is at a code limit.
 
uint8_t ads9324::Frame::diag {0}
 The DIAG byte, 0 when not appended.
 
uint8_t ads9324::Frame::prbs {0}
 The PRBS byte, 0 when not appended.
 
bool ads9324::Frame::window_alert {false}
 DIAG bit 6: some window comparator alerts.
 
bool ads9324::Frame::reset_detected {false}
 DIAG bit 0: the chip reset.
 
constexpr uint8_t ads9324::kDiagWindowAlert = 0x40
 DIAG bit 6, DWC_ALERT_FLAG (Table 7-13).
 
constexpr uint8_t ads9324::kDiagResetDetect = 0x01
 DIAG bit 0, RESET_DETECT_FLAG.
 

Friends

constexpr bool ads9324::WindowFlags::operator== (const WindowFlags &lhs, const WindowFlags &rhs) noexcept=default
 Equal when both masks are.
 

Detailed Description

Errors, results, enumerations, configuration and frame decoding.

Enumeration Type Documentation

◆ AlarmFunction

enum class ads9324::AlarmFunction : uint8_t
strong

What the DRDY/ALARM pin shows (DRDY_ALRM_SEL, Table 7-10).

Enumerator
Drdy 

ADC data ready. Reset value.

WindowAlert 

Digital window comparator alert.

CalDone 

ADC calibration done.

OrMasked 

The OR of the sources selected by Alarm::sources (bit map unverified).

◆ Bandwidth

enum class ads9324::Bandwidth : uint8_t
strong

Analog low-pass filter of a channel (PGA_BW_SEL_AINn, Table 7-2).

Enumerator
Low 

25.5 kHz for every range.

Wide 

280 kHz to 350 kHz, by range.

◆ CalibrationMode

enum class ads9324::CalibrationMode : uint8_t
strong

Which errors ADC_CAL removes (ADC_CAL_MODE).

Enumerator
Offset 

Offset error.

Gain 

Gain error.

OffsetAndGain 

Both.

◆ CalibrationTrigger

enum class ads9324::CalibrationTrigger : uint8_t
strong

How the CONVST clock behaves during ADC calibration (section 7.3.10).

Enumerator
SingleShot 

INT_TRIG_MODE = 1: one CONVST pulse, 125 ms.

Continuous 

A free-running CONVST: 100,000 periods.

◆ ChannelCount

enum class ads9324::ChannelCount : uint8_t
strong

How many channels the data frame carries (ADC_NUM_SEL, Table 7-12).

Enumerator
All16 

16 channels. Reset value.

Eight 

8 channels; group 0 or 1.

Four 

4 channels; group 0 to 3.

Two 

2 channels; group 0 to 7.

◆ DataFormat

enum class ads9324::DataFormat : uint8_t
strong

Coding of the conversion result (EN_OFS_BINARY).

Enumerator
TwosComplement 

Binary two's complement. Reset value.

OffsetBinary 

Straight offset binary.

◆ DriveStrength

enum class ads9324::DriveStrength : uint8_t
strong

Drive strength of the digital outputs (DRIVE_STRENGTH, Table 7-15).

Enumerator
Normal 

1 x. Reset value.

Half 

0.5 x.

Double 

2 x.

OneAndHalf 

1.5 x.

◆ Error

enum class ads9324::Error : uint8_t
strong

Why a call failed. Every call of the driver returns one of these in its Result.

Values 0 to 9 are the shared base set; chip-specific values start at 16. Crc and Busy are in the set but this chip never produces them (it has no CRC and no busy reply).

Enumerator
Ok 

The call succeeded.

NotInitialized 

EnsureInitialized() has not succeeded, or the driver was reset.

InvalidArgument 

An argument or a Config field is out of range; nothing was sent.

Bus 

A port hook returned false.

Timeout 

A flag did not change in the allowed time.

DeviceIdMismatch 

DEVICE_ID or BANK_SEL did not read as a ADS9324 after a reset.

Crc 

Never returned: the chip has no CRC.

Busy 

Never returned: the chip has no busy reply.

DeviceFault 

Reserved for a chip fault flag; the ADS9324 reports none.

Unsupported 

The port hook or chip feature this call needs is absent.

UnexpectedReset 

RESET_DETECT_FLAG is set: the chip reset since the start.

VerifyFailed 

A read-back differs from what was written.

Refused 

The call is not allowed in the current state; nothing was sent.

DataMismatch 

A data frame is not what the chip can produce (stuck line, self-test).

◆ FilterKind

enum class ads9324::FilterKind : uint8_t
strong

Which one digital filter is in the data path (section 7.3.11).

Enumerator
None 

No filter.

BlockAverage 

Block average over Filter::length conversions.

MovingAverage 

Moving average over Filter::length conversions.

Fir 

A FIR filter, Filter::fir.

◆ FirFilter

enum class ads9324::FirFilter : uint8_t
strong

The FIR low-pass filters (FIR_FILT_SEL, Table 7-9). FIR6 is reserved and absent.

Enumerator
Fir1 

Decimation 2.

Fir2 

Decimation 2.

Fir3 

Decimation 4.

Fir4 

Decimation 2.

Fir5 

Decimation 4.

Fir7 

Decimation 8.

◆ InputRange

enum class ads9324::InputRange : uint8_t
strong

Input range of a channel (INPUT_RANGE_AINn, Table 7-1).

Enumerator
V5 

+-5 V.

V2_5 

+-2.5 V.

V6_25 

+-6.25 V.

V10 

+-10 V.

V12_5 

+-12.5 V.

◆ InputType

enum class ads9324::InputType : uint8_t
strong

Input type of a channel (CM_RANGE_AINn, Table 7-1).

Enumerator
Differential 

Differential, common mode up to +-12.5 V.

SingleEnded 

AINnM tied to ground.

SingleEndedOpenWireSafe 

Single ended with the least code change on an open wire.

◆ Lanes

enum class ads9324::Lanes : uint8_t
strong

Number of data lanes (DOUT_LANE_SEL, Table 7-11).

Enumerator
Eight 

D7 to D0. Reset value.

Four 

D7 to D4.

Two 

D7 and D6.

One 

D7, or SDOUT with Interface::data_on_sdout.

◆ LogLevel

enum class ads9324::LogLevel : uint8_t
strong

Severity passed to the optional Log() hook.

Enumerator
Error 

A call failed.

Warning 

Something unexpected that the driver recovered from.

Info 

Lifecycle events.

Debug 

Detail for bring-up.

◆ PatternKind

enum class ads9324::PatternKind : uint8_t
strong

Kind of a test pattern (TP_MODE, Table 7-14).

Enumerator
Constant 

A fixed 16-bit value per channel.

Ramp 

A ramp whose step is the value of the group's first channel plus one.

◆ ReadySource

enum class ads9324::ReadySource : uint8_t
strong

How WaitDataReady() learns that a result is ready.

Enumerator
Time 

Wait the conversion time (no pin needed).

Pin 

Poll the DRDY/ALARM pin through GpioGet().

◆ ReferenceSource

enum class ads9324::ReferenceSource : uint8_t
strong

Where the ADC reference comes from (Table 7-3).

Enumerator
Pin 

The REFSEL pin chooses. Reset value.

Internal 

Internal 4.096 V reference, REFSEL ignored.

External 

External reference on REFIO, REFSEL ignored. No reference: the chip powers down.

◆ ResetKind

enum class ads9324::ResetKind : uint8_t
strong

How Reset() resets the chip.

Enumerator
Software 

SW_RST in GEN_CFG1.

Hardware 

A pulse on the RESET pin through GpioSet().

◆ Verify

enum class ads9324::Verify : uint8_t
strong

Whether a setter reads back what it wrote (costs one two-frame read per register).

Enumerator
None 

No read-back.

ReadBack 

Read every register the call touched and compare with the shadow.

◆ WordLength

enum class ads9324::WordLength : uint8_t
strong

Bits per conversion result on the data interface (DOUT_LENGTH).

Enumerator
Bits16 

16 bits. Reset value.

Bits24 

24 bits: the result and an extra byte.

Function Documentation

◆ AverageFactor()

constexpr uint32_t ads9324::AverageFactor ( AverageLength  length)
constexprnoexcept

The averaging factor of a length code: 1, 2, 4, 6, 8, 10, 12, 16, 20, 32, 64, 128.

Parameters
lengthThe length.
Returns
Samples averaged; 1 for None.

◆ CheckedConfig()

consteval ads9324::CheckedConfig::CheckedConfig ( const Config &  config)
inlineexplicit
Parameters
configThe configuration; not valid per Validate() fails the build.

◆ ChipResetConfig()

constexpr Config ads9324::ChipResetConfig ( )
constexprnoexcept

The chip's reset state as a Config: eight lanes on D7 to D0, everything else as Config{}.

Returns
The configuration.

◆ CodeToMicrovolts()

constexpr int32_t ads9324::CodeToMicrovolts ( int32_t  code,
InputRange  range 
)
constexprnoexcept

Microvolts of a signed code: code x full scale / 32768, rounded half away from zero.

Parameters
codeThe code, -32768 to 32767, in two's complement terms.
rangeThe channel range.
Returns
The input voltage in microvolts.

◆ ConversionTimeUs()

constexpr uint32_t ads9324::ConversionTimeUs ( const Config &  config)
constexprnoexcept

Time from the start of a conversion to a ready result, rounded up to microseconds, at least 2.

Section 5.7: tCONV = (N - 1) x tCYC + 1.25 us, with N the block average length or the FIR decimation and tCYC = 1 / fCONVST; 1.25 us without a digital filter that combines results.

Parameters
configThe configuration.
Returns
The time in microseconds.

◆ DefaultInputs()

constexpr std::array< Input, 16 > ads9324::DefaultInputs ( )
constexprnoexcept

The default settings of the 16 inputs, spelled out because GCC skips nested member initialisers in inputs{}.

Returns
Sixteen default Input values.

◆ DerandomizeMask()

constexpr uint16_t ads9324::DerandomizeMask ( uint8_t  prbs)
constexprnoexcept

The XOR mask of the randomizer (equations 7 and 8, section 7.3.14.4).

Parameters
prbsThe PRBS byte appended to the frame.
Returns
prbs x 256 + (prbs bit 0) x 255.

◆ Failure() [1/2]

template<typename T >
static constexpr Result ads9324::Result< T >::Failure ( Error  e)
inlinestaticconstexprnoexcept

A failed result.

Parameters
eWhy it failed; never Error::Ok.
Returns
{T{}, e}.

◆ Failure() [2/2]

static constexpr Result ads9324::Result< void >::Failure ( Error  e)
inlinestaticconstexprnoexcept

A failed result.

Parameters
eWhy it failed; never Error::Ok.
Returns
{e}.

◆ FirDecimation()

constexpr uint32_t ads9324::FirDecimation ( FirFilter  fir)
constexprnoexcept

The decimation of a FIR filter (Table 7-9).

Parameters
firThe filter.
Returns
2, 4 or 8.

◆ FrameBytes()

constexpr std::size_t ads9324::FrameBytes ( const Interface &  interface,
const ChannelSelect &  select 
)
constexprnoexcept

Bytes of one data frame (section 7.3.14).

Parameters
interfaceThe data interface.
selectThe channel selection.
Returns
Channels x 2 or 3 bytes, plus the DIAG byte and the PRBS byte when enabled.

◆ FrameChannels()

constexpr uint32_t ads9324::FrameChannels ( const ChannelSelect &  select)
constexprnoexcept

Number of channels in a frame.

Parameters
selectThe channel selection.
Returns
16, 8, 4 or 2.

◆ FrameSlotChannel()

constexpr uint8_t ads9324::FrameSlotChannel ( const ChannelSelect &  select,
uint32_t  slot 
)
constexprnoexcept

Which channel a slot of the frame carries (Table 7-12).

Parameters
selectThe channel selection; the group must be valid.
slotThe slot, counted from 0, below FrameChannels().
Returns
The channel counted from 0 (AIN1 is 0).

◆ GainCorrectionFor()

constexpr int16_t ads9324::GainCorrectionFor ( int32_t  expected_code,
int32_t  measured_code 
)
constexprnoexcept

The GAN value that removes a measured gain error (equations 2 to 4, section 7.3.9).

Parameters
expected_codeThe code a full-scale input should give.
measured_codeThe code measured; 0 gives 0.
Returns
(expected - measured) * 65536 / measured, rounded half away from zero, clamped.

◆ Get()

constexpr const Config & ads9324::CheckedConfig::Get ( ) const &
inlineconstexprnoexcept
Returns
The configuration.

◆ GetDriverVersion()

constexpr const char * ads9324::GetDriverVersion ( )
constexprnoexcept
Returns
The version as text, for example "0.1.0".

◆ GetDriverVersionMajor()

constexpr int ads9324::GetDriverVersionMajor ( )
constexprnoexcept
Returns
The major version of the driver, from the generated version header.

◆ GetDriverVersionMinor()

constexpr int ads9324::GetDriverVersionMinor ( )
constexprnoexcept
Returns
The minor version of the driver.

◆ GetDriverVersionPatch()

constexpr int ads9324::GetDriverVersionPatch ( )
constexprnoexcept
Returns
The patch version of the driver.

◆ HasDiagByte()

constexpr bool ads9324::HasDiagByte ( const Interface &  interface)
constexprnoexcept

Whether the frame ends with a DIAG byte: asked for, or implied by the randomizer (the datasheet shows the PRBS byte only together with the DIAG byte, assumption A14).

Parameters
interfaceThe data interface.
Returns
true when the DIAG byte is appended.

◆ IsStuckFrame()

constexpr bool ads9324::IsStuckFrame ( std::span< const uint8_t >  bytes)
constexprnoexcept

Whether a data frame could come from a stuck or floating line: every byte 0x00 or every byte 0xFF (hardware lessons, KB-CPP-116).

Parameters
bytesThe frame.
Returns
true for four or more identical 0x00 or 0xFF bytes.

◆ IsValid() [1/7]

constexpr bool ads9324::IsValid ( AlarmFunction  v)
constexprnoexcept

Whether an alarm function holds a documented code.

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ IsValid() [2/7]

constexpr bool ads9324::IsValid ( CalibrationMode  v)
constexprnoexcept

Whether a calibration mode holds a documented code.

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ IsValid() [3/7]

constexpr bool ads9324::IsValid ( FirFilter  v)
constexprnoexcept

Whether a FIR filter holds a documented code (110b is reserved).

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ IsValid() [4/7]

constexpr bool ads9324::IsValid ( InputRange  v)
constexprnoexcept

Whether an input range holds a documented code.

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ IsValid() [5/7]

constexpr bool ads9324::IsValid ( InputType  v)
constexprnoexcept

Whether an input type holds a documented code.

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ IsValid() [6/7]

constexpr bool ads9324::IsValid ( PatternKind  v)
constexprnoexcept

Whether a test pattern kind holds a documented code (only 0 and 2 are reachable).

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ IsValid() [7/7]

constexpr bool ads9324::IsValid ( WordLength  v)
constexprnoexcept

Whether a word length holds a documented code (01b is reserved).

Parameters
vThe value to check.
Returns
true when it is an enumerator the chip documents.

◆ OffsetCorrectionFor()

constexpr int16_t ads9324::OffsetCorrectionFor ( int32_t  expected_code,
int32_t  measured_code 
)
constexprnoexcept

The OFS value that removes a measured offset (equation 1, section 7.3.9).

Parameters
expected_codeThe code the input should give.
measured_codeThe code measured.
Returns
Quarter LSBs, 4 * (expected - measured), clamped to the register range.

◆ ok() [1/2]

template<typename T >
constexpr bool ads9324::Result< T >::ok ( ) const
inlineconstexprnoexcept
Returns
true when the call succeeded.

◆ ok() [2/2]

constexpr bool ads9324::Result< void >::ok ( ) const
inlineconstexprnoexcept
Returns
true when the call succeeded.

◆ operator bool() [1/2]

template<typename T >
constexpr ads9324::Result< T >::operator bool ( ) const
inlineexplicitconstexprnoexcept
Returns
true when the call succeeded.

◆ operator bool() [2/2]

constexpr ads9324::Result< void >::operator bool ( ) const
inlineexplicitconstexprnoexcept
Returns
true when the call succeeded.

◆ OutputRateHz()

constexpr uint32_t ads9324::OutputRateHz ( const Config &  config)
constexprnoexcept

Result rate of the data interface in hertz.

Parameters
configThe configuration.
Returns
convst_hz divided by the block average length or the FIR decimation.

◆ PulsesPerResult()

constexpr uint32_t ads9324::PulsesPerResult ( const Filter &  filter)
constexprnoexcept

CONVST falling edges the chip needs for one result.

Parameters
filterThe digital filter.
Returns
The FIR decimation, the block average length with the external clock, and 1 otherwise (including the internal oversampling clock, where one falling edge starts the whole block).

◆ RangeMillivolts()

constexpr int32_t ads9324::RangeMillivolts ( InputRange  range)
constexprnoexcept

Full-scale voltage of a range in millivolts.

Parameters
rangeThe range.
Returns
5000, 2500, 6250, 10000 or 12500.

◆ ResultsPerOutput()

constexpr uint32_t ads9324::ResultsPerOutput ( const Filter &  filter)
constexprnoexcept

Samples that make one result of the digital filter in the data path.

Parameters
filterThe filter.
Returns
The block average length, the FIR decimation, or 1.

◆ Success() [1/2]

static constexpr Result ads9324::Result< void >::Success ( )
inlinestaticconstexprnoexcept
Returns
A successful result.

◆ Success() [2/2]

template<typename T >
static constexpr Result ads9324::Result< T >::Success ( T  v)
inlinestaticconstexprnoexcept

A successful result.

Parameters
vThe value.
Returns
{v, Error::Ok}.

◆ ToSigned16()

constexpr int16_t ads9324::ToSigned16 ( uint16_t  raw)
constexprnoexcept

Reinterpret a 16-bit wire value as a signed code (two's complement).

Parameters
rawThe wire value.
Returns
The signed code.

◆ ToString()

constexpr const char * ads9324::ToString ( Error  error)
constexprnoexcept

The name of an error, for logs.

Parameters
errorThe error.
Returns
A static string such as "Timeout"; "Unknown" for a value that is not an enumerator.

◆ Validate()

constexpr Error ads9324::Validate ( const Config &  c)
constexprnoexcept

Check a configuration against the documented ranges and combinations, with no I/O.

Parameters
cThe configuration.
Returns
Ok; Unsupported when the daisy chain is asked for (out of scope in this version); otherwise InvalidArgument.

◆ WireToCode()

constexpr int16_t ads9324::WireToCode ( uint16_t  raw,
DataFormat  format 
)
constexprnoexcept

The signed code of a wire value.

Parameters
rawThe 16 bits as received, after derandomizing.
formatThe coding in use.
Returns
-32768 to 32767.

Variable Documentation

◆ iovdd_mv

uint32_t ads9324::Supply::iovdd_mv {0}

IOVDD, 1700 to 3600; the timing is specified at 1700 to 1900 only.

◆ kAlarmSourceDrdy

constexpr uint8_t ads9324::kAlarmSourceDrdy = 0x01
inlineconstexpr

Sources of the OR output; bit n of Alarm::sources is the source with code n.

Source code 0, DRDY.

Friends

◆ operator==

constexpr bool operator== ( const WindowFlags &  lhs,
const WindowFlags &  rhs 
)
friend

Equal when both masks are.

Parameters
lhsThe left operand.
rhsThe right operand.
Returns
true when high and low are equal.