diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 145bb8788..985ff837b 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -222,6 +222,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `parl_io::{no_clk_pin(), NoClkPin}` (#2531) - Removed `get_core` function in favour of `Cpu::current` (#2533) +- Removed `uart::Config` setters and `symbol_length`. (#2847) + ## [0.21.1] ### Fixed diff --git a/esp-hal/MIGRATING-0.22.md b/esp-hal/MIGRATING-0.22.md index 59f6a2d5c..fce9779dd 100644 --- a/esp-hal/MIGRATING-0.22.md +++ b/esp-hal/MIGRATING-0.22.md @@ -199,7 +199,6 @@ is enabled. To retrieve the address and size of the initialized external memory, The usage of `esp_alloc::psram_allocator!` remains unchanged. - ## embedded-hal 0.2.* is not supported anymore. As per https://github.com/rust-embedded/embedded-hal/pull/640, our driver no longer implements traits from `embedded-hal 0.2.x`. @@ -343,3 +342,15 @@ The reexports that were previously part of the prelude are available through oth - uart0.set_at_cmd(AtCmdConfig::new(None, None, None, b'#', None)); + uart0.set_at_cmd(AtCmdConfig::default().with_cmd_char(b'#')); ``` + +## UART changes + +The `Config` struct's setters are now prefixed with `with_`. `parity_none`, `parity_even`, +`parity_odd` have been replaced by `with_parity` that takes a `Parity` parameter. + +```diff + let config = Config::default() +- .rx_fifo_full_threshold(30) ++ .with_rx_fifo_full_threshold(30) +- .parity_even(); ++ .with_parity(Parity::Even); \ No newline at end of file diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index cc5f529cd..f14a73a73 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -152,7 +152,7 @@ any(esp32s2, esp32s3), doc = "let (tx_pin, rx_pin) = (peripherals.GPIO43, peripherals.GPIO44);" )] -//! let config = Config::default().rx_fifo_full_threshold(30); +//! let config = Config::default().with_rx_fifo_full_threshold(30); //! //! let mut uart0 = Uart::new( //! peripherals.UART0, @@ -421,51 +421,9 @@ pub struct Config { } impl Config { - /// Sets the baud rate for the UART configuration. - pub fn baudrate(mut self, baudrate: u32) -> Self { - self.baudrate = baudrate; - self - } - - /// Configures the UART to use no parity check. - pub fn parity_none(mut self) -> Self { - self.parity = Parity::ParityNone; - self - } - - /// Configures the UART to use even parity check. - pub fn parity_even(mut self) -> Self { - self.parity = Parity::ParityEven; - self - } - - /// Configures the UART to use odd parity check. - pub fn parity_odd(mut self) -> Self { - self.parity = Parity::ParityOdd; - self - } - - /// Sets the number of data bits for the UART configuration. - pub fn data_bits(mut self, data_bits: DataBits) -> Self { - self.data_bits = data_bits; - self - } - - /// Sets the number of stop bits for the UART configuration. - pub fn stop_bits(mut self, stop_bits: StopBits) -> Self { - self.stop_bits = stop_bits; - self - } - - /// Sets the clock source for the UART configuration. - pub fn clock_source(mut self, source: ClockSource) -> Self { - self.clock_source = source; - self - } - /// Calculates the total symbol length in bits based on the configured /// data bits, parity, and stop bits. - pub fn symbol_length(&self) -> u8 { + fn symbol_length(&self) -> u8 { let mut length: u8 = 1; // start bit length += match self.data_bits { DataBits::DataBits5 => 5, @@ -483,18 +441,6 @@ impl Config { }; length } - - /// Sets the RX FIFO full threshold for the UART configuration. - pub fn rx_fifo_full_threshold(mut self, threshold: u16) -> Self { - self.rx_fifo_full_threshold = threshold; - self - } - - /// Sets the RX timeout for the UART configuration. - pub fn rx_timeout(mut self, timeout: Option) -> Self { - self.rx_timeout = timeout; - self - } } impl Default for Config { diff --git a/examples/src/bin/embassy_serial.rs b/examples/src/bin/embassy_serial.rs index e32fb50f2..b5477b552 100644 --- a/examples/src/bin/embassy_serial.rs +++ b/examples/src/bin/embassy_serial.rs @@ -87,7 +87,7 @@ async fn main(spawner: Spawner) { } } - let config = Config::default().rx_fifo_full_threshold(READ_BUF_SIZE as u16); + let config = Config::default().with_rx_fifo_full_threshold(READ_BUF_SIZE as u16); let mut uart0 = Uart::new(peripherals.UART0, config, rx_pin, tx_pin) .unwrap()