Struct stm32_hal2::serial::Serial[][src]

pub struct Serial<USART> { /* fields omitted */ }

Serial abstraction

Implementations

impl Serial<USART1>[src]

pub fn new_usart1<C: ClockCfg>(
    usart: USART1,
    config: Config,
    clocks: &C,
    rcc: &mut RCC
) -> Self
[src]

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.)

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

Starts listening for an interrupt event

pub fn check_for_error() -> Result<(), Error>[src]

Check for, and return, any errors

See Rx::check_for_error.

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

Stops listening for an interrupt event

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

Splits the Serial abstraction into a transmitter and a receiver half

pub fn release(self) -> USART1[src]

Frees the USART peripheral

impl Serial<USART2>[src]

pub fn new_usart2<C: ClockCfg>(
    usart: USART2,
    config: Config,
    clocks: &C,
    rcc: &mut RCC
) -> Self
[src]

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.)

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

Starts listening for an interrupt event

pub fn check_for_error() -> Result<(), Error>[src]

Check for, and return, any errors

See Rx::check_for_error.

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

Stops listening for an interrupt event

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

Splits the Serial abstraction into a transmitter and a receiver half

pub fn release(self) -> USART2[src]

Frees the USART peripheral

Trait Implementations

impl Read<u8> for Serial<USART1>[src]

type Error = Error

Read error

impl Read<u8> for Serial<USART2>[src]

type Error = Error

Read error

impl<USART> Write for Serial<USART> where
    Serial<USART>: Write<u8>, 
[src]

impl Write<u8> for Serial<USART1>[src]

type Error = Error

Write error

impl Write<u8> for Serial<USART2>[src]

type Error = Error

Write error

Auto Trait Implementations

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.