Struct mcp3425::MCP3425
[−]
[src]
pub struct MCP3425<I2C, D, M> { /* fields omitted */ }
Driver for the MCP3425 ADC
Methods
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,
[src]
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
M: ConversionMode,
pub fn new(i2c: I2C, address: u8, delay: D, mode: M) -> Self
[src]
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.
impl<I2C, D, E> MCP3425<I2C, D, OneShotMode> where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
[src]
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
pub fn oneshot(i2c: I2C, address: u8, delay: D) -> Self
[src]
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.
pub fn into_continuous(self) -> MCP3425<I2C, D, ContinuousMode>
[src]
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.
pub fn measure(&mut self, config: &Config) -> Result<Voltage, Error<E>>
[src]
Do a one-shot voltage measurement.
Return the result in millivolts.
impl<I2C, D, E> MCP3425<I2C, D, ContinuousMode> where
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
[src]
I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
D: DelayMs<u8>,
pub fn continuous(i2c: I2C, address: u8, delay: D) -> Self
[src]
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.
pub fn into_oneshot(self) -> MCP3425<I2C, D, OneShotMode>
[src]
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.
pub fn set_config(&mut self, config: &Config) -> Result<(), Error<E>>
[src]
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
.
pub fn read_measurement(&mut self) -> Result<Voltage, Error<E>>
[src]
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
impl<I2C: Debug, D: Debug, M: Debug> Debug for MCP3425<I2C, D, M>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more