|
ADS7952 Driver 0.1.0
API reference
|
Errors, results, variants and configuration. More...
Classes | |
| struct | ads7952::Result< T > |
| The value of a call, or why there is none. More... | |
| struct | ads7952::Result< void > |
| The result of a call that returns no value. More... | |
| struct | ads7952::GpioConfig |
The GPIO program register and the GPIO output levels. GpioConfig{} is the reset state: every pin an input with no function. More... | |
| struct | ads7952::AlarmThreshold |
The two alarm thresholds of one channel, in 12-bit result codes. The chip keeps the upper 10 bits and compares them with the upper 10 bits of each result (Table 13), so the two lowest bits of a threshold are dropped. AlarmThreshold{} is the reset state: no alarm. More... | |
| struct | ads7952::Bank |
| The result of one Auto-1 or Auto-2 scan: one code per channel of the sequence. More... | |
| struct | ads7952::ScaleMonitor |
| A channel the board drives with a known voltage, so the driver can prove the scale every code is converted with: the range the chip is really in, and a reference that is present. More... | |
| struct | ads7952::Config |
What the driver is told about the chip and the board. Config{} is an ADS7952 in TSSOP left in its reset state (Tables 1 to 13): Range 1, every GPIO an input, every channel in Auto-1, channel 11 the last of Auto-2, no alarm; with a 2.5 V reference and a 5 V analog supply. More... | |
Functions | |
| constexpr const char * | ads7952::ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr uint8_t | ads7952::ChannelCount (Variant variant) noexcept |
| Number of analog inputs of a variant. | |
| constexpr uint16_t | ads7952::AllChannels (Variant variant) noexcept |
| The mask of every channel of a variant: also the reset value of its Auto-1 program register (section 8.4.1). | |
| constexpr Error | ads7952::ValidateMonitor (const Config &config) noexcept |
| Check the scale monitor of a configuration. | |
| constexpr Error | ads7952::CheckScaleCode (const Config &config, uint16_t code) noexcept |
| Judge one code of the scale monitor's channel. No I/O. | |
| constexpr Error | ads7952::ValidateGpio (const Config &config) noexcept |
| Check the GPIO settings of a configuration against its package. | |
| constexpr Error | ads7952::ValidateAlarms (const Config &config) noexcept |
| Check the alarm thresholds of a configuration against its variant. | |
| constexpr bool | ads7952::ValidSupplies (const Config &config) noexcept |
| Check the reference and the analog supply (section 7.3), and Range 2 against them (2 x VREF <= +VA, section 7.6). | |
| constexpr bool | ads7952::ValidPark (const Config &config) noexcept |
Check Config::park_channel against the variant. | |
| constexpr Error | ads7952::Validate (const Config &config) noexcept |
| Check a configuration without touching the chip. | |
| constexpr Config | ads7952::ResetConfig (Variant variant) noexcept |
The Config of a variant left in its reset state: Config{} with that variant's Auto-1 mask and Auto-2 last channel. | |
| constexpr uint32_t | ads7952::CodeToMicrovolts (uint16_t code, Range range, uint16_t vref_mv) noexcept |
| Convert a result code to the input voltage it stands for (Table 8: one LSB is full scale / 4096, code 4095 is full scale less one LSB). | |
| constexpr const char * | ads7952::GetDriverVersion () noexcept |
| constexpr uint32_t | ads7952::GetDriverVersionMajor () noexcept |
| constexpr uint32_t | ads7952::GetDriverVersionMinor () noexcept |
| constexpr uint32_t | ads7952::GetDriverVersionPatch () noexcept |
Variables | |
| constexpr std::size_t | ads7952::kMaxChannels = 16 |
| Channels of the largest part (ADS7953); arrays indexed by channel have this size. | |
| constexpr uint16_t | ads7952::kMaxCode = 4095 |
| Largest result code: 12 bits, straight binary (Table 8). | |
| constexpr uint32_t | ads7952::kCodesPerFullScale = 4096 |
| Codes per full scale: one LSB is full scale / 4096 (Table 8). | |
| constexpr uint32_t | ads7952::kPowerUpUs = 1 |
| constexpr std::size_t | ads7952::kMaxTraceFrames = 32 |
Longest TraceFrames() request, in frames. | |
| constexpr std::size_t | ads7952::kFrameBytes = 2 |
| Bytes per transfer: every frame is 16 bits with CS low throughout (section 8.1). | |
| constexpr uint8_t | ads7952::kNoMonitor = 0xFF |
ScaleMonitor::channel when no channel carries a known voltage: no scale check. | |
| constexpr uint8_t | ads7952::kNoPark = 0xFF |
Config::park_channel when the chip stays on channel 0 after a read of it: no parking. | |
Errors, results, variants and configuration.
|
strong |
What GPIO0 and GPIO1 do besides general-purpose I/O: DI06:04 of the GPIO program register (Table 11). Alarm outputs are active high.
|
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. The type is [[nodiscard]]: a call whose Error is dropped does not compile quietly (KB-CPP20-037).
| Enumerator | |
|---|---|
| Ok | The call succeeded. |
| NotInitialized |
|
| InvalidArgument | An argument or a |
| Bus | The port's |
| Timeout | Not returned by this driver: no call waits for the chip. |
| DeviceIdMismatch | At start-up, the replies do not carry the channel addresses the chip must send back (MISO stuck low or carrying a pattern, SDI not reaching the chip, another part on the chip select). |
| Crc | Not returned by this driver (the chip sends no CRC). |
| Busy | Not returned by this driver (the chip is never busy to a frame). |
| DeviceFault | Not returned by this driver (the chip reports no faults). |
| Unsupported | A setting the configured part or package lacks (GPIO1 to GPIO3 on the VQFN package), or |
| NoDevice | At start-up, every reply was 0xFFFF: nothing drives MISO (no chip on the chip select, MISO pulled or floating high). |
| ChannelMismatch | A reply that must carry a channel's result carries another address: a frame was lost, the chip was reset, or the bus is broken. The result was not returned. |
| SequenceMismatch | The replies of an Auto-1 or Auto-2 scan are not one pass of the programmed sequence: the chip left the mode, lost its program register (a reset or brown-out), or a frame was lost. |
| WriteMismatch |
|
| RangeMismatch | The scale monitor ( |
| ScaleMismatch | The scale monitor reads outside its window in both ranges: the reference is missing, wrong or not yet settled, or the monitor input is not the voltage |
| DeviceReset | The chip was reset behind the driver (a brown-out): a reply came from channel 0, the power-on channel (section 8.4.3), where the driver expected another, or the scale monitor found Range 1, the reset value. The registers hold their reset values (no alarm function, no GPIO outputs, the reset alarm thresholds); the driver is uninitialised and |
|
strong |
|
strong |
|
strong |
|
strong |
Which 12-bit member of the family is fitted. The chip cannot tell, so it is configured.
The four parts share the frame format, the modes and the registers; they differ in the number of channels, which sets the reset value of the Auto-1 mask and the Auto-2 last channel and the number of alarm groups (section 8.4.1, Tables 4 and 12). The 10-bit (ADS7954 to ADS7957) and 8-bit (ADS7958 to ADS7961) parts are not supported.
| Enumerator | |
|---|---|
| Ads7950 | 4 channels. |
| Ads7951 | 8 channels. |
| Ads7952 | 12 channels. The default. |
| Ads7953 | 16 channels. |
|
strong |
Extra verification for one call, chosen per call (handbook KB-ARCH-041).
The datasheet needs none of it: Verify::None, the default, sends only the frames the chip needs. Verify::ReadBack costs frames on the bus; each call that takes it says how many.
| Enumerator | |
|---|---|
| None | No extra frame. The default. |
| ReadBack | Read back what the chip took (GPIO levels, the scanned sequence). |
|
constexprnoexcept |
The mask of every channel of a variant: also the reset value of its Auto-1 program register (section 8.4.1).
| variant | The part. |
|
constexprnoexcept |
Number of analog inputs of a variant.
| variant | The part. |
Judge one code of the scale monitor's channel. No I/O.
| config | The configuration (its monitor, range and vref_mv). |
| code | The monitor channel's code, from any read, Bank or DMA stream converted in config.range. |
Ok; RangeMismatch when the code is what the other range gives; ScaleMismatch when it is in neither window; InvalidArgument with no monitor or an invalid one.
|
constexprnoexcept |
Convert a result code to the input voltage it stands for (Table 8: one LSB is full scale / 4096, code 4095 is full scale less one LSB).
| code | 0 to 4095. |
| range | The range the conversion was made in. |
| vref_mv | The reference, in millivolts. |
|
constexprnoexcept |
"0.1.0", from the generated ads7952_version.h. No I/O.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
The name of an error, for logs.
| error | The error. |
"Bus"; "Unknown" for a value that is not an enumerator. Check a configuration without touching the chip.
| config | The configuration. |
Ok; InvalidArgument for a value that is not an enumerator, a voltage outside section 7.3, Range 2 with 2 x VREF above +VA, a channel the variant lacks, a threshold above 4095, a scale monitor ValidateMonitor() refuses, a park channel ValidPark() refuses, or a GPIO setting that contradicts itself; Unsupported for a GPIO the package lacks. Check the alarm thresholds of a configuration against its variant.
| config | The configuration. |
Ok, or InvalidArgument for a code above 4095 or a threshold other than the reset value on a channel the variant lacks. Check the GPIO settings of a configuration against its package.
| config | The configuration. |
Ok, InvalidArgument or Unsupported (a pin or function the VQFN package lacks). Check the scale monitor of a configuration.
| config | The configuration. |
Ok with no monitor or a usable one; InvalidArgument for a channel the variant lacks, a zero tolerance, a window that touches code 0 or 4095 (a dead or clipped input would pass), or windows of the two ranges that touch (a lost range could pass).
|
constexprnoexcept |
Check Config::park_channel against the variant.
| config | The configuration. |
kNoPark or a channel from 1 to the variant's last.
|
constexprnoexcept |
Check the reference and the analog supply (section 7.3), and Range 2 against them (2 x VREF <= +VA, section 7.6).
| config | The configuration. |
vref_mv, va_min_mv and range fit together.
|
inlineconstexpr |
Longest wait after the chip leaves power-down or reset before its first conversion, in microseconds (section 7.6, "Power-up time").