From 0a86dad34ccc99c339138997035bae90257ad2c1 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Sat, 15 Oct 2022 11:53:16 +0000 Subject: [PATCH] Implement UartConfig::new constructor method --- rp2040-hal/src/uart/utils.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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