Skip to content

Commit 1d5c6b5

Browse files
committed
Remove unused InvalidInputData error.
1 parent dca7dd9 commit 1d5c6b5

File tree

7 files changed

+27
-48
lines changed

7 files changed

+27
-48
lines changed

src/devices/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Common functions.
22
3-
use crate::{register::Config, Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, Error};
3+
use crate::{register::Config, Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115};
44

55
macro_rules! impl_common_features {
66
($Ads:ident) => {
@@ -9,7 +9,7 @@ macro_rules! impl_common_features {
99
I2C: embedded_hal::i2c::I2c<Error = E>,
1010
{
1111
/// Checks whether a measurement is currently in progress.
12-
pub fn is_measurement_in_progress(&mut self) -> Result<bool, Error<E>> {
12+
pub fn is_measurement_in_progress(&mut self) -> Result<bool, E> {
1313
let config = self.read_reg_u16::<Config>()?;
1414
Ok(!config.contains(Config::OS))
1515
}

src/devices/features/tier1.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
//! Features supported on all ADS1x1x devices.
2-
3-
use crate::{
4-
Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, DataRate12Bit, DataRate16Bit, Error,
5-
};
1+
use crate::{Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, DataRate12Bit, DataRate16Bit};
62

73
macro_rules! impl_tier1_features {
84
($Ads:ident, $DataRate:ty) => {
@@ -11,7 +7,7 @@ macro_rules! impl_tier1_features {
117
I2C: embedded_hal::i2c::I2c<Error = E>,
128
{
139
/// Sets the data rate.
14-
pub fn set_data_rate(&mut self, rate: $DataRate) -> Result<(), Error<E>> {
10+
pub fn set_data_rate(&mut self, rate: $DataRate) -> Result<(), E> {
1511
let config = rate.configure(self.config);
1612
self.write_reg_u16(config)?;
1713
self.config = config;

src/devices/features/tier2.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::{
44
register::{Config, Conversion12, Conversion16, HiThresh, LoThresh},
55
Ads1014, Ads1015, Ads1114, Ads1115, ComparatorLatching, ComparatorMode, ComparatorPolarity,
6-
ComparatorQueue, Error, FullScaleRange,
6+
ComparatorQueue, FullScaleRange,
77
};
88

99
macro_rules! doc_threshold {
@@ -34,7 +34,7 @@ macro_rules! impl_tier2_features {
3434
/// Sets the input voltage measurable range.
3535
///
3636
/// This configures the programmable gain amplifier (PGA) and determines the measurable input voltage range.
37-
pub fn set_full_scale_range(&mut self, range: FullScaleRange) -> Result<(), Error<E>> {
37+
pub fn set_full_scale_range(&mut self, range: FullScaleRange) -> Result<(), E> {
3838
let config = range.configure(self.config);
3939
self.write_reg_u16(config)?;
4040
self.config = config;
@@ -47,7 +47,7 @@ macro_rules! impl_tier2_features {
4747
/// full-scale range ([`FullScaleRange`]) selected.
4848
///
4949
#[doc = doc_threshold!($($th_range)+)]
50-
pub fn set_low_threshold_raw(&mut self, value: i16) -> Result<(), Error<E>> {
50+
pub fn set_low_threshold_raw(&mut self, value: i16) -> Result<(), E> {
5151
let register_value = <$conv>::convert_threshold(value);
5252
self.write_reg_u16(LoThresh(register_value))
5353
}
@@ -58,13 +58,13 @@ macro_rules! impl_tier2_features {
5858
/// full-scale range ([`FullScaleRange`]) selected.
5959
///
6060
#[doc = doc_threshold!($($th_range)+)]
61-
pub fn set_high_threshold_raw(&mut self, value: i16) -> Result<(), Error<E>> {
61+
pub fn set_high_threshold_raw(&mut self, value: i16) -> Result<(), E> {
6262
let register_value = <$conv>::convert_threshold(value);
6363
self.write_reg_u16(HiThresh(register_value))
6464
}
6565

6666
/// Sets the comparator mode.
67-
pub fn set_comparator_mode(&mut self, mode: ComparatorMode) -> Result<(), Error<E>> {
67+
pub fn set_comparator_mode(&mut self, mode: ComparatorMode) -> Result<(), E> {
6868
let config = match mode {
6969
ComparatorMode::Traditional => self.config.difference(Config::COMP_MODE),
7070
ComparatorMode::Window => self.config.union(Config::COMP_MODE),
@@ -78,7 +78,7 @@ macro_rules! impl_tier2_features {
7878
pub fn set_comparator_polarity(
7979
&mut self,
8080
polarity: ComparatorPolarity,
81-
) -> Result<(), Error<E>> {
81+
) -> Result<(), E> {
8282
let config = match polarity {
8383
ComparatorPolarity::ActiveLow => self.config.difference(Config::COMP_POL),
8484
ComparatorPolarity::ActiveHigh => self.config.union(Config::COMP_POL),
@@ -92,7 +92,7 @@ macro_rules! impl_tier2_features {
9292
pub fn set_comparator_latching(
9393
&mut self,
9494
latching: ComparatorLatching,
95-
) -> Result<(), Error<E>> {
95+
) -> Result<(), E> {
9696
let config = match latching {
9797
ComparatorLatching::Nonlatching => self.config.difference(Config::COMP_LAT),
9898
ComparatorLatching::Latching => self.config.union(Config::COMP_LAT),
@@ -105,7 +105,7 @@ macro_rules! impl_tier2_features {
105105
/// Activates the comparator and sets the alert queue.
106106
///
107107
/// The comparator can be disabled with [`disable_comparator`](Self::disable_comparator).
108-
pub fn set_comparator_queue(&mut self, queue: ComparatorQueue) -> Result<(), Error<E>> {
108+
pub fn set_comparator_queue(&mut self, queue: ComparatorQueue) -> Result<(), E> {
109109
let config = match queue {
110110
ComparatorQueue::One => {
111111
self.config.difference(Config::COMP_QUE1).difference(Config::COMP_QUE0)
@@ -128,7 +128,7 @@ macro_rules! impl_tier2_features {
128128
///
129129
/// The comparator can be enabled by setting the comparator queue using
130130
/// the [`set_comparator_queue`](Self::set_comparator_queue) method.
131-
pub fn disable_comparator(&mut self) -> Result<(), Error<E>> {
131+
pub fn disable_comparator(&mut self) -> Result<(), E> {
132132
let config = self
133133
.config
134134
.union(Config::COMP_QUE1)
@@ -144,7 +144,7 @@ macro_rules! impl_tier2_features {
144144
/// in continuous-conversion mode, provides a continuous-conversion ready pulse.
145145
///
146146
/// When calling this the comparator will be reset to default and any thresholds will be cleared.
147-
pub fn use_alert_rdy_pin_as_ready(&mut self) -> Result<(), Error<E>> {
147+
pub fn use_alert_rdy_pin_as_ready(&mut self) -> Result<(), E> {
148148
if !self.config.contains(Config::COMP_QUE)
149149
{
150150
self.set_comparator_queue(ComparatorQueue::default())?;

src/devices/mode/continuous.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::{
44
mode,
55
register::{Config, Conversion12, Conversion16},
6-
Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, ChannelId, Error,
6+
Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, ChannelId,
77
};
88
use core::marker::PhantomData;
99

@@ -16,7 +16,7 @@ macro_rules! impl_continuous {
1616
/// Changes to one-shot operating mode.
1717
///
1818
/// On error, returns a pair of the error and the current instance.
19-
pub fn into_one_shot(mut self) -> Result<$Ads<I2C, mode::OneShot>, (Error<E>, Self)> {
19+
pub fn into_one_shot(mut self) -> Result<$Ads<I2C, mode::OneShot>, (E, Self)> {
2020
let config = self.config.union(Config::MODE);
2121
if let Err(e) = self.write_reg_u16(config) {
2222
return Err((e, self));
@@ -31,7 +31,7 @@ macro_rules! impl_continuous {
3131
}
3232

3333
/// Reads the most recent measurement.
34-
pub fn read(&mut self) -> Result<i16, Error<E>> {
34+
pub fn read(&mut self) -> Result<i16, E> {
3535
let value = self.read_reg_u16::<$conv>()?;
3636
Ok(<$conv>::convert_measurement(value.0))
3737
}
@@ -42,10 +42,7 @@ macro_rules! impl_continuous {
4242
/// ongoing conversion will be completed.
4343
/// The following conversions will use the new channel configuration.
4444
#[allow(unused_variables)]
45-
pub fn select_channel<CH: ChannelId<Self>>(
46-
&mut self,
47-
channel: CH,
48-
) -> Result<(), Error<E>> {
45+
pub fn select_channel<CH: ChannelId<Self>>(&mut self, channel: CH) -> Result<(), E> {
4946
let config = self.config.with_mux_bits(CH::channel_id());
5047
self.write_reg_u16(config)?;
5148
self.config = config;

src/devices/mode/oneshot.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::marker::PhantomData;
55
use crate::{
66
mode,
77
register::{Config, Conversion12, Conversion16},
8-
Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, ChannelId, Error,
8+
Ads1013, Ads1014, Ads1015, Ads1113, Ads1114, Ads1115, ChannelId,
99
};
1010

1111
macro_rules! impl_one_shot {
@@ -17,9 +17,7 @@ macro_rules! impl_one_shot {
1717
/// Changes to continuous operating mode.
1818
///
1919
/// On error, returns a pair of the error and the current instance.
20-
pub fn into_continuous(
21-
mut self,
22-
) -> Result<$Ads<I2C, mode::Continuous>, (Error<E>, Self)> {
20+
pub fn into_continuous(mut self) -> Result<$Ads<I2C, mode::Continuous>, (E, Self)> {
2321
let config = self.config.difference(Config::MODE);
2422
if let Err(e) = self.write_reg_u16(config) {
2523
return Err((e, self));
@@ -33,7 +31,7 @@ macro_rules! impl_one_shot {
3331
})
3432
}
3533

36-
fn trigger_measurement(&mut self, config: &Config) -> Result<(), Error<E>> {
34+
fn trigger_measurement(&mut self, config: &Config) -> Result<(), E> {
3735
let config = config.union(Config::OS);
3836
self.write_reg_u16(config)
3937
}
@@ -51,7 +49,7 @@ macro_rules! impl_one_shot {
5149
/// measurement on a different channel is requested, a new measurement on
5250
/// using the new channel selection is triggered.
5351
#[allow(unused_variables)]
54-
pub fn read<CH: ChannelId<Self>>(&mut self, channel: CH) -> nb::Result<i16, Error<E>> {
52+
pub fn read<CH: ChannelId<Self>>(&mut self, channel: CH) -> nb::Result<i16, E> {
5553
if self
5654
.is_measurement_in_progress()
5755
.map_err(nb::Error::Other)?

src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mod devices;
194194
mod types;
195195
pub use types::{
196196
ComparatorLatching, ComparatorMode, ComparatorPolarity, ComparatorQueue, DataRate12Bit,
197-
DataRate16Bit, Error, FullScaleRange, TargetAddr,
197+
DataRate16Bit, FullScaleRange, TargetAddr,
198198
};
199199
pub mod mode;
200200
pub use mode::*;
@@ -230,20 +230,17 @@ macro_rules! impl_ads1x1x {
230230
where
231231
I2C: embedded_hal::i2c::I2c<Error = E>,
232232
{
233-
pub(crate) fn read_reg_u16<R: Reg<u16>>(&mut self) -> Result<R, Error<E>> {
233+
pub(crate) fn read_reg_u16<R: Reg<u16>>(&mut self) -> Result<R, E> {
234234
let mut buf = [0, 0];
235235
self.i2c
236-
.write_read(self.address.bits(), &[R::ADDR], &mut buf)
237-
.map_err(Error::I2C)?;
236+
.write_read(self.address.bits(), &[R::ADDR], &mut buf)?;
238237
Ok(R::from_reg(u16::from_be_bytes(buf)))
239238
}
240239

241-
pub(crate) fn write_reg_u16<R: Reg<u16>>(&mut self, reg: R) -> Result<(), Error<E>> {
240+
pub(crate) fn write_reg_u16<R: Reg<u16>>(&mut self, reg: R) -> Result<(), E> {
242241
let buf = reg.to_reg().to_be_bytes();
243242
let payload: [u8; 3] = [R::ADDR, buf[0], buf[1]];
244-
self.i2c
245-
.write(self.address.bits(), &payload)
246-
.map_err(Error::I2C)
243+
self.i2c.write(self.address.bits(), &payload)
247244
}
248245
}
249246

src/types.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
33
use crate::Config;
44

5-
/// Errors in this crate
6-
#[derive(Debug, PartialEq)]
7-
pub enum Error<E> {
8-
/// I²C bus error
9-
I2C(E),
10-
/// Invalid input data provided
11-
InvalidInputData,
12-
}
13-
145
/// Data rate for ADS101x.
156
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
167
pub enum DataRate12Bit {

0 commit comments

Comments
 (0)