Skip to content

Commit fcf5741

Browse files
authored
Added support for SPI Alternate<OpenDrain> configuration on Mosi and Sck pins (#291)
* Added support for OpenDrain configuration on Sck and Mosi SPI pins.
1 parent ca01418 commit fcf5741

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- Support for OpenDrain pin configuration on SPI CLK and MOSI pins
1213
- LSB/MSB bit format selection for `SPI`
1314

1415
### Fixed

src/spi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
To construct the SPI instances, use the `Spi::spiX` functions.
44
55
The pin parameter is a tuple containing `(sck, miso, mosi)` which should be configured as `(Alternate<PushPull>, Input<Floating>, Alternate<PushPull>)`.
6+
As some STM32F1xx chips have 5V tolerant SPI pins, it is also possible to configure Sck and Mosi outputs as `Alternate<PushPull>`. Then
7+
a simple Pull-Up to 5V can be used to use SPI on a 5V bus without a level shifter.
68
79
You can also use `NoSck`, `NoMiso` or `NoMosi` if you don't want to use the pins
810
@@ -48,7 +50,7 @@ use crate::gpio::gpioa::{PA5, PA6, PA7};
4850
use crate::gpio::gpiob::{PB13, PB14, PB15, PB3, PB4, PB5};
4951
#[cfg(feature = "connectivity")]
5052
use crate::gpio::gpioc::{PC10, PC11, PC12};
51-
use crate::gpio::{Alternate, Floating, Input, PushPull};
53+
use crate::gpio::{Alternate, Floating, Input, OpenDrain, PushPull};
5254
use crate::rcc::{Clocks, Enable, GetBusFreq, Reset, APB1, APB2};
5355
use crate::time::Hertz;
5456

@@ -144,8 +146,10 @@ macro_rules! remap {
144146
const REMAP: bool = $state;
145147
}
146148
impl Sck<$name> for $SCK<Alternate<PushPull>> {}
149+
impl Sck<$name> for $SCK<Alternate<OpenDrain>> {}
147150
impl Miso<$name> for $MISO<Input<Floating>> {}
148151
impl Mosi<$name> for $MOSI<Alternate<PushPull>> {}
152+
impl Mosi<$name> for $MOSI<Alternate<OpenDrain>> {}
149153
};
150154
}
151155

0 commit comments

Comments
 (0)