From 43ebcbeb8ceef050adff1e2fb220175079d72022 Mon Sep 17 00:00:00 2001 From: AndreySmirnov81 <489a930ac752@mail.ru> Date: Fri, 26 Feb 2021 15:41:01 +0300 Subject: [PATCH 1/2] Fix SPI3 alternate function remapping. --- CHANGELOG.md | 1 + src/spi.rs | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) 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..deea63db 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 @@ -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, From 15be7b34f7affa3b9c88b100aec7ead087e2ee83 Mon Sep 17 00:00:00 2001 From: AndreySmirnov81 <489a930ac752@mail.ru> Date: Tue, 2 Mar 2021 09:36:29 +0300 Subject: [PATCH 2/2] Fix wrong cfg attribute for SPI3 no remap. --- src/spi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spi.rs b/src/spi.rs index deea63db..e08cfbba 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -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);