Struct stm32_hal2::usart::Usart[][src]

pub struct Usart<U> {
    pub baud: u32,
    pub config: UsartConfig,
    // some fields omitted
}
Expand description

Represents the USART peripheral, for serial communications.

Fields

baud: u32config: UsartConfig

Implementations

impl<U> Usart<U> where
    U: Deref<Target = RegisterBlock>, 
[src]

pub fn new<C: ClockCfg>(
    regs: U,
    device: UsartDevice,
    baud: u32,
    config: UsartConfig,
    clock_cfg: &C,
    rcc: &mut RCC
) -> Self
[src]

pub fn set_baud<C: ClockCfg>(&mut self, baud: u32, clock_cfg: &C)[src]

Set the BAUD rate. Called during init, and can be called later to change BAUD during program execution.

pub fn write(&mut self, data: &[u8])[src]

Transmit data, as a sequence of u8.. See L44 RM, section 38.5.2: “Character transmission procedure”

pub fn read(&mut self, buf: &mut [u8])[src]

Receive data into a u8 buffer. See L44 RM, section 38.5.3: “Character reception procedure”

pub fn read_one(&mut self) -> u8[src]

Read a single word, without confirming if it’s ready. This is useful in async concepts, when you know word is ready to be read.

pub fn enable_dma<D>(&mut self, dma: &mut Dma<D>) where
    D: Deref<Target = RegisterBlock>, 
[src]

Enable use of DMA transmission for U[s]ART: (L44 RM, section 38.5.15)

pub fn write_dma<D>(
    &mut self,
    buf: &[u8],
    channel: DmaChannel,
    dma: &mut Dma<D>
) where
    D: Deref<Target = RegisterBlock>, 
[src]

Transmit data using DMA. (L44 RM, section 38.5.15) Note that the channel argument is only used on F3 and L4.

pub fn read_dma<D>(
    &mut self,
    buf: &mut [u8],
    channel: DmaChannel,
    dma: &mut Dma<D>
) where
    D: Deref<Target = RegisterBlock>, 
[src]

Receive data using DMA. (L44 RM, section 38.5.15) Note that the channel argument is only used on F3 and L4.

pub fn flush(&self)[src]

Flush the transmit buffer.

pub fn enable_interrupt(&mut self, interrupt: UsartInterrupt)[src]

Enable a specific type of interrupt.

pub fn clear_interrupt(&mut self, interrupt: UsartInterrupt)[src]

Clears the interrupt pending flag for a specific type of interrupt.

Trait Implementations

impl<U> Read<u8> for Usart<U> where
    U: Deref<Target = RegisterBlock>, 
[src]

type Error = Error

Read error

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

Reads a single word from the serial interface

impl<U> Write<u8> for Usart<U> where
    U: Deref<Target = RegisterBlock>, 
[src]

type Error = Error

The type of error that can occur when writing

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

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

fn bflush(&mut self) -> Result<(), Error>[src]

Block until the serial interface has sent all buffered words

impl<U> Write<u8> for Usart<U> where
    U: Deref<Target = RegisterBlock>, 
[src]

type Error = Error

Write error

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

Writes a single word to the serial interface

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

Ensures that none of the previously written words are still buffered

Auto Trait Implementations

impl<U> Send for Usart<U> where
    U: Send

impl<U> Sync for Usart<U> where
    U: Sync

impl<U> Unpin for Usart<U> where
    U: Unpin

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.