Checkpoint with lifetime issues.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#![macro_use]
|
||||
|
||||
#[cfg_attr(usart_v1, path = "v1.rs")]
|
||||
#[cfg_attr(usart_v2, path = "v2.rs")]
|
||||
//#[cfg_attr(usart_v2, path = "v2.rs")]
|
||||
mod _version;
|
||||
use crate::peripherals;
|
||||
pub use _version::*;
|
||||
@ -25,6 +25,7 @@ pub enum Error {
|
||||
|
||||
pub(crate) mod sealed {
|
||||
use super::*;
|
||||
use crate::dma::WriteDma;
|
||||
|
||||
pub trait Instance {
|
||||
fn regs(&self) -> Usart;
|
||||
@ -44,7 +45,12 @@ pub(crate) mod sealed {
|
||||
pub trait CkPin<T: Instance>: Pin {
|
||||
fn af_num(&self) -> u8;
|
||||
}
|
||||
|
||||
pub trait RxDma<T: Instance> {}
|
||||
|
||||
pub trait TxDma<T: Instance>: WriteDma<T> {}
|
||||
}
|
||||
|
||||
pub trait Instance: sealed::Instance {}
|
||||
pub trait RxPin<T: Instance>: sealed::RxPin<T> {}
|
||||
pub trait TxPin<T: Instance>: sealed::TxPin<T> {}
|
||||
@ -52,6 +58,9 @@ pub trait CtsPin<T: Instance>: sealed::CtsPin<T> {}
|
||||
pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {}
|
||||
pub trait CkPin<T: Instance>: sealed::CkPin<T> {}
|
||||
|
||||
pub trait RxDma<T: Instance>: sealed::RxDma<T> {}
|
||||
pub trait TxDma<T: Instance>: sealed::TxDma<T> {}
|
||||
|
||||
crate::pac::peripherals!(
|
||||
(usart, $inst:ident) => {
|
||||
impl sealed::Instance for peripherals::$inst {
|
||||
|
@ -104,11 +104,16 @@ 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 crate::dma::Channel,
|
||||
ch: &mut impl TxDma<T>,
|
||||
buffer: &[u8],
|
||||
) -> Result<(), Error> {
|
||||
let ch_func = 4; // USART3_TX
|
||||
let r = self.inner.regs();
|
||||
let dst = r.dr().ptr() as *mut u8;
|
||||
ch.transfer(buffer, dst).await;
|
||||
Ok(())
|
||||
/*
|
||||
let ch_func = 4; // USART3_TX
|
||||
|
||||
unsafe {
|
||||
r.cr3().write(|w| {
|
||||
@ -121,6 +126,7 @@ impl<'d, T: Instance> Uart<'d, T> {
|
||||
}
|
||||
|
||||
Ok(())
|
||||
*/
|
||||
}
|
||||
|
||||
pub fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error> {
|
||||
|
Reference in New Issue
Block a user