Crate mcp3424

Source
Expand description

This crate provides an async Rust driver for the MCP342[2/3/4] ADC, based on the embedded-hal traits.

§Modes

ModeDescription
OneShotInstructs the device to do a single conversion and awaits the result.
ContinuousInstructs the device to do conversions continuously. Every subsequent call will read the last available value only.
MultiShotA variation of the OneShotMode. The measure functions execute a series of one-shot conversions and return all values at once.

§MCP3422 and MCP3423

In contrast to the MCP3424, the MCP3422 and MCP3423 provide only two channels instead of four. But these device offer the same I2C interface. Therefor this crate can also be used for MCP3422 and MCP3423 devices with the exception that these devices treat Channel::Channel3 as Channel::Channel1 and Channel::Channel4 as Channel::Channel2.

§Crate Features

Enable or disable features according to your needs and in order to optimize for compile time and space.

FeatureDefaultDescription
defmtWhen enabled, certain types will provide an implementation for the defmt::Format trait.
fmtWhen enabled, certain types will provide an implementation for core::fmt::Debug and core::fmt::Display traits.
streamWhen enabled, the driver offers additional measure functions which return a futures::stream::Stream.
uomWhen enabled, all measure functions return the measured value as uom::si::f32::ElectricPotential instead of a plain f32.

✔ enabled, ✗ disabled

§UOM

This driver integrates with the uom crate which provides units of measurement. After activating the corresponding uom feature all measure functions return the measured value as uom::si::f32::ElectricPotential instead of a plain f32.

Read more

Modules§

doc
This module delivers supplementary documentation.

Structs§

Configuration
Mode independent user configuration.
ContinuousMode
A mode where the device continuously converts data.
MCP3424
Driver for the MCP342[2/3/4].
MultiShotMode
A mode which triggers a sequence of one-shot conversions.
OneShotMode
A mode where the device executes a single conversion.

Enums§

Channel
Configuration parameter to select the device’s channel.
ConversionTime
Configuration parameter to adjust the driver’s assumed conversion time.
Error
Error type used by the driver.
Gain
Configuration parameter to set the value for the programmable gain amplifier (PGA).
Resolution
Configuration parameter to set the resolution used to convert an analogue value.

Traits§

Mode