Browse Source

Add support for stm32f031

trying.tmp
Jesse Braham 4 years ago
parent
commit
e6db427c09
  1. 3
      Cargo.toml
  2. 21
      src/adc.rs
  3. 10
      src/gpio.rs
  4. 10
      src/i2c.rs
  5. 2
      src/lib.rs
  6. 9
      src/serial.rs
  7. 7
      src/timers.rs

3
Cargo.toml

@ -46,12 +46,13 @@ panic-halt = "0.2.0"
[features]
device-selected = []
rt = ["stm32f0/rt"]
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
stm32f030 = ["stm32f0/stm32f0x0", "device-selected"]
stm32f030x4 = ["stm32f030x6"]
stm32f030x6 = ["stm32f030"]
stm32f030x8 = ["stm32f030"]
stm32f030xc = ["stm32f030"]
stm32f031 = ["stm32f0/stm32f0x1", "device-selected"]
stm32f042 = ["stm32f0/stm32f0x2", "device-selected"]
stm32f070 = ["stm32f0/stm32f0x0", "device-selected"]
stm32f070x6 = ["stm32f070"]
stm32f070xb = ["stm32f070"]

21
src/adc.rs

@ -350,17 +350,32 @@ impl VRef {
}
}
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
#[cfg(any(
feature = "stm32f031",
feature = "stm32f042",
feature = "stm32f072",
feature = "stm32f091",
))]
#[derive(Debug, Default)]
/// Battery reference voltage (ADC Channel 18)
pub struct VBat;
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
#[cfg(any(
feature = "stm32f031",
feature = "stm32f042",
feature = "stm32f072",
feature = "stm32f091",
))]
adc_pins!(
VBat => 18_u8,
);
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
#[cfg(any(
feature = "stm32f031",
feature = "stm32f042",
feature = "stm32f072",
feature = "stm32f091",
))]
impl VBat {
/// Init a new VBat
pub fn new() -> Self {

10
src/gpio.rs

@ -654,8 +654,14 @@ gpio!(GPIOF, gpiof, iopfen, PF, [
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>),
PF6: (pf6, 6, Input<Floating>),
PF7: (pf7, 7, Input<Floating>),
]);
#[cfg(feature = "stm32f031")]
gpio!(GPIOF, gpiof, iopfen, PF, [
PF6: (pf6, 6, Input<Floating>),
PF7: (pf7, 7, Input<Floating>),
]);
#[cfg(feature = "stm32f070")]

10
src/i2c.rs

@ -43,6 +43,7 @@ i2c_pins! {
#[cfg(any(
feature = "stm32f030x6",
feature = "stm32f030xc",
feature = "stm32f031",
feature = "stm32f042",
feature = "stm32f091",
))]
@ -52,7 +53,7 @@ i2c_pins! {
sda => [gpioa::PA10<Alternate<AF4>>],
}
}
#[cfg(any(feature = "stm32f042", feature = "stm32f030x6"))]
#[cfg(any(feature = "stm32f031", feature = "stm32f042", feature = "stm32f030x6"))]
i2c_pins! {
I2C1 => {
scl => [gpiob::PB10<Alternate<AF1>>],
@ -66,7 +67,12 @@ i2c_pins! {
sda => [gpiob::PB14<Alternate<AF5>>, gpiof::PF0<Alternate<AF1>>],
}
}
#[cfg(any(feature = "stm32f070", feature = "stm32f072", feature = "stm32f091"))]
#[cfg(any(
feature = "stm32f031",
feature = "stm32f070",
feature = "stm32f072",
feature = "stm32f091",
))]
i2c_pins! {
I2C1 => {
scl => [gpiob::PB6<Alternate<AF1>>, gpiob::PB8<Alternate<AF1>>],

2
src/lib.rs

@ -6,7 +6,7 @@ pub use stm32f0;
#[cfg(any(feature = "stm32f030", feature = "stm32f070"))]
pub use stm32f0::stm32f0x0 as stm32;
#[cfg(feature = "stm32f091")]
#[cfg(any(feature = "stm32f031", feature = "stm32f091"))]
pub use stm32f0::stm32f0x1 as stm32;
#[cfg(any(feature = "stm32f042", feature = "stm32f072"))]

9
src/serial.rs

@ -92,14 +92,19 @@ usart_pins! {
rx => [gpioa::PA10<Alternate<AF1>>, gpiob::PB6<Alternate<AF0>>],
}
}
#[cfg(feature = "stm32f030x6")]
#[cfg(any(feature = "stm32f031", feature = "stm32f030x6"))]
usart_pins! {
USART1 => {
tx => [gpioa::PA2<Alternate<AF1>>, gpioa::PA14<Alternate<AF1>>],
rx => [gpioa::PA3<Alternate<AF1>>, gpioa::PA15<Alternate<AF1>>],
}
}
#[cfg(any(feature = "stm32f070", feature = "stm32f072", feature = "stm32f091"))]
#[cfg(any(
feature = "stm32f031",
feature = "stm32f070",
feature = "stm32f072",
feature = "stm32f091",
))]
usart_pins! {
USART1 => {
tx => [gpioa::PA9<Alternate<AF1>>, gpiob::PB6<Alternate<AF0>>],

7
src/timers.rs

@ -244,7 +244,12 @@ timers! {
TIM7: (tim7, tim7en, tim7rst, apb1enr, apb1rstr),
}
#[cfg(any(feature = "stm32f042", feature = "stm32f072", feature = "stm32f091"))]
#[cfg(any(
feature = "stm32f031",
feature = "stm32f042",
feature = "stm32f072",
feature = "stm32f091",
))]
timers! {
TIM2: (tim2, tim2en, tim2rst, apb1enr, apb1rstr),
}

Loading…
Cancel
Save