diff options
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 5b81c791a..e5ba746e4 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -10,7 +10,7 @@ pub use embedded_hal_02::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MO | |||
| 10 | use self::sealed::WordSize; | 10 | use self::sealed::WordSize; |
| 11 | use crate::dma::{slice_ptr_parts, Transfer}; | 11 | use crate::dma::{slice_ptr_parts, Transfer}; |
| 12 | use crate::gpio::sealed::{AFType, Pin as _}; | 12 | use crate::gpio::sealed::{AFType, Pin as _}; |
| 13 | use crate::gpio::AnyPin; | 13 | use crate::gpio::{AnyPin, Pull}; |
| 14 | use crate::pac::spi::{regs, vals, Spi as Regs}; | 14 | use crate::pac::spi::{regs, vals, Spi as Regs}; |
| 15 | use crate::rcc::RccPeripheral; | 15 | use crate::rcc::RccPeripheral; |
| 16 | use crate::time::Hertz; | 16 | use crate::time::Hertz; |
| @@ -93,8 +93,14 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 93 | config: Config, | 93 | config: Config, |
| 94 | ) -> Self { | 94 | ) -> Self { |
| 95 | into_ref!(peri, sck, mosi, miso); | 95 | into_ref!(peri, sck, mosi, miso); |
| 96 | |||
| 97 | let sck_pull_mode = match config.mode.polarity { | ||
| 98 | Polarity::IdleLow => Pull::Down, | ||
| 99 | Polarity::IdleHigh => Pull::Up, | ||
| 100 | }; | ||
| 101 | |||
| 96 | unsafe { | 102 | unsafe { |
| 97 | sck.set_as_af(sck.af_num(), AFType::OutputPushPull); | 103 | sck.set_as_af_pull(sck.af_num(), AFType::OutputPushPull, sck_pull_mode); |
| 98 | sck.set_speed(crate::gpio::Speed::VeryHigh); | 104 | sck.set_speed(crate::gpio::Speed::VeryHigh); |
| 99 | mosi.set_as_af(mosi.af_num(), AFType::OutputPushPull); | 105 | mosi.set_as_af(mosi.af_num(), AFType::OutputPushPull); |
| 100 | mosi.set_speed(crate::gpio::Speed::VeryHigh); | 106 | mosi.set_speed(crate::gpio::Speed::VeryHigh); |
