Serial

Struct Serial 

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

Serial abstraction

Implementations§

Source§

impl<PINS> Serial<USART1, PINS>

Source

pub fn usart1( usart: USART1, pins: PINS, config: impl Into<Config>, clocks: Clocks, apb: &mut <USART1 as RccBus>::Bus, ) -> Self
where PINS: Pins<USART1>,

Configures the serial interface and creates the interface struct.

Config is a config struct that configures baud rate, stop bits and parity.

Clocks passes information about the current frequencies of the clocks. The existence of the struct ensures that the clock settings are fixed.

The serial struct takes ownership over the USARTX device registers and the specified PINS

MAPR and APBX are register handles which are passed for configuration. (MAPR is used to map the USART to the corresponding pins. APBX is used to reset the USART.)

Source

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

Starts listening for an interrupt event

Source

pub fn check_for_error() -> Result<(), Error>

Check for, and return, any errors

See Rx::check_for_error.

Source

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

Stops listening for an interrupt event

Source

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

Splits the Serial abstraction into a transmitter and a receiver half

Source

pub fn release(self) -> (USART1, PINS)

Frees the USART peripheral

Source§

impl<PINS> Serial<USART2, PINS>

Source

pub fn usart2( usart: USART2, pins: PINS, config: impl Into<Config>, clocks: Clocks, apb: &mut <USART2 as RccBus>::Bus, ) -> Self
where PINS: Pins<USART2>,

Configures the serial interface and creates the interface struct.

Config is a config struct that configures baud rate, stop bits and parity.

Clocks passes information about the current frequencies of the clocks. The existence of the struct ensures that the clock settings are fixed.

The serial struct takes ownership over the USARTX device registers and the specified PINS

MAPR and APBX are register handles which are passed for configuration. (MAPR is used to map the USART to the corresponding pins. APBX is used to reset the USART.)

Source

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

Starts listening for an interrupt event

Source

pub fn check_for_error() -> Result<(), Error>

Check for, and return, any errors

See Rx::check_for_error.

Source

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

Stops listening for an interrupt event

Source

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

Splits the Serial abstraction into a transmitter and a receiver half

Source

pub fn release(self) -> (USART2, PINS)

Frees the USART peripheral

Trait Implementations§

Source§

impl<USART, PINS> Write for Serial<USART, PINS>
where Serial<USART, PINS>: Write<u8>,

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<PINS> Read<u8> for Serial<USART1, PINS>

Source§

type Error = Error

Read error
Source§

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

Reads a single word from the serial interface
Source§

impl<PINS> Read<u8> for Serial<USART2, PINS>

Source§

type Error = Error

Read error
Source§

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

Reads a single word from the serial interface
Source§

impl<PINS> Write<u8> for Serial<USART1, PINS>

Source§

type Error = Error

Write error
Source§

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

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

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

Writes a single word to the serial interface
Source§

impl<PINS> Write<u8> for Serial<USART2, PINS>

Source§

type Error = Error

Write error
Source§

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

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

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

Writes a single word to the serial interface

Auto Trait Implementations§

§

impl<USART, PINS> Freeze for Serial<USART, PINS>
where USART: Freeze, PINS: Freeze,

§

impl<USART, PINS> RefUnwindSafe for Serial<USART, PINS>
where USART: RefUnwindSafe, PINS: RefUnwindSafe,

§

impl<USART, PINS> Send for Serial<USART, PINS>
where USART: Send, PINS: Send,

§

impl<USART, PINS> Sync for Serial<USART, PINS>
where USART: Sync, PINS: Sync,

§

impl<USART, PINS> Unpin for Serial<USART, PINS>
where USART: Unpin, PINS: Unpin,

§

impl<USART, PINS> UnwindSafe for Serial<USART, PINS>
where USART: UnwindSafe, PINS: 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.