Skip to content

Commit

Permalink
Remove redundant config setters
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 19, 2024
1 parent f83ab23 commit e0611c7
Showing 1 changed file with 1 addition and 55 deletions.
56 changes: 1 addition & 55 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,51 +421,9 @@ pub struct Config {
}

impl Config {
/// Sets the baud rate for the UART configuration.
pub fn baudrate(mut self, baudrate: u32) -> Self {
self.baudrate = baudrate;
self
}

/// Configures the UART to use no parity check.
pub fn parity_none(mut self) -> Self {
self.parity = Parity::ParityNone;
self
}

/// Configures the UART to use even parity check.
pub fn parity_even(mut self) -> Self {
self.parity = Parity::ParityEven;
self
}

/// Configures the UART to use odd parity check.
pub fn parity_odd(mut self) -> Self {
self.parity = Parity::ParityOdd;
self
}

/// Sets the number of data bits for the UART configuration.
pub fn data_bits(mut self, data_bits: DataBits) -> Self {
self.data_bits = data_bits;
self
}

/// Sets the number of stop bits for the UART configuration.
pub fn stop_bits(mut self, stop_bits: StopBits) -> Self {
self.stop_bits = stop_bits;
self
}

/// Sets the clock source for the UART configuration.
pub fn clock_source(mut self, source: ClockSource) -> Self {
self.clock_source = source;
self
}

/// Calculates the total symbol length in bits based on the configured
/// data bits, parity, and stop bits.
pub fn symbol_length(&self) -> u8 {
fn symbol_length(&self) -> u8 {
let mut length: u8 = 1; // start bit
length += match self.data_bits {
DataBits::DataBits5 => 5,
Expand All @@ -483,18 +441,6 @@ impl Config {
};
length
}

/// Sets the RX FIFO full threshold for the UART configuration.
pub fn rx_fifo_full_threshold(mut self, threshold: u16) -> Self {
self.rx_fifo_full_threshold = threshold;
self
}

/// Sets the RX timeout for the UART configuration.
pub fn rx_timeout(mut self, timeout: Option<u8>) -> Self {
self.rx_timeout = timeout;
self
}
}

impl Default for Config {
Expand Down

0 comments on commit e0611c7

Please sign in to comment.