Struct Serial

Source
pub struct Serial<USART, TXPIN, RXPIN> { /* private fields */ }
Expand description

Serial abstraction

Implementations§

Source§

impl<TXPIN, RXPIN> Serial<USART1, TXPIN, RXPIN>
where TXPIN: TxPin<USART1>, RXPIN: RxPin<USART1>,

Source

pub fn usart1( usart: USART1, pins: (TXPIN, RXPIN), baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART1, TXPIN, RXPIN>

Creates a new serial instance

Source§

impl<TXPIN> Serial<USART1, TXPIN, ()>
where TXPIN: TxPin<USART1>,

Source

pub fn usart1tx( usart: USART1, txpin: TXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART1, TXPIN, ()>

Creates a new tx-only serial instance

Source§

impl<RXPIN> Serial<USART1, (), RXPIN>
where RXPIN: RxPin<USART1>,

Source

pub fn usart1rx( usart: USART1, rxpin: RXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART1, (), RXPIN>

Creates a new tx-only serial instance

Source§

impl<TXPIN, RXPIN> Serial<USART1, TXPIN, RXPIN>

Source

pub fn listen(&mut self, event: Event)

Starts listening for an interrupt event

Source

pub fn unlisten(&mut self, event: Event)

Stop listening for an interrupt event

Source§

impl<TXPIN, RXPIN> Serial<USART2, TXPIN, RXPIN>
where TXPIN: TxPin<USART2>, RXPIN: RxPin<USART2>,

Source

pub fn usart2( usart: USART2, pins: (TXPIN, RXPIN), baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART2, TXPIN, RXPIN>

Creates a new serial instance

Source§

impl<TXPIN> Serial<USART2, TXPIN, ()>
where TXPIN: TxPin<USART2>,

Source

pub fn usart2tx( usart: USART2, txpin: TXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART2, TXPIN, ()>

Creates a new tx-only serial instance

Source§

impl<RXPIN> Serial<USART2, (), RXPIN>
where RXPIN: RxPin<USART2>,

Source

pub fn usart2rx( usart: USART2, rxpin: RXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART2, (), RXPIN>

Creates a new tx-only serial instance

Source§

impl<TXPIN, RXPIN> Serial<USART2, TXPIN, RXPIN>

Source

pub fn listen(&mut self, event: Event)

Starts listening for an interrupt event

Source

pub fn unlisten(&mut self, event: Event)

Stop listening for an interrupt event

Source§

impl<TXPIN, RXPIN> Serial<USART3, TXPIN, RXPIN>
where TXPIN: TxPin<USART3>, RXPIN: RxPin<USART3>,

Source

pub fn usart3( usart: USART3, pins: (TXPIN, RXPIN), baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART3, TXPIN, RXPIN>

Creates a new serial instance

Source§

impl<TXPIN> Serial<USART3, TXPIN, ()>
where TXPIN: TxPin<USART3>,

Source

pub fn usart3tx( usart: USART3, txpin: TXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART3, TXPIN, ()>

Creates a new tx-only serial instance

Source§

impl<RXPIN> Serial<USART3, (), RXPIN>
where RXPIN: RxPin<USART3>,

Source

pub fn usart3rx( usart: USART3, rxpin: RXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART3, (), RXPIN>

Creates a new tx-only serial instance

Source§

impl<TXPIN, RXPIN> Serial<USART3, TXPIN, RXPIN>

Source

pub fn listen(&mut self, event: Event)

Starts listening for an interrupt event

Source

pub fn unlisten(&mut self, event: Event)

Stop listening for an interrupt event

Source§

impl<TXPIN, RXPIN> Serial<USART4, TXPIN, RXPIN>
where TXPIN: TxPin<USART4>, RXPIN: RxPin<USART4>,

Source

pub fn usart4( usart: USART4, pins: (TXPIN, RXPIN), baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART4, TXPIN, RXPIN>

Creates a new serial instance

Source§

impl<TXPIN> Serial<USART4, TXPIN, ()>
where TXPIN: TxPin<USART4>,

Source

pub fn usart4tx( usart: USART4, txpin: TXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART4, TXPIN, ()>

Creates a new tx-only serial instance

Source§

impl<RXPIN> Serial<USART4, (), RXPIN>
where RXPIN: RxPin<USART4>,

Source

pub fn usart4rx( usart: USART4, rxpin: RXPIN, baud_rate: Bps, rcc: &mut Rcc, ) -> Serial<USART4, (), RXPIN>

Creates a new tx-only serial instance

Source§

impl<TXPIN, RXPIN> Serial<USART4, TXPIN, RXPIN>

Source

pub fn listen(&mut self, event: Event)

Starts listening for an interrupt event

Source

pub fn unlisten(&mut self, event: Event)

Stop listening for an interrupt event

Source§

impl<USART, TXPIN, RXPIN> Serial<USART, TXPIN, RXPIN>
where USART: Deref<Target = RegisterBlock>,

Source

pub fn split(self) -> (Tx<USART>, Rx<USART>)
where TXPIN: TxPin<USART>, RXPIN: RxPin<USART>,

Splits the UART Peripheral in a Tx and an Rx part This is required for sending/receiving

Source

pub fn release(self) -> (USART, (TXPIN, RXPIN))

Trait Implementations§

Source§

impl<USART, TXPIN, RXPIN> Write for Serial<USART, TXPIN, RXPIN>
where USART: Deref<Target = RegisterBlock>, TXPIN: TxPin<USART>,

Source§

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

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, TXPIN, RXPIN> Read<u8> for Serial<USART, TXPIN, RXPIN>
where USART: Deref<Target = RegisterBlock>, RXPIN: RxPin<USART>,

Source§

fn read(&mut self) -> Result<u8, Error<Error>>

Tries to read a byte from the uart

Source§

type Error = Error

Read error
Source§

impl<USART, TXPIN, RXPIN> Write<u8> for Serial<USART, TXPIN, RXPIN>
where USART: Deref<Target = RegisterBlock>, TXPIN: TxPin<USART>,

Source§

fn flush( &mut self, ) -> Result<(), Error<<Serial<USART, TXPIN, RXPIN> as Write<u8>>::Error>>

Ensures that none of the previously written words are still buffered

Source§

fn write( &mut self, byte: u8, ) -> Result<(), Error<<Serial<USART, TXPIN, RXPIN> as Write<u8>>::Error>>

Tries to write a byte to the uart Fails if the transmit buffer is full

Source§

type Error = Void

Write error

Auto Trait Implementations§

§

impl<USART, TXPIN, RXPIN> Freeze for Serial<USART, TXPIN, RXPIN>
where USART: Freeze, TXPIN: Freeze, RXPIN: Freeze,

§

impl<USART, TXPIN, RXPIN> RefUnwindSafe for Serial<USART, TXPIN, RXPIN>
where USART: RefUnwindSafe, TXPIN: RefUnwindSafe, RXPIN: RefUnwindSafe,

§

impl<USART, TXPIN, RXPIN> Send for Serial<USART, TXPIN, RXPIN>
where USART: Send, TXPIN: Send, RXPIN: Send,

§

impl<USART, TXPIN, RXPIN> Sync for Serial<USART, TXPIN, RXPIN>
where USART: Sync, TXPIN: Sync, RXPIN: Sync,

§

impl<USART, TXPIN, RXPIN> Unpin for Serial<USART, TXPIN, RXPIN>
where USART: Unpin, TXPIN: Unpin, RXPIN: Unpin,

§

impl<USART, TXPIN, RXPIN> UnwindSafe for Serial<USART, TXPIN, RXPIN>
where USART: UnwindSafe, TXPIN: UnwindSafe, RXPIN: 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> Same for T

Source§

type Output = T

Should always be Self
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.