[UCPD] Use ChannelAndRequest
helper
This commit is contained in:
parent
a7eb9bced1
commit
5c93e9dadd
1 changed files with 16 additions and 24 deletions
|
@ -20,10 +20,10 @@ use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
|
|
||||||
use embassy_hal_internal::drop::OnDrop;
|
use embassy_hal_internal::drop::OnDrop;
|
||||||
use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef};
|
use embassy_hal_internal::{into_ref, Peripheral};
|
||||||
use embassy_sync::waitqueue::AtomicWaker;
|
use embassy_sync::waitqueue::AtomicWaker;
|
||||||
|
|
||||||
use crate::dma::{AnyChannel, Request, Transfer, TransferOptions};
|
use crate::dma::{ChannelAndRequest, TransferOptions};
|
||||||
use crate::interrupt;
|
use crate::interrupt;
|
||||||
use crate::interrupt::typelevel::Interrupt;
|
use crate::interrupt::typelevel::Interrupt;
|
||||||
use crate::pac::ucpd::vals::{Anamode, Ccenable, PscUsbpdclk, Txmode};
|
use crate::pac::ucpd::vals::{Anamode, Ccenable, PscUsbpdclk, Txmode};
|
||||||
|
@ -179,10 +179,14 @@ impl<'d, T: Instance> Ucpd<'d, T> {
|
||||||
self.cc_phy,
|
self.cc_phy,
|
||||||
PdPhy {
|
PdPhy {
|
||||||
_lifetime: PhantomData,
|
_lifetime: PhantomData,
|
||||||
rx_dma_ch: rx_dma.map_into(),
|
rx_dma: ChannelAndRequest {
|
||||||
rx_dma_req,
|
channel: rx_dma.map_into(),
|
||||||
tx_dma_ch: tx_dma.map_into(),
|
request: rx_dma_req,
|
||||||
tx_dma_req,
|
},
|
||||||
|
tx_dma: ChannelAndRequest {
|
||||||
|
channel: tx_dma.map_into(),
|
||||||
|
request: tx_dma_req,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -309,10 +313,8 @@ pub enum TxError {
|
||||||
/// Power Delivery (PD) PHY.
|
/// Power Delivery (PD) PHY.
|
||||||
pub struct PdPhy<'d, T: Instance> {
|
pub struct PdPhy<'d, T: Instance> {
|
||||||
_lifetime: PhantomData<&'d mut T>,
|
_lifetime: PhantomData<&'d mut T>,
|
||||||
rx_dma_ch: PeripheralRef<'d, AnyChannel>,
|
rx_dma: ChannelAndRequest<'d>,
|
||||||
rx_dma_req: Request,
|
tx_dma: ChannelAndRequest<'d>,
|
||||||
tx_dma_ch: PeripheralRef<'d, AnyChannel>,
|
|
||||||
tx_dma_req: Request,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: Instance> Drop for PdPhy<'d, T> {
|
impl<'d, T: Instance> Drop for PdPhy<'d, T> {
|
||||||
|
@ -337,13 +339,8 @@ impl<'d, T: Instance> PdPhy<'d, T> {
|
||||||
let r = T::REGS;
|
let r = T::REGS;
|
||||||
|
|
||||||
let dma = unsafe {
|
let dma = unsafe {
|
||||||
Transfer::new_read(
|
self.rx_dma
|
||||||
&mut self.rx_dma_ch,
|
.read(r.rxdr().as_ptr() as *mut u8, buf, TransferOptions::default())
|
||||||
self.rx_dma_req,
|
|
||||||
r.rxdr().as_ptr() as *mut u8,
|
|
||||||
buf,
|
|
||||||
TransferOptions::default(),
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear interrupt flags (possibly set from last receive).
|
// Clear interrupt flags (possibly set from last receive).
|
||||||
|
@ -418,13 +415,8 @@ impl<'d, T: Instance> PdPhy<'d, T> {
|
||||||
|
|
||||||
// Start the DMA and let it do its thing in the background.
|
// Start the DMA and let it do its thing in the background.
|
||||||
let _dma = unsafe {
|
let _dma = unsafe {
|
||||||
Transfer::new_write(
|
self.tx_dma
|
||||||
&mut self.tx_dma_ch,
|
.write(buf, r.txdr().as_ptr() as *mut u8, TransferOptions::default())
|
||||||
self.tx_dma_req,
|
|
||||||
buf,
|
|
||||||
r.txdr().as_ptr() as *mut u8,
|
|
||||||
TransferOptions::default(),
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Configure and start the transmission.
|
// Configure and start the transmission.
|
||||||
|
|
Loading…
Reference in a new issue