pub struct SliceDmaWriteTop<S: SliceId, M: ValidSliceMode<S>> { /* private fields */ }
Expand description

Type representing DMA access to PWM top register.

use cortex_m::{prelude::*, singleton};
use rp2040_hal::dma::{double_buffer, DMAExt};
use rp2040_hal::pwm::{SliceDmaWrite, Slices, TopFormat};


let mut pac = rp2040_pac::Peripherals::take().unwrap();

// Init PWMs
let pwm_slices = Slices::new(pac.PWM, &mut pac.RESETS);

// Configure PWM4
let mut pwm = pwm_slices.pwm4;
pwm.enable();

// Just set to something mesurable.
pwm.channel_a.set_duty(0x1000);
pwm.channel_b.set_duty(0x1000);

let buf = singleton!(: [TopFormat; 4] = [TopFormat::new(0x7fff); 4]).unwrap();
let buf2 = singleton!(: [TopFormat; 4] = [TopFormat::new(0xfffe); 4]).unwrap();

let dma = pac.DMA.split(&mut pac.RESETS);

// Reserve PWM slice for dma.
let dma_pwm = SliceDmaWrite::from(pwm);

let dma_conf = double_buffer::Config::new((dma.ch0, dma.ch1), buf, dma_pwm.top);

Trait Implementations§

source§

impl<S: SliceId, M: ValidSliceMode<S>> WriteTarget for SliceDmaWriteTop<S, M>

Safety: tx_address_count points to a register which is always a valid write target.

§

type TransmittedWord = TopFormat

Type which is transferred in a single DMA transfer.
source§

fn tx_treq() -> Option<u8>

Returns the DREQ number for this data sink (None for memory buffers).
source§

fn tx_address_count(&mut self) -> (u32, u32)

Returns the address and the maximum number of words that can be transferred from this data source in a single DMA operation. Read more
source§

fn tx_increment(&self) -> bool

Returns whether the address shall be incremented after each transfer.
source§

impl<S: SliceId, M: ValidSliceMode<S>> EndlessWriteTarget for SliceDmaWriteTop<S, M>

Auto Trait Implementations§

§

impl<S, M> RefUnwindSafe for SliceDmaWriteTop<S, M>

§

impl<S, M> Send for SliceDmaWriteTop<S, M>
where M: Send, S: Send,

§

impl<S, M> Sync for SliceDmaWriteTop<S, M>
where M: Sync, S: Sync,

§

impl<S, M> Unpin for SliceDmaWriteTop<S, M>
where M: Unpin, S: Unpin,

§

impl<S, M> UnwindSafe for SliceDmaWriteTop<S, M>
where M: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

source§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

source§

fn lift_into(self) -> U

Performs the indexed conversion.
source§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.