From 07a668687929b4145e95132f2ac0e5cc8dd542f6 Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Tue, 29 Jun 2021 13:00:52 -0400 Subject: [PATCH] Protect DMA-related things with cfg. --- embassy-stm32/src/usart/mod.rs | 6 ++++++ 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 { pub(crate) mod sealed { use super::*; + + #[cfg(dma)] use crate::dma::WriteDma; pub trait Instance { @@ -47,8 +49,10 @@ pub(crate) mod sealed { fn af_num(&self) -> u8; } + #[cfg(dma)] pub trait RxDma {} + #[cfg(dma)] pub trait TxDma: WriteDma {} } @@ -59,7 +63,9 @@ pub trait CtsPin: sealed::CtsPin {} pub trait RtsPin: sealed::RtsPin {} pub trait CkPin: sealed::CkPin {} +#[cfg(dma)] pub trait RxDma: sealed::RxDma {} +#[cfg(dma)] pub trait TxDma: sealed::TxDma {} 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> { } } - #[cfg(dma_v2)] - pub async fn write_dma( - &mut self, - //ch: &mut impl crate::dma::Channel, - ch: &mut impl TxDma, - buffer: &[u8], - ) -> Result<(), Error> { + #[cfg(dma)] + pub async fn write_dma(&mut self, ch: &mut impl TxDma, buffer: &[u8]) -> Result<(), Error> { unsafe { self.inner.regs().cr3().modify(|reg| { reg.set_dmat(true);