pub struct MCP3425<I2C, D, M> { /* private fields */ }
Expand description
Driver for the MCP3425 ADC
Implementations§
source§impl<I2C, D, E, M> MCP3425<I2C, D, M>where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
M: ConversionMode,
impl<I2C, D, E, M> MCP3425<I2C, D, M>where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
M: ConversionMode,
source§impl<I2C, D, E> MCP3425<I2C, D, OneShotMode>where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
impl<I2C, D, E> MCP3425<I2C, D, OneShotMode>where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
sourcepub fn oneshot(i2c: I2C, address: u8, delay: D) -> Self
pub fn oneshot(i2c: I2C, address: u8, delay: D) -> Self
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.
sourcepub fn into_continuous(self) -> MCP3425<I2C, D, ContinuousMode>
pub fn into_continuous(self) -> MCP3425<I2C, D, ContinuousMode>
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.
source§impl<I2C, D, E> MCP3425<I2C, D, ContinuousMode>where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
impl<I2C, D, E> MCP3425<I2C, D, ContinuousMode>where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
sourcepub fn continuous(i2c: I2C, address: u8, delay: D) -> Self
pub fn continuous(i2c: I2C, address: u8, delay: D) -> Self
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.
sourcepub fn into_oneshot(self) -> MCP3425<I2C, D, OneShotMode>
pub fn into_oneshot(self) -> MCP3425<I2C, D, OneShotMode>
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.
sourcepub fn set_config(&mut self, config: &Config) -> Result<(), Error<E>>
pub fn set_config(&mut self, config: &Config) -> Result<(), Error<E>>
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
.
sourcepub fn read_measurement(&mut self) -> Result<Voltage, Error<E>>
pub fn read_measurement(&mut self) -> Result<Voltage, Error<E>>
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.