Remove redundant config setters (#2847)
Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
This commit is contained in:
parent
06a15807e3
commit
1f929af377
@ -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)
|
- `parl_io::{no_clk_pin(), NoClkPin}` (#2531)
|
||||||
- Removed `get_core` function in favour of `Cpu::current` (#2533)
|
- Removed `get_core` function in favour of `Cpu::current` (#2533)
|
||||||
|
|
||||||
|
- Removed `uart::Config` setters and `symbol_length`. (#2847)
|
||||||
|
|
||||||
## [0.21.1]
|
## [0.21.1]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@ -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.
|
The usage of `esp_alloc::psram_allocator!` remains unchanged.
|
||||||
|
|
||||||
|
|
||||||
## embedded-hal 0.2.* is not supported anymore.
|
## 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`.
|
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::new(None, None, None, b'#', None));
|
||||||
+ uart0.set_at_cmd(AtCmdConfig::default().with_cmd_char(b'#'));
|
+ 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);
|
||||||
@ -152,7 +152,7 @@
|
|||||||
any(esp32s2, esp32s3),
|
any(esp32s2, esp32s3),
|
||||||
doc = "let (tx_pin, rx_pin) = (peripherals.GPIO43, peripherals.GPIO44);"
|
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(
|
//! let mut uart0 = Uart::new(
|
||||||
//! peripherals.UART0,
|
//! peripherals.UART0,
|
||||||
@ -421,51 +421,9 @@ pub struct Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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
|
/// Calculates the total symbol length in bits based on the configured
|
||||||
/// data bits, parity, and stop bits.
|
/// data bits, parity, and stop bits.
|
||||||
pub fn symbol_length(&self) -> u8 {
|
fn symbol_length(&self) -> u8 {
|
||||||
let mut length: u8 = 1; // start bit
|
let mut length: u8 = 1; // start bit
|
||||||
length += match self.data_bits {
|
length += match self.data_bits {
|
||||||
DataBits::DataBits5 => 5,
|
DataBits::DataBits5 => 5,
|
||||||
@ -483,18 +441,6 @@ impl Config {
|
|||||||
};
|
};
|
||||||
length
|
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<u8>) -> Self {
|
|
||||||
self.rx_timeout = timeout;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
|||||||
@ -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)
|
let mut uart0 = Uart::new(peripherals.UART0, config, rx_pin, tx_pin)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user