Skip to content

Commit 4e1e98a

Browse files
committed
Implement SPI for STM32F070 devices
1 parent 5af487e commit 4e1e98a

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/spi.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ pub use embedded_hal::spi::{Mode, Phase, Polarity};
88
use crate::stm32;
99
// TODO Put this inside the macro
1010
// Currently that causes a compiler panic
11-
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
11+
#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))]
1212
use crate::stm32::SPI1;
13-
#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))]
13+
#[cfg(any(
14+
feature = "stm32f030x8",
15+
feature = "stm32f030xc",
16+
feature = "stm32f070xb"
17+
))]
1418
use crate::stm32::SPI2;
1519

1620
use crate::gpio::*;
@@ -60,7 +64,7 @@ macro_rules! spi_pins {
6064
}
6165
}
6266

63-
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
67+
#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))]
6468
spi_pins! {
6569
SPI1 => {
6670
sck => [gpioa::PA5<Alternate<AF0>>, gpiob::PB3<Alternate<AF0>>],
@@ -76,15 +80,19 @@ spi_pins! {
7680
mosi => [gpiob::PB15<Alternate<AF0>>],
7781
}
7882
}
79-
#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))]
83+
#[cfg(any(
84+
feature = "stm32f030x8",
85+
feature = "stm32f030xc",
86+
feature = "stm32f070xb"
87+
))]
8088
spi_pins! {
8189
SPI2 => {
8290
sck => [gpiob::PB13<Alternate<AF0>>],
8391
miso => [gpiob::PB14<Alternate<AF0>>],
8492
mosi => [gpiob::PB15<Alternate<AF0>>],
8593
}
8694
}
87-
#[cfg(feature = "stm32f030xc")]
95+
#[cfg(any(feature = "stm32f030xc", feature = "stm32f070xb"))]
8896
spi_pins! {
8997
SPI2 => {
9098
sck => [gpiob::PB10<Alternate<AF5>>],
@@ -126,11 +134,15 @@ macro_rules! spi {
126134
}
127135
}
128136

129-
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
137+
#[cfg(any(feature = "stm32f042", feature = "stm32f030", feature = "stm32f070"))]
130138
spi! {
131139
SPI1: (spi1, spi1en, spi1rst, apb2enr, apb2rstr),
132140
}
133-
#[cfg(any(feature = "stm32f030x8", feature = "stm32f030xc"))]
141+
#[cfg(any(
142+
feature = "stm32f030x8",
143+
feature = "stm32f030xc",
144+
feature = "stm32f070xb"
145+
))]
134146
spi! {
135147
SPI2: (spi2, spi2en, spi2rst, apb1enr, apb1rstr),
136148
}

0 commit comments

Comments
 (0)