diff --git a/Cargo.toml b/Cargo.toml index f5dd873..49bd9c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ include = [ "/LICENSE-MIT", "/LICENSE-APACHE", ] +edition = "2018" [badges] travis-ci = { repository = "eldruin/ds323x-rs", branch = "master" } diff --git a/README.md b/README.md index 692a01a..a140f24 100644 --- a/README.md +++ b/README.md @@ -137,12 +137,11 @@ Please find additional examples using hardware in this repository: [driver-examp [driver-examples]: https://github.com/eldruin/driver-examples ```rust -extern crate ds323x; -extern crate linux_embedded_hal as hal; use ds323x::{Ds323x, NaiveDate, Rtcc}; +use linux_embedded_hal::I2cdev; fn main() { - let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); + let dev = I2cdev::new("/dev/i2c-1").unwrap(); let mut rtc = Ds323x::new_ds3231(dev); let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58); rtc.set_datetime(&datetime).unwrap(); diff --git a/examples/linux.rs b/examples/linux.rs index 0a02e0d..fc342e6 100644 --- a/examples/linux.rs +++ b/examples/linux.rs @@ -1,9 +1,8 @@ -extern crate ds323x; -extern crate linux_embedded_hal as hal; use ds323x::{Ds323x, NaiveDate, Rtcc}; +use linux_embedded_hal::I2cdev; fn main() { - let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); + let dev = I2cdev::new("/dev/i2c-1").unwrap(); let mut rtc = Ds323x::new_ds3231(dev); let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58); rtc.set_datetime(&datetime).unwrap(); diff --git a/src/ds3231.rs b/src/ds3231.rs index b013ede..21fb176 100644 --- a/src/ds3231.rs +++ b/src/ds3231.rs @@ -1,13 +1,12 @@ //! Functions exclusive of DS3231 -use super::{ic, BitFlags, Ds323x, CONTROL_POR_VALUE}; +use crate::{ic, interface::I2cInterface, BitFlags, Ds323x, CONTROL_POR_VALUE}; use core::marker::PhantomData; -use hal::blocking; -use interface::I2cInterface; +use embedded_hal::blocking::i2c; impl Ds323x, ic::DS3231> where - I2C: blocking::i2c::Write + blocking::i2c::WriteRead, + I2C: i2c::Write + i2c::WriteRead, { /// Create a new instance of the DS3231 device. pub fn new_ds3231(i2c: I2C) -> Self { diff --git a/src/ds3232.rs b/src/ds3232.rs index db7ae06..1d24669 100644 --- a/src/ds3232.rs +++ b/src/ds3232.rs @@ -1,13 +1,14 @@ //! Functions exclusive of DS3232 -use super::{ic, BitFlags, Ds323x, Error, TempConvRate, CONTROL_POR_VALUE}; +use crate::{ + ic, interface::I2cInterface, BitFlags, Ds323x, Error, TempConvRate, CONTROL_POR_VALUE, +}; use core::marker::PhantomData; -use hal::blocking; -use interface::I2cInterface; +use embedded_hal::blocking::i2c; impl Ds323x, ic::DS3232> where - I2C: blocking::i2c::Write + blocking::i2c::WriteRead, + I2C: i2c::Write + i2c::WriteRead, { /// Create a new instance of the DS3232 device. pub fn new_ds3232(i2c: I2C) -> Self { diff --git a/src/ds3234.rs b/src/ds3234.rs index 95e2504..c5f0dfd 100644 --- a/src/ds3234.rs +++ b/src/ds3234.rs @@ -1,13 +1,13 @@ //! Functions exclusive of DS3234 -use super::{ic, BitFlags, Ds323x, Error, Register, TempConvRate, CONTROL_POR_VALUE}; +use crate::interface::{SpiInterface, WriteData}; +use crate::{ic, BitFlags, Ds323x, Error, Register, TempConvRate, CONTROL_POR_VALUE}; use core::marker::PhantomData; -use hal::blocking; -use interface::{SpiInterface, WriteData}; +use embedded_hal::{blocking::spi, digital::v2::OutputPin}; impl Ds323x, ic::DS3234> where - SPI: blocking::spi::Transfer + blocking::spi::Write, - CS: hal::digital::v2::OutputPin, + SPI: spi::Transfer + spi::Write, + CS: OutputPin, { /// Create a new instance. pub fn new_ds3234(spi: SPI, chip_select: CS) -> Self { diff --git a/src/ds323x/alarms.rs b/src/ds323x/alarms.rs index 7c5b892..20e29c4 100644 --- a/src/ds323x/alarms.rs +++ b/src/ds323x/alarms.rs @@ -1,9 +1,11 @@ //! Alarm support -use super::super::{BitFlags, Ds323x, Error, Hours, Register}; use super::{decimal_to_packed_bcd, hours_to_register}; -use crate::ds323x::{NaiveTime, Timelike}; -use interface::{ReadData, WriteData}; +use crate::{ + ds323x::{NaiveTime, Timelike}, + interface::{ReadData, WriteData}, + BitFlags, Ds323x, Error, Hours, Register, +}; /// Parameters for setting Alarm1 on a day of the month /// diff --git a/src/ds323x/configuration.rs b/src/ds323x/configuration.rs index 5f7b0f9..4c4912c 100644 --- a/src/ds323x/configuration.rs +++ b/src/ds323x/configuration.rs @@ -1,7 +1,9 @@ //! Device configuration -use super::super::{BitFlags, Ds323x, Error, Register, SqWFreq}; -use interface::{ReadData, WriteData}; +use crate::{ + interface::{ReadData, WriteData}, + BitFlags, Ds323x, Error, Register, SqWFreq, +}; impl Ds323x where diff --git a/src/ds323x/datetime.rs b/src/ds323x/datetime.rs index d9620e1..a54d999 100644 --- a/src/ds323x/datetime.rs +++ b/src/ds323x/datetime.rs @@ -1,9 +1,11 @@ //! Common implementation -use super::super::{BitFlags, Ds323x, Error, Register}; use super::{decimal_to_packed_bcd, hours_to_register, packed_bcd_to_decimal}; -use super::{Datelike, Hours, NaiveDate, NaiveDateTime, NaiveTime, Rtcc, Timelike}; -use interface::{ReadData, WriteData}; +use crate::{ + interface::{ReadData, WriteData}, + BitFlags, Datelike, Ds323x, Error, Hours, NaiveDate, NaiveDateTime, NaiveTime, Register, Rtcc, + Timelike, +}; impl Rtcc for Ds323x where diff --git a/src/ds323x/mod.rs b/src/ds323x/mod.rs index b398f8b..1a8ea3c 100644 --- a/src/ds323x/mod.rs +++ b/src/ds323x/mod.rs @@ -5,8 +5,7 @@ pub use self::alarms::{ Alarm1Matching, Alarm2Matching, DayAlarm1, DayAlarm2, WeekdayAlarm1, WeekdayAlarm2, }; mod datetime; -use super::{BitFlags, Error}; -use super::{Datelike, Hours, NaiveDate, NaiveDateTime, NaiveTime, Rtcc, Timelike}; +use crate::{BitFlags, Error, Hours, NaiveTime, Timelike}; // Transforms a decimal number to packed BCD format fn decimal_to_packed_bcd(dec: u8) -> u8 { diff --git a/src/ds323x/status.rs b/src/ds323x/status.rs index a3ce40e..3da5988 100644 --- a/src/ds323x/status.rs +++ b/src/ds323x/status.rs @@ -1,7 +1,9 @@ //! Device status -use super::super::{BitFlags, Ds323x, Error, Register}; -use interface::{ReadData, WriteData}; +use crate::{ + interface::{ReadData, WriteData}, + BitFlags, Ds323x, Error, Register, +}; impl Ds323x where diff --git a/src/interface.rs b/src/interface.rs index 74f2352..e507d89 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -1,7 +1,10 @@ //! I2C/SPI interfaces -use super::{private, Error, DEVICE_ADDRESS}; -use hal::blocking; +use crate::{private, Error, DEVICE_ADDRESS}; +use embedded_hal::{ + blocking::{i2c, spi}, + digital::v2::OutputPin, +}; /// I2C interface #[derive(Debug, Default)] @@ -28,7 +31,7 @@ pub trait WriteData: private::Sealed { impl WriteData for I2cInterface where - I2C: blocking::i2c::Write, + I2C: i2c::Write, { type Error = Error; fn write_register(&mut self, register: u8, data: u8) -> Result<(), Self::Error> { @@ -47,8 +50,8 @@ where impl WriteData for SpiInterface where - SPI: blocking::spi::Write, - CS: hal::digital::v2::OutputPin, + SPI: spi::Write, + CS: OutputPin, { type Error = Error; fn write_register(&mut self, register: u8, data: u8) -> Result<(), Self::Error> { @@ -83,7 +86,7 @@ pub trait ReadData: private::Sealed { impl ReadData for I2cInterface where - I2C: blocking::i2c::WriteRead, + I2C: i2c::WriteRead, { type Error = Error; fn read_register(&mut self, register: u8) -> Result { @@ -104,8 +107,8 @@ where impl ReadData for SpiInterface where - SPI: blocking::spi::Transfer, - CS: hal::digital::v2::OutputPin, + SPI: spi::Transfer, + CS: OutputPin, { type Error = Error; fn read_register(&mut self, register: u8) -> Result { diff --git a/src/lib.rs b/src/lib.rs index c483b75..20b5b7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,84 +155,69 @@ //! ### Create a driver instance for the DS3231 //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let rtc = Ds323x::new_ds3231(dev); //! // do something... //! //! // get the I2C device back //! let dev = rtc.destroy_ds3231(); -//! # } //! ``` //! //! ### Create a driver instance for the DS3232 //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let rtc = Ds323x::new_ds3232(dev); //! // do something... //! //! // get the I2C device back //! let dev = rtc.destroy_ds3232(); -//! # } //! ``` //! //! ### Create a driver instance for the DS3234 //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::{Pin, Spidev}; //! -//! # fn main() { -//! let dev = hal::Spidev::open("/dev/spidev0.0").unwrap(); -//! let chip_select = hal::Pin::new(24); +//! let dev = Spidev::open("/dev/spidev0.0").unwrap(); +//! let chip_select = Pin::new(24); //! let rtc = Ds323x::new_ds3234(dev, chip_select); //! // do something... //! //! // get the SPI device and chip select pin back //! let (dev, chip_select) = rtc.destroy_ds3234(); -//! # } //! ``` //! //! ### Set the current date and time at once //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, NaiveDate, Rtcc}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let datetime = NaiveDate::from_ymd(2020, 5, 1).and_hms(19, 59, 58); //! rtc.set_datetime(&datetime).unwrap(); -//! # } //! ``` //! //! ### Get the current date and time at once //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, Rtcc}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let dt = rtc.get_datetime().unwrap(); //! println!("{}", dt); //! // This will print something like: 2020-05-01 19:59:58 -//! # } //! ``` //! //! ### Get the year @@ -240,16 +225,13 @@ //! Similar methods exist for month, day, weekday, hours, minutes and seconds. //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, Rtcc}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let year = rtc.get_year().unwrap(); //! println!("Year: {}", year); -//! # } //! ``` //! //! ### Set the year @@ -257,78 +239,63 @@ //! Similar methods exist for month, day, weekday, hours, minutes and seconds. //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, Rtcc}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! rtc.set_year(2018).unwrap(); -//! # } //! ``` //! //! ### Enable/disable the device //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! rtc.disable().unwrap(); // stops the clock //! let running = rtc.running().unwrap(); //! println!("Is running: {}", running); // will print false //! rtc.enable().unwrap(); // set clock to run //! println!("Is running: {}", running); // will print true -//! # } //! ``` //! //! ### Read the temperature //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let temperature = rtc.get_temperature().unwrap(); -//! # } //! ``` //! //! ### Read busy status //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let busy = rtc.busy().unwrap(); -//! # } //! ``` //! //! ### Enable the square-wave output with a frequency of 4.096Hz //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, SqWFreq}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! rtc.set_square_wave_frequency(SqWFreq::_4_096Hz).unwrap(); //! // The same output pin can be used for interrupts or as square-wave output //! rtc.use_int_sqw_output_as_square_wave().unwrap(); //! rtc.enable_square_wave().unwrap(); -//! # } //! ``` //! //! ### Enable the 32kHz output except when on battery power @@ -337,30 +304,24 @@ //! available for the devices DS3232 and DS3234. //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, SqWFreq}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3232(dev); //! rtc.disable_32khz_output_on_battery().unwrap(); // only available for DS3232 and DS3234 //! rtc.enable_32khz_output().unwrap(); -//! # } //! ``` //! //! ### Set the aging offset //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::Ds323x; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! rtc.set_aging_offset(-15).unwrap(); -//! # } //! ``` //! //! ### Set the temperature conversion rate to once every 128 seconds @@ -368,26 +329,21 @@ //! This is only available for the devices DS3232 and DS3234. //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, TempConvRate}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3232(dev); //! rtc.set_temperature_conversion_rate(TempConvRate::_128s).unwrap(); -//! # } //! ``` //! //! ### Set the Alarm1 to each week on a week day at a specific time //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, Hours, WeekdayAlarm1, Alarm1Matching}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let alarm1 = WeekdayAlarm1 { //! weekday: 1, @@ -396,7 +352,6 @@ //! second: 15 //! }; //! rtc.set_alarm1_weekday(alarm1, Alarm1Matching::AllMatch).unwrap(); -//! # } //! ``` //! //! ### Set the Alarm2 to each day at the same time and enable interrupts on output @@ -404,12 +359,10 @@ //! The INT/SQW output pin will be set to 1 when it the alarm matches. //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, Hours, DayAlarm2, Alarm2Matching}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let alarm2 = DayAlarm2 { //! day: 1, // does not matter given the chosen matching @@ -419,32 +372,26 @@ //! rtc.set_alarm2_day(alarm2, Alarm2Matching::HoursAndMinutesMatch).unwrap(); //! rtc.use_int_sqw_output_as_interrupt().unwrap(); //! rtc.enable_alarm2_interrupts().unwrap(); -//! # } //! ``` //! //! ### Set the Alarm1 to a specific time //! //! ```no_run -//! extern crate ds323x; -//! extern crate linux_embedded_hal as hal; //! use ds323x::{Ds323x, Hours, NaiveTime}; +//! use linux_embedded_hal::I2cdev; //! -//! # fn main() { -//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let dev = I2cdev::new("/dev/i2c-1").unwrap(); //! let mut rtc = Ds323x::new_ds3231(dev); //! let time = NaiveTime::from_hms(19, 59, 58); //! rtc.set_alarm1_hms(time).unwrap(); -//! # } //! ``` #![deny(unsafe_code, missing_docs)] #![no_std] -extern crate embedded_hal as hal; use core::marker::PhantomData; -use hal::spi::{Mode, MODE_1, MODE_3}; -extern crate rtcc; -pub use self::rtcc::{Datelike, Hours, NaiveDate, NaiveDateTime, NaiveTime, Rtcc, Timelike}; +use embedded_hal::spi::{Mode, MODE_1, MODE_3}; +pub use rtcc::{Datelike, Hours, NaiveDate, NaiveDateTime, NaiveTime, Rtcc, Timelike}; /// SPI mode 1 (CPOL = 0, CPHA = 1) pub const SPI_MODE_1: Mode = MODE_1; @@ -560,7 +507,7 @@ pub struct Ds323x { mod ds323x; pub mod interface; -pub use ds323x::{ +pub use crate::ds323x::{ Alarm1Matching, Alarm2Matching, DayAlarm1, DayAlarm2, WeekdayAlarm1, WeekdayAlarm2, }; mod ds3231; diff --git a/tests/alarms.rs b/tests/alarms.rs index a2565ba..e88bca1 100644 --- a/tests/alarms.rs +++ b/tests/alarms.rs @@ -1,12 +1,9 @@ -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -use hal::spi::Transaction as SpiTrans; +use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans}; mod common; use common::{ destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234, BitFlags as BF, Register, DEVICE_ADDRESS as DEV_ADDR, }; -extern crate ds323x; use ds323x::{ Alarm1Matching as A1M, Alarm2Matching as A2M, DayAlarm1, DayAlarm2, Error, Hours, NaiveTime, WeekdayAlarm1, WeekdayAlarm2, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 6121a63..5a4f31a 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,9 +1,8 @@ -extern crate ds323x; -extern crate embedded_hal; -use self::ds323x::{ic, interface, Ds323x}; -extern crate embedded_hal_mock as hal; -use self::hal::i2c::{Mock as I2cMock, Transaction as I2cTrans}; -use self::hal::spi::{Mock as SpiMock, Transaction as SpiTrans}; +use ds323x::{ic, interface, Ds323x}; +use embedded_hal_mock::{ + i2c::{Mock as I2cMock, Transaction as I2cTrans}, + spi::{Mock as SpiMock, Transaction as SpiTrans}, +}; #[allow(unused)] pub const DEVICE_ADDRESS: u8 = 0b110_1000; diff --git a/tests/configuration.rs b/tests/configuration.rs index 6b0c8de..8af0e5d 100644 --- a/tests/configuration.rs +++ b/tests/configuration.rs @@ -1,9 +1,5 @@ -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -use hal::spi::Transaction as SpiTrans; - -extern crate ds323x; use ds323x::SqWFreq; +use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans}; mod common; use common::{ diff --git a/tests/datetime.rs b/tests/datetime.rs index 05a7b53..5be163b 100644 --- a/tests/datetime.rs +++ b/tests/datetime.rs @@ -1,12 +1,9 @@ -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -use hal::spi::Transaction as SpiTrans; +use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans}; mod common; use common::{ destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234, Register, DEVICE_ADDRESS as DEV_ADDR, }; -extern crate ds323x; #[allow(unused)] // Rust 1.31.0 is confused due to the macros use ds323x::Rtcc; use ds323x::{Error, Hours, NaiveDate, NaiveTime}; diff --git a/tests/ds3232_4.rs b/tests/ds3232_4.rs index 1a69479..ca405f9 100644 --- a/tests/ds3232_4.rs +++ b/tests/ds3232_4.rs @@ -1,9 +1,5 @@ -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -use hal::spi::Transaction as SpiTrans; - -extern crate ds323x; use ds323x::TempConvRate; +use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans}; #[allow(unused)] mod common; diff --git a/tests/ds3234.rs b/tests/ds3234.rs index 810eec1..a14dbd7 100644 --- a/tests/ds3234.rs +++ b/tests/ds3234.rs @@ -1,5 +1,4 @@ -extern crate embedded_hal_mock as hal; -use hal::spi::Transaction as SpiTrans; +use embedded_hal_mock::spi::Transaction as SpiTrans; #[allow(unused)] mod common; diff --git a/tests/status.rs b/tests/status.rs index 90d8a93..1d6ed9d 100644 --- a/tests/status.rs +++ b/tests/status.rs @@ -1,6 +1,4 @@ -extern crate embedded_hal_mock as hal; -use hal::i2c::Transaction as I2cTrans; -use hal::spi::Transaction as SpiTrans; +use embedded_hal_mock::{i2c::Transaction as I2cTrans, spi::Transaction as SpiTrans}; mod common; use common::{ destroy_ds3231, destroy_ds3232, destroy_ds3234, new_ds3231, new_ds3232, new_ds3234,