diff options
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index be8cfcecf..9238e0f6f 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -54,7 +54,7 @@ pub struct Config { | |||
| 54 | /// | 54 | /// |
| 55 | /// There are some ICs that require a pull-up on the MISO pin for some applications. | 55 | /// There are some ICs that require a pull-up on the MISO pin for some applications. |
| 56 | /// If you are unsure, you probably don't need this. | 56 | /// If you are unsure, you probably don't need this. |
| 57 | pub miso_pullup: bool, | 57 | pub miso_pullup: Pull, |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | impl Default for Config { | 60 | impl Default for Config { |
| @@ -63,7 +63,7 @@ impl Default for Config { | |||
| 63 | mode: MODE_0, | 63 | mode: MODE_0, |
| 64 | bit_order: BitOrder::MsbFirst, | 64 | bit_order: BitOrder::MsbFirst, |
| 65 | frequency: Hertz(1_000_000), | 65 | frequency: Hertz(1_000_000), |
| 66 | miso_pullup: false, | 66 | miso_pullup: Pull::None, |
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| @@ -280,14 +280,8 @@ impl<'d, M: PeriMode> Spi<'d, M> { | |||
| 280 | }; | 280 | }; |
| 281 | 281 | ||
| 282 | let miso_pullup = match &self.miso { | 282 | let miso_pullup = match &self.miso { |
| 283 | None => false, | 283 | None => Pull::None, |
| 284 | Some(pin) => { | 284 | Some(pin) => pin.pull(), |
| 285 | if pin.pull() == Pull::Up { | ||
| 286 | true | ||
| 287 | } else { | ||
| 288 | false | ||
| 289 | } | ||
| 290 | } | ||
| 291 | }; | 285 | }; |
| 292 | 286 | ||
| 293 | #[cfg(any(spi_v1, spi_f1, spi_v2))] | 287 | #[cfg(any(spi_v1, spi_f1, spi_v2))] |
| @@ -424,15 +418,7 @@ impl<'d> Spi<'d, Blocking> { | |||
| 424 | peri, | 418 | peri, |
| 425 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), | 419 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), |
| 426 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), | 420 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), |
| 427 | new_pin!( | 421 | new_pin!(miso, AFType::Input, Speed::VeryHigh, config.miso_pullup), |
| 428 | miso, | ||
| 429 | AFType::Input, | ||
| 430 | Speed::VeryHigh, | ||
| 431 | match config.miso_pullup { | ||
| 432 | true => Pull::Up, | ||
| 433 | false => Pull::None, | ||
| 434 | } | ||
| 435 | ), | ||
| 436 | None, | 422 | None, |
| 437 | None, | 423 | None, |
| 438 | config, | 424 | config, |
| @@ -450,15 +436,7 @@ impl<'d> Spi<'d, Blocking> { | |||
| 450 | peri, | 436 | peri, |
| 451 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), | 437 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), |
| 452 | None, | 438 | None, |
| 453 | new_pin!( | 439 | new_pin!(miso, AFType::Input, Speed::VeryHigh, config.miso_pullup), |
| 454 | miso, | ||
| 455 | AFType::Input, | ||
| 456 | Speed::VeryHigh, | ||
| 457 | match config.miso_pullup { | ||
| 458 | true => Pull::Up, | ||
| 459 | false => Pull::None, | ||
| 460 | } | ||
| 461 | ), | ||
| 462 | None, | 440 | None, |
| 463 | None, | 441 | None, |
| 464 | config, | 442 | config, |
