pub struct Ade791x<SPI, CS> { /* private fields */ }
Expand description
Represents a single ADE7912/ADE7913 3-Channel, Isolated, Sigma-Delta ADC with SPI.
Implementations§
source§impl<SPI, CS, S, P> Ade791x<SPI, CS>where
SPI: Transfer<u8, Error = S>,
CS: OutputPin<Error = P>,
impl<SPI, CS, S, P> Ade791x<SPI, CS>where
SPI: Transfer<u8, Error = S>,
CS: OutputPin<Error = P>,
sourcepub fn new_ade7912(spi: SPI, cs: CS) -> Self
pub fn new_ade7912(spi: SPI, cs: CS) -> Self
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 thespi::Transfer
trait.cs
- The CS output pin implementing theOutputPin
trait.
sourcepub fn new_ade7913(spi: SPI, cs: CS) -> Self
pub fn new_ade7913(spi: SPI, cs: CS) -> Self
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 thespi::Transfer
trait.cs
- The CS output pin implementing theOutputPin
trait.
sourcepub fn init(
&mut self,
delay: &mut dyn DelayMs<u32>,
config: Config,
calibration: Calibration
) -> Result<(), Error<S, P>>
pub fn init(
&mut self,
delay: &mut dyn DelayMs<u32>,
config: Config,
calibration: Calibration
) -> Result<(), Error<S, P>>
Initializes the ADC, applying the given configuration. After this method, the ADC is ready to use.
Arguments
delay
- The delay source implementing theDelayMs
trait.config
- TheConfig
struct containing the configuration for the ADC.calibration
- TheCalibration
struct containing the calibration values for the ADC.
sourcepub fn hard_reset(&mut self) -> Result<(), Error<S, P>>
pub fn hard_reset(&mut self) -> Result<(), Error<S, P>>
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()
.
sourcepub fn soft_reset(&mut self) -> Result<(), Error<S, P>>
pub fn soft_reset(&mut self) -> Result<(), Error<S, P>>
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()
.
sourcepub fn powerdown(&mut self) -> Result<(), Error<S, P>>
pub fn powerdown(&mut self) -> Result<(), Error<S, P>>
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.
sourcepub fn wakeup(&mut self) -> Result<(), Error<S, P>>
pub fn wakeup(&mut self) -> Result<(), Error<S, P>>
Wakes-up the ADC by turning on the dc-to-dc converter and activating the Σ-Δ modulators.
sourcepub fn get_raw_measurement(&mut self) -> Result<RawMeasurement, Error<S, P>>
pub fn get_raw_measurement(&mut self) -> Result<RawMeasurement, Error<S, P>>
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.
sourcepub fn get_measurement(&mut self) -> Result<Measurement, Error<S, P>>
pub fn get_measurement(&mut self) -> Result<Measurement, Error<S, P>>
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.