Skip to content

Commit 8e60bd3

Browse files
Implement gpio for stm32f030
1 parent 705bbb3 commit 8e60bd3

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ panic-halt = "0.2.0"
4444
[features]
4545
rt = ["stm32f0/rt"]
4646
stm32f042 = ["stm32f0/stm32f0x2"]
47+
stm32f030 = ["stm32f0/stm32f0x0"]
48+
stm32f030x4 = ["stm32f030x6"]
49+
stm32f030x6 = ["stm32f030"]
50+
stm32f030x8 = ["stm32f0/stm32f0x0"]
51+
stm32f030xc = ["stm32f0/stm32f0x0"]
4752

4853
[profile.dev]
4954
debug = true
@@ -52,3 +57,7 @@ debug = true
5257
debug = true
5358
lto = true
5459
opt-level = "s"
60+
61+
[[example]]
62+
name = "led_hal_button_irq"
63+
required-features = ["stm32f042"]

src/gpio.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ macro_rules! gpio {
450450
}
451451
}
452452

453+
#[cfg(any(feature = "stm32f042", feature = "stm32f030",))]
453454
gpio!(GPIOA, gpioa, iopaen, PA, [
454455
PA0: (pa0, 0, Input<Floating>),
455456
PA1: (pa1, 1, Input<Floating>),
@@ -469,6 +470,7 @@ gpio!(GPIOA, gpioa, iopaen, PA, [
469470
PA15: (pa15, 15, Input<Floating>),
470471
]);
471472

473+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
472474
gpio!(GPIOB, gpiob, iopben, PB, [
473475
PB0: (pb0, 0, Input<Floating>),
474476
PB1: (pb1, 1, Input<Floating>),
@@ -488,14 +490,53 @@ gpio!(GPIOB, gpiob, iopben, PB, [
488490
PB15: (pb15, 15, Input<Floating>),
489491
]);
490492

493+
#[cfg(feature = "stm32f042")]
491494
gpio!(GPIOC, gpioc, iopcen, PC, [
492495
PC13: (pc13, 13, Input<Floating>),
493496
PC14: (pc14, 14, Input<Floating>),
494497
PC15: (pc15, 15, Input<Floating>),
495498
]);
496499

500+
#[cfg(feature = "stm32f030")]
501+
gpio!(GPIOC, gpioc, iopcen, PC, [
502+
PC0: (pb0, 0, Input<Floating>),
503+
PC1: (pb1, 1, Input<Floating>),
504+
PC2: (pb2, 2, Input<Floating>),
505+
PC3: (pb3, 3, Input<Floating>),
506+
PC4: (pb4, 4, Input<Floating>),
507+
PC5: (pb5, 5, Input<Floating>),
508+
PC6: (pb6, 6, Input<Floating>),
509+
PC7: (pb7, 7, Input<Floating>),
510+
PC8: (pb8, 8, Input<Floating>),
511+
PC9: (pb9, 9, Input<Floating>),
512+
PC10: (pb10, 10, Input<Floating>),
513+
PC11: (pb11, 11, Input<Floating>),
514+
PC12: (pb12, 12, Input<Floating>),
515+
PC13: (pb13, 13, Input<Floating>),
516+
PC14: (pb14, 14, Input<Floating>),
517+
PC15: (pb15, 15, Input<Floating>),
518+
]);
519+
520+
// TODO Check if the bit is implemented yet
521+
// In the device crate the iopden bit is missing, so it won't compile
522+
// #[cfg(feature = "stm32f030")]
523+
// gpio!(GPIOD, gpiod, iopden, PD, [
524+
// PD2: (pd2, 2, Input<Floating>),
525+
// ]);
526+
527+
#[cfg(feature = "stm32f042")]
497528
gpio!(GPIOF, gpiof, iopfen, PF, [
498529
PF0: (pf0, 0, Input<Floating>),
499530
PF1: (pf1, 1, Input<Floating>),
500531
PF11: (pf11, 11, Input<Floating>),
501532
]);
533+
534+
#[cfg(feature = "stm32f030")]
535+
gpio!(GPIOF, gpiof, iopfen, PF, [
536+
PF0: (pf0, 0, Input<Floating>),
537+
PF1: (pf1, 1, Input<Floating>),
538+
PF4: (pf4, 4, Input<Floating>),
539+
PF5: (pf5, 5, Input<Floating>),
540+
PF6: (pf6, 5, Input<Floating>),
541+
PF7: (pf7, 5, Input<Floating>),
542+
]);

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub use stm32f0;
1010
#[cfg(feature = "stm32f042")]
1111
pub use stm32f0::stm32f0x2 as stm32;
1212

13+
#[cfg(feature = "stm32f030")]
14+
pub use stm32f0::stm32f0x0 as stm32;
15+
1316
// Enable use of interrupt macro
1417
#[cfg(feature = "rt")]
1518
pub use stm32f0::interrupt;

0 commit comments

Comments
 (0)