Struct rp2040_hal::pwm::SliceDmaWriteTop
source · 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>
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 TransmittedWord = TopFormat
Type which is transferred in a single DMA transfer.
source§fn tx_treq() -> Option<u8>
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)
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
fn tx_increment(&self) -> bool
Returns whether the address shall be incremented after each transfer.
impl<S: SliceId, M: ValidSliceMode<S>> EndlessWriteTarget for SliceDmaWriteTop<S, M>
Auto Trait Implementations§
impl<S, M> RefUnwindSafe for SliceDmaWriteTop<S, M>where
M: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, M> Send for SliceDmaWriteTop<S, M>
impl<S, M> Sync for SliceDmaWriteTop<S, M>
impl<S, M> Unpin for SliceDmaWriteTop<S, M>
impl<S, M> UnwindSafe for SliceDmaWriteTop<S, M>where
M: UnwindSafe,
S: 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
Mutably borrows from an owned value. Read more