Properly update the Uart config in examples (#1759)

* fix: Properly update the config

* feat: Make rx_timeout optional

* docs: Update changelog
This commit is contained in:
Sergio Gasquez Arcos 2024-07-08 11:30:45 +02:00 committed by GitHub
parent 967c478846
commit ea34196d8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 8 deletions

View File

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add support for GPIO wake-up source (#1724)
- dma: add Mem2Mem to support memory to memory transfer (#1738)
- Add `uart` wake source (#1727)
- uart: Make `rx_timeout` optional in Config struct (#1759)
### Fixed

View File

@ -274,7 +274,7 @@ pub mod config {
pub stop_bits: StopBits,
pub clock_source: super::ClockSource,
pub rx_fifo_full_threshold: u16,
pub rx_timeout: u8,
pub rx_timeout: Option<u8>,
}
impl Config {
@ -337,7 +337,7 @@ pub mod config {
self
}
pub fn rx_timeout(mut self, timeout: u8) -> Self {
pub fn rx_timeout(mut self, timeout: Option<u8>) -> Self {
self.rx_timeout = timeout;
self
}
@ -355,7 +355,7 @@ pub mod config {
#[cfg(not(any(esp32c6, esp32h2, lp_uart)))]
clock_source: super::ClockSource::Apb,
rx_fifo_full_threshold: UART_FULL_THRESH_DEFAULT,
rx_timeout: UART_TOUT_THRESH_DEFAULT,
rx_timeout: Some(UART_TOUT_THRESH_DEFAULT),
}
}
}
@ -764,7 +764,7 @@ where
serial
.rx
.set_rx_fifo_full_threshold(config.rx_fifo_full_threshold)?;
serial.rx.set_rx_timeout(Some(config.rx_timeout))?;
serial.rx.set_rx_timeout(config.rx_timeout)?;
serial.change_baud_internal(config.baudrate, config.clock_source, clocks);
serial.change_data_bits(config.data_bits);
serial.change_parity(config.parity);

View File

@ -106,8 +106,7 @@ async fn main(spawner: Spawner) {
#[cfg(feature = "esp32s3")]
let (tx_pin, rx_pin) = (io.pins.gpio43, io.pins.gpio44);
let config = Config::default();
config.rx_fifo_full_threshold(READ_BUF_SIZE as u16);
let config = Config::default().rx_fifo_full_threshold(READ_BUF_SIZE as u16);
let mut uart0 =
Uart::new_async_with_config(peripherals.UART0, config, &clocks, tx_pin, rx_pin).unwrap();

View File

@ -52,8 +52,7 @@ fn main() -> ! {
let (tx_pin, rx_pin) = (io.pins.gpio43, io.pins.gpio44);
#[cfg(feature = "esp32s3")]
let (tx_pin, rx_pin) = (io.pins.gpio43, io.pins.gpio44);
let config = Config::default();
config.rx_fifo_full_threshold(30);
let config = Config::default().rx_fifo_full_threshold(30);
let mut uart0 = Uart::new_with_config(
peripherals.UART0,