Struct Serial

Source
pub struct Serial<USART: CommonPins, WORD = u8> { /* private fields */ }
Expand description

Serial abstraction

Implementations§

Source§

impl<UART: Instance, WORD> Serial<UART, WORD>

Source

pub fn tx( usart: UART, tx_pin: impl Into<UART::Tx<PushPull>>, config: impl Into<Config>, clocks: &Clocks, ) -> Result<Tx<UART, WORD>, InvalidConfig>
where NoPin: Into<UART::Rx<PushPull>>,

Source§

impl<UART: Instance, WORD> Serial<UART, WORD>

Source

pub fn rx( usart: UART, rx_pin: impl Into<UART::Rx<PushPull>>, config: impl Into<Config>, clocks: &Clocks, ) -> Result<Rx<UART, WORD>, InvalidConfig>
where NoPin: Into<UART::Tx<PushPull>>,

Source§

impl<Serial_: Instance> Serial<Serial_>

Source

pub fn use_dma<TX_STREAM, const TX_CH: u8, RX_STREAM, const RX_CH: u8>( self, tx_stream: TX_STREAM, rx_stream: RX_STREAM, ) -> 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>,

Converts blocking Serial to non-blocking SerialDma that use tx_stream and rx_stream to send/receive data

Source

pub fn use_dma_tx<TX_STREAM, const TX_CH: u8>( self, tx_stream: TX_STREAM, ) -> 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>,

Converts blocking Serial to non-blocking SerialDma that use tx_stream to only send data

Source

pub fn use_dma_rx<RX_STREAM, const RX_CH: u8>( self, rx_stream: RX_STREAM, ) -> 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>,

Converts blocking Serial to non-blocking SerialDma that use rx_stream to only receive data

Source§

impl<USART: Instance, WORD> Serial<USART, WORD>

Source

pub fn new( usart: USART, pins: (impl Into<USART::Tx<PushPull>>, impl Into<USART::Rx<PushPull>>), config: impl Into<Config>, clocks: &Clocks, ) -> Result<Self, InvalidConfig>

Source§

impl<UART: CommonPins, WORD> Serial<UART, WORD>

Source

pub fn split(self) -> (Tx<UART, WORD>, Rx<UART, WORD>)

Source

pub fn release(self) -> (UART, (UART::Tx<PushPull>, UART::Rx<PushPull>))

Source§

impl<UART: Instance> Serial<UART, u8>

Source

pub fn with_u16_data(self) -> Serial<UART, u16>

Converts this Serial into a version that can read and write u16 values instead of u8s

This can be used with a word length of 9 bits.

Source§

impl<UART: Instance> Serial<UART, u16>

Source

pub fn with_u8_data(self) -> Serial<UART, u8>

Converts this Serial into a version that can read and write u8 values instead of u16s

This can be used with a word length of 8 bits.

Trait Implementations§

Source§

impl<UART: Instance, WORD> AsMut<Rx<UART, WORD>> for Serial<UART, WORD>

Source§

fn as_mut(&mut self) -> &mut Rx<UART, WORD>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<UART: Instance, WORD> AsMut<Tx<UART, WORD>> for Serial<UART, WORD>

Source§

fn as_mut(&mut self) -> &mut Tx<UART, WORD>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<UART: Instance, WORD> AsRef<Rx<UART, WORD>> for Serial<UART, WORD>

Source§

fn as_ref(&self) -> &Rx<UART, WORD>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<UART: Instance, WORD> AsRef<Tx<UART, WORD>> for Serial<UART, WORD>

Source§

fn as_ref(&self) -> &Tx<UART, WORD>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<UART: Instance, WORD> ClearFlags for Serial<UART, WORD>

Source§

type Flag = CFlag

Enum of manually clearable flags
Source§

fn clear_flags(&mut self, flags: impl Into<BitFlags<Self::Flag>>)

Clear interrupts flags with Self::Flagss Read more
Source§

fn clear_all_flags(&mut self)

Clears all interrupts flags
Source§

impl<USART: Instance, WORD> ErrorType for Serial<USART, WORD>

Source§

type Error = Error

Error type
Source§

impl<USART: Instance, WORD> ErrorType for Serial<USART, WORD>

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl<UART: Instance, WORD> Listen for Serial<UART, WORD>

Source§

type Event = Event

Enum of bit flags associated with events
Source§

fn listen(&mut self, event: impl Into<BitFlags<Event>>)

Start listening for Events Read more
Source§

fn listen_only(&mut self, event: impl Into<BitFlags<Self::Event>>)

Start listening for Events, stop all other Read more
Source§

fn unlisten(&mut self, event: impl Into<BitFlags<Event>>)

Stop listening for Events
Source§

fn listen_all(&mut self)

Start listening all Events
Source§

fn unlisten_all(&mut self)

Stop listening all Events
Source§

impl<USART: Instance, WORD: Copy> Read<WORD> for Serial<USART, WORD>
where Rx<USART, WORD>: Read<WORD, Error = Error>,

Source§

fn read(&mut self) -> Result<WORD, Self::Error>

Reads a single word from the serial interface
Source§

impl<UART: Instance, WORD> ReadFlags for Serial<UART, WORD>

Source§

type Flag = Flag

Enum of bit flags
Source§

fn flags(&self) -> BitFlags<Self::Flag>

Get all interrupts flags a once.
Source§

impl<UART: Instance, WORD> RxISR for Serial<UART, WORD>
where Rx<UART, WORD>: RxISR,

Source§

fn clear_idle_interrupt(&self)

This clears Idle, Overrun, Noise, FrameError and ParityError flags

Source§

fn is_idle(&self) -> bool

Return true if the line idle status is set
Source§

fn is_rx_not_empty(&self) -> bool

Return true if the rx register is not empty (and can be read)
Source§

impl<UART: Instance, WORD> TxISR for Serial<UART, WORD>
where Tx<UART, WORD>: TxISR,

Source§

fn is_tx_empty(&self) -> bool

Return true if the tx register is empty (and can accept data)
Source§

impl<USART: Instance, WORD: Copy> Write<WORD> for Serial<USART, WORD>
where Tx<USART, WORD>: Write<WORD, Error = Error>,

Source§

fn flush(&mut self) -> Result<(), Self::Error>

Ensures that none of the previously written words are still buffered.
Source§

fn write(&mut self, byte: WORD) -> Result<(), Self::Error>

Writes a single word to the serial interface.
Source§

impl<UART: Instance> Write for Serial<UART>
where Tx<UART>: Write,

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl<USART: Instance> Write for Serial<USART, u8>
where Tx<USART, u8>: Write<Error = Error>,

Source§

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

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write an entire buffer into this writer. Read more
Source§

fn write_fmt( &mut self, fmt: Arguments<'_>, ) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered. Read more
Source§

impl<USART: Instance> Write<u16> for Serial<USART, u16>
where Tx<USART, u16>: Write<u16, Error = Error>,

Source§

type Error = Error

The type of error that can occur when writing
Source§

fn bwrite_all(&mut self, bytes: &[u16]) -> Result<(), Self::Error>

Writes a slice, blocking until everything has been written Read more
Source§

fn bflush(&mut self) -> Result<(), Self::Error>

Block until the serial interface has sent all buffered words
Source§

impl<USART: Instance> Write<u8> for Serial<USART, u8>
where Tx<USART, u8>: Write<u8, Error = Error>,

Source§

type Error = Error

The type of error that can occur when writing
Source§

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

Writes a slice, blocking until everything has been written Read more
Source§

fn bflush(&mut self) -> Result<(), Self::Error>

Block until the serial interface has sent all buffered words
Source§

impl<USART: Instance, WORD> Read<WORD> for Serial<USART, WORD>
where Rx<USART, WORD>: Read<WORD, Error = Error>,

Source§

type Error = Error

Read error
Source§

fn read(&mut self) -> Result<WORD, Self::Error>

Reads a single word from the serial interface
Source§

impl<USART: Instance, WORD> Write<WORD> for Serial<USART, WORD>
where Tx<USART, WORD>: Write<WORD, Error = Error>,

Source§

type Error = Error

Write error
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Ensures that none of the previously written words are still buffered
Source§

fn write(&mut self, byte: WORD) -> Result<(), Self::Error>

Writes a single word to the serial interface

Auto Trait Implementations§

§

impl<USART, WORD> Freeze for Serial<USART, WORD>
where USART: Freeze, <USART as SerialAsync>::Tx<PushPull>: Freeze, <USART as SerialAsync>::Rx<PushPull>: Freeze,

§

impl<USART, WORD> RefUnwindSafe for Serial<USART, WORD>

§

impl<USART, WORD> Send for Serial<USART, WORD>
where USART: Send, <USART as SerialAsync>::Tx<PushPull>: Send, <USART as SerialAsync>::Rx<PushPull>: Send, WORD: Send,

§

impl<USART, WORD> Sync for Serial<USART, WORD>
where USART: Sync, <USART as SerialAsync>::Tx<PushPull>: Sync, <USART as SerialAsync>::Rx<PushPull>: Sync, WORD: Sync,

§

impl<USART, WORD> Unpin for Serial<USART, WORD>
where USART: Unpin, <USART as SerialAsync>::Tx<PushPull>: Unpin, <USART as SerialAsync>::Rx<PushPull>: Unpin, WORD: Unpin,

§

impl<USART, WORD> UnwindSafe for Serial<USART, WORD>
where USART: UnwindSafe, <USART as SerialAsync>::Tx<PushPull>: UnwindSafe, <USART as SerialAsync>::Rx<PushPull>: UnwindSafe, WORD: 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.