Skip to content

Commit e6db427

Browse files
committed
Add support for stm32f031
1 parent c6b96c3 commit e6db427

File tree

7 files changed

+50
-12
lines changed

7 files changed

+50
-12
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ panic-halt = "0.2.0"
4646
[features]
4747
device-selected = []
4848
rt = ["stm32f0/rt"]
49-
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
5049
stm32f030 = ["stm32f0/stm32f0x0", "device-selected"]
5150
stm32f030x4 = ["stm32f030x6"]
5251
stm32f030x6 = ["stm32f030"]
5352
stm32f030x8 = ["stm32f030"]
5453
stm32f030xc = ["stm32f030"]
54+
stm32f031 = ["stm32f0/stm32f0x1", "device-selected"]
55+
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
5556
stm32f070 = ["stm32f0/stm32f0x0", "device-selected"]
5657
stm32f070x6 = ["stm32f070"]
5758
stm32f070xb = ["stm32f070"]

src/adc.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,32 @@ impl VRef {
350350
}
351351
}
352352

353-
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
353+
#[cfg(any(
354+
feature = "stm32f031",
355+
feature = "stm32f042",
356+
feature = "stm32f072",
357+
feature = "stm32f091",
358+
))]
354359
#[derive(Debug, Default)]
355360
/// Battery reference voltage (ADC Channel 18)
356361
pub struct VBat;
357362

358-
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
363+
#[cfg(any(
364+
feature = "stm32f031",
365+
feature = "stm32f042",
366+
feature = "stm32f072",
367+
feature = "stm32f091",
368+
))]
359369
adc_pins!(
360370
VBat => 18_u8,
361371
);
362372

363-
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
373+
#[cfg(any(
374+
feature = "stm32f031",
375+
feature = "stm32f042",
376+
feature = "stm32f072",
377+
feature = "stm32f091",
378+
))]
364379
impl VBat {
365380
/// Init a new VBat
366381
pub fn new() -> Self {

src/gpio.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,14 @@ gpio!(GPIOF, gpiof, iopfen, PF, [
654654
PF1: (pf1, 1, Input<Floating>),
655655
PF4: (pf4, 4, Input<Floating>),
656656
PF5: (pf5, 5, Input<Floating>),
657-
PF6: (pf6, 5, Input<Floating>),
658-
PF7: (pf7, 5, Input<Floating>),
657+
PF6: (pf6, 6, Input<Floating>),
658+
PF7: (pf7, 7, Input<Floating>),
659+
]);
660+
661+
#[cfg(feature = "stm32f031")]
662+
gpio!(GPIOF, gpiof, iopfen, PF, [
663+
PF6: (pf6, 6, Input<Floating>),
664+
PF7: (pf7, 7, Input<Floating>),
659665
]);
660666

661667
#[cfg(feature = "stm32f070")]

src/i2c.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ i2c_pins! {
4343
#[cfg(any(
4444
feature = "stm32f030x6",
4545
feature = "stm32f030xc",
46+
feature = "stm32f031",
4647
feature = "stm32f042",
4748
feature = "stm32f091",
4849
))]
@@ -52,7 +53,7 @@ i2c_pins! {
5253
sda => [gpioa::PA10<Alternate<AF4>>],
5354
}
5455
}
55-
#[cfg(any(feature = "stm32f042", feature = "stm32f030x6"))]
56+
#[cfg(any(feature = "stm32f031", feature = "stm32f042", feature = "stm32f030x6"))]
5657
i2c_pins! {
5758
I2C1 => {
5859
scl => [gpiob::PB10<Alternate<AF1>>],
@@ -66,7 +67,12 @@ i2c_pins! {
6667
sda => [gpiob::PB14<Alternate<AF5>>, gpiof::PF0<Alternate<AF1>>],
6768
}
6869
}
69-
#[cfg(any(feature = "stm32f070", feature = "stm32f072", feature = "stm32f091"))]
70+
#[cfg(any(
71+
feature = "stm32f031",
72+
feature = "stm32f070",
73+
feature = "stm32f072",
74+
feature = "stm32f091",
75+
))]
7076
i2c_pins! {
7177
I2C1 => {
7278
scl => [gpiob::PB6<Alternate<AF1>>, gpiob::PB8<Alternate<AF1>>],

src/lib.rs

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

9-
#[cfg(feature = "stm32f091")]
9+
#[cfg(any(feature = "stm32f031", feature = "stm32f091"))]
1010
pub use stm32f0::stm32f0x1 as stm32;
1111

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

src/serial.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,19 @@ usart_pins! {
9292
rx => [gpioa::PA10<Alternate<AF1>>, gpiob::PB6<Alternate<AF0>>],
9393
}
9494
}
95-
#[cfg(feature = "stm32f030x6")]
95+
#[cfg(any(feature = "stm32f031", feature = "stm32f030x6"))]
9696
usart_pins! {
9797
USART1 => {
9898
tx => [gpioa::PA2<Alternate<AF1>>, gpioa::PA14<Alternate<AF1>>],
9999
rx => [gpioa::PA3<Alternate<AF1>>, gpioa::PA15<Alternate<AF1>>],
100100
}
101101
}
102-
#[cfg(any(feature = "stm32f070", feature = "stm32f072", feature = "stm32f091"))]
102+
#[cfg(any(
103+
feature = "stm32f031",
104+
feature = "stm32f070",
105+
feature = "stm32f072",
106+
feature = "stm32f091",
107+
))]
103108
usart_pins! {
104109
USART1 => {
105110
tx => [gpioa::PA9<Alternate<AF1>>, gpiob::PB6<Alternate<AF0>>],

src/timers.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ timers! {
244244
TIM7: (tim7, tim7en, tim7rst, apb1enr, apb1rstr),
245245
}
246246

247-
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
247+
#[cfg(any(
248+
feature = "stm32f031",
249+
feature = "stm32f042",
250+
feature = "stm32f072",
251+
feature = "stm32f091",
252+
))]
248253
timers! {
249254
TIM2: (tim2, tim2en, tim2rst, apb1enr, apb1rstr),
250255
}

0 commit comments

Comments
 (0)