Struct UART

Source
pub struct UART { /* private fields */ }
Expand description

This struct represents a configured UART peripheral.

Implementations§

Source§

impl UART

Source

pub fn new( core: u8, tx_pin: (char, u8), rx_pin: (char, u8), baud: u32, ) -> Result<Self, ProgError>

Configure a serial connection with one of the internal UART peripherals.

This Method expects the used UART core, two pin identifiers for the tx and rx-pins and a baudrate as parameters and returns the UART Struct. Panics if the core or pins are already used or invalid.

Source

pub fn end(self)

Deacitivates the UART connection and destroys the struct, freeing the core and pins.

Source

pub fn print_char(&self, data: char) -> Result<(), SerialError>

Sends an ASCII char over the serial connection. Returns an error-enum if problems with the connection are detected.

Source

pub fn print_str(&self, data: &str) -> Result<(), SerialError>

Sends an ASCII string over the serial connection. Returns an error-enum if problems with the connection are detected.

Source

pub fn println_char(&self, data: char) -> Result<(), SerialError>

Acts like print_char except it prints a newline at the end of the string.

Source

pub fn println_str(&self, data: &str) -> Result<(), SerialError>

Acts like print_str except it prints a newline at the end of the string.

Source

pub fn write(&self, data: u8) -> Result<(), SerialError>

Sends a raw byte over the serial connection. Returns an error-enum if problems with the connection are detected.

Source

pub fn read_char(&self) -> Option<char>

Waits until it recieves an ASCII char. Returns an error-enum if problems with the connection are detected.

Source

pub fn read_byte(&self) -> Option<u8>

Waits until it recieves a byte. Returns an error-enum if problems with the connection are detected.

Auto Trait Implementations§

§

impl Freeze for UART

§

impl RefUnwindSafe for UART

§

impl Send for UART

§

impl Sync for UART

§

impl Unpin for UART

§

impl UnwindSafe for UART

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.