Struct SerialDma

Source
pub struct SerialDma<Serial_: Instance, TX_TRANSFER, RX_TRANSFER> { /* private fields */ }
Expand description

Serial abstraction that can work in non-blocking mode by using DMA

The struct should be used for sending/receiving bytes to/from the serial interface in non-blocking mode. A client must follow these requirements to use that feature:

  • Enable interrupts DMAx_STREAMy used for transmit and another DMAq_STREAMp used for receive.
  • In these interrupts call handle_dma_interrupt; defined in trait SerialHandleIT.
  • Enable interrupts USARTx or UARTx for handling errors and call handle_error_interrupt in corresponding handler; defined in trait SerialHandleIT.

The struct can be also used to send/receive bytes in blocking mode with methods: write, read, write_read.

Implementations§

Source§

impl<Serial_: Instance, TX_TRANSFER, RX_TRANSFER> SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: DMATransfer<&'static [u8]>, RX_TRANSFER: DMATransfer<&'static mut [u8]>,

Common implementation

Source

pub fn write(&mut self, bytes: &[u8]) -> Result<(), Error>

Source

pub fn read(&mut self, bytes: &mut [u8]) -> Result<(), Error>

Trait Implementations§

Source§

impl<Serial_: Instance, RX_STREAM, const RX_CH: u8> SerialHandleIT for SerialDma<Serial_, NoDMA, RxDMA<Serial_, RX_STREAM, RX_CH>>
where RX_STREAM: Stream, ChannelX<RX_CH>: Channel, Rx<Serial_>: DMASet<RX_STREAM, RX_CH, PeripheralToMemory>,

Source§

impl<Serial_: Instance, TX_STREAM, const TX_CH: u8> SerialHandleIT for SerialDma<Serial_, TxDMA<Serial_, TX_STREAM, TX_CH>, NoDMA>
where TX_STREAM: Stream, ChannelX<TX_CH>: Channel, Tx<Serial_>: DMASet<TX_STREAM, TX_CH, MemoryToPeripheral>,

Source§

impl<Serial_: Instance, TX_STREAM, const TX_CH: u8, RX_STREAM, const RX_CH: u8> SerialHandleIT for SerialDma<Serial_, TxDMA<Serial_, TX_STREAM, TX_CH>, RxDMA<Serial_, RX_STREAM, RX_CH>>
where TX_STREAM: Stream, ChannelX<TX_CH>: Channel, Tx<Serial_>: DMASet<TX_STREAM, TX_CH, MemoryToPeripheral>, RX_STREAM: Stream, ChannelX<RX_CH>: Channel, Rx<Serial_>: DMASet<RX_STREAM, RX_CH, PeripheralToMemory>,

Only for both TX and RX DMA

Source§

impl<Serial_: Instance, TX_TRANSFER, RX_STREAM, const RX_CH: u8> SerialReadDMA for SerialDma<Serial_, TX_TRANSFER, RxDMA<Serial_, RX_STREAM, RX_CH>>
where RX_STREAM: Stream, ChannelX<RX_CH>: Channel, Rx<Serial_>: DMASet<RX_STREAM, RX_CH, PeripheralToMemory>, TX_TRANSFER: DMATransfer<&'static [u8]>,

Source§

unsafe fn read_dma( &mut self, buf: &mut [u8], callback: Option<SerialCompleteCallback>, ) -> Result<(), Error>

Reads bytes from the serial interface in non-blocking mode and writes these bytes in buf Read more
Source§

impl<Serial_: Instance, TX_STREAM, const TX_CH: u8, RX_TRANSFER> SerialWriteDMA for SerialDma<Serial_, TxDMA<Serial_, TX_STREAM, TX_CH>, RX_TRANSFER>
where TX_STREAM: Stream, ChannelX<TX_CH>: Channel, Tx<Serial_>: DMASet<TX_STREAM, TX_CH, MemoryToPeripheral>, RX_TRANSFER: DMATransfer<&'static mut [u8]>,

Source§

unsafe fn write_dma( &mut self, bytes: &[u8], callback: Option<SerialCompleteCallback>, ) -> Result<(), Error>

Writes bytes to the serial interface in non-blocking mode Read more

Auto Trait Implementations§

§

impl<Serial_, TX_TRANSFER, RX_TRANSFER> Freeze for SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: Freeze, RX_TRANSFER: Freeze, Serial_: Freeze, <Serial_ as SerialAsync>::Tx<PushPull>: Freeze, <Serial_ as SerialAsync>::Rx<PushPull>: Freeze,

§

impl<Serial_, TX_TRANSFER, RX_TRANSFER> RefUnwindSafe for SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: RefUnwindSafe, RX_TRANSFER: RefUnwindSafe, Serial_: RefUnwindSafe, <Serial_ as SerialAsync>::Tx<PushPull>: RefUnwindSafe, <Serial_ as SerialAsync>::Rx<PushPull>: RefUnwindSafe,

§

impl<Serial_, TX_TRANSFER, RX_TRANSFER> Send for SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: Send, RX_TRANSFER: Send, Serial_: Send, <Serial_ as SerialAsync>::Tx<PushPull>: Send, <Serial_ as SerialAsync>::Rx<PushPull>: Send,

§

impl<Serial_, TX_TRANSFER, RX_TRANSFER> Sync for SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: Sync, RX_TRANSFER: Sync, Serial_: Sync, <Serial_ as SerialAsync>::Tx<PushPull>: Sync, <Serial_ as SerialAsync>::Rx<PushPull>: Sync,

§

impl<Serial_, TX_TRANSFER, RX_TRANSFER> Unpin for SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: Unpin, RX_TRANSFER: Unpin, Serial_: Unpin, <Serial_ as SerialAsync>::Tx<PushPull>: Unpin, <Serial_ as SerialAsync>::Rx<PushPull>: Unpin,

§

impl<Serial_, TX_TRANSFER, RX_TRANSFER> UnwindSafe for SerialDma<Serial_, TX_TRANSFER, RX_TRANSFER>
where TX_TRANSFER: UnwindSafe, RX_TRANSFER: UnwindSafe, Serial_: UnwindSafe, <Serial_ as SerialAsync>::Tx<PushPull>: UnwindSafe, <Serial_ as SerialAsync>::Rx<PushPull>: 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<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> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.