File tree Expand file tree Collapse file tree 5 files changed +38
-7
lines changed Expand file tree Collapse file tree 5 files changed +38
-7
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ stm32l082 = ["stm32l0x2"]
6565
6666# Features based on the GPIO peripheral version.
6767# This determines the pin function mapping of the MCU.
68+ # Note: The easiest way to pick the proper io-* feature is to apply
69+ # the matching mcu-* feature for your MCU!
6870io-STM32L021 = []
6971io-STM32L031 = []
7072io-STM32L051 = []
@@ -302,9 +304,13 @@ required-features = ["rt"]
302304name = " flash"
303305required-features = [" rt" ," stm32l082" ]
304306
307+ [[example ]]
308+ name = " i2c"
309+ required-features = [" rt" ," stm32l0x2" ," io-STM32L071" ]
310+
305311[[example ]]
306312name = " i2c_dma"
307- required-features = [" rt" ," stm32l0x2" ]
313+ required-features = [" rt" ," stm32l0x2" , " io-STM32L071 " ]
308314
309315[[example ]]
310316name = " rng"
Original file line number Diff line number Diff line change @@ -28,20 +28,24 @@ use as_slice::AsSlice;
2828
2929use crate :: {
3030 adc,
31- i2c,
3231 pac:: {
3332 self ,
3433 dma1:: ch:: cr,
35- I2C1 ,
36- I2C2 ,
37- I2C3 ,
3834 USART1 ,
3935 USART2 ,
4036 } ,
4137 rcc:: Rcc ,
4238 serial,
4339} ;
4440
41+ #[ cfg( any(
42+ feature = "io-STM32L021" ,
43+ feature = "io-STM32L031" ,
44+ feature = "io-STM32L051" ,
45+ feature = "io-STM32L071" ,
46+ ) ) ]
47+ use crate :: { i2c, pac:: { I2C1 , I2C2 , I2C3 } } ;
48+
4549#[ cfg( feature = "stm32l082" ) ]
4650use crate :: aes;
4751
@@ -536,6 +540,12 @@ impl_target!(
536540) ;
537541
538542#[ cfg( feature = "stm32l0x2" ) ]
543+ #[ cfg( any(
544+ feature = "io-STM32L021" ,
545+ feature = "io-STM32L031" ,
546+ feature = "io-STM32L051" ,
547+ feature = "io-STM32L071" ,
548+ ) ) ]
539549impl_target ! (
540550 // I2C1
541551 i2c:: Tx <I2C1 >, Channel2 , 6 ;
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ use as_slice::{
1515 AsMutSlice ,
1616} ;
1717
18- use crate :: hal:: blocking:: i2c:: { Read , Write , WriteRead } ;
1918
2019#[ cfg( feature = "stm32l0x2" ) ]
2120use crate :: dma:: {
@@ -32,6 +31,9 @@ use crate::rcc::Rcc;
3231use crate :: time:: Hertz ;
3332use cast:: u8;
3433
34+ // I²C traits
35+ use crate :: hal:: blocking:: i2c:: { Read , Write , WriteRead } ;
36+
3537// I/O Imports
3638use crate :: gpio:: { AltMode , OpenDrain , Output } ;
3739#[ cfg( feature = "io-STM32L021" ) ]
Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ pub mod exti;
2323#[ cfg( feature = "stm32l0x2" ) ]
2424pub mod flash;
2525pub mod gpio;
26+ #[ cfg( any(
27+ feature = "io-STM32L021" ,
28+ feature = "io-STM32L031" ,
29+ feature = "io-STM32L051" ,
30+ feature = "io-STM32L071" ,
31+ ) ) ]
2632pub mod i2c;
2733pub mod lptim;
2834pub mod prelude;
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ pub use crate::{
1313 adc:: AdcExt as _,
1414 delay:: DelayExt as _,
1515 gpio:: GpioExt as _,
16- i2c:: I2cExt as _,
1716 pwr:: PowerMode as _,
1817 rcc:: RccExt as _,
1918 serial:: {
@@ -28,3 +27,11 @@ pub use crate::{
2827 WindowWatchdogExt as _,
2928 } ,
3029} ;
30+
31+ #[ cfg( any(
32+ feature = "io-STM32L021" ,
33+ feature = "io-STM32L031" ,
34+ feature = "io-STM32L051" ,
35+ feature = "io-STM32L071" ,
36+ ) ) ]
37+ pub use crate :: i2c:: I2cExt as _;
You can’t perform that action at this time.
0 commit comments