Sfoglia il codice sorgente

Fix SPI3 alternate function remapping. (#312)

* Fix SPI3 alternate function remapping.

* Fix wrong cfg attribute for SPI3 no remap.

Co-authored-by: AndreySmirnov81 <489a930ac752@mail.ru>
AndreySmirnov81 3 anni fa
parent
commit
01482efb3e
2 ha cambiato i file con 28 aggiunte e 2 eliminazioni
  1. 1 0
      CHANGELOG.md
  2. 27 2
      src/spi.rs

+ 1 - 0
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

+ 27 - 2
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<REMAP, PINS> Spi<SPI2, REMAP, PINS, u8> {
 
 #[cfg(any(feature = "high", feature = "connectivity"))]
 impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8> {
+    /**
+      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<PushPull>, Input<Floating>, Alternate<PushPull>)`.
+
+      You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins
+    */
+    #[cfg(not(feature = "connectivity"))]
+    pub fn spi3<F, POS>(
+        spi: SPI3,
+        pins: PINS,
+        mode: Mode,
+        freq: F,
+        clocks: Clocks,
+        apb: &mut APB1,
+    ) -> Self
+    where
+        F: Into<Hertz>,
+        REMAP: Remap<Periph = SPI3>,
+        PINS: Pins<REMAP, POS>,
+    {
+        Spi::<SPI3, _, _, u8>::_spi(spi, pins, mode, freq.into(), clocks, apb)
+    }
+
     /**
       Constructs an SPI instance using SPI3 in 8bit dataframe mode.
 
@@ -222,6 +246,7 @@ impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8> {
 
       You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins
     */
+    #[cfg(feature = "connectivity")]
     pub fn spi3<F, POS>(
         spi: SPI3,
         pins: PINS,