From 9e75cec551429719da2f84b2f40eeaaecbf7f3cd Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Tue, 18 Jan 2022 11:17:01 +0100 Subject: [PATCH 1/3] Added `impl Default` for UartConfig --- rp2040-hal/src/uart/utils.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rp2040-hal/src/uart/utils.rs b/rp2040-hal/src/uart/utils.rs index ba6b455..e44011b 100644 --- a/rp2040-hal/src/uart/utils.rs +++ b/rp2040-hal/src/uart/utils.rs @@ -59,6 +59,16 @@ pub enum Parity { } /// A struct holding the configuration for an UART device. +/// +/// The `Default` implementation implements the following values: +/// ``` +/// UartConfig { +/// baudrate: Baud(0), +/// data_bits: DataBits::Eight, +/// stop_bits: StopBits::One, +/// parity: None, +///} +/// ``` #[non_exhaustive] pub struct UartConfig { /// The baudrate the uart will run at. @@ -74,6 +84,17 @@ pub struct UartConfig { pub parity: Option, } +impl Default for UartConfig { + fn default() -> Self { + Self { + baudrate: Baud(0), + data_bits: DataBits::Eight, + stop_bits: StopBits::One, + parity: None, + } + } +} + /// Same as core::convert::Infallible, but implementing serial::Error /// /// For eh 1.0.0-alpha.6, Infallible doesn't implement serial::Error, From b3b4d9ff6fcf9b217b071f4052ec8d419a56be0d Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Tue, 18 Jan 2022 11:31:28 +0100 Subject: [PATCH 2/3] Fixed doc test --- rp2040-hal/src/uart/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rp2040-hal/src/uart/utils.rs b/rp2040-hal/src/uart/utils.rs index e44011b..4fe286c 100644 --- a/rp2040-hal/src/uart/utils.rs +++ b/rp2040-hal/src/uart/utils.rs @@ -61,7 +61,8 @@ pub enum Parity { /// A struct holding the configuration for an UART device. /// /// The `Default` implementation implements the following values: -/// ``` +/// ```ignore +/// # // can't actually create this with the non_exhaustive attribute /// UartConfig { /// baudrate: Baud(0), /// data_bits: DataBits::Eight, From d6e3c7b61567ade03e492ee8bc7b58c61406c1de Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Tue, 18 Jan 2022 17:28:13 +0100 Subject: [PATCH 3/3] Set the uart config default baud rate to 115200 --- rp2040-hal/src/uart/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rp2040-hal/src/uart/utils.rs b/rp2040-hal/src/uart/utils.rs index 4fe286c..f96a2cb 100644 --- a/rp2040-hal/src/uart/utils.rs +++ b/rp2040-hal/src/uart/utils.rs @@ -64,7 +64,7 @@ pub enum Parity { /// ```ignore /// # // can't actually create this with the non_exhaustive attribute /// UartConfig { -/// baudrate: Baud(0), +/// baudrate: Baud(115_200), /// data_bits: DataBits::Eight, /// stop_bits: StopBits::One, /// parity: None, @@ -88,7 +88,7 @@ pub struct UartConfig { impl Default for UartConfig { fn default() -> Self { Self { - baudrate: Baud(0), + baudrate: Baud(115_200), data_bits: DataBits::Eight, stop_bits: StopBits::One, parity: None,