Skip to content

Commit a075397

Browse files
committed
Implement I2C for STM32F070 devices
1 parent 4e1e98a commit a075397

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/i2c.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,32 @@ i2c_pins! {
6464
sda => [gpiob::PB14<Alternate<AF5>>, gpiof::PF0<Alternate<AF1>>],
6565
}
6666
}
67-
#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))]
67+
#[cfg(feature = "stm32f070")]
68+
i2c_pins! {
69+
I2C1 => {
70+
scl => [gpiob::PB6<Alternate<AF1>>, gpiob::PB8<Alternate<AF1>>],
71+
sda => [gpiob::PB7<Alternate<AF1>>, gpiob::PB9<Alternate<AF1>>],
72+
}
73+
}
74+
#[cfg(feature = "stm32f070x6")]
75+
i2c_pins! {
76+
I2C1 => {
77+
scl => [gpioa::PA9<Alternate<AF4>>, gpiof::PF0<Alternate<AF1>>],
78+
sda => [gpioa::PA10<Alternate<AF4>>, gpiof::PF1<Alternate<AF1>>],
79+
}
80+
}
81+
#[cfg(any(
82+
feature = "stm32f030x8",
83+
feature = "stm32f030xc",
84+
feature = "stm32f070xb"
85+
))]
6886
i2c_pins! {
6987
I2C2 => {
7088
scl => [gpiob::PB10<Alternate<AF1>>],
7189
sda => [gpiob::PB11<Alternate<AF1>>],
7290
}
7391
}
74-
#[cfg(feature = "stm32f030xc")]
92+
#[cfg(any(feature = "stm32f030xc", feature = "stm32f070xb"))]
7593
i2c_pins! {
7694
I2C2 => {
7795
scl => [gpiob::PB13<Alternate<AF5>>],
@@ -110,11 +128,15 @@ macro_rules! i2c {
110128
)+
111129
}
112130
}
113-
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
131+
#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))]
114132
i2c! {
115133
I2C1: (i2c1, i2c1en, i2c1rst, apb1enr, apb1rstr),
116134
}
117-
#[cfg(any(feature = "stm32f030xc", feature = "stm32f030xc"))]
135+
#[cfg(any(
136+
feature = "stm32f030xc",
137+
feature = "stm32f030xc",
138+
feature = "stm32f070xb"
139+
))]
118140
i2c! {
119141
I2C2: (i2c2, i2c2en, i2c2rst, apb1enr, apb1rstr),
120142
}

0 commit comments

Comments
 (0)