Protect DMA-related things with cfg.

This commit is contained in:
Bob McWhirter 2021-06-29 13:00:52 -04:00
parent 2a25de3d3e
commit 07a6686879
2 changed files with 8 additions and 7 deletions

View File

@ -26,6 +26,8 @@ pub enum Error {
pub(crate) mod sealed { pub(crate) mod sealed {
use super::*; use super::*;
#[cfg(dma)]
use crate::dma::WriteDma; use crate::dma::WriteDma;
pub trait Instance { pub trait Instance {
@ -47,8 +49,10 @@ pub(crate) mod sealed {
fn af_num(&self) -> u8; fn af_num(&self) -> u8;
} }
#[cfg(dma)]
pub trait RxDma<T: Instance> {} pub trait RxDma<T: Instance> {}
#[cfg(dma)]
pub trait TxDma<T: Instance>: WriteDma<T> {} pub trait TxDma<T: Instance>: WriteDma<T> {}
} }
@ -59,7 +63,9 @@ pub trait CtsPin<T: Instance>: sealed::CtsPin<T> {}
pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {} pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {}
pub trait CkPin<T: Instance>: sealed::CkPin<T> {} pub trait CkPin<T: Instance>: sealed::CkPin<T> {}
#[cfg(dma)]
pub trait RxDma<T: Instance>: sealed::RxDma<T> {} pub trait RxDma<T: Instance>: sealed::RxDma<T> {}
#[cfg(dma)]
pub trait TxDma<T: Instance>: sealed::TxDma<T> {} pub trait TxDma<T: Instance>: sealed::TxDma<T> {}
crate::pac::peripherals!( crate::pac::peripherals!(

View File

@ -104,13 +104,8 @@ impl<'d, T: Instance> Uart<'d, T> {
} }
} }
#[cfg(dma_v2)] #[cfg(dma)]
pub async fn write_dma( pub async fn write_dma(&mut self, ch: &mut impl TxDma<T>, buffer: &[u8]) -> Result<(), Error> {
&mut self,
//ch: &mut impl crate::dma::Channel,
ch: &mut impl TxDma<T>,
buffer: &[u8],
) -> Result<(), Error> {
unsafe { unsafe {
self.inner.regs().cr3().modify(|reg| { self.inner.regs().cr3().modify(|reg| {
reg.set_dmat(true); reg.set_dmat(true);