Skip to content

Commit 01482ef

Browse files
Fix SPI3 alternate function remapping. (#312)
* Fix SPI3 alternate function remapping. * Fix wrong cfg attribute for SPI3 no remap. Co-authored-by: AndreySmirnov81 <[email protected]>
1 parent 0f367e6 commit 01482ef

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
- Fix > 2 byte i2c reads
1818
- Send stop after acknowledge errors on i2c
1919
- Fix i2c interactions after errors
20+
- Fix SPI3 alternate function remapping.
2021

2122
### Changed
2223
- Use `cortex-m-rtic` instead of `cortex-m-rtfm` in the examples

src/spi.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
- `SPI1` can use `(PA5, PA6, PA7)` or `(PB3, PB4, PB5)`.
1212
- `SPI2` can use `(PB13, PB14, PB15)`
13-
- `SPI3` can use `(PB3, PB4, PB5)` or `(PC10, PC11, PC12)`
13+
- `SPI3` can use `(PB3, PB4, PB5)` or only in connectivity line devices `(PC10, PC11, PC12)`
1414
1515
1616
## Initialisation example
@@ -156,7 +156,7 @@ macro_rules! remap {
156156
remap!(Spi1NoRemap, SPI1, false, PA5, PA6, PA7);
157157
remap!(Spi1Remap, SPI1, true, PB3, PB4, PB5);
158158
remap!(Spi2NoRemap, SPI2, false, PB13, PB14, PB15);
159-
#[cfg(feature = "high")]
159+
#[cfg(any(feature = "high", feature = "connectivity"))]
160160
remap!(Spi3NoRemap, SPI3, false, PB3, PB4, PB5);
161161
#[cfg(feature = "connectivity")]
162162
remap!(Spi3Remap, SPI3, true, PC10, PC11, PC12);
@@ -215,13 +215,38 @@ impl<REMAP, PINS> Spi<SPI2, REMAP, PINS, u8> {
215215

216216
#[cfg(any(feature = "high", feature = "connectivity"))]
217217
impl<REMAP, PINS> Spi<SPI3, REMAP, PINS, u8> {
218+
/**
219+
Constructs an SPI instance using SPI3 in 8bit dataframe mode.
220+
221+
The pin parameter tuple (sck, miso, mosi) should be `(PB3, PB4, PB5)` configured as `(Alternate<PushPull>, Input<Floating>, Alternate<PushPull>)`.
222+
223+
You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins
224+
*/
225+
#[cfg(not(feature = "connectivity"))]
226+
pub fn spi3<F, POS>(
227+
spi: SPI3,
228+
pins: PINS,
229+
mode: Mode,
230+
freq: F,
231+
clocks: Clocks,
232+
apb: &mut APB1,
233+
) -> Self
234+
where
235+
F: Into<Hertz>,
236+
REMAP: Remap<Periph = SPI3>,
237+
PINS: Pins<REMAP, POS>,
238+
{
239+
Spi::<SPI3, _, _, u8>::_spi(spi, pins, mode, freq.into(), clocks, apb)
240+
}
241+
218242
/**
219243
Constructs an SPI instance using SPI3 in 8bit dataframe mode.
220244
221245
The pin parameter tuple (sck, miso, mosi) should be `(PB3, PB4, PB5)` or `(PC10, PC11, PC12)` configured as `(Alternate<PushPull>, Input<Floating>, Alternate<PushPull>)`.
222246
223247
You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins
224248
*/
249+
#[cfg(feature = "connectivity")]
225250
pub fn spi3<F, POS>(
226251
spi: SPI3,
227252
pins: PINS,

0 commit comments

Comments
 (0)