Struct ade791x::Ade791x

source ·
pub struct Ade791x<SPI, CS> { /* private fields */ }
Expand description

Represents a single ADE7912/ADE7913 3-Channel, Isolated, Sigma-Delta ADC with SPI.

Implementations§

Creates a new Ade791x instance representing a ADE7912 chip, given the SPI peripheral and the CS output pin. The newly created instance must be initialized using Self::init().

Arguments
  • spi - The SPI interface implementing the spi::Transfer trait.
  • cs - The CS output pin implementing the OutputPin trait.

Creates a new Ade791x instance representing a ADE7913 chip, given the SPI peripheral and the CS output pin. The newly created instance must be initialized using Self::init().

Arguments
  • spi - The SPI interface implementing the spi::Transfer trait.
  • cs - The CS output pin implementing the OutputPin trait.

Initializes the ADC, applying the given configuration. After this method, the ADC is ready to use.

Arguments
  • delay - The delay source implementing the DelayMs trait.
  • config - The Config struct containing the configuration for the ADC.
  • calibration - The Calibration struct containing the calibration values for the ADC.

Performs a hardware reset of the ADC. During a hardware reset, all the registers are set to their default values and the dc-to-dc converter is shut down. After a hardware reset, the ADC needs to be initialized again, using Self::init().

Performs a software reset of the ADC. During a software reset, all the internal registers are reset to their default values. The dc-to-dc converter continues to function. After a software reset, the ADC needs to be initialized again, using Self::init().

Powers-down the ADC by turning off the dc-to-dc converter and shutting down the Σ-Δ modulators. Although the ADE7912/ADE7913 configuration registers maintain their values, the iwv, v1wv, and v2wv Measurement fields are in an undefined state.

Wakes-up the ADC by turning on the dc-to-dc converter and activating the Σ-Δ modulators.

Returns the latest available measurement from the ADC as a RawMeasurement struct. Call this method inside the ISR from the DREADY pin to get a new measurement as soon as it’s ready. This method does not convert the received data. To get converted metrics, use Self::get_measurement() instead. This method does not perform CRC checks on received data.

Returns the latest available measurement from the ADC as a Measurement struct. Call this method inside the ISR from the DREADY pin to get a new measurement as soon as it’s ready. This method converts raw data to voltage, current and temperature measurements using the provided calibration values. This method does not perform CRC checks on received data.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.