diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 2441a45094..233c9d3e92 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -212,6 +212,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 159475131f..95a0b212dd 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`. @@ -317,3 +316,16 @@ To avoid abbreviations and contractions (as per the esp-hal guidelines), some er - Error::InvalidZeroLength + Error::ZeroLengthInvalid ``` + +## 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); +``` diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 3b01681a61..8c7cccd4b4 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -153,7 +153,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 2df7dcc996..f709913c6f 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()