Skip to content

Commit

Permalink
Improve imports
Browse files Browse the repository at this point in the history
  • Loading branch information
eldruin committed Jan 30, 2021
1 parent f82b97e commit 3b27222
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Communication interface
use super::{private, Error, DEVICE_ADDRESS, EEPROM_ADDRESS};
use crate::hal::blocking;
use crate::{private, Error, DEVICE_ADDRESS, EEPROM_ADDRESS};
use embedded_hal::blocking;

/// I2C interface
#[derive(Debug, Default)]
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,8 @@
#![deny(unsafe_code, missing_docs)]
#![no_std]

extern crate embedded_hal as hal;
extern crate rtcc;
use core::marker::PhantomData;
use embedded_hal::blocking::i2c;
pub use rtcc::{Datelike, Hours, NaiveDate, NaiveDateTime, NaiveTime, Rtcc, Timelike};

/// Feature markers
Expand Down Expand Up @@ -469,7 +468,7 @@ macro_rules! create_destroy_i2c {
($ic:ident, $create:ident) => {
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, ic::$ic>
where
I2C: hal::blocking::i2c::Write<Error = E> + hal::blocking::i2c::WriteRead<Error = E>,
I2C: i2c::Write<Error = E> + i2c::WriteRead<Error = E>,
{
/// Create a new instance of the device.
pub fn $create(i2c: I2C) -> Self {
Expand Down
4 changes: 1 addition & 3 deletions tests/alarms.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
mod common;
use crate::common::{
destroy_mcp79400, destroy_mcp79401, destroy_mcp79402, destroy_mcp7940m, destroy_mcp7940n,
destroy_mcp79410, destroy_mcp79411, destroy_mcp79412, new_mcp79400, new_mcp79401, new_mcp79402,
new_mcp7940m, new_mcp7940n, new_mcp79410, new_mcp79411, new_mcp79412, BitFlags, Register,
DEVICE_ADDRESS as DEV_ADDR,
};
extern crate mcp794xx;
use mcp794xx::{
Alarm, AlarmDateTime, AlarmMatching, AlarmOutputPinPolarity, Error, Hours, NaiveDate, Rtcc,
};
Expand Down
4 changes: 1 addition & 3 deletions tests/battery_power.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
extern crate mcp794xx;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
use mcp794xx::{Hours, PowerFailDateTime};
mod common;
use crate::common::{
Expand Down
7 changes: 2 additions & 5 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
extern crate embedded_hal;
extern crate mcp794xx;
use self::mcp794xx::{ic, interface, Mcp794xx};
extern crate embedded_hal_mock as hal;
use self::hal::i2c::{Mock as I2cMock, Transaction as I2cTrans};
use mcp794xx::{ic, interface, Mcp794xx};
use embedded_hal_mock::i2c::{Mock as I2cMock, Transaction as I2cTrans};

#[allow(unused)]
pub const DEVICE_ADDRESS: u8 = 0b1101111;
Expand Down
4 changes: 1 addition & 3 deletions tests/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
extern crate mcp794xx;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
use mcp794xx::{OutputPinLevel, SqWFreq};
mod common;
use crate::common::{
Expand Down
4 changes: 1 addition & 3 deletions tests/datetime.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
mod common;
use crate::common::{
destroy_mcp79400, destroy_mcp79401, destroy_mcp79402, destroy_mcp7940m, destroy_mcp7940n,
destroy_mcp79410, destroy_mcp79411, destroy_mcp79412, new_mcp79400, new_mcp79401, new_mcp79402,
new_mcp7940m, new_mcp7940n, new_mcp79410, new_mcp79411, new_mcp79412, BitFlags, Register,
DEVICE_ADDRESS as DEV_ADDR,
};
extern crate mcp794xx;
use mcp794xx::{Error, Hours, NaiveDate, NaiveTime, Rtcc};

macro_rules! set_invalid_param_range_test {
Expand Down
4 changes: 1 addition & 3 deletions tests/eeprom.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
extern crate mcp794xx;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
use mcp794xx::{EepromWriteProtection, Error};
mod common;
use crate::common::{
Expand Down
4 changes: 1 addition & 3 deletions tests/protected_eeprom.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
extern crate mcp794xx;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
use mcp794xx::Error;
mod common;
use crate::common::{
Expand Down
4 changes: 1 addition & 3 deletions tests/sram.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extern crate embedded_hal_mock as hal;
use crate::hal::i2c::Transaction as I2cTrans;
extern crate mcp794xx;
use embedded_hal_mock::i2c::Transaction as I2cTrans;
use mcp794xx::Error;
mod common;
use crate::common::{
Expand Down

0 comments on commit 3b27222

Please sign in to comment.