diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-04-15 21:56:08 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-04-15 21:56:08 +0200 |
| commit | 2eab099b85a7e0ba10d1f558dce89112cd577c68 (patch) | |
| tree | 652c7f4c71f3fdcd9aa5ac18d6c17c0b3040c975 | |
| parent | 09a284e9592cc426b5a3c3b72b3f02c0c4844742 (diff) | |
stm32/spi: rename rxdma, txdma -> rx_dma, tx_dma.
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 303b85346..c39ef1913 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -97,8 +97,8 @@ pub struct Spi<'d, T: Instance, M: PeriMode> { | |||
| 97 | sck: Option<PeripheralRef<'d, AnyPin>>, | 97 | sck: Option<PeripheralRef<'d, AnyPin>>, |
| 98 | mosi: Option<PeripheralRef<'d, AnyPin>>, | 98 | mosi: Option<PeripheralRef<'d, AnyPin>>, |
| 99 | miso: Option<PeripheralRef<'d, AnyPin>>, | 99 | miso: Option<PeripheralRef<'d, AnyPin>>, |
| 100 | txdma: Option<ChannelAndRequest<'d>>, | 100 | tx_dma: Option<ChannelAndRequest<'d>>, |
| 101 | rxdma: Option<ChannelAndRequest<'d>>, | 101 | rx_dma: Option<ChannelAndRequest<'d>>, |
| 102 | _phantom: PhantomData<M>, | 102 | _phantom: PhantomData<M>, |
| 103 | current_word_size: word_impl::Config, | 103 | current_word_size: word_impl::Config, |
| 104 | } | 104 | } |
| @@ -109,8 +109,8 @@ impl<'d, T: Instance, M: PeriMode> Spi<'d, T, M> { | |||
| 109 | sck: Option<PeripheralRef<'d, AnyPin>>, | 109 | sck: Option<PeripheralRef<'d, AnyPin>>, |
| 110 | mosi: Option<PeripheralRef<'d, AnyPin>>, | 110 | mosi: Option<PeripheralRef<'d, AnyPin>>, |
| 111 | miso: Option<PeripheralRef<'d, AnyPin>>, | 111 | miso: Option<PeripheralRef<'d, AnyPin>>, |
| 112 | txdma: Option<ChannelAndRequest<'d>>, | 112 | tx_dma: Option<ChannelAndRequest<'d>>, |
| 113 | rxdma: Option<ChannelAndRequest<'d>>, | 113 | rx_dma: Option<ChannelAndRequest<'d>>, |
| 114 | config: Config, | 114 | config: Config, |
| 115 | ) -> Self { | 115 | ) -> Self { |
| 116 | into_ref!(peri); | 116 | into_ref!(peri); |
| @@ -209,8 +209,8 @@ impl<'d, T: Instance, M: PeriMode> Spi<'d, T, M> { | |||
| 209 | sck, | 209 | sck, |
| 210 | mosi, | 210 | mosi, |
| 211 | miso, | 211 | miso, |
| 212 | txdma, | 212 | tx_dma, |
| 213 | rxdma, | 213 | rx_dma, |
| 214 | current_word_size: <u8 as SealedWord>::CONFIG, | 214 | current_word_size: <u8 as SealedWord>::CONFIG, |
| 215 | _phantom: PhantomData, | 215 | _phantom: PhantomData, |
| 216 | } | 216 | } |
| @@ -479,8 +479,8 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 479 | sck: impl Peripheral<P = impl SckPin<T>> + 'd, | 479 | sck: impl Peripheral<P = impl SckPin<T>> + 'd, |
| 480 | mosi: impl Peripheral<P = impl MosiPin<T>> + 'd, | 480 | mosi: impl Peripheral<P = impl MosiPin<T>> + 'd, |
| 481 | miso: impl Peripheral<P = impl MisoPin<T>> + 'd, | 481 | miso: impl Peripheral<P = impl MisoPin<T>> + 'd, |
| 482 | txdma: impl Peripheral<P = impl TxDma<T>> + 'd, | 482 | tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd, |
| 483 | rxdma: impl Peripheral<P = impl RxDma<T>> + 'd, | 483 | rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, |
| 484 | config: Config, | 484 | config: Config, |
| 485 | ) -> Self { | 485 | ) -> Self { |
| 486 | Self::new_inner( | 486 | Self::new_inner( |
| @@ -488,8 +488,8 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 488 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), | 488 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), |
| 489 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), | 489 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), |
| 490 | new_pin!(miso, AFType::Input, Speed::VeryHigh), | 490 | new_pin!(miso, AFType::Input, Speed::VeryHigh), |
| 491 | new_dma!(txdma), | 491 | new_dma!(tx_dma), |
| 492 | new_dma!(rxdma), | 492 | new_dma!(rx_dma), |
| 493 | config, | 493 | config, |
| 494 | ) | 494 | ) |
| 495 | } | 495 | } |
| @@ -499,7 +499,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 499 | peri: impl Peripheral<P = T> + 'd, | 499 | peri: impl Peripheral<P = T> + 'd, |
| 500 | sck: impl Peripheral<P = impl SckPin<T>> + 'd, | 500 | sck: impl Peripheral<P = impl SckPin<T>> + 'd, |
| 501 | miso: impl Peripheral<P = impl MisoPin<T>> + 'd, | 501 | miso: impl Peripheral<P = impl MisoPin<T>> + 'd, |
| 502 | rxdma: impl Peripheral<P = impl RxDma<T>> + 'd, | 502 | rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, |
| 503 | config: Config, | 503 | config: Config, |
| 504 | ) -> Self { | 504 | ) -> Self { |
| 505 | Self::new_inner( | 505 | Self::new_inner( |
| @@ -508,7 +508,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 508 | None, | 508 | None, |
| 509 | new_pin!(miso, AFType::Input, Speed::VeryHigh), | 509 | new_pin!(miso, AFType::Input, Speed::VeryHigh), |
| 510 | None, | 510 | None, |
| 511 | new_dma!(rxdma), | 511 | new_dma!(rx_dma), |
| 512 | config, | 512 | config, |
| 513 | ) | 513 | ) |
| 514 | } | 514 | } |
| @@ -518,7 +518,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 518 | peri: impl Peripheral<P = T> + 'd, | 518 | peri: impl Peripheral<P = T> + 'd, |
| 519 | sck: impl Peripheral<P = impl SckPin<T>> + 'd, | 519 | sck: impl Peripheral<P = impl SckPin<T>> + 'd, |
| 520 | mosi: impl Peripheral<P = impl MosiPin<T>> + 'd, | 520 | mosi: impl Peripheral<P = impl MosiPin<T>> + 'd, |
| 521 | txdma: impl Peripheral<P = impl TxDma<T>> + 'd, | 521 | tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd, |
| 522 | config: Config, | 522 | config: Config, |
| 523 | ) -> Self { | 523 | ) -> Self { |
| 524 | Self::new_inner( | 524 | Self::new_inner( |
| @@ -526,7 +526,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 526 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), | 526 | new_pin!(sck, AFType::OutputPushPull, Speed::VeryHigh, config.sck_pull_mode()), |
| 527 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), | 527 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), |
| 528 | None, | 528 | None, |
| 529 | new_dma!(txdma), | 529 | new_dma!(tx_dma), |
| 530 | None, | 530 | None, |
| 531 | config, | 531 | config, |
| 532 | ) | 532 | ) |
| @@ -538,7 +538,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 538 | pub fn new_txonly_nosck( | 538 | pub fn new_txonly_nosck( |
| 539 | peri: impl Peripheral<P = T> + 'd, | 539 | peri: impl Peripheral<P = T> + 'd, |
| 540 | mosi: impl Peripheral<P = impl MosiPin<T>> + 'd, | 540 | mosi: impl Peripheral<P = impl MosiPin<T>> + 'd, |
| 541 | txdma: impl Peripheral<P = impl TxDma<T>> + 'd, | 541 | tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd, |
| 542 | config: Config, | 542 | config: Config, |
| 543 | ) -> Self { | 543 | ) -> Self { |
| 544 | Self::new_inner( | 544 | Self::new_inner( |
| @@ -546,7 +546,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 546 | None, | 546 | None, |
| 547 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), | 547 | new_pin!(mosi, AFType::OutputPushPull, Speed::VeryHigh), |
| 548 | None, | 548 | None, |
| 549 | new_dma!(txdma), | 549 | new_dma!(tx_dma), |
| 550 | None, | 550 | None, |
| 551 | config, | 551 | config, |
| 552 | ) | 552 | ) |
| @@ -556,8 +556,8 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 556 | /// Useful for on chip peripherals like SUBGHZ which are hardwired. | 556 | /// Useful for on chip peripherals like SUBGHZ which are hardwired. |
| 557 | pub fn new_subghz( | 557 | pub fn new_subghz( |
| 558 | peri: impl Peripheral<P = T> + 'd, | 558 | peri: impl Peripheral<P = T> + 'd, |
| 559 | txdma: impl Peripheral<P = impl TxDma<T>> + 'd, | 559 | tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd, |
| 560 | rxdma: impl Peripheral<P = impl RxDma<T>> + 'd, | 560 | rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, |
| 561 | ) -> Self { | 561 | ) -> Self { |
| 562 | // see RM0453 rev 1 section 7.2.13 page 291 | 562 | // see RM0453 rev 1 section 7.2.13 page 291 |
| 563 | // The SUBGHZSPI_SCK frequency is obtained by PCLK3 divided by two. | 563 | // The SUBGHZSPI_SCK frequency is obtained by PCLK3 divided by two. |
| @@ -569,17 +569,17 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 569 | config.bit_order = BitOrder::MsbFirst; | 569 | config.bit_order = BitOrder::MsbFirst; |
| 570 | config.frequency = freq; | 570 | config.frequency = freq; |
| 571 | 571 | ||
| 572 | Self::new_inner(peri, None, None, None, new_dma!(txdma), new_dma!(rxdma), config) | 572 | Self::new_inner(peri, None, None, None, new_dma!(tx_dma), new_dma!(rx_dma), config) |
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | #[allow(dead_code)] | 575 | #[allow(dead_code)] |
| 576 | pub(crate) fn new_internal( | 576 | pub(crate) fn new_internal( |
| 577 | peri: impl Peripheral<P = T> + 'd, | 577 | peri: impl Peripheral<P = T> + 'd, |
| 578 | txdma: impl Peripheral<P = impl TxDma<T>> + 'd, | 578 | tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd, |
| 579 | rxdma: impl Peripheral<P = impl RxDma<T>> + 'd, | 579 | rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, |
| 580 | config: Config, | 580 | config: Config, |
| 581 | ) -> Self { | 581 | ) -> Self { |
| 582 | Self::new_inner(peri, None, None, None, new_dma!(txdma), new_dma!(rxdma), config) | 582 | Self::new_inner(peri, None, None, None, new_dma!(tx_dma), new_dma!(rx_dma), config) |
| 583 | } | 583 | } |
| 584 | 584 | ||
| 585 | /// SPI write, using DMA. | 585 | /// SPI write, using DMA. |
| @@ -594,7 +594,7 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 594 | }); | 594 | }); |
| 595 | 595 | ||
| 596 | let tx_dst = T::REGS.tx_ptr(); | 596 | let tx_dst = T::REGS.tx_ptr(); |
| 597 | let tx_f = unsafe { self.txdma.as_mut().unwrap().write(data, tx_dst, Default::default()) }; | 597 | let tx_f = unsafe { self.tx_dma.as_mut().unwrap().write(data, tx_dst, Default::default()) }; |
| 598 | 598 | ||
| 599 | set_txdmaen(T::REGS, true); | 599 | set_txdmaen(T::REGS, true); |
| 600 | T::REGS.cr1().modify(|w| { | 600 | T::REGS.cr1().modify(|w| { |
| @@ -632,12 +632,12 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 632 | let clock_byte_count = data.len(); | 632 | let clock_byte_count = data.len(); |
| 633 | 633 | ||
| 634 | let rx_src = T::REGS.rx_ptr(); | 634 | let rx_src = T::REGS.rx_ptr(); |
| 635 | let rx_f = unsafe { self.rxdma.as_mut().unwrap().read(rx_src, data, Default::default()) }; | 635 | let rx_f = unsafe { self.rx_dma.as_mut().unwrap().read(rx_src, data, Default::default()) }; |
| 636 | 636 | ||
| 637 | let tx_dst = T::REGS.tx_ptr(); | 637 | let tx_dst = T::REGS.tx_ptr(); |
| 638 | let clock_byte = 0x00u8; | 638 | let clock_byte = 0x00u8; |
| 639 | let tx_f = unsafe { | 639 | let tx_f = unsafe { |
| 640 | self.txdma | 640 | self.tx_dma |
| 641 | .as_mut() | 641 | .as_mut() |
| 642 | .unwrap() | 642 | .unwrap() |
| 643 | .write_repeated(&clock_byte, clock_byte_count, tx_dst, Default::default()) | 643 | .write_repeated(&clock_byte, clock_byte_count, tx_dst, Default::default()) |
| @@ -679,11 +679,11 @@ impl<'d, T: Instance> Spi<'d, T, Async> { | |||
| 679 | set_rxdmaen(T::REGS, true); | 679 | set_rxdmaen(T::REGS, true); |
| 680 | 680 | ||
| 681 | let rx_src = T::REGS.rx_ptr(); | 681 | let rx_src = T::REGS.rx_ptr(); |
| 682 | let rx_f = unsafe { self.rxdma.as_mut().unwrap().read_raw(rx_src, read, Default::default()) }; | 682 | let rx_f = unsafe { self.rx_dma.as_mut().unwrap().read_raw(rx_src, read, Default::default()) }; |
| 683 | 683 | ||
| 684 | let tx_dst = T::REGS.tx_ptr(); | 684 | let tx_dst = T::REGS.tx_ptr(); |
| 685 | let tx_f = unsafe { | 685 | let tx_f = unsafe { |
| 686 | self.txdma | 686 | self.tx_dma |
| 687 | .as_mut() | 687 | .as_mut() |
| 688 | .unwrap() | 688 | .unwrap() |
| 689 | .write_raw(write, tx_dst, Default::default()) | 689 | .write_raw(write, tx_dst, Default::default()) |
