diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2020-06-21 22:52:41 +0200 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2020-06-21 22:52:41 +0200 |
commit | 6aed921780dbe12c058e0aa0ce8b617e404b5a87 (patch) | |
tree | 3b76c4d8946aede3e48fcfade62a2e19488ee118 | |
parent | b7e9c9acf1bb42f4966930354135782bab57394a (diff) | |
download | ads1x1x-async-6aed921780dbe12c058e0aa0ce8b617e404b5a87.tar.gz ads1x1x-async-6aed921780dbe12c058e0aa0ce8b617e404b5a87.tar.xz ads1x1x-async-6aed921780dbe12c058e0aa0ce8b617e404b5a87.zip |
Use edition 2018
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | examples/all_channels.rs | 8 | ||||
-rw-r--r-- | examples/linux.rs | 8 | ||||
-rw-r--r-- | examples/typed.rs | 7 | ||||
-rw-r--r-- | src/channels.rs | 5 | ||||
-rw-r--r-- | src/construction.rs | 9 | ||||
-rw-r--r-- | src/conversion.rs | 2 | ||||
-rw-r--r-- | src/devices/common.rs | 3 | ||||
-rw-r--r-- | src/devices/features/tier1.rs | 8 | ||||
-rw-r--r-- | src/devices/features/tier2.rs | 4 | ||||
-rw-r--r-- | src/devices/mode/continuous.rs | 7 | ||||
-rw-r--r-- | src/devices/mode/oneshot.rs | 15 | ||||
-rw-r--r-- | src/ic.rs | 2 | ||||
-rw-r--r-- | src/interface.rs | 5 | ||||
-rw-r--r-- | src/lib.rs | 54 | ||||
-rw-r--r-- | tests/construction.rs | 2 | ||||
-rw-r--r-- | tests/mux.rs | 10 | ||||
-rw-r--r-- | tests/tier1.rs | 10 | ||||
-rw-r--r-- | tests/tier2.rs | 6 |
20 files changed, 72 insertions, 102 deletions
@@ -18,6 +18,7 @@ include = [ "/LICENSE-MIT", "/LICENSE-APACHE", ] +edition = "2018" [badges] travis-ci = { repository = "eldruin/ads1x1x-rs", branch = "master" } @@ -77,15 +77,11 @@ Please find additional examples using hardware in this repository: [driver-examp [driver-examples]: https://github.com/eldruin/driver-examples ```rust -extern crate embedded_hal; use embedded_hal::adc::OneShot; -extern crate linux_embedded_hal; -#[macro_use(block)] -extern crate nb; -extern crate ads1x1x; +use linux_embedded_hal::I2cdev; +use nb::block; use ads1x1x::{channel, Ads1x1x, SlaveAddr}; -use linux_embedded_hal::I2cdev; fn main() { let dev = I2cdev::new("/dev/i2c-1").unwrap(); diff --git a/examples/all_channels.rs b/examples/all_channels.rs index be016e8..888737c 100644 --- a/examples/all_channels.rs +++ b/examples/all_channels.rs @@ -1,12 +1,8 @@ -extern crate embedded_hal; use embedded_hal::adc::OneShot; -extern crate linux_embedded_hal; -#[macro_use(block)] -extern crate nb; -extern crate ads1x1x; +use linux_embedded_hal::I2cdev; +use nb::block; use ads1x1x::{channel, Ads1x1x, SlaveAddr}; -use linux_embedded_hal::I2cdev; fn main() { let dev = I2cdev::new("/dev/i2c-1").unwrap(); diff --git a/examples/linux.rs b/examples/linux.rs index d0b2bc5..7364816 100644 --- a/examples/linux.rs +++ b/examples/linux.rs @@ -1,12 +1,8 @@ -extern crate embedded_hal; use embedded_hal::adc::OneShot; -extern crate linux_embedded_hal; -#[macro_use(block)] -extern crate nb; -extern crate ads1x1x; +use linux_embedded_hal::I2cdev; +use nb::block; use ads1x1x::{channel, Ads1x1x, SlaveAddr}; -use linux_embedded_hal::I2cdev; fn main() { let dev = I2cdev::new("/dev/i2c-1").unwrap(); diff --git a/examples/typed.rs b/examples/typed.rs index 22a2212..61268cf 100644 --- a/examples/typed.rs +++ b/examples/typed.rs @@ -1,15 +1,10 @@ // This example demonstrates the use of a type alias for the `Ads1x1x` struct // to ease usage in signatures. -#[macro_use(block)] -extern crate nb; - -extern crate embedded_hal; use embedded_hal::adc::OneShot; -extern crate linux_embedded_hal; use linux_embedded_hal::I2cdev; +use nb::block; -extern crate ads1x1x; use ads1x1x::{ channel::SingleA0, ic::{Ads1115, Resolution16Bit}, diff --git a/src/channels.rs b/src/channels.rs index 90b9b5d..c0f0ff9 100644 --- a/src/channels.rs +++ b/src/channels.rs @@ -1,5 +1,6 @@ //! ADC input channels -use {hal, ic, Ads1x1x, BitFlags as BF, Config}; +use crate::{ic, Ads1x1x, BitFlags as BF, Config}; +use embedded_hal::adc; /// ADC input channel selection #[allow(dead_code)] @@ -36,7 +37,7 @@ pub enum ChannelSelection { macro_rules! impl_channel { ( $IC:ident, $CH:ident ) => { - impl<DI, CONV, MODE> hal::adc::Channel<Ads1x1x<DI, ic::$IC, CONV, MODE>> for channel::$CH { + impl<DI, CONV, MODE> adc::Channel<Ads1x1x<DI, ic::$IC, CONV, MODE>> for channel::$CH { type ID = ChannelSelection; fn channel() -> Self::ID { diff --git a/src/construction.rs b/src/construction.rs index 61abb06..e217c85 100644 --- a/src/construction.rs +++ b/src/construction.rs @@ -1,10 +1,11 @@ //! Constructor/destructor functions. -extern crate embedded_hal as hal; +use crate::{ + ic, interface::I2cInterface, mode, Ads1x1x, Config, FullScaleRange, SlaveAddr, + DEVICE_BASE_ADDRESS, +}; use core::marker::PhantomData; -use hal::blocking; -use interface::I2cInterface; -use {ic, mode, Ads1x1x, Config, FullScaleRange, SlaveAddr, DEVICE_BASE_ADDRESS}; +use embedded_hal::blocking; macro_rules! impl_new_destroy { ( $IC:ident, $create:ident, $destroy:ident, $conv:ty ) => { diff --git a/src/conversion.rs b/src/conversion.rs index 2be9f1e..d6aea82 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -1,4 +1,4 @@ -use {ic, private, Error}; +use crate::{ic, private, Error}; #[doc(hidden)] pub trait ConvertThreshold<E>: private::Sealed { diff --git a/src/devices/common.rs b/src/devices/common.rs index 57d67b9..2234d93 100644 --- a/src/devices/common.rs +++ b/src/devices/common.rs @@ -1,7 +1,6 @@ //! Common functions -use super::OperatingMode; -use {interface, Ads1x1x, BitFlags, Config, Error, Register}; +use crate::{devices::OperatingMode, interface, Ads1x1x, BitFlags, Config, Error, Register}; impl<DI, IC, CONV, MODE, E> Ads1x1x<DI, IC, CONV, MODE> where diff --git a/src/devices/features/tier1.rs b/src/devices/features/tier1.rs index 9e5cb77..0c940ee 100644 --- a/src/devices/features/tier1.rs +++ b/src/devices/features/tier1.rs @@ -1,6 +1,8 @@ //! Common functions -use {ic, interface, Ads1x1x, BitFlags as BF, DataRate12Bit, DataRate16Bit, Error, Register}; +use crate::{ + ic, interface, Ads1x1x, BitFlags as BF, DataRate12Bit, DataRate16Bit, Error, Register, +}; impl<DI, IC, MODE, E> Ads1x1x<DI, IC, ic::Resolution12Bit, MODE> where @@ -8,7 +10,7 @@ where { /// Set data rate pub fn set_data_rate(&mut self, rate: DataRate12Bit) -> Result<(), Error<E>> { - use DataRate12Bit as DR; + use crate::DataRate12Bit as DR; let cfg = self.config.clone(); let config = match rate { DR::Sps128 => cfg.with_low(BF::DR2).with_low(BF::DR1).with_low(BF::DR0), @@ -31,7 +33,7 @@ where { /// Set data rate pub fn set_data_rate(&mut self, rate: DataRate16Bit) -> Result<(), Error<E>> { - use DataRate16Bit as DR; + use crate::DataRate16Bit as DR; let cfg = self.config.clone(); let config = match rate { DR::Sps8 => cfg.with_low(BF::DR2).with_low(BF::DR1).with_low(BF::DR0), diff --git a/src/devices/features/tier2.rs b/src/devices/features/tier2.rs index 0b0b92c..96330a0 100644 --- a/src/devices/features/tier2.rs +++ b/src/devices/features/tier2.rs @@ -2,7 +2,7 @@ //! //! These are the features included only in ADS1x14, ADS1x15 -use { +use crate::{ conversion, ic, interface, Ads1x1x, BitFlags as BF, ComparatorLatching, ComparatorMode, ComparatorPolarity, ComparatorQueue, Error, FullScaleRange, Register, }; @@ -17,7 +17,7 @@ where /// /// This configures the programmable gain amplifier and determines the measurable input voltage range. pub fn set_full_scale_range(&mut self, range: FullScaleRange) -> Result<(), Error<E>> { - use FullScaleRange as FSR; + use crate::FullScaleRange as FSR; let cfg = self.config.clone(); let config = match range { FSR::Within6_144V => cfg.with_low(BF::PGA2).with_low(BF::PGA1).with_low(BF::PGA0), diff --git a/src/devices/mode/continuous.rs b/src/devices/mode/continuous.rs index 29471de..d2955aa 100644 --- a/src/devices/mode/continuous.rs +++ b/src/devices/mode/continuous.rs @@ -1,9 +1,10 @@ //! Continuous measurement mode -use super::super::OperatingMode; -use channels::ChannelSelection; +use crate::{ + channels::ChannelSelection, conversion, devices::OperatingMode, hal, interface, mode, Ads1x1x, + Error, ModeChangeError, Register, +}; use core::marker::PhantomData; -use {conversion, hal, interface, mode, Ads1x1x, Error, ModeChangeError, Register}; impl<DI, IC, CONV, E> Ads1x1x<DI, IC, CONV, mode::Continuous> where diff --git a/src/devices/mode/oneshot.rs b/src/devices/mode/oneshot.rs index 5901292..579c2fb 100644 --- a/src/devices/mode/oneshot.rs +++ b/src/devices/mode/oneshot.rs @@ -1,10 +1,11 @@ //! Common functions - -use super::super::OperatingMode; -use channels::ChannelSelection; +use crate::{ + channels::ChannelSelection, conversion, devices::OperatingMode, interface, mode, Ads1x1x, + BitFlags, Config, Error, ModeChangeError, Register, +}; use core::marker::PhantomData; -use {conversion, hal, interface, nb}; -use {mode, Ads1x1x, BitFlags, Config, Error, ModeChangeError, Register}; +use embedded_hal::adc; +use nb; impl<DI, IC, CONV, E> Ads1x1x<DI, IC, CONV, mode::OneShot> where @@ -35,12 +36,12 @@ where } } -impl<DI, IC, CONV, E, CH> hal::adc::OneShot<Ads1x1x<DI, IC, CONV, mode::OneShot>, i16, CH> +impl<DI, IC, CONV, E, CH> adc::OneShot<Ads1x1x<DI, IC, CONV, mode::OneShot>, i16, CH> for Ads1x1x<DI, IC, CONV, mode::OneShot> where DI: interface::ReadData<Error = E> + interface::WriteData<Error = E>, CONV: conversion::ConvertMeasurement, - CH: hal::adc::Channel<Ads1x1x<DI, IC, CONV, mode::OneShot>, ID = ChannelSelection>, + CH: adc::Channel<Ads1x1x<DI, IC, CONV, mode::OneShot>, ID = ChannelSelection>, { type Error = Error<E>; @@ -1,5 +1,5 @@ /// ICs -use private; +use crate::private; pub struct Resolution12Bit(pub(crate) ()); pub struct Resolution16Bit(pub(crate) ()); diff --git a/src/interface.rs b/src/interface.rs index cf61b9b..960c7ef 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -1,8 +1,7 @@ //! I2C interface -extern crate embedded_hal as hal; -use hal::blocking; -use {private, Error}; +use crate::{private, Error}; +use embedded_hal::blocking; /// I2C interface #[derive(Debug, Default)] @@ -87,12 +87,11 @@ //! ### Create a driver instance for the ADS1013 //! //! ```no_run -//! extern crate linux_embedded_hal as hal; -//! extern crate ads1x1x; -//! use ads1x1x::{ Ads1x1x, SlaveAddr }; +//! use linux_embedded_hal::I2cdev; +//! use ads1x1x::{Ads1x1x, SlaveAddr}; //! //! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let address = SlaveAddr::default(); //! let adc = Ads1x1x::new_ads1013(dev, address); //! // do something... @@ -105,12 +104,11 @@ //! ### Create a driver instance for the ADS1013 with an alternative address //! //! ```no_run -//! extern crate linux_embedded_hal as hal; -//! extern crate ads1x1x; -//! use ads1x1x::{ Ads1x1x, SlaveAddr }; +//! use linux_embedded_hal::I2cdev; +//! use ads1x1x::{Ads1x1x, SlaveAddr}; //! //! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let (a1, a0) = (true, false); //! let address = SlaveAddr::Alternative(a1, a0); //! let adc = Ads1x1x::new_ads1013(dev, address); @@ -119,15 +117,10 @@ //! //! ### Make a one-shot measurement //! ```no_run -//! extern crate embedded_hal; +//! use ads1x1x::{channel, Ads1x1x, SlaveAddr}; //! use embedded_hal::adc::OneShot; -//! extern crate linux_embedded_hal; -//! #[macro_use(block)] -//! extern crate nb; -//! extern crate ads1x1x; -//! //! use linux_embedded_hal::I2cdev; -//! use ads1x1x::{ Ads1x1x, SlaveAddr, channel }; +//! use nb::block; //! //! # fn main() { //! let dev = I2cdev::new("/dev/i2c-1").unwrap(); @@ -144,12 +137,11 @@ //! In this case, you can retrieve the unchanged device from the error type. //! //! ```no_run -//! extern crate linux_embedded_hal as hal; -//! extern crate ads1x1x; -//! use ads1x1x::{ Ads1x1x, SlaveAddr, ModeChangeError }; +//! use linux_embedded_hal::I2cdev; +//! use ads1x1x::{Ads1x1x, ModeChangeError, SlaveAddr}; //! //! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let address = SlaveAddr::default(); //! let adc = Ads1x1x::new_ads1013(dev, address); //! match adc.into_continuous() { @@ -168,12 +160,11 @@ //! For 16-bit devices, the available data rates are given by `DataRate16Bit`. //! //! ```no_run -//! extern crate linux_embedded_hal as hal; -//! extern crate ads1x1x; -//! use ads1x1x::{ Ads1x1x, SlaveAddr, DataRate16Bit }; +//! use linux_embedded_hal::I2cdev; +//! use ads1x1x::{Ads1x1x, DataRate16Bit, SlaveAddr}; //! //! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let address = SlaveAddr::default(); //! let mut adc = Ads1x1x::new_ads1115(dev, address); //! adc.set_data_rate(DataRate16Bit::Sps860).unwrap(); @@ -188,13 +179,14 @@ //! the master. //! //! ```no_run -//! extern crate linux_embedded_hal as hal; -//! extern crate ads1x1x; -//! use ads1x1x::{ Ads1x1x, SlaveAddr, ComparatorQueue, ComparatorPolarity, -//! ComparatorMode, ComparatorLatching, FullScaleRange }; +//! use linux_embedded_hal::I2cdev; +//! use ads1x1x::{ +//! Ads1x1x, SlaveAddr, ComparatorQueue, ComparatorPolarity, +//! ComparatorMode, ComparatorLatching, FullScaleRange +//! }; //! //! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let address = SlaveAddr::default(); //! let mut adc = Ads1x1x::new_ads1015(dev, address); //! adc.set_comparator_queue(ComparatorQueue::Two).unwrap(); @@ -472,12 +464,12 @@ mod channels; pub mod ic; #[doc(hidden)] pub mod interface; -pub use channels::channel; +pub use crate::channels::channel; mod construction; mod conversion; mod devices; -pub use conversion::ConvertMeasurement; -pub use conversion::ConvertThreshold; +pub use crate::conversion::ConvertMeasurement; +pub use crate::conversion::ConvertThreshold; mod private { use super::{ic, interface}; diff --git a/tests/construction.rs b/tests/construction.rs index f31ad2f..6d56526 100644 --- a/tests/construction.rs +++ b/tests/construction.rs @@ -1,5 +1,5 @@ mod common; -use common::{ +use crate::common::{ destroy_ads1013, destroy_ads1014, destroy_ads1015, destroy_ads1113, destroy_ads1114, destroy_ads1115, new_ads1013, new_ads1014, new_ads1015, new_ads1113, new_ads1114, new_ads1115, }; diff --git a/tests/mux.rs b/tests/mux.rs index 309656e..b539ebe 100644 --- a/tests/mux.rs +++ b/tests/mux.rs @@ -1,13 +1,9 @@ -#[macro_use(block)] -extern crate nb; -extern crate embedded_hal; -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -extern crate ads1x1x; use ads1x1x::channel; +use embedded_hal_mock::i2c::Transaction as I2cTrans; +use nb::block; mod common; -use common::{ +use crate::common::{ destroy_ads1015 as destroy, new_ads1015 as new, BitFlags as BF, Config, Register, DEVICE_ADDRESS as DEV_ADDR, }; diff --git a/tests/tier1.rs b/tests/tier1.rs index 89a60e0..1f1a542 100644 --- a/tests/tier1.rs +++ b/tests/tier1.rs @@ -1,13 +1,9 @@ -#[macro_use(block)] -extern crate nb; -extern crate embedded_hal; -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -extern crate ads1x1x; use ads1x1x::{channel, DataRate12Bit, DataRate16Bit}; +use embedded_hal_mock::i2c::Transaction as I2cTrans; +use nb::block; mod common; -use common::{ +use crate::common::{ destroy_ads1013, destroy_ads1113, new_ads1013, new_ads1113, BitFlags as BF, Config, Register, DEVICE_ADDRESS as DEV_ADDR, }; diff --git a/tests/tier2.rs b/tests/tier2.rs index e42a348..15a7865 100644 --- a/tests/tier2.rs +++ b/tests/tier2.rs @@ -1,12 +1,10 @@ -extern crate embedded_hal_mock; -use embedded_hal_mock::i2c::Transaction as I2cTrans; -extern crate ads1x1x; use ads1x1x::{ ComparatorLatching, ComparatorMode, ComparatorPolarity, ComparatorQueue, FullScaleRange, }; +use embedded_hal_mock::i2c::Transaction as I2cTrans; mod common; -use common::{ +use crate::common::{ destroy_ads1014, new_ads1014, BitFlags as BF, Config, Register, DEVICE_ADDRESS as DEV_ADDR, }; |