pub struct UART { /* private fields */ }
Expand description
This struct represents a configured UART peripheral.
Implementations§
Source§impl UART
impl UART
Sourcepub fn new(
core: u8,
tx_pin: (char, u8),
rx_pin: (char, u8),
baud: u32,
) -> Result<Self, ProgError>
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.
Sourcepub fn end(self)
pub fn end(self)
Deacitivates the UART connection and destroys the struct, freeing the core and pins.
Sourcepub fn print_char(&self, data: char) -> Result<(), SerialError>
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.
Sourcepub fn print_str(&self, data: &str) -> Result<(), SerialError>
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.
Sourcepub fn println_char(&self, data: char) -> Result<(), SerialError>
pub fn println_char(&self, data: char) -> Result<(), SerialError>
Acts like print_char except it prints a newline at the end of the string.
Sourcepub fn println_str(&self, data: &str) -> Result<(), SerialError>
pub fn println_str(&self, data: &str) -> Result<(), SerialError>
Acts like print_str except it prints a newline at the end of the string.
Sourcepub fn write(&self, data: u8) -> Result<(), SerialError>
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.