Browse Source

Implement gpio for stm32f030

features/pwm
David Sawatzke 4 years ago
parent
commit
8e60bd30be
  1. 9
      Cargo.toml
  2. 41
      src/gpio.rs
  3. 3
      src/lib.rs

9
Cargo.toml

@ -44,6 +44,11 @@ panic-halt = "0.2.0"
[features]
rt = ["stm32f0/rt"]
stm32f042 = ["stm32f0/stm32f0x2"]
stm32f030 = ["stm32f0/stm32f0x0"]
stm32f030x4 = ["stm32f030x6"]
stm32f030x6 = ["stm32f030"]
stm32f030x8 = ["stm32f0/stm32f0x0"]
stm32f030xc = ["stm32f0/stm32f0x0"]
[profile.dev]
debug = true
@ -52,3 +57,7 @@ debug = true
debug = true
lto = true
opt-level = "s"
[[example]]
name = "led_hal_button_irq"
required-features = ["stm32f042"]

41
src/gpio.rs

@ -450,6 +450,7 @@ macro_rules! gpio {
}
}
#[cfg(any(feature = "stm32f042", feature = "stm32f030",))]
gpio!(GPIOA, gpioa, iopaen, PA, [
PA0: (pa0, 0, Input<Floating>),
PA1: (pa1, 1, Input<Floating>),
@ -469,6 +470,7 @@ gpio!(GPIOA, gpioa, iopaen, PA, [
PA15: (pa15, 15, Input<Floating>),
]);
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
gpio!(GPIOB, gpiob, iopben, PB, [
PB0: (pb0, 0, Input<Floating>),
PB1: (pb1, 1, Input<Floating>),
@ -488,14 +490,53 @@ gpio!(GPIOB, gpiob, iopben, PB, [
PB15: (pb15, 15, Input<Floating>),
]);
#[cfg(feature = "stm32f042")]
gpio!(GPIOC, gpioc, iopcen, PC, [
PC13: (pc13, 13, Input<Floating>),
PC14: (pc14, 14, Input<Floating>),
PC15: (pc15, 15, Input<Floating>),
]);
#[cfg(feature = "stm32f030")]
gpio!(GPIOC, gpioc, iopcen, PC, [
PC0: (pb0, 0, Input<Floating>),
PC1: (pb1, 1, Input<Floating>),
PC2: (pb2, 2, Input<Floating>),
PC3: (pb3, 3, Input<Floating>),
PC4: (pb4, 4, Input<Floating>),
PC5: (pb5, 5, Input<Floating>),
PC6: (pb6, 6, Input<Floating>),
PC7: (pb7, 7, Input<Floating>),
PC8: (pb8, 8, Input<Floating>),
PC9: (pb9, 9, Input<Floating>),
PC10: (pb10, 10, Input<Floating>),
PC11: (pb11, 11, Input<Floating>),
PC12: (pb12, 12, Input<Floating>),
PC13: (pb13, 13, Input<Floating>),
PC14: (pb14, 14, Input<Floating>),
PC15: (pb15, 15, Input<Floating>),
]);
// TODO Check if the bit is implemented yet
// In the device crate the iopden bit is missing, so it won't compile
// #[cfg(feature = "stm32f030")]
// gpio!(GPIOD, gpiod, iopden, PD, [
// PD2: (pd2, 2, Input<Floating>),
// ]);
#[cfg(feature = "stm32f042")]
gpio!(GPIOF, gpiof, iopfen, PF, [
PF0: (pf0, 0, Input<Floating>),
PF1: (pf1, 1, Input<Floating>),
PF11: (pf11, 11, Input<Floating>),
]);
#[cfg(feature = "stm32f030")]
gpio!(GPIOF, gpiof, iopfen, PF, [
PF0: (pf0, 0, Input<Floating>),
PF1: (pf1, 1, Input<Floating>),
PF4: (pf4, 4, Input<Floating>),
PF5: (pf5, 5, Input<Floating>),
PF6: (pf6, 5, Input<Floating>),
PF7: (pf7, 5, Input<Floating>),
]);

3
src/lib.rs

@ -10,6 +10,9 @@ pub use stm32f0;
#[cfg(feature = "stm32f042")]
pub use stm32f0::stm32f0x2 as stm32;
#[cfg(feature = "stm32f030")]
pub use stm32f0::stm32f0x0 as stm32;
// Enable use of interrupt macro
#[cfg(feature = "rt")]
pub use stm32f0::interrupt;

Loading…
Cancel
Save