Skip to content

Commit

Permalink
The i2c module requires an io-* feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Mar 28, 2020
1 parent 47c2ece commit 2f0109f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,13 @@ required-features = ["rt"]
name = "flash"
required-features = ["rt","stm32l082"]

[[example]]
name = "i2c"
required-features = ["rt","stm32l0x2","io-STM32L071"]

[[example]]
name = "i2c_dma"
required-features = ["rt","stm32l0x2"]
required-features = ["rt","stm32l0x2","io-STM32L071"]

[[example]]
name = "rng"
Expand Down
18 changes: 14 additions & 4 deletions src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ use as_slice::AsSlice;

use crate::{
adc,
i2c,
pac::{
self,
dma1::ch::cr,
I2C1,
I2C2,
I2C3,
USART1,
USART2,
},
rcc::Rcc,
serial,
};

#[cfg(any(
feature = "io-STM32L021",
feature = "io-STM32L031",
feature = "io-STM32L051",
feature = "io-STM32L071",
))]
use crate::{i2c, pac::{I2C1, I2C2, I2C3}};

#[cfg(feature = "stm32l082")]
use crate::aes;

Expand Down Expand Up @@ -536,6 +540,12 @@ impl_target!(
);

#[cfg(feature = "stm32l0x2")]
#[cfg(any(
feature = "io-STM32L021",
feature = "io-STM32L031",
feature = "io-STM32L051",
feature = "io-STM32L071",
))]
impl_target!(
// I2C1
i2c::Tx<I2C1>, Channel2, 6;
Expand Down
4 changes: 3 additions & 1 deletion src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use as_slice::{
AsMutSlice,
};

use crate::hal::blocking::i2c::{Read, Write, WriteRead};

#[cfg(feature = "stm32l0x2")]
use crate::dma::{
Expand All @@ -32,6 +31,9 @@ use crate::rcc::Rcc;
use crate::time::Hertz;
use cast::u8;

// I²C traits
use crate::hal::blocking::i2c::{Read, Write, WriteRead};

// I/O Imports
use crate::gpio::{AltMode, OpenDrain, Output};
#[cfg(feature = "io-STM32L021")]
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ pub mod exti;
#[cfg(feature = "stm32l0x2")]
pub mod flash;
pub mod gpio;
#[cfg(any(
feature = "io-STM32L021",
feature = "io-STM32L031",
feature = "io-STM32L051",
feature = "io-STM32L071",
))]
pub mod i2c;
pub mod lptim;
pub mod prelude;
Expand Down
9 changes: 8 additions & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub use crate::{
adc::AdcExt as _,
delay::DelayExt as _,
gpio::GpioExt as _,
i2c::I2cExt as _,
pwr::PowerMode as _,
rcc::RccExt as _,
serial::{
Expand All @@ -28,3 +27,11 @@ pub use crate::{
WindowWatchdogExt as _,
},
};

#[cfg(any(
feature = "io-STM32L021",
feature = "io-STM32L031",
feature = "io-STM32L051",
feature = "io-STM32L071",
))]
pub use crate::i2c::I2cExt as _;

0 comments on commit 2f0109f

Please sign in to comment.