Struct mcp3425::MCP3425

source ·
pub struct MCP3425<I2C, D, M> { /* private fields */ }
Expand description

Driver for the MCP3425 ADC

Implementations§

Initialize the MCP3425 driver.

This constructor is side-effect free, so it will not write any configuration to the device until a first measurement is triggered.

Initialize the MCP3425 driver in One-Shot mode.

This constructor is side-effect free, so it will not write any configuration to the device until a first measurement is triggered.

Examples found in repository?
src/lib.rs (line 607)
606
607
608
    pub fn into_oneshot(self) -> MCP3425<I2C, D, OneShotMode> {
        MCP3425::oneshot(self.i2c, self.address, self.delay)
    }

Change the conversion mode to continuous.

This conversion is side-effect free, so it will not write any configuration to the device until set_config is called.

Do a one-shot voltage measurement.

Return the result in millivolts.

Initialize the MCP3425 driver in Continuous Measurement mode.

This constructor is side-effect free, so it will not write any configuration to the device until a first measurement is triggered.

Examples found in repository?
src/lib.rs (line 543)
542
543
544
    pub fn into_continuous(self) -> MCP3425<I2C, D, ContinuousMode> {
        MCP3425::continuous(self.i2c, self.address, self.delay)
    }

Change the conversion mode to one-shot.

This conversion is side-effect free, so it will not write any configuration to the device until a first one-shot measurement is triggered.

Write the specified configuration to the device and block until the first measurement is ready.

The wait-for-measurement logic is implemented with polling, since there are no non-blocking embedded_hal traits yet.

Note: Since the wait-until-ready logic needs to read the data register, when reading the measurement immediately after setting the configuration, that measurement will be returned as NotFresh.

Read a measurement from the device.

Note that the set_config method MUST have been called before, otherwise Error::NotInitialized will be returned.

If you poll faster than the sample rate, Error::NotReady will be returned.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

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.