summaryrefslogtreecommitdiffstats
path: root/src/devices/mode/continuous.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/mode/continuous.rs')
-rw-r--r--src/devices/mode/continuous.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/devices/mode/continuous.rs b/src/devices/mode/continuous.rs
index d514a9a..a7a94b3 100644
--- a/src/devices/mode/continuous.rs
+++ b/src/devices/mode/continuous.rs
@@ -7,14 +7,14 @@ use core::marker::PhantomData;
impl<I2C, IC, CONV, E> Ads1x1x<I2C, IC, CONV, mode::Continuous>
where
- I2C: embedded_hal::i2c::I2c<Error = E>,
+ I2C: embedded_hal_async::i2c::I2c<Error = E>,
CONV: conversion::ConvertMeasurement,
{
/// Changes to one-shot operating mode.
- pub fn into_one_shot(
+ pub async fn into_one_shot(
mut self,
) -> Result<Ads1x1x<I2C, IC, CONV, mode::OneShot>, ModeChangeError<E, Self>> {
- if let Err(Error::I2C(e)) = self.set_operating_mode(OperatingMode::OneShot) {
+ if let Err(Error::I2C(e)) = self.set_operating_mode(OperatingMode::OneShot).await {
return Err(ModeChangeError::I2C(e, self));
}
Ok(Ads1x1x {
@@ -30,8 +30,8 @@ where
}
/// Reads the most recent measurement.
- pub fn read(&mut self) -> Result<i16, Error<E>> {
- let value = self.read_register(Register::CONVERSION)?;
+ pub async fn read(&mut self) -> Result<i16, Error<E>> {
+ let value = self.read_register(Register::CONVERSION).await?;
Ok(CONV::convert_measurement(value))
}
@@ -41,9 +41,12 @@ where
/// ongoing conversion will be completed.
/// The following conversions will use the new channel configuration.
#[allow(unused_variables)]
- pub fn select_channel<CH: ChannelId<Self>>(&mut self, channel: CH) -> Result<(), Error<E>> {
+ pub async fn select_channel<CH: ChannelId<Self>>(
+ &mut self,
+ channel: CH,
+ ) -> Result<(), Error<E>> {
let config = self.config.with_mux_bits(CH::channel_id());
- self.write_register(Register::CONFIG, config.bits)?;
+ self.write_register(Register::CONFIG, config.bits).await?;
self.config = config;
Ok(())
}