diff --git a/rp2040-hal/src/uart/utils.rs b/rp2040-hal/src/uart/utils.rs index 508207d..094096d 100644 --- a/rp2040-hal/src/uart/utils.rs +++ b/rp2040-hal/src/uart/utils.rs @@ -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, } +impl UartConfig { + /// Create a new instance of UartConfig + pub fn new( + baudrate: HertzU32, + data_bits: DataBits, + parity: Option, + stop_bits: StopBits, + ) -> UartConfig { + UartConfig { + baudrate, + data_bits, + stop_bits, + parity, + } + } +} + /// Rx/Tx FIFO Watermark /// /// Determine the FIFO level that trigger DMA/Interrupt