Implement UartConfig::new constructor method

This commit is contained in:
Jan Niehusmann 2022-10-15 11:53:16 +00:00
parent 71c39a4431
commit 0a86dad34c

View file

@ -1,8 +1,7 @@
use fugit::HertzU32;
use crate::pac::{uart0::RegisterBlock, UART0, UART1};
use crate::resets::SubsystemReset;
use core::ops::Deref;
use fugit::HertzU32;
/// Error type for UART operations.
#[derive(Debug)]
@ -84,6 +83,23 @@ pub struct UartConfig {
pub parity: Option<Parity>,
}
impl UartConfig {
/// Create a new instance of UartConfig
pub fn new(
baudrate: HertzU32,
data_bits: DataBits,
parity: Option<Parity>,
stop_bits: StopBits,
) -> UartConfig {
UartConfig {
baudrate,
data_bits,
stop_bits,
parity,
}
}
}
/// Rx/Tx FIFO Watermark
///
/// Determine the FIFO level that trigger DMA/Interrupt