diff options
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index c8d83f07e..4c5308eba 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -71,7 +71,7 @@ pub struct Config { | |||
| 71 | pub miso_pull: Pull, | 71 | pub miso_pull: Pull, |
| 72 | /// signal rise/fall speed (slew rate) - defaults to `Medium`. | 72 | /// signal rise/fall speed (slew rate) - defaults to `Medium`. |
| 73 | /// Increase for high SPI speeds. Change to `Low` to reduce ringing. | 73 | /// Increase for high SPI speeds. Change to `Low` to reduce ringing. |
| 74 | pub rise_fall_speed: Speed, | 74 | pub gpio_speed: Speed, |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | impl Default for Config { | 77 | impl Default for Config { |
| @@ -81,7 +81,7 @@ impl Default for Config { | |||
| 81 | bit_order: BitOrder::MsbFirst, | 81 | bit_order: BitOrder::MsbFirst, |
| 82 | frequency: Hertz(1_000_000), | 82 | frequency: Hertz(1_000_000), |
| 83 | miso_pull: Pull::None, | 83 | miso_pull: Pull::None, |
| 84 | rise_fall_speed: Speed::VeryHigh, | 84 | gpio_speed: Speed::VeryHigh, |
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| @@ -110,14 +110,14 @@ impl Config { | |||
| 110 | 110 | ||
| 111 | #[cfg(gpio_v1)] | 111 | #[cfg(gpio_v1)] |
| 112 | fn sck_af(&self) -> AfType { | 112 | fn sck_af(&self) -> AfType { |
| 113 | AfType::output(OutputType::PushPull, self.rise_fall_speed) | 113 | AfType::output(OutputType::PushPull, self.gpio_speed) |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | #[cfg(gpio_v2)] | 116 | #[cfg(gpio_v2)] |
| 117 | fn sck_af(&self) -> AfType { | 117 | fn sck_af(&self) -> AfType { |
| 118 | AfType::output_pull( | 118 | AfType::output_pull( |
| 119 | OutputType::PushPull, | 119 | OutputType::PushPull, |
| 120 | self.rise_fall_speed, | 120 | self.gpio_speed, |
| 121 | match self.mode.polarity { | 121 | match self.mode.polarity { |
| 122 | Polarity::IdleLow => Pull::Down, | 122 | Polarity::IdleLow => Pull::Down, |
| 123 | Polarity::IdleHigh => Pull::Up, | 123 | Polarity::IdleHigh => Pull::Up, |
| @@ -136,7 +136,7 @@ pub struct Spi<'d, M: PeriMode> { | |||
| 136 | rx_dma: Option<ChannelAndRequest<'d>>, | 136 | rx_dma: Option<ChannelAndRequest<'d>>, |
| 137 | _phantom: PhantomData<M>, | 137 | _phantom: PhantomData<M>, |
| 138 | current_word_size: word_impl::Config, | 138 | current_word_size: word_impl::Config, |
| 139 | rise_fall_speed: Speed, | 139 | gpio_speed: Speed, |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | impl<'d, M: PeriMode> Spi<'d, M> { | 142 | impl<'d, M: PeriMode> Spi<'d, M> { |
| @@ -159,7 +159,7 @@ impl<'d, M: PeriMode> Spi<'d, M> { | |||
| 159 | rx_dma, | 159 | rx_dma, |
| 160 | current_word_size: <u8 as SealedWord>::CONFIG, | 160 | current_word_size: <u8 as SealedWord>::CONFIG, |
| 161 | _phantom: PhantomData, | 161 | _phantom: PhantomData, |
| 162 | rise_fall_speed: config.rise_fall_speed, | 162 | gpio_speed: config.gpio_speed, |
| 163 | }; | 163 | }; |
| 164 | this.enable_and_init(config); | 164 | this.enable_and_init(config); |
| 165 | this | 165 | this |
| @@ -265,12 +265,12 @@ impl<'d, M: PeriMode> Spi<'d, M> { | |||
| 265 | 265 | ||
| 266 | #[cfg(gpio_v2)] | 266 | #[cfg(gpio_v2)] |
| 267 | { | 267 | { |
| 268 | self.rise_fall_speed = config.rise_fall_speed; | 268 | self.gpio_speed = config.gpio_speed; |
| 269 | if let Some(sck) = self.sck.as_ref() { | 269 | if let Some(sck) = self.sck.as_ref() { |
| 270 | sck.set_speed(config.rise_fall_speed); | 270 | sck.set_speed(config.gpio_speed); |
| 271 | } | 271 | } |
| 272 | if let Some(mosi) = self.mosi.as_ref() { | 272 | if let Some(mosi) = self.mosi.as_ref() { |
| 273 | mosi.set_speed(config.rise_fall_speed); | 273 | mosi.set_speed(config.gpio_speed); |
| 274 | } | 274 | } |
| 275 | } | 275 | } |
| 276 | 276 | ||
| @@ -347,7 +347,7 @@ impl<'d, M: PeriMode> Spi<'d, M> { | |||
| 347 | bit_order, | 347 | bit_order, |
| 348 | frequency, | 348 | frequency, |
| 349 | miso_pull, | 349 | miso_pull, |
| 350 | rise_fall_speed: self.rise_fall_speed, | 350 | gpio_speed: self.gpio_speed, |
| 351 | } | 351 | } |
| 352 | } | 352 | } |
| 353 | 353 | ||
| @@ -481,7 +481,7 @@ impl<'d> Spi<'d, Blocking> { | |||
| 481 | Self::new_inner( | 481 | Self::new_inner( |
| 482 | peri, | 482 | peri, |
| 483 | new_pin!(sck, config.sck_af()), | 483 | new_pin!(sck, config.sck_af()), |
| 484 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.rise_fall_speed)), | 484 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.gpio_speed)), |
| 485 | new_pin!(miso, AfType::input(config.miso_pull)), | 485 | new_pin!(miso, AfType::input(config.miso_pull)), |
| 486 | None, | 486 | None, |
| 487 | None, | 487 | None, |
| @@ -517,7 +517,7 @@ impl<'d> Spi<'d, Blocking> { | |||
| 517 | Self::new_inner( | 517 | Self::new_inner( |
| 518 | peri, | 518 | peri, |
| 519 | new_pin!(sck, config.sck_af()), | 519 | new_pin!(sck, config.sck_af()), |
| 520 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.rise_fall_speed)), | 520 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.gpio_speed)), |
| 521 | None, | 521 | None, |
| 522 | None, | 522 | None, |
| 523 | None, | 523 | None, |
| @@ -536,7 +536,7 @@ impl<'d> Spi<'d, Blocking> { | |||
| 536 | Self::new_inner( | 536 | Self::new_inner( |
| 537 | peri, | 537 | peri, |
| 538 | None, | 538 | None, |
| 539 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.rise_fall_speed)), | 539 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.gpio_speed)), |
| 540 | None, | 540 | None, |
| 541 | None, | 541 | None, |
| 542 | None, | 542 | None, |
| @@ -559,7 +559,7 @@ impl<'d> Spi<'d, Async> { | |||
| 559 | Self::new_inner( | 559 | Self::new_inner( |
| 560 | peri, | 560 | peri, |
| 561 | new_pin!(sck, config.sck_af()), | 561 | new_pin!(sck, config.sck_af()), |
| 562 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.rise_fall_speed)), | 562 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.gpio_speed)), |
| 563 | new_pin!(miso, AfType::input(config.miso_pull)), | 563 | new_pin!(miso, AfType::input(config.miso_pull)), |
| 564 | new_dma!(tx_dma), | 564 | new_dma!(tx_dma), |
| 565 | new_dma!(rx_dma), | 565 | new_dma!(rx_dma), |
| @@ -601,7 +601,7 @@ impl<'d> Spi<'d, Async> { | |||
| 601 | Self::new_inner( | 601 | Self::new_inner( |
| 602 | peri, | 602 | peri, |
| 603 | new_pin!(sck, config.sck_af()), | 603 | new_pin!(sck, config.sck_af()), |
| 604 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.rise_fall_speed)), | 604 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.gpio_speed)), |
| 605 | None, | 605 | None, |
| 606 | new_dma!(tx_dma), | 606 | new_dma!(tx_dma), |
| 607 | None, | 607 | None, |
| @@ -621,7 +621,7 @@ impl<'d> Spi<'d, Async> { | |||
| 621 | Self::new_inner( | 621 | Self::new_inner( |
| 622 | peri, | 622 | peri, |
| 623 | None, | 623 | None, |
| 624 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.rise_fall_speed)), | 624 | new_pin!(mosi, AfType::output(OutputType::PushPull, config.gpio_speed)), |
| 625 | None, | 625 | None, |
| 626 | new_dma!(tx_dma), | 626 | new_dma!(tx_dma), |
| 627 | None, | 627 | None, |
