Skip to content

Commit 81f56fb

Browse files
authored
Merge pull request #50 from jessebraham/stm32f0x8
Support stm32f0x8 line
2 parents 7e0b205 + 1c7e2cd commit 81f56fb

File tree

10 files changed

+203
-48
lines changed

10 files changed

+203
-48
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Support for stm32f0x8 line - @jessebraham
13+
1014
## [v0.12.0] - 2019-01-13
1115

1216
### Added

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,24 @@ panic-halt = "0.2.0"
5050
device-selected = []
5151
rt = ["stm32f0/rt"]
5252
stm32f030 = ["stm32f0/stm32f0x0", "device-selected"]
53-
stm32f030x4 = ["stm32f030x6"]
53+
stm32f030x4 = ["stm32f030"]
5454
stm32f030x6 = ["stm32f030"]
5555
stm32f030x8 = ["stm32f030"]
5656
stm32f030xc = ["stm32f030"]
5757
stm32f031 = ["stm32f0/stm32f0x1", "device-selected"]
58+
stm32f038 = ["stm32f0/stm32f0x8", "device-selected"]
5859
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
60+
stm32f048 = ["stm32f0/stm32f0x8", "device-selected"]
5961
stm32f051 = ["stm32f0/stm32f0x1", "device-selected"]
62+
stm32f058 = ["stm32f0/stm32f0x8", "device-selected"]
6063
stm32f070 = ["stm32f0/stm32f0x0", "device-selected"]
6164
stm32f070x6 = ["stm32f070"]
6265
stm32f070xb = ["stm32f070"]
6366
stm32f071 = ["stm32f0/stm32f0x1", "device-selected"]
6467
stm32f072 = ["stm32f0/stm32f0x2", "device-selected"]
68+
stm32f078 = ["stm32f0/stm32f0x8", "device-selected"]
6569
stm32f091 = ["stm32f0/stm32f0x1", "device-selected"]
70+
stm32f098 = ["stm32f0/stm32f0x8", "device-selected"]
6671

6772
[profile.dev]
6873
debug = true

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ stm32f0xx-hal
77

88
[_stm32f0xx-hal_](https://github.com/stm32-rs/stm32f0xx-hal) contains a hardware abstraction on top of the peripheral access API for the STMicro STM32F0xx family of microcontrollers.
99

10-
This crate replaces the [stm32f042-hal](https://github.com/therealprof/stm32f042-hal) by a more ubiqitous version suitable for additional families. The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model.
10+
This crate replaces the [stm32f042-hal](https://github.com/therealprof/stm32f042-hal) by a more ubiquitous version suitable for additional families. The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model.
1111

1212
This crate relies on Adam Greig's fantastic [stm32f0](https://crates.io/crates/stm32f0) crate to provide appropriate register definitions, and implements a partial set of the [embedded-hal](https://github.com/rust-embedded/embedded-hal) traits. Some of the implementation was shamelessly adapted from the [stm32f103xx-hal](https://github.com/japaric/stm32f103xx-hal) crate by Jorge Aparicio.
1313

@@ -19,12 +19,17 @@ Supported Configurations
1919

2020
* __stm32f030__ (stm32f030x4, stm32f030x6, stm32f030x8, stm32f030xc)
2121
* __stm32f031__
22+
* __stm32f038__
2223
* __stm32f042__
24+
* __stm32f048__
2325
* __stm32f051__
26+
* __stm32f058__
2427
* __stm32f070__ (stm32f070x6, stm32f070xb)
2528
* __stm32f071__
2629
* __stm32f072__
30+
* __stm32f078__
2731
* __stm32f091__
32+
* __stm32f098__
2833

2934

3035
Getting Started

src/adc.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,13 @@ adc_pins!(
207207
#[cfg(any(
208208
feature = "stm32f030",
209209
feature = "stm32f051",
210+
feature = "stm32f058",
210211
feature = "stm32f070",
211212
feature = "stm32f071",
212213
feature = "stm32f072",
213-
feature = "stm32f091"
214+
feature = "stm32f078",
215+
feature = "stm32f091",
216+
feature = "stm32f098",
214217
))]
215218
adc_pins!(
216219
gpioc::PC0<Analog> => 10_u8,
@@ -354,35 +357,50 @@ impl VRef {
354357

355358
#[cfg(any(
356359
feature = "stm32f031",
360+
feature = "stm32f038",
357361
feature = "stm32f042",
362+
feature = "stm32f048",
358363
feature = "stm32f051",
364+
feature = "stm32f058",
359365
feature = "stm32f071",
360366
feature = "stm32f072",
367+
feature = "stm32f078",
361368
feature = "stm32f091",
369+
feature = "stm32f098",
362370
))]
363371
#[derive(Debug, Default)]
364372
/// Battery reference voltage (ADC Channel 18)
365373
pub struct VBat;
366374

367375
#[cfg(any(
368376
feature = "stm32f031",
377+
feature = "stm32f038",
369378
feature = "stm32f042",
379+
feature = "stm32f048",
370380
feature = "stm32f051",
381+
feature = "stm32f058",
371382
feature = "stm32f071",
372383
feature = "stm32f072",
384+
feature = "stm32f078",
373385
feature = "stm32f091",
386+
feature = "stm32f098",
374387
))]
375388
adc_pins!(
376389
VBat => 18_u8,
377390
);
378391

379392
#[cfg(any(
380393
feature = "stm32f031",
394+
feature = "stm32f038",
381395
feature = "stm32f042",
396+
feature = "stm32f048",
382397
feature = "stm32f051",
398+
feature = "stm32f058",
383399
feature = "stm32f071",
384400
feature = "stm32f072",
401+
feature = "stm32f078",
385402
feature = "stm32f091",
403+
feature = "stm32f098",
386404
))]
387405
impl VBat {
388406
/// Init a new VBat

src/gpio.rs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -561,20 +561,22 @@ gpio!(GPIOB, gpiob, iopben, PB, [
561561
PB15: (pb15, 15, Input<Floating>),
562562
]);
563563

564-
#[cfg(feature = "stm32f042")]
564+
#[cfg(any(feature = "stm32f038", feature = "stm32f042", feature = "stm32f048"))]
565565
gpio!(GPIOC, gpioc, iopcen, PC, [
566566
PC13: (pc13, 13, Input<Floating>),
567567
PC14: (pc14, 14, Input<Floating>),
568568
PC15: (pc15, 15, Input<Floating>),
569569
]);
570-
571570
#[cfg(any(
572571
feature = "stm32f030",
573572
feature = "stm32f051",
573+
feature = "stm32f058",
574574
feature = "stm32f070",
575575
feature = "stm32f071",
576576
feature = "stm32f072",
577+
feature = "stm32f078",
577578
feature = "stm32f091",
579+
feature = "stm32f098",
578580
))]
579581
gpio!(GPIOC, gpioc, iopcen, PC, [
580582
PC0: (pc0, 0, Input<Floating>),
@@ -595,12 +597,22 @@ gpio!(GPIOC, gpioc, iopcen, PC, [
595597
PC15: (pc15, 15, Input<Floating>),
596598
]);
597599

598-
#[cfg(any(feature = "stm32f030", feature = "stm32f051", feature = "stm32f070"))]
600+
#[cfg(any(
601+
feature = "stm32f030",
602+
feature = "stm32f051",
603+
feature = "stm32f058",
604+
feature = "stm32f070",
605+
))]
599606
gpio!(GPIOD, gpiod, iopden, PD, [
600607
PD2: (pd2, 2, Input<Floating>),
601608
]);
602-
603-
#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
609+
#[cfg(any(
610+
feature = "stm32f071",
611+
feature = "stm32f072",
612+
feature = "stm32f078",
613+
feature = "stm32f091",
614+
feature = "stm32f098",
615+
))]
604616
gpio!(GPIOD, gpiod, iopden, PD, [
605617
PD0: (pd0, 0, Input<Floating>),
606618
PD1: (pd1, 1, Input<Floating>),
@@ -623,7 +635,13 @@ gpio!(GPIOD, gpiod, iopden, PD, [
623635
// TODO: The ST SVD files are missing the entire PE enable register.
624636
// Re-enable as soon as this gets fixed.
625637

626-
// #[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
638+
// #[cfg(any(
639+
// feature = "stm32f071",
640+
// feature = "stm32f072",
641+
// feature = "stm32f078",
642+
// feature = "stm32f091",
643+
// feature = "stm32f098",
644+
// ))]
627645
// gpio!(GPIOE, gpioe, iopeen, PE, [
628646
// PE0: (pe0, 0, Input<Floating>),
629647
// PE1: (pe1, 1, Input<Floating>),
@@ -643,14 +661,7 @@ gpio!(GPIOD, gpiod, iopden, PD, [
643661
// PE15: (pe15, 15, Input<Floating>),
644662
// ]);
645663

646-
#[cfg(feature = "stm32f042")]
647-
gpio!(GPIOF, gpiof, iopfen, PF, [
648-
PF0: (pf0, 0, Input<Floating>),
649-
PF1: (pf1, 1, Input<Floating>),
650-
PF11: (pf11, 11, Input<Floating>),
651-
]);
652-
653-
#[cfg(any(feature = "stm32f030", feature = "stm32f051"))]
664+
#[cfg(any(feature = "stm32f030", feature = "stm32f051", feature = "stm32f058"))]
654665
gpio!(GPIOF, gpiof, iopfen, PF, [
655666
PF0: (pf0, 0, Input<Floating>),
656667
PF1: (pf1, 1, Input<Floating>),
@@ -666,13 +677,34 @@ gpio!(GPIOF, gpiof, iopfen, PF, [
666677
PF7: (pf7, 7, Input<Floating>),
667678
]);
668679

680+
#[cfg(feature = "stm32f038")]
681+
gpio!(GPIOF, gpiof, iopfen, PF, [
682+
PF0: (pf0, 0, Input<Floating>),
683+
PF1: (pf1, 1, Input<Floating>),
684+
PF6: (pf6, 6, Input<Floating>),
685+
PF7: (pf7, 7, Input<Floating>),
686+
]);
687+
688+
#[cfg(any(feature = "stm32f042", feature = "stm32f048"))]
689+
gpio!(GPIOF, gpiof, iopfen, PF, [
690+
PF0: (pf0, 0, Input<Floating>),
691+
PF1: (pf1, 1, Input<Floating>),
692+
PF11: (pf11, 11, Input<Floating>),
693+
]);
694+
669695
#[cfg(feature = "stm32f070")]
670696
gpio!(GPIOF, gpiof, iopfen, PF, [
671697
PF0: (pf0, 0, Input<Floating>),
672698
PF1: (pf1, 1, Input<Floating>),
673699
]);
674700

675-
#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))]
701+
#[cfg(any(
702+
feature = "stm32f071",
703+
feature = "stm32f072",
704+
feature = "stm32f078",
705+
feature = "stm32f091",
706+
feature = "stm32f098",
707+
))]
676708
gpio!(GPIOF, gpiof, iopfen, PF, [
677709
PF0: (pf0, 0, Input<Floating>),
678710
PF1: (pf1, 1, Input<Floating>),

src/i2c.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ macro_rules! i2c_pins {
3636
#[cfg(any(
3737
feature = "stm32f030",
3838
feature = "stm32f031",
39+
feature = "stm32f038",
3940
feature = "stm32f042",
41+
feature = "stm32f048",
4042
feature = "stm32f051",
43+
feature = "stm32f058",
4144
feature = "stm32f070",
4245
feature = "stm32f071",
4346
feature = "stm32f072",
47+
feature = "stm32f078",
4448
feature = "stm32f091",
49+
feature = "stm32f098",
4550
))]
4651
i2c_pins! {
4752
I2C1 => {
@@ -54,33 +59,48 @@ i2c_pins! {
5459
feature = "stm32f030xc",
5560
feature = "stm32f031",
5661
feature = "stm32f042",
62+
feature = "stm32f048",
5763
feature = "stm32f091",
64+
feature = "stm32f098",
5865
))]
5966
i2c_pins! {
6067
I2C1 => {
6168
scl => [gpioa::PA9<Alternate<AF4>>],
6269
sda => [gpioa::PA10<Alternate<AF4>>],
6370
}
6471
}
65-
#[cfg(any(feature = "stm32f030", feature = "stm32f042"))]
72+
#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f048"))]
6673
i2c_pins! {
6774
I2C1 => {
6875
scl => [gpioa::PA11<Alternate<AF5>>],
6976
sda => [gpioa::PA12<Alternate<AF5>>],
7077
}
7178
}
72-
#[cfg(any(feature = "stm32f031", feature = "stm32f042", feature = "stm32f030x6"))]
79+
#[cfg(any(
80+
feature = "stm32f031",
81+
feature = "stm32f038",
82+
feature = "stm32f042",
83+
feature = "stm32f048",
84+
feature = "stm32f030x6",
85+
))]
7386
i2c_pins! {
7487
I2C1 => {
7588
scl => [gpiob::PB10<Alternate<AF1>>],
7689
sda => [gpiob::PB11<Alternate<AF1>>],
7790
}
7891
}
79-
#[cfg(any(feature = "stm32f042", feature = "stm32f030xc"))]
92+
#[cfg(any(feature = "stm32f030xc", feature = "stm32f042", feature = "stm32f048"))]
93+
i2c_pins! {
94+
I2C1 => {
95+
scl => [gpiob::PB13<Alternate<AF5>>],
96+
sda => [gpiob::PB14<Alternate<AF5>>],
97+
}
98+
}
99+
#[cfg(any(feature = "stm32f042", feature = "stm32f030xc", feature = "stm32f098"))]
80100
i2c_pins! {
81101
I2C1 => {
82-
scl => [gpiob::PB13<Alternate<AF5>>, gpiof::PF1<Alternate<AF1>>],
83-
sda => [gpiob::PB14<Alternate<AF5>>, gpiof::PF0<Alternate<AF1>>],
102+
scl => [gpiof::PF1<Alternate<AF1>>],
103+
sda => [gpiof::PF0<Alternate<AF1>>],
84104
}
85105
}
86106
#[cfg(feature = "stm32f070x6")]
@@ -98,7 +118,7 @@ i2c_pins! {
98118
}
99119
}
100120

101-
#[cfg(any(feature = "stm32f030x8", feature = "stm32f051"))]
121+
#[cfg(any(feature = "stm32f030x8", feature = "stm32f051", feature = "stm32f058"))]
102122
i2c_pins! {
103123
I2C2 => {
104124
scl => [gpiob::PB10<Alternate<AF1>>],
@@ -110,15 +130,17 @@ i2c_pins! {
110130
feature = "stm32f070xb",
111131
feature = "stm32f071",
112132
feature = "stm32f072",
133+
feature = "stm32f078",
113134
feature = "stm32f091",
135+
feature = "stm32f098",
114136
))]
115137
i2c_pins! {
116138
I2C2 => {
117139
scl => [gpiob::PB10<Alternate<AF1>>, gpiob::PB13<Alternate<AF5>>],
118140
sda => [gpiob::PB11<Alternate<AF1>>, gpiob::PB14<Alternate<AF5>>],
119141
}
120142
}
121-
#[cfg(feature = "stm32f091")]
143+
#[cfg(any(feature = "stm32f091", feature = "stm32f098"))]
122144
i2c_pins! {
123145
I2C2 => {
124146
scl => [gpioa::PA11<Alternate<AF5>>],
@@ -162,10 +184,13 @@ i2c! {
162184
#[cfg(any(
163185
feature = "stm32f030xc",
164186
feature = "stm32f051",
187+
feature = "stm32f058",
165188
feature = "stm32f070xb",
166189
feature = "stm32f071",
167190
feature = "stm32f072",
191+
feature = "stm32f078",
168192
feature = "stm32f091",
193+
feature = "stm32f098",
169194
))]
170195
i2c! {
171196
I2C2: (i2c2, i2c2en, i2c2rst, apb1enr, apb1rstr),

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ pub use stm32f0::stm32f0x1 as stm32;
1717
#[cfg(any(feature = "stm32f042", feature = "stm32f072"))]
1818
pub use stm32f0::stm32f0x2 as stm32;
1919

20+
#[cfg(any(
21+
feature = "stm32f038",
22+
feature = "stm32f048",
23+
feature = "stm32f058",
24+
feature = "stm32f078",
25+
feature = "stm32f098",
26+
))]
27+
pub use stm32f0::stm32f0x8 as stm32;
28+
2029
#[cfg(feature = "device-selected")]
2130
pub mod adc;
2231
#[cfg(feature = "device-selected")]

0 commit comments

Comments
 (0)