Struct mnemos_d1_core::dmac::descriptor::DescriptorBuilder
source · pub struct DescriptorBuilder<S = (), D = ()> {
cfg: Cfg,
param: Param,
link: u32,
source: S,
dest: D,
}
Expand description
A builder for constructing DMA Descriptor
s.
Fields§
§cfg: Cfg
§param: Param
§link: u32
§source: S
§dest: D
Implementations§
source§impl<S, D> DescriptorBuilder<S, D>
impl<S, D> DescriptorBuilder<S, D>
pub fn src_block_size(self, val: BlockSize) -> Self
pub fn src_data_width(self, val: DataWidth) -> Self
pub fn dest_block_size(self, val: BlockSize) -> Self
pub fn dest_data_width(self, val: DataWidth) -> Self
pub fn bmode_sel(self, val: BModeSel) -> Self
pub fn link( self, link: impl Into<Option<NonNull<Descriptor>>>, ) -> Result<Self, InvalidLink>
pub fn wait_clock_cycles(self, wait_clock_cycles: u8) -> Self
sourcepub fn source_slice(
self,
source: &[u8],
) -> Result<DescriptorBuilder<&[u8], D>, InvalidOperand>
pub fn source_slice( self, source: &[u8], ) -> Result<DescriptorBuilder<&[u8], D>, InvalidOperand>
Sets the provided slice as the source for the DMA transfer. Bytes will be copied out of this slice to the destination operand of the transfer.
Since the slice is in memory, this automatically sets the source address
mode to AddressMode::LinearMode
and the source DRQ type to
SrcDrqType::Dram
.
§Returns
Ok
(
DescriptorBuilder
)
withdest
as the destination operand, if the provided slice’s address is a valid DMA destination.Err
(
InvalidOperand
)
withInvalidOperandReason::TooLong
if the provided slice is longer thanDescriptor::MAX_LEN
.Err
(
InvalidOperand
)
withInvalidOperandReason::AddrTooHigh
if the provided slice’s address is higher thanDescriptor::ADDR_MAX
.
sourcepub fn dest_slice(
self,
dest: &'_ mut [MaybeUninit<u8>],
) -> Result<DescriptorBuilder<S, &'_ mut [MaybeUninit<u8>]>, InvalidOperand>
pub fn dest_slice( self, dest: &'_ mut [MaybeUninit<u8>], ) -> Result<DescriptorBuilder<S, &'_ mut [MaybeUninit<u8>]>, InvalidOperand>
Sets the provided slice as the destination of the DMA transfer. Bytes will be copied from the source operand of the transfer into this slice.
Since the slice is in memory, this automatically sets the destination address
mode to AddressMode::LinearMode
, and the destination DRQ type to
`DestDrqType::Dram.
§Returns
Ok
(
DescriptorBuilder
)
withdest
as the destination operand, if the provided slice’s address is a valid DMA destination.Err
(
InvalidOperand
)
withInvalidOperandReason::TooLong
if the provided slice is longer thanDescriptor::MAX_LEN
.Err
(
InvalidOperand
)
withInvalidOperandReason::AddrTooHigh
if the provided slice’s address is higher thanDescriptor::ADDR_MAX
.
sourcepub fn source_reg<R: RegisterSpec>(
self,
source: &Reg<R>,
drq_type: SrcDrqType,
) -> Result<DescriptorBuilder<*const (), D>, InvalidOperand>
pub fn source_reg<R: RegisterSpec>( self, source: &Reg<R>, drq_type: SrcDrqType, ) -> Result<DescriptorBuilder<*const (), D>, InvalidOperand>
Sets the provided pointer to a memory-mapped IO register as the source for the DMA transfer. Bytes will be copied from this register to the destination operand of the transfer.
Since the source is a memory-mapped IO register, this automatically sets
the source address mode to AddressMode::IoMode
. The provided
SrcDrqType
describes the type of DRQ signal that should be used
when transferring from this register. Note that if this is not the correct
DRQ for this register, the DMA transfer may never complete.
§Safety
source
MUST point to a memory-mapped IO register which is a valid
source for a DMA transfer. Otherwise, you will have a bad time.
§Returns
Ok
(
DescriptorBuilder
)
withsource
as the source operand, if the provided register’s address is a valid DMA source.Err
(
InvalidOperand
)
withInvalidOperandReason::AddrTooHigh
if the provided register’s address is higher thanDescriptor::ADDR_MAX
.
sourcepub fn dest_reg<R: RegisterSpec>(
self,
dest: &Reg<R>,
drq_type: DestDrqType,
) -> Result<DescriptorBuilder<S, *mut ()>, InvalidOperand>
pub fn dest_reg<R: RegisterSpec>( self, dest: &Reg<R>, drq_type: DestDrqType, ) -> Result<DescriptorBuilder<S, *mut ()>, InvalidOperand>
Sets the provided memory-mapped IO register as the destination for the DMA transfer. Bytes will be copied from the source operand to the pointed MMIO register.
Since the destination is a memory-mapped IO register, this automatically sets
the destination address mode to AddressMode::IoMode
. The provided
DestDrqType
describes the type of DRQ signal that should be used
when transferring to this register. Note that if this is not the correct
DRQ for this register, the DMA transfer may never complete.
§Returns
Ok
(
DescriptorBuilder
)
withdest
as the destination operand, if the provided register’s address is a valid DMA destination.Err
(
InvalidOperand
)
withInvalidOperandReason::AddrTooHigh
if the provided register’s address is higher thanDescriptor::ADDR_MAX
.
fn high_bits(addr: *const (), kind: Operand) -> Result<u32, InvalidOperand>
sourcefn build_inner(
self,
source_addr: usize,
dest_addr: usize,
byte_counter: u32,
) -> Descriptor
fn build_inner( self, source_addr: usize, dest_addr: usize, byte_counter: u32, ) -> Descriptor
This method assumes that the value of byte_counter
, as well as the
source, destination, and link addresses, have already been validated.
source§impl DescriptorBuilder<&[u8], &'_ mut [MaybeUninit<u8>]>
impl DescriptorBuilder<&[u8], &'_ mut [MaybeUninit<u8>]>
pub fn build(self) -> Descriptor
source§impl DescriptorBuilder<*const (), &'_ mut [MaybeUninit<u8>]>
impl DescriptorBuilder<*const (), &'_ mut [MaybeUninit<u8>]>
pub fn build(self) -> Descriptor
source§impl DescriptorBuilder<&[u8], *mut ()>
impl DescriptorBuilder<&[u8], *mut ()>
pub fn build(self) -> Descriptor
source§impl DescriptorBuilder<*const (), *mut ()>
impl DescriptorBuilder<*const (), *mut ()>
pub fn try_build(self, len: u32) -> Result<Descriptor, InvalidDescriptor>
Trait Implementations§
source§impl<S: Clone, D: Clone> Clone for DescriptorBuilder<S, D>
impl<S: Clone, D: Clone> Clone for DescriptorBuilder<S, D>
source§fn clone(&self) -> DescriptorBuilder<S, D>
fn clone(&self) -> DescriptorBuilder<S, D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Default for DescriptorBuilder
impl Default for DescriptorBuilder
impl<S: Copy, D: Copy> Copy for DescriptorBuilder<S, D>
Auto Trait Implementations§
impl<S, D> Freeze for DescriptorBuilder<S, D>
impl<S, D> RefUnwindSafe for DescriptorBuilder<S, D>where
S: RefUnwindSafe,
D: RefUnwindSafe,
impl<S, D> Send for DescriptorBuilder<S, D>
impl<S, D> Sync for DescriptorBuilder<S, D>
impl<S, D> Unpin for DescriptorBuilder<S, D>
impl<S, D> UnwindSafe for DescriptorBuilder<S, D>where
S: UnwindSafe,
D: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)