Skip to content

Commit

Permalink
Use cfg_if in favour of multiple cfgs in `set_rx_fifo_full_thresh…
Browse files Browse the repository at this point in the history
…old` function (#2670)
  • Loading branch information
jessebraham authored Dec 3, 2024
1 parent da59a4e commit a189eff
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2324,14 +2324,17 @@ impl Info {
/// - `esp32c3`, `esp32c2`, `esp32s2` **0x1FF**
/// - `esp32s3` **0x3FF**
fn set_rx_fifo_full_threshold(&self, threshold: u16) -> Result<(), ConfigError> {
#[cfg(esp32)]
const MAX_THRHD: u16 = 0x7F;
#[cfg(any(esp32c6, esp32h2))]
const MAX_THRHD: u16 = 0xFF;
#[cfg(any(esp32c3, esp32c2, esp32s2))]
const MAX_THRHD: u16 = 0x1FF;
#[cfg(esp32s3)]
const MAX_THRHD: u16 = 0x3FF;
cfg_if::cfg_if! {
if #[cfg(esp32)] {
const MAX_THRHD: u16 = 0x7F;
} else if #[cfg(any(esp32c6, esp32h2))] {
const MAX_THRHD: u16 = 0xFF;
} else if #[cfg(any(esp32c3, esp32c2, esp32s2))] {
const MAX_THRHD: u16 = 0x1FF;
} else if #[cfg(esp32s3)] {
const MAX_THRHD: u16 = 0x3FF;
}
}

if threshold > MAX_THRHD {
return Err(ConfigError::UnsupportedFifoThreshold);
Expand Down

0 comments on commit a189eff

Please sign in to comment.