1
- #[ cfg( feature = "stm32f042" ) ]
1
+ #[ cfg( any ( feature = "stm32f042" , feature = "stm32f030" ) ) ]
2
2
use crate :: stm32:: { I2C1 , RCC } ;
3
3
4
4
use embedded_hal:: blocking:: i2c:: { Write , WriteRead } ;
5
5
6
- use core:: cmp;
7
- #[ cfg( feature = "stm32f042" ) ]
8
- use crate :: gpio:: gpioa:: { PA10 , PA11 , PA12 , PA9 } ;
9
- #[ cfg( feature = "stm32f042" ) ]
10
- use crate :: gpio:: gpiob:: { PB10 , PB11 , PB13 , PB14 , PB6 , PB7 , PB8 , PB9 } ;
11
- #[ cfg( feature = "stm32f042" ) ]
12
- use crate :: gpio:: gpiof:: { PF0 , PF1 } ;
13
- #[ cfg( feature = "stm32f042" ) ]
14
- use crate :: gpio:: { Alternate , AF1 , AF4 , AF5 } ;
6
+ use crate :: gpio:: * ;
15
7
use crate :: time:: { KiloHertz , U32Ext } ;
8
+ use core:: cmp;
16
9
17
10
/// I2C abstraction
18
11
pub struct I2c < I2C , PINS > {
@@ -22,28 +15,32 @@ pub struct I2c<I2C, PINS> {
22
15
23
16
pub trait Pins < I2c > { }
24
17
25
- #[ cfg( feature = "stm32f042" ) ]
26
- impl Pins < I2C1 > for ( PA9 < Alternate < AF4 > > , PA10 < Alternate < AF4 > > ) { }
27
- #[ cfg( feature = "stm32f042" ) ]
28
- impl Pins < I2C1 > for ( PA11 < Alternate < AF5 > > , PA12 < Alternate < AF5 > > ) { }
29
- #[ cfg( feature = "stm32f042" ) ]
30
- impl Pins < I2C1 > for ( PB6 < Alternate < AF1 > > , PB7 < Alternate < AF1 > > ) { }
31
- #[ cfg( feature = "stm32f042" ) ]
32
- impl Pins < I2C1 > for ( PB8 < Alternate < AF1 > > , PB9 < Alternate < AF1 > > ) { }
33
- #[ cfg( feature = "stm32f042" ) ]
34
- impl Pins < I2C1 > for ( PB10 < Alternate < AF1 > > , PB11 < Alternate < AF1 > > ) { }
35
- #[ cfg( feature = "stm32f042" ) ]
36
- impl Pins < I2C1 > for ( PB13 < Alternate < AF5 > > , PB14 < Alternate < AF5 > > ) { }
37
- #[ cfg( feature = "stm32f042" ) ]
38
- impl Pins < I2C1 > for ( PF1 < Alternate < AF1 > > , PF0 < Alternate < AF1 > > ) { }
18
+ #[ cfg( any(
19
+ feature = "stm32f042" ,
20
+ feature = "stm32f030x6" ,
21
+ feature = "stm32f030xc"
22
+ ) ) ]
23
+ impl Pins < I2C1 > for ( gpioa:: PA9 < Alternate < AF4 > > , gpioa:: PA10 < Alternate < AF4 > > ) { }
24
+ #[ cfg( any( feature = "stm32f042" , feature = "stm32f030" ) ) ]
25
+ impl Pins < I2C1 > for ( gpioa:: PA11 < Alternate < AF5 > > , gpioa:: PA12 < Alternate < AF5 > > ) { }
26
+ #[ cfg( any( feature = "stm32f042" , feature = "stm32f030" ) ) ]
27
+ impl Pins < I2C1 > for ( gpiob:: PB6 < Alternate < AF1 > > , gpiob:: PB7 < Alternate < AF1 > > ) { }
28
+ #[ cfg( any( feature = "stm32f042" , feature = "stm32f030" ) ) ]
29
+ impl Pins < I2C1 > for ( gpiob:: PB8 < Alternate < AF1 > > , gpiob:: PB9 < Alternate < AF1 > > ) { }
30
+ #[ cfg( any( feature = "stm32f042" , feature = "stm32f030x6" ) ) ]
31
+ impl Pins < I2C1 > for ( gpiob:: PB10 < Alternate < AF1 > > , gpiob:: PB11 < Alternate < AF1 > > ) { }
32
+ #[ cfg( any( feature = "stm32f042" , feature = "stm32f030xc" ) ) ]
33
+ impl Pins < I2C1 > for ( gpiob:: PB13 < Alternate < AF5 > > , gpiob:: PB14 < Alternate < AF5 > > ) { }
34
+ #[ cfg( any( feature = "stm32f042" , feature = "stm32f030xc" ) ) ]
35
+ impl Pins < I2C1 > for ( gpiof:: PF1 < Alternate < AF1 > > , gpiof:: PF0 < Alternate < AF1 > > ) { }
39
36
40
37
#[ derive( Debug ) ]
41
38
pub enum Error {
42
39
OVERRUN ,
43
40
NACK ,
44
41
}
45
42
46
- #[ cfg( feature = "stm32f042" ) ]
43
+ #[ cfg( any ( feature = "stm32f042" , feature = "stm32f030" ) ) ]
47
44
impl < PINS > I2c < I2C1 , PINS > {
48
45
pub fn i2c1 ( i2c : I2C1 , pins : PINS , speed : KiloHertz ) -> Self
49
46
where
@@ -136,7 +133,7 @@ impl<PINS> I2c<I2C1, PINS> {
136
133
}
137
134
}
138
135
139
- #[ cfg( feature = "stm32f042" ) ]
136
+ #[ cfg( any ( feature = "stm32f042" , feature = "stm32f030" ) ) ]
140
137
impl < PINS > WriteRead for I2c < I2C1 , PINS > {
141
138
type Error = Error ;
142
139
@@ -214,7 +211,7 @@ impl<PINS> WriteRead for I2c<I2C1, PINS> {
214
211
}
215
212
}
216
213
217
- #[ cfg( feature = "stm32f042" ) ]
214
+ #[ cfg( any ( feature = "stm32f042" , feature = "stm32f030" ) ) ]
218
215
impl < PINS > Write for I2c < I2C1 , PINS > {
219
216
type Error = Error ;
220
217
0 commit comments