Skip to content

Commit b724b52

Browse files
Add spi for stm32f030 (incomplete)
1 parent 7f7a7d6 commit b724b52

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/spi.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use nb;
44

55
pub use embedded_hal::spi::{Mode, Phase, Polarity};
66

7-
#[cfg(feature = "stm32f042")]
7+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
88
use crate::stm32::{RCC, SPI1};
99

1010
use crate::gpio::*;
@@ -32,15 +32,15 @@ pub struct Spi<SPI, PINS> {
3232

3333
pub trait Pins<Spi> {}
3434

35-
#[cfg(feature = "stm32f042")]
35+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
3636
impl Pins<SPI1>
3737
for (
3838
gpioa::PA5<Alternate<AF0>>,
3939
gpioa::PA6<Alternate<AF0>>,
4040
gpioa::PA7<Alternate<AF0>>,
4141
)
4242
{}
43-
#[cfg(feature = "stm32f042")]
43+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
4444
impl Pins<SPI1>
4545
for (
4646
gpiob::PB3<Alternate<AF0>>,
@@ -49,7 +49,17 @@ impl Pins<SPI1>
4949
)
5050
{}
5151

52-
#[cfg(feature = "stm32f042")]
52+
#[cfg(feature = "stm32f030x6")]
53+
impl Pins<SPI1>
54+
for (
55+
gpiob::PB13<Alternate<AF0>>,
56+
gpiob::PB14<Alternate<AF0>>,
57+
gpiob::PB15<Alternate<AF0>>,
58+
)
59+
{
60+
}
61+
62+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
5363
impl<PINS> Spi<SPI1, PINS> {
5464
pub fn spi1<F>(spi: SPI1, pins: PINS, mode: Mode, speed: F, clocks: Clocks) -> Self
5565
where
@@ -128,7 +138,7 @@ impl<PINS> Spi<SPI1, PINS> {
128138
}
129139
}
130140

131-
#[cfg(feature = "stm32f042")]
141+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
132142
impl<PINS> ::embedded_hal::spi::FullDuplex<u8> for Spi<SPI1, PINS> {
133143
type Error = Error;
134144

@@ -169,7 +179,7 @@ impl<PINS> ::embedded_hal::spi::FullDuplex<u8> for Spi<SPI1, PINS> {
169179
}
170180
}
171181

172-
#[cfg(feature = "stm32f042")]
182+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
173183
impl<PINS> ::embedded_hal::blocking::spi::transfer::Default<u8> for Spi<SPI1, PINS> {}
174-
#[cfg(feature = "stm32f042")]
184+
#[cfg(any(feature = "stm32f042", feature = "stm32f030"))]
175185
impl<PINS> ::embedded_hal::blocking::spi::write::Default<u8> for Spi<SPI1, PINS> {}

0 commit comments

Comments
 (0)