aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/gpio.rs15
-rw-r--r--embassy-stm32/src/spi/mod.rs27
2 files changed, 26 insertions, 16 deletions
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs
index d2db0a257..7de223455 100644
--- a/embassy-stm32/src/gpio.rs
+++ b/embassy-stm32/src/gpio.rs
@@ -680,7 +680,6 @@ pub(crate) trait SealedPin {
680 self.block().ospeedr().modify(|w| w.set_ospeedr(pin, speed.into())); 680 self.block().ospeedr().modify(|w| w.set_ospeedr(pin, speed.into()));
681 } 681 }
682 682
683
684 /// Get the pull-up configuration. 683 /// Get the pull-up configuration.
685 #[inline] 684 #[inline]
686 fn pull(&self) -> Pull { 685 fn pull(&self) -> Pull {
@@ -692,12 +691,14 @@ pub(crate) trait SealedPin {
692 let crlh = if n < 8 { 0 } else { 1 }; 691 let crlh = if n < 8 { 0 } else { 1 };
693 match r.cr(crlh).cnf(n % 8) { 692 match r.cr(crlh).cnf(n % 8) {
694 vals::CnfIn::FLOATING => Pull::None, 693 vals::CnfIn::FLOATING => Pull::None,
695 _ => if r.bsrr().read().bs(n % 8) { 694 _ => {
696 Pull::Up 695 if r.bsrr().read().bs(n % 8) {
697 } else if r.bsrr().read().br(n % 8) { 696 Pull::Up
698 Pull::Down 697 } else if r.bsrr().read().br(n % 8) {
699 } else { 698 Pull::Down
700 Pull::None 699 } else {
700 Pull::None
701 }
701 } 702 }
702 } 703 }
703 } 704 }
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs
index bcd6b0bf4..76d58def6 100644
--- a/embassy-stm32/src/spi/mod.rs
+++ b/embassy-stm32/src/spi/mod.rs
@@ -283,11 +283,12 @@ impl<'d, T: Instance, M: PeriMode> Spi<'d, T, M> {
283 283
284 let miso_pullup = match &self.miso { 284 let miso_pullup = match &self.miso {
285 None => false, 285 None => false,
286 Some(pin) => 286 Some(pin) => {
287 if pin.pull() == Pull::Up { 287 if pin.pull() == Pull::Up {
288 true 288 true
289 } else { 289 } else {
290 false 290 false
291 }
291 } 292 }
292 }; 293 };
293 294
@@ -426,11 +427,15 @@ impl<'d, T: Instance> Spi<'d, T, Blocking> {
426 peri, 427 peri,
427 new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), 428 new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()),
428 new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), 429 new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh),
429 new_pin!(miso, AFType::Input, Speed::Input, 430 new_pin!(
431 miso,
432 AFType::Input,
433 Speed::Input,
430 match config.miso_pullup { 434 match config.miso_pullup {
431 true => Pull::Up, 435 true => Pull::Up,
432 false => Pull::None, 436 false => Pull::None,
433 }), 437 }
438 ),
434 None, 439 None,
435 None, 440 None,
436 config, 441 config,
@@ -448,11 +453,15 @@ impl<'d, T: Instance> Spi<'d, T, Blocking> {
448 peri, 453 peri,
449 new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), 454 new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()),
450 None, 455 None,
451 new_pin!(miso, AFType::Input, Speed::Input, 456 new_pin!(
457 miso,
458 AFType::Input,
459 Speed::Input,
452 match config.miso_pullup { 460 match config.miso_pullup {
453 true => Pull::Up, 461 true => Pull::Up,
454 false => Pull::None, 462 false => Pull::None,
455 }), 463 }
464 ),
456 None, 465 None,
457 None, 466 None,
458 config, 467 config,