From 19413e12e480222c559d6dc81c586a992664c1e9 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Mon, 6 Jan 2025 11:38:23 +0100 Subject: [PATCH] Resolve naming violations for `DataBits` and `StopBits` enums --- esp-hal/src/uart.rs | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index 20f261cc0a..108fbc6081 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -351,14 +351,14 @@ const UART_TOUT_THRESH_DEFAULT: u8 = 10; #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum DataBits { /// 5 data bits per frame. - DataBits5 = 0, + _5 = 0, /// 6 data bits per frame. - DataBits6 = 1, + _6 = 1, /// 7 data bits per frame. - DataBits7 = 2, - /// 8 data bits per frame (most common). + _7 = 2, + /// 8 data bits per frame. #[default] - DataBits8 = 3, + _8 = 3, } /// Parity check @@ -388,15 +388,14 @@ pub enum Parity { /// bits. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] -#[allow(clippy::enum_variant_names)] // FIXME: resolve this pub enum StopBits { /// 1 stop bit. #[default] - Stop1 = 1, + _1 = 1, /// 1.5 stop bits. - Stop1P5 = 2, + _1p5 = 2, /// 2 stop bits. - Stop2 = 3, + _2 = 3, } /// UART Configuration @@ -427,17 +426,17 @@ impl Config { fn symbol_length(&self) -> u8 { let mut length: u8 = 1; // start bit length += match self.data_bits { - DataBits::DataBits5 => 5, - DataBits::DataBits6 => 6, - DataBits::DataBits7 => 7, - DataBits::DataBits8 => 8, + DataBits::_5 => 5, + DataBits::_6 => 6, + DataBits::_7 => 7, + DataBits::_8 => 8, }; length += match self.parity { Parity::None => 0, _ => 1, }; length += match self.stop_bits { - StopBits::Stop1 => 1, + StopBits::_1 => 1, _ => 2, // esp-idf also counts 2 bits for settings 1.5 and 2 stop bits }; length @@ -2557,18 +2556,14 @@ impl Info { #[cfg(esp32)] { // workaround for hardware issue, when UART stop bit set as 2-bit mode. - if stop_bits == StopBits::Stop2 { + if stop_bits == StopBits::_2 { self.register_block() .rs485_conf() - .modify(|_, w| w.dl1_en().bit(stop_bits == StopBits::Stop2)); - - self.register_block().conf0().modify(|_, w| { - if stop_bits == StopBits::Stop2 { - unsafe { w.stop_bit_num().bits(1) } - } else { - unsafe { w.stop_bit_num().bits(stop_bits as u8) } - } - }); + .modify(|_, w| w.dl1_en().bit(stop_bits == StopBits::_2)); + + self.register_block() + .conf0() + .modify(|_, w| unsafe { w.stop_bit_num().bits(1) }); } }