|
ADS7952 Driver 0.1.0
API reference
|
The ADS7952 driver: everything it declares lives here; internals in detail.
More...
Namespaces | |
| namespace | reg |
| The ADS795x frame format. | |
Classes | |
| class | ADS7952 |
| Driver for one ADS7950, ADS7951, ADS7952 or ADS7953 on a platform port. More... | |
| struct | 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 | Bank |
| The result of one Auto-1 or Auto-2 scan: one code per channel of the sequence. More... | |
| struct | 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... | |
| struct | GpioConfig |
The GPIO program register and the GPIO output levels. GpioConfig{} is the reset state: every pin an input with no function. More... | |
| struct | Result |
| The value of a call, or why there is none. More... | |
| struct | Result< void > |
| The result of a call that returns no value. More... | |
| struct | 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... | |
| class | SpiInterface |
| CRTP base of the platform SPI port. More... | |
Concepts | |
| concept | SpiPort |
Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool. | |
Enumerations | |
| enum class | Error : uint8_t { Error::Ok = 0 , Error::NotInitialized = 1 , Error::InvalidArgument = 2 , Error::Bus = 3 , Error::Timeout = 4 , Error::DeviceIdMismatch = 5 , Error::Crc = 6 , Error::Busy = 7 , Error::DeviceFault = 8 , Error::Unsupported = 9 , Error::NoDevice = 16 , Error::ChannelMismatch = 17 , Error::SequenceMismatch = 18 , Error::WriteMismatch = 19 , Error::RangeMismatch = 20 , Error::ScaleMismatch = 21 , Error::DeviceReset = 22 } |
Why a call failed. Every call of the driver returns one of these in its Result. More... | |
| enum class | LogLevel : uint8_t { LogLevel::Error = 0 , LogLevel::Warning , LogLevel::Info , LogLevel::Debug } |
Severity passed to the optional Log() hook. More... | |
| enum class | Variant : uint8_t { Variant::Ads7950 = 0 , Variant::Ads7951 = 1 , Variant::Ads7952 = 2 , Variant::Ads7953 = 3 } |
| Which 12-bit member of the family is fitted. The chip cannot tell, so it is configured. More... | |
| enum class | Package : uint8_t { Package::Tssop = 0 , Package::Vqfn = 1 } |
| The package: the VQFN parts bring out GPIO0 only (section 8.5.2). More... | |
| enum class | Range : uint8_t { Range::Vref = 0 , Range::TwoVref = 1 } |
| Input range, DI06 of the mode control word (Tables 1, 2, 5; Table 8). More... | |
| enum class | Verify : uint8_t { Verify::None = 0 , Verify::ReadBack = 1 } |
| Extra verification for one call, chosen per call (handbook KB-ARCH-041). More... | |
| enum class | AlarmOutput : uint8_t { AlarmOutput::None = 0 , AlarmOutput::Gpio0HighOrLow = 1 , AlarmOutput::Gpio0High = 2 , AlarmOutput::Gpio1Low = 4 , AlarmOutput::Gpio1LowGpio0High = 6 } |
| What GPIO0 and GPIO1 do besides general-purpose I/O: DI06:04 of the GPIO program register (Table 11). Alarm outputs are active high. More... | |
Functions | |
| constexpr Config | KconfigDefaults () noexcept |
| The configuration menuconfig selected, on top of the chosen part's reset state. | |
| constexpr const char * | ToString (Error error) noexcept |
| The name of an error, for logs. | |
| constexpr uint8_t | ChannelCount (Variant variant) noexcept |
| Number of analog inputs of a variant. | |
| constexpr uint16_t | 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 | ValidateMonitor (const Config &config) noexcept |
| Check the scale monitor of a configuration. | |
| constexpr Error | CheckScaleCode (const Config &config, uint16_t code) noexcept |
| Judge one code of the scale monitor's channel. No I/O. | |
| constexpr Error | ValidateGpio (const Config &config) noexcept |
| Check the GPIO settings of a configuration against its package. | |
| constexpr Error | ValidateAlarms (const Config &config) noexcept |
| Check the alarm thresholds of a configuration against its variant. | |
| constexpr bool | 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 | ValidPark (const Config &config) noexcept |
Check Config::park_channel against the variant. | |
| constexpr Error | Validate (const Config &config) noexcept |
| Check a configuration without touching the chip. | |
| constexpr Config | 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 | 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 * | GetDriverVersion () noexcept |
| constexpr uint32_t | GetDriverVersionMajor () noexcept |
| constexpr uint32_t | GetDriverVersionMinor () noexcept |
| constexpr uint32_t | GetDriverVersionPatch () noexcept |
Variables | |
| constexpr std::size_t | kMaxChannels = 16 |
| Channels of the largest part (ADS7953); arrays indexed by channel have this size. | |
| constexpr uint16_t | kMaxCode = 4095 |
| Largest result code: 12 bits, straight binary (Table 8). | |
| constexpr uint32_t | kCodesPerFullScale = 4096 |
| Codes per full scale: one LSB is full scale / 4096 (Table 8). | |
| constexpr uint32_t | kPowerUpUs = 1 |
| constexpr std::size_t | kMaxTraceFrames = 32 |
Longest TraceFrames() request, in frames. | |
| constexpr std::size_t | kFrameBytes = 2 |
| Bytes per transfer: every frame is 16 bits with CS low throughout (section 8.1). | |
| constexpr uint8_t | kNoMonitor = 0xFF |
ScaleMonitor::channel when no channel carries a known voltage: no scale check. | |
| constexpr uint8_t | kNoPark = 0xFF |
Config::park_channel when the chip stays on channel 0 after a read of it: no parking. | |
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 | |
| constexpr uint8_t | kSpiMode = 0 |
| constexpr bool | kMsbFirst = true |
| Each word is clocked most significant bit first (DI15 and DO15 first, Figure 2). | |
| constexpr uint32_t | kMaxClockHz = 20'000'000 |
| Highest SCLK frequency, f(SCLK) max (sections 7.3 and 7.9). | |
| constexpr uint32_t | kMinCsHighNs = 20 |
| Shortest time CS stays high between two frames, t_w1 (section 7.9). | |
| constexpr uint32_t | 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 | kCsHoldNs = 0 |
| constexpr uint32_t | kQuietNs = 40 |
| constexpr uint32_t | kSdoReleaseNs = 26 |
| constexpr bool | kContinuousWord = true |
| constexpr uint32_t | kFrameBits = 16 |
| SCLK cycles per frame: one 16-bit word with CS low throughout (section 8.1). | |
The ADS7952 driver: everything it declares lives here; internals in detail.
|
constexprnoexcept |
The configuration menuconfig selected, on top of the chosen part's reset state.
ResetConfig(variant) with the package, range, voltages and sequences from Kconfig.
|
inlineconstexpr |
true: the 16 clocks of a frame come back to back, with no idle SCLK between the two bytes. The chip converts with SCLK (t_conv = 16 SCLK, section 7.9; section 8.1) and the datasheet specifies no conversion with the clock stopped inside a frame.
|
inlineconstexpr |
Last SCLK edge to CS high: section 7.9 gives no minimum; CS may rise once the 16th SCLK falling edge has passed (section 8.1).
|
inlineconstexpr |
Quiet time from SDO going to 3-state (at most 26 ns after the 16th SCLK falling edge, t_d3) to the next CS falling edge, t_q (section 7.9). With CS high for kMinCsHighNs the 16th falling edge must come at least kSdoReleaseNs + kQuietNs before the next CS falling edge.
|
inlineconstexpr |
Longest delay from the 16th SCLK falling edge to SDO in 3-state, t_d3 at +VBD = 1.8 V (section 7.9).
|
inlineconstexpr |
SPI mode 0: CPOL 0, CPHA 0. SDI is latched on the rising SCLK edge and SDO changes on the falling edge (section 8.1, Figure 2).