diff --git a/CHANGELOG.md b/CHANGELOG.md index de13b6cd..03316ac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix > 2 byte i2c reads - Send stop after acknowledge errors on i2c - Fix i2c interactions after errors +- Fix SPI3 alternate function remapping. ### Changed - Use `cortex-m-rtic` instead of `cortex-m-rtfm` in the examples diff --git a/src/spi.rs b/src/spi.rs index 70014d07..e08cfbba 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -10,7 +10,7 @@ - `SPI1` can use `(PA5, PA6, PA7)` or `(PB3, PB4, PB5)`. - `SPI2` can use `(PB13, PB14, PB15)` - - `SPI3` can use `(PB3, PB4, PB5)` or `(PC10, PC11, PC12)` + - `SPI3` can use `(PB3, PB4, PB5)` or only in connectivity line devices `(PC10, PC11, PC12)` ## Initialisation example @@ -156,7 +156,7 @@ 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")] +#[cfg(any(feature = "high", feature = "connectivity"))] remap!(Spi3NoRemap, SPI3, false, PB3, PB4, PB5); #[cfg(feature = "connectivity")] remap!(Spi3Remap, SPI3, true, PC10, PC11, PC12); @@ -215,6 +215,30 @@ impl Spi { #[cfg(any(feature = "high", feature = "connectivity"))] impl Spi { + /** + Constructs an SPI instance using SPI3 in 8bit dataframe mode. + + The pin parameter tuple (sck, miso, mosi) should be `(PB3, PB4, PB5)` configured as `(Alternate, Input, Alternate)`. + + You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins + */ + #[cfg(not(feature = "connectivity"))] + pub fn spi3( + spi: SPI3, + pins: PINS, + mode: Mode, + freq: F, + clocks: Clocks, + apb: &mut APB1, + ) -> Self + where + F: Into, + REMAP: Remap, + PINS: Pins, + { + Spi::::_spi(spi, pins, mode, freq.into(), clocks, apb) + } + /** Constructs an SPI instance using SPI3 in 8bit dataframe mode. @@ -222,6 +246,7 @@ impl Spi { You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins */ + #[cfg(feature = "connectivity")] pub fn spi3( spi: SPI3, pins: PINS,