Skip to content

Commit

Permalink
Use upper camel case for UART's StopBits variants (#2669)
Browse files Browse the repository at this point in the history
* Use upper camel case for UART's `StopBits` variants

* Update `CHANGELOG.md`
  • Loading branch information
jessebraham authored Dec 3, 2024
1 parent 94e7ffb commit da59a4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed how `Spi`, (split or unsplit) `Uart`, `LpUart`, `I8080`, `Camera`, `DPI` and `I2C` drivers are constructed (#2610)
- I8080, camera, DPI: The various standalone configuration options have been merged into `Config` (#2610)
- Dropped GPIO futures stop listening for interrupts (#2625)
- UART driver's `StopBits` enum variants now correctly use UpperCamelCase (#2669)

### Fixed

Expand Down
14 changes: 7 additions & 7 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ pub enum Parity {
pub enum StopBits {
/// 1 stop bit.
#[default]
STOP1 = 1,
Stop1 = 1,
/// 1.5 stop bits.
STOP1P5 = 2,
Stop1P5 = 2,
/// 2 stop bits.
STOP2 = 3,
Stop2 = 3,
}

/// UART Configuration
Expand Down Expand Up @@ -461,7 +461,7 @@ impl Config {
_ => 1,
};
length += match self.stop_bits {
StopBits::STOP1 => 1,
StopBits::Stop1 => 1,
_ => 2, // esp-idf also counts 2 bits for settings 1.5 and 2 stop bits
};
length
Expand Down Expand Up @@ -2549,13 +2549,13 @@ 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::Stop2 {
self.register_block()
.rs485_conf()
.modify(|_, w| w.dl1_en().bit(stop_bits == StopBits::STOP2));
.modify(|_, w| w.dl1_en().bit(stop_bits == StopBits::Stop2));

self.register_block().conf0().modify(|_, w| {
if stop_bits == StopBits::STOP2 {
if stop_bits == StopBits::Stop2 {
unsafe { w.stop_bit_num().bits(1) }
} else {
unsafe { w.stop_bit_num().bits(stop_bits as u8) }
Expand Down

0 comments on commit da59a4e

Please sign in to comment.