Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly update the Uart config in examples #1759

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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),
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions examples/src/bin/embassy_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions examples/src/bin/serial_interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down