pub struct Cs4272<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>where
Pio: PIOExt,
ChA: SingleChannel,
ChB: SingleChannel,
P0: OutputPin,
P1: AnyPin,
P2: AnyPin,
P3: AnyPin,
P4: AnyPin,
P5: AnyPin,{ /* private fields */ }Expand description
Main driver struct, keeps ownership of all necessary resources while the driver is running
Implementations§
Source§impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>where
Pio: PIOExt,
ChA: SingleChannel,
ChB: SingleChannel,
P0: OutputPin,
P1: AnyPin<Function = Pio::PinFunction>,
P2: AnyPin<Function = Pio::PinFunction>,
P3: AnyPin<Function = Pio::PinFunction>,
P4: AnyPin<Function = Pio::PinFunction>,
P5: AnyPin<Function = Pio::PinFunction>,
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>where
Pio: PIOExt,
ChA: SingleChannel,
ChB: SingleChannel,
P0: OutputPin,
P1: AnyPin<Function = Pio::PinFunction>,
P2: AnyPin<Function = Pio::PinFunction>,
P3: AnyPin<Function = Pio::PinFunction>,
P4: AnyPin<Function = Pio::PinFunction>,
P5: AnyPin<Function = Pio::PinFunction>,
Sourcepub fn handle_irq(&mut self)
pub fn handle_irq(&mut self)
Required method for restarting the DMA and swapping the buffers internally.
#[interrupt]
fn DMA_IRQ_0() {
cortex_m::interrupt::free(|cs| {
let mut cs4272 = CS4272.borrow(cs).borrow_mut();
cs4272.as_mut().unwrap().handle_irq();
});
}Sourcepub fn poll(&self) -> bool
pub fn poll(&self) -> bool
Check if the current free output buffer has already been written to.
This makes it easy to periodically check when the driver is ready for new input.
if cs4272.poll() {
// buffer is ready for new input
}Sourcepub fn get_input_buffer<'a>(
&'a self,
) -> Ref<'a, &'static mut [u32; BUFFER_SIZE]>
pub fn get_input_buffer<'a>( &'a self, ) -> Ref<'a, &'static mut [u32; BUFFER_SIZE]>
Get a reference to the currently free input buffer.
If you are using the driver from a mutex getting to the data
requires a cs from an interrupt::free callback for memory safety.
Consider cloning the buffer to process it without blocking any other interrupts:
let buffer = cortex_m::interrupt::free(|cs| {
CS4272.borrow(cs).borrow_mut().as_ref().unwrap().get_input_buffer().clone()
});Sourcepub fn set_output_buffer(&mut self, buffer: &[u32; BUFFER_SIZE])
pub fn set_output_buffer(&mut self, buffer: &[u32; BUFFER_SIZE])
Sets the current free output buffer for the next buffer switch.
// Output silence
let buffer: [u32; BUFFER_SIZE] = [0; BUFFER_SIZE];
cortex_m::interrupt::free(|cs| {
CS4272.borrow(cs).borrow_mut().as_mut().unwrap().set_output_buffer(&buffer).clone()
});Auto Trait Implementations§
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> !Freeze for Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> !RefUnwindSafe for Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> Send for Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>where
P0: Send,
<P5 as AnyPin>::Id: Send,
<P5 as AnyPin>::Function: Send,
<P5 as AnyPin>::Pull: Send,
<P2 as AnyPin>::Id: Send,
<P2 as AnyPin>::Function: Send,
<P2 as AnyPin>::Pull: Send,
<P1 as AnyPin>::Id: Send,
<P1 as AnyPin>::Function: Send,
<P1 as AnyPin>::Pull: Send,
<P3 as AnyPin>::Id: Send,
<P3 as AnyPin>::Function: Send,
<P3 as AnyPin>::Pull: Send,
<P4 as AnyPin>::Id: Send,
<P4 as AnyPin>::Function: Send,
<P4 as AnyPin>::Pull: Send,
ChB: Send,
ChA: Send,
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> !Sync for Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> Unpin for Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>where
P0: Unpin,
<P5 as AnyPin>::Id: Unpin,
<P5 as AnyPin>::Function: Unpin,
<P5 as AnyPin>::Pull: Unpin,
<P2 as AnyPin>::Id: Unpin,
<P2 as AnyPin>::Function: Unpin,
<P2 as AnyPin>::Pull: Unpin,
<P1 as AnyPin>::Id: Unpin,
<P1 as AnyPin>::Function: Unpin,
<P1 as AnyPin>::Pull: Unpin,
<P3 as AnyPin>::Id: Unpin,
<P3 as AnyPin>::Function: Unpin,
<P3 as AnyPin>::Pull: Unpin,
<P4 as AnyPin>::Id: Unpin,
<P4 as AnyPin>::Function: Unpin,
<P4 as AnyPin>::Pull: Unpin,
Pio: Unpin,
ChB: Unpin,
ChA: Unpin,
impl<const BUFFER_SIZE: usize, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5> !UnwindSafe for Cs4272<BUFFER_SIZE, Pio, ChA, ChB, P0, P1, P2, P3, P4, P5>
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
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more