Skip to content

Commit c4967c2

Browse files
committed
Add support for stm32f071
1 parent b016ffd commit c4967c2

File tree

8 files changed

+69
-35
lines changed

8 files changed

+69
-35
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ stm32f051 = ["stm32f0/stm32f0x1", "device-selected"]
5757
stm32f070 = ["stm32f0/stm32f0x0", "device-selected"]
5858
stm32f070x6 = ["stm32f070"]
5959
stm32f070xb = ["stm32f070"]
60+
stm32f071 = ["stm32f0/stm32f0x1", "device-selected"]
6061
stm32f072 = ["stm32f0/stm32f0x2", "device-selected"]
6162
stm32f091 = ["stm32f0/stm32f0x1", "device-selected"]
6263

src/adc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ adc_pins!(
208208
feature = "stm32f030",
209209
feature = "stm32f051",
210210
feature = "stm32f070",
211+
feature = "stm32f071",
211212
feature = "stm32f072",
212213
feature = "stm32f091"
213214
))]
@@ -355,6 +356,7 @@ impl VRef {
355356
feature = "stm32f031",
356357
feature = "stm32f042",
357358
feature = "stm32f051",
359+
feature = "stm32f071",
358360
feature = "stm32f072",
359361
feature = "stm32f091",
360362
))]
@@ -366,6 +368,7 @@ pub struct VBat;
366368
feature = "stm32f031",
367369
feature = "stm32f042",
368370
feature = "stm32f051",
371+
feature = "stm32f071",
369372
feature = "stm32f072",
370373
feature = "stm32f091",
371374
))]
@@ -377,6 +380,7 @@ adc_pins!(
377380
feature = "stm32f031",
378381
feature = "stm32f042",
379382
feature = "stm32f051",
383+
feature = "stm32f071",
380384
feature = "stm32f072",
381385
feature = "stm32f091",
382386
))]

src/gpio.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ gpio!(GPIOC, gpioc, iopcen, PC, [
572572
feature = "stm32f030",
573573
feature = "stm32f051",
574574
feature = "stm32f070",
575+
feature = "stm32f071",
575576
feature = "stm32f072",
576577
feature = "stm32f091",
577578
))]
@@ -599,7 +600,7 @@ gpio!(GPIOD, gpiod, iopden, PD, [
599600
PD2: (pd2, 2, Input<Floating>),
600601
]);
601602

602-
#[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
603+
#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
603604
gpio!(GPIOD, gpiod, iopden, PD, [
604605
PD0: (pd0, 0, Input<Floating>),
605606
PD1: (pd1, 1, Input<Floating>),
@@ -622,7 +623,7 @@ gpio!(GPIOD, gpiod, iopden, PD, [
622623
// TODO: The ST SVD files are missing the entire PE enable register.
623624
// Re-enable as soon as this gets fixed.
624625

625-
// #[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
626+
// #[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
626627
// gpio!(GPIOE, gpioe, iopeen, PE, [
627628
// PE0: (pe0, 0, Input<Floating>),
628629
// PE1: (pe1, 1, Input<Floating>),
@@ -671,7 +672,7 @@ gpio!(GPIOF, gpiof, iopfen, PF, [
671672
PF1: (pf1, 1, Input<Floating>),
672673
]);
673674

674-
#[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
675+
#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
675676
gpio!(GPIOF, gpiof, iopfen, PF, [
676677
PF0: (pf0, 0, Input<Floating>),
677678
PF1: (pf1, 1, Input<Floating>),

src/i2c.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@ macro_rules! i2c_pins {
3333
}
3434
}
3535

36-
#[cfg(any(feature = "stm32f030", feature = "stm32f042"))]
36+
#[cfg(any(
37+
feature = "stm32f030",
38+
feature = "stm32f031",
39+
feature = "stm32f042",
40+
feature = "stm32f051",
41+
feature = "stm32f070",
42+
feature = "stm32f071",
43+
feature = "stm32f072",
44+
feature = "stm32f091",
45+
))]
3746
i2c_pins! {
3847
I2C1 => {
39-
scl => [gpioa::PA11<Alternate<AF5>>, gpiob::PB6<Alternate<AF1>>, gpiob::PB8<Alternate<AF1>>],
40-
sda => [gpioa::PA12<Alternate<AF5>>, gpiob::PB7<Alternate<AF1>>, gpiob::PB9<Alternate<AF1>>],
48+
scl => [gpiob::PB6<Alternate<AF1>>, gpiob::PB8<Alternate<AF1>>],
49+
sda => [gpiob::PB7<Alternate<AF1>>, gpiob::PB9<Alternate<AF1>>],
4150
}
4251
}
4352
#[cfg(any(
@@ -53,6 +62,13 @@ i2c_pins! {
5362
sda => [gpioa::PA10<Alternate<AF4>>],
5463
}
5564
}
65+
#[cfg(any(feature = "stm32f030", feature = "stm32f042"))]
66+
i2c_pins! {
67+
I2C1 => {
68+
scl => [gpioa::PA11<Alternate<AF5>>],
69+
sda => [gpioa::PA12<Alternate<AF5>>],
70+
}
71+
}
5672
#[cfg(any(feature = "stm32f031", feature = "stm32f042", feature = "stm32f030x6"))]
5773
i2c_pins! {
5874
I2C1 => {
@@ -67,19 +83,6 @@ i2c_pins! {
6783
sda => [gpiob::PB14<Alternate<AF5>>, gpiof::PF0<Alternate<AF1>>],
6884
}
6985
}
70-
#[cfg(any(
71-
feature = "stm32f031",
72-
feature = "stm32f051",
73-
feature = "stm32f070",
74-
feature = "stm32f072",
75-
feature = "stm32f091",
76-
))]
77-
i2c_pins! {
78-
I2C1 => {
79-
scl => [gpiob::PB6<Alternate<AF1>>, gpiob::PB8<Alternate<AF1>>],
80-
sda => [gpiob::PB7<Alternate<AF1>>, gpiob::PB9<Alternate<AF1>>],
81-
}
82-
}
8386
#[cfg(feature = "stm32f070x6")]
8487
i2c_pins! {
8588
I2C1 => {
@@ -105,6 +108,7 @@ i2c_pins! {
105108
#[cfg(any(
106109
feature = "stm32f030xc",
107110
feature = "stm32f070xb",
111+
feature = "stm32f071",
108112
feature = "stm32f072",
109113
feature = "stm32f091",
110114
))]
@@ -159,6 +163,7 @@ i2c! {
159163
feature = "stm32f030xc",
160164
feature = "stm32f051",
161165
feature = "stm32f070xb",
166+
feature = "stm32f071",
162167
feature = "stm32f072",
163168
feature = "stm32f091",
164169
))]

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ pub use stm32f0;
66
#[cfg(any(feature = "stm32f030", feature = "stm32f070"))]
77
pub use stm32f0::stm32f0x0 as stm32;
88

9-
#[cfg(any(feature = "stm32f031", feature = "stm32f051", feature = "stm32f091"))]
9+
#[cfg(any(
10+
feature = "stm32f031",
11+
feature = "stm32f051",
12+
feature = "stm32f071",
13+
feature = "stm32f091",
14+
))]
1015
pub use stm32f0::stm32f0x1 as stm32;
1116

1217
#[cfg(any(feature = "stm32f042", feature = "stm32f072"))]

src/serial.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ macro_rules! usart_pins {
8585
}
8686
}
8787

88-
#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f051"))]
88+
#[cfg(any(
89+
feature = "stm32f030",
90+
feature = "stm32f042",
91+
feature = "stm32f051",
92+
feature = "stm32f071",
93+
))]
8994
usart_pins! {
9095
USART1 => {
9196
tx => [gpioa::PA9<Alternate<AF1>>, gpiob::PB6<Alternate<AF0>>],
@@ -118,6 +123,7 @@ usart_pins! {
118123
feature = "stm32f042",
119124
feature = "stm32f051",
120125
feature = "stm32f070",
126+
feature = "stm32f071",
121127
feature = "stm32f072",
122128
feature = "stm32f091",
123129
))]
@@ -127,16 +133,18 @@ usart_pins! {
127133
rx => [gpioa::PA3<Alternate<AF1>>, gpioa::PA15<Alternate<AF1>>],
128134
}
129135
}
130-
#[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
136+
#[cfg(any(feature = "stm32f072", feature = "stm32f071", feature = "stm32f091"))]
131137
usart_pins! {
132138
USART2 => {
133139
tx => [gpiod::PD5<Alternate<AF0>>],
134140
rx => [gpiod::PD6<Alternate<AF0>>],
135141
}
136142
}
143+
137144
#[cfg(any(
138145
feature = "stm32f030xc",
139146
feature = "stm32f070xb",
147+
feature = "stm32f071",
140148
feature = "stm32f072",
141149
feature = "stm32f091",
142150
))]
@@ -151,13 +159,14 @@ usart_pins! {
151159
rx => [gpioa::PA1<Alternate<AF4>>, gpioc::PC11<Alternate<AF0>>],
152160
}
153161
}
154-
#[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
162+
#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
155163
usart_pins! {
156164
USART3 => {
157165
tx => [gpiod::PD8<Alternate<AF0>>],
158166
rx => [gpiod::PD9<Alternate<AF0>>],
159167
}
160168
}
169+
161170
// TODO: The ST SVD files are missing the entire PE enable register.
162171
// Re-enable as soon as this gets fixed.
163172
// #[cfg(feature = "stm32f091")]
@@ -167,6 +176,7 @@ usart_pins! {
167176
// rx => [gpioe::PE9<Alternate<AF1>>],
168177
// }
169178
// }
179+
170180
#[cfg(any(feature = "stm32f030xc", feature = "stm32f091"))]
171181
usart_pins! {
172182
USART5 => {
@@ -287,6 +297,7 @@ usart! {
287297
feature = "stm32f042",
288298
feature = "stm32f051",
289299
feature = "stm32f070",
300+
feature = "stm32f071",
290301
feature = "stm32f072",
291302
feature = "stm32f091",
292303
))]
@@ -296,6 +307,7 @@ usart! {
296307
#[cfg(any(
297308
feature = "stm32f030xc",
298309
feature = "stm32f070xb",
310+
feature = "stm32f071",
299311
feature = "stm32f072",
300312
feature = "stm32f091",
301313
))]

src/spi.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ use crate::stm32::SPI1;
5050
feature = "stm32f030x8",
5151
feature = "stm32f030xc",
5252
feature = "stm32f070xb",
53+
feature = "stm32f071",
5354
feature = "stm32f091",
5455
))]
5556
use crate::stm32::SPI2;
@@ -121,7 +122,7 @@ spi_pins! {
121122
// TODO: The ST SVD files are missing the entire PE enable register.
122123
// So those pins do not exist in the register definitions.
123124
// Re-enable as soon as this gets fixed.
124-
// #[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
125+
// #[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
125126
// spi_pins! {
126127
// SPI1 => {
127128
// sck => [gpioe::PE13<Alternate<AF1>>],
@@ -135,6 +136,7 @@ spi_pins! {
135136
feature = "stm32f030xc",
136137
feature = "stm32f051",
137138
feature = "stm32f070xb",
139+
feature = "stm32f071",
138140
feature = "stm32f072",
139141
feature = "stm32f091",
140142
))]
@@ -148,6 +150,7 @@ spi_pins! {
148150
#[cfg(any(
149151
feature = "stm32f030xc",
150152
feature = "stm32f070xb",
153+
feature = "stm32f071",
151154
feature = "stm32f072",
152155
feature = "stm32f091",
153156
))]
@@ -158,7 +161,7 @@ spi_pins! {
158161
mosi => [gpioc::PC3<Alternate<AF1>>],
159162
}
160163
}
161-
#[cfg(any(feature = "stm32f072", feature = "stm32f091"))]
164+
#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
162165
spi_pins! {
163166
SPI2 => {
164167
sck => [gpiod::PD1<Alternate<AF1>>],
@@ -207,6 +210,7 @@ spi! {
207210
feature = "stm32f030xc",
208211
feature = "stm32f051",
209212
feature = "stm32f070xb",
213+
feature = "stm32f071",
210214
feature = "stm32f091",
211215
))]
212216
spi! {

src/timers.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,35 +223,37 @@ timers! {
223223
}
224224

225225
#[cfg(any(
226-
feature = "stm32f030x8",
227-
feature = "stm32f030xc",
226+
feature = "stm32f031",
227+
feature = "stm32f042",
228228
feature = "stm32f051",
229-
feature = "stm32f070xb",
229+
feature = "stm32f071",
230230
feature = "stm32f072",
231231
feature = "stm32f091",
232232
))]
233233
timers! {
234-
TIM6: (tim6, tim6en, tim6rst, apb1enr, apb1rstr),
235-
TIM15: (tim15, tim15en, tim15rst, apb2enr, apb2rstr),
234+
TIM2: (tim2, tim2en, tim2rst, apb1enr, apb1rstr),
236235
}
237236

238237
#[cfg(any(
238+
feature = "stm32f030x8",
239239
feature = "stm32f030xc",
240+
feature = "stm32f051",
240241
feature = "stm32f070xb",
242+
feature = "stm32f071",
241243
feature = "stm32f072",
242244
feature = "stm32f091",
243245
))]
244246
timers! {
245-
TIM7: (tim7, tim7en, tim7rst, apb1enr, apb1rstr),
247+
TIM6: (tim6, tim6en, tim6rst, apb1enr, apb1rstr),
248+
TIM15: (tim15, tim15en, tim15rst, apb2enr, apb2rstr),
246249
}
247250

248251
#[cfg(any(
249-
feature = "stm32f031",
250-
feature = "stm32f042",
251-
feature = "stm32f051",
252+
feature = "stm32f030xc",
253+
feature = "stm32f070xb",
252254
feature = "stm32f072",
253255
feature = "stm32f091",
254256
))]
255257
timers! {
256-
TIM2: (tim2, tim2en, tim2rst, apb1enr, apb1rstr),
258+
TIM7: (tim7, tim7en, tim7rst, apb1enr, apb1rstr),
257259
}

0 commit comments

Comments
 (0)