Skip to content

Commit

Permalink
spi3
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Nov 26, 2019
1 parent e304e9f commit eb8b2b6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ bus! {
WWDG => (APB1, wwdgen, wwdgrst),
}

#[cfg(feature = "high")]
bus! {
SPI3 => (APB1, spi3en, spi3rst),
}

ahb_bus! {
CRC => (crcen),
DMA1 => (dma1en),
Expand Down
27 changes: 27 additions & 0 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use nb;

pub use crate::hal::spi::{Mode, Phase, Polarity};
use crate::pac::{SPI1, SPI2};
#[cfg(feature="high")]
use crate::pac::SPI3;

use crate::afio::MAPR;
use crate::gpio::gpioa::{PA5, PA6, PA7};
Expand Down Expand Up @@ -86,6 +88,8 @@ macro_rules! remap {
remap!(Spi1NoRemap, SPI1, false, PA5, PA6, PA7);
remap!(Spi1Remap, SPI1, true, PB3, PB4, PB5);
remap!(Spi2NoRemap, SPI2, false, PB13, PB14, PB15);
#[cfg(feature="high")]
remap!(Spi3NoRemap, SPI3, false, PB3, PB4, PB5);

impl<REMAP, PINS> Spi<SPI1, REMAP, PINS> {
pub fn spi1<F>(
Expand Down Expand Up @@ -125,6 +129,25 @@ impl<REMAP, PINS> Spi<SPI2, REMAP, PINS> {
}
}

#[cfg(feature="high")]
impl<REMAP, PINS> Spi<SPI3, REMAP, PINS> {
pub fn spi3<F>(
spi: SPI3,
pins: PINS,
mode: Mode,
freq: F,
clocks: Clocks,
apb: &mut <SPI3 as RccBus>::Bus,
) -> Self
where
F: Into<Hertz>,
REMAP: Remap<Periph = SPI3>,
PINS: Pins<REMAP>,
{
Spi::_spi3(spi, pins, mode, freq.into(), clocks, apb)
}
}

macro_rules! hal {
($($SPIX:ident: ($spiX:ident),)+) => {
$(
Expand Down Expand Up @@ -250,6 +273,10 @@ hal! {
SPI1: (_spi1),
SPI2: (_spi2),
}
#[cfg(feature="high")]
hal! {
SPI3: (_spi3),
}

// DMA

Expand Down

0 comments on commit eb8b2b6

Please sign in to comment.