diff options
| author | Bob McWhirter <[email protected]> | 2021-06-29 13:00:52 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-06-29 13:00:52 -0400 |
| commit | 07a668687929b4145e95132f2ac0e5cc8dd542f6 (patch) | |
| tree | c413ee86a83d39b35312b5d60c33439ef8a73be9 | |
| parent | 2a25de3d3e16ebf8f21323ce016fe2ecf4d21629 (diff) | |
Protect DMA-related things with cfg.
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/v1.rs | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 08be583c7..a75793f84 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -26,6 +26,8 @@ pub enum Error { | |||
| 26 | 26 | ||
| 27 | pub(crate) mod sealed { | 27 | pub(crate) mod sealed { |
| 28 | use super::*; | 28 | use super::*; |
| 29 | |||
| 30 | #[cfg(dma)] | ||
| 29 | use crate::dma::WriteDma; | 31 | use crate::dma::WriteDma; |
| 30 | 32 | ||
| 31 | pub trait Instance { | 33 | pub trait Instance { |
| @@ -47,8 +49,10 @@ pub(crate) mod sealed { | |||
| 47 | fn af_num(&self) -> u8; | 49 | fn af_num(&self) -> u8; |
| 48 | } | 50 | } |
| 49 | 51 | ||
| 52 | #[cfg(dma)] | ||
| 50 | pub trait RxDma<T: Instance> {} | 53 | pub trait RxDma<T: Instance> {} |
| 51 | 54 | ||
| 55 | #[cfg(dma)] | ||
| 52 | pub trait TxDma<T: Instance>: WriteDma<T> {} | 56 | pub trait TxDma<T: Instance>: WriteDma<T> {} |
| 53 | } | 57 | } |
| 54 | 58 | ||
| @@ -59,7 +63,9 @@ pub trait CtsPin<T: Instance>: sealed::CtsPin<T> {} | |||
| 59 | pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {} | 63 | pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {} |
| 60 | pub trait CkPin<T: Instance>: sealed::CkPin<T> {} | 64 | pub trait CkPin<T: Instance>: sealed::CkPin<T> {} |
| 61 | 65 | ||
| 66 | #[cfg(dma)] | ||
| 62 | pub trait RxDma<T: Instance>: sealed::RxDma<T> {} | 67 | pub trait RxDma<T: Instance>: sealed::RxDma<T> {} |
| 68 | #[cfg(dma)] | ||
| 63 | pub trait TxDma<T: Instance>: sealed::TxDma<T> {} | 69 | pub trait TxDma<T: Instance>: sealed::TxDma<T> {} |
| 64 | 70 | ||
| 65 | crate::pac::peripherals!( | 71 | crate::pac::peripherals!( |
diff --git a/embassy-stm32/src/usart/v1.rs b/embassy-stm32/src/usart/v1.rs index 1f05dc9a2..37b325d8f 100644 --- a/embassy-stm32/src/usart/v1.rs +++ b/embassy-stm32/src/usart/v1.rs | |||
| @@ -104,13 +104,8 @@ impl<'d, T: Instance> Uart<'d, T> { | |||
| 104 | } | 104 | } |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | #[cfg(dma_v2)] | 107 | #[cfg(dma)] |
| 108 | pub async fn write_dma( | 108 | pub async fn write_dma(&mut self, ch: &mut impl TxDma<T>, buffer: &[u8]) -> Result<(), Error> { |
| 109 | &mut self, | ||
| 110 | //ch: &mut impl crate::dma::Channel, | ||
| 111 | ch: &mut impl TxDma<T>, | ||
| 112 | buffer: &[u8], | ||
| 113 | ) -> Result<(), Error> { | ||
| 114 | unsafe { | 109 | unsafe { |
| 115 | self.inner.regs().cr3().modify(|reg| { | 110 | self.inner.regs().cr3().modify(|reg| { |
| 116 | reg.set_dmat(true); | 111 | reg.set_dmat(true); |
