Remove some unused fields from UartPeripheral and Reader (#315)

* Remove unused field `effective_baudrate` from uart code

* Remove unused field `config` from uart code
This commit is contained in:
Jan Niehusmann 2022-03-18 10:57:45 +01:00 committed by GitHub
parent 990085948a
commit f67b650bb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 19 deletions

View file

@ -23,8 +23,6 @@ pub struct UartPeripheral<S: State, D: UartDevice, P: ValidUartPinout<D>> {
device: D, device: D,
_state: S, _state: S,
pins: P, pins: P,
config: UartConfig,
effective_baudrate: Baud,
} }
impl<S: State, D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<S, D, P> { impl<S: State, D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<S, D, P> {
@ -32,8 +30,6 @@ impl<S: State, D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<S, D, P> {
UartPeripheral { UartPeripheral {
device: self.device, device: self.device,
pins: self.pins, pins: self.pins,
config: self.config,
effective_baudrate: self.effective_baudrate,
_state: state, _state: state,
} }
} }
@ -54,8 +50,6 @@ impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Disabled, D, P> {
device, device,
_state: Disabled, _state: Disabled,
pins, pins,
config: common_configs::_9600_8_N_1, // placeholder
effective_baudrate: Baud(0),
} }
} }
@ -66,7 +60,7 @@ impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Disabled, D, P> {
frequency: Hertz, frequency: Hertz,
) -> Result<UartPeripheral<Enabled, D, P>, Error> { ) -> Result<UartPeripheral<Enabled, D, P>, Error> {
let (mut device, pins) = self.free(); let (mut device, pins) = self.free();
let effective_baudrate = configure_baudrate(&mut device, &config.baudrate, &frequency)?; configure_baudrate(&mut device, &config.baudrate, &frequency)?;
device.uartlcr_h.write(|w| { device.uartlcr_h.write(|w| {
// FIFOs are enabled // FIFOs are enabled
@ -94,9 +88,7 @@ impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Disabled, D, P> {
Ok(UartPeripheral { Ok(UartPeripheral {
device, device,
config,
pins, pins,
effective_baudrate,
_state: Enabled, _state: Enabled,
}) })
} }
@ -193,8 +185,6 @@ impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Enabled, D, P> {
device: reader.device, device: reader.device,
_state: Enabled, _state: Enabled,
pins: reader.pins, pins: reader.pins,
config: reader.config,
effective_baudrate: reader.effective_baudrate,
} }
} }
} }
@ -205,8 +195,6 @@ impl<P: ValidUartPinout<UART0>> UartPeripheral<Enabled, UART0, P> {
let reader = Reader { let reader = Reader {
device: self.device, device: self.device,
pins: self.pins, pins: self.pins,
config: self.config,
effective_baudrate: self.effective_baudrate,
}; };
// Safety: reader and writer will never write to the same address // Safety: reader and writer will never write to the same address
let device_copy = unsafe { Peripherals::steal().UART0 }; let device_copy = unsafe { Peripherals::steal().UART0 };
@ -225,8 +213,6 @@ impl<P: ValidUartPinout<UART1>> UartPeripheral<Enabled, UART1, P> {
let reader = Reader { let reader = Reader {
device: self.device, device: self.device,
pins: self.pins, pins: self.pins,
config: self.config,
effective_baudrate: self.effective_baudrate,
}; };
// Safety: reader and writer will never write to the same address // Safety: reader and writer will never write to the same address
let device_copy = unsafe { Peripherals::steal().UART1 }; let device_copy = unsafe { Peripherals::steal().UART1 };

View file

@ -2,11 +2,10 @@
//! //!
//! This module is for receiving data with a UART. //! This module is for receiving data with a UART.
use super::{UartConfig, UartDevice, ValidUartPinout}; use super::{UartDevice, ValidUartPinout};
use rp2040_pac::uart0::RegisterBlock; use rp2040_pac::uart0::RegisterBlock;
use embedded_hal::serial::Read; use embedded_hal::serial::Read;
use embedded_time::rate::Baud;
use nb::Error::*; use nb::Error::*;
#[cfg(feature = "eh1_0_alpha")] #[cfg(feature = "eh1_0_alpha")]
@ -167,8 +166,6 @@ pub(crate) fn read_full_blocking<D: UartDevice>(
pub struct Reader<D: UartDevice, P: ValidUartPinout<D>> { pub struct Reader<D: UartDevice, P: ValidUartPinout<D>> {
pub(super) device: D, pub(super) device: D,
pub(super) pins: P, pub(super) pins: P,
pub(super) config: UartConfig,
pub(super) effective_baudrate: Baud,
} }
impl<D: UartDevice, P: ValidUartPinout<D>> Reader<D, P> { impl<D: UartDevice, P: ValidUartPinout<D>> Reader<D, P> {