From f67b650bb38044ff009c7bbabc510de90eab4910 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Fri, 18 Mar 2022 10:57:45 +0100 Subject: [PATCH] Remove some unused fields from UartPeripheral and Reader (#315) * Remove unused field `effective_baudrate` from uart code * Remove unused field `config` from uart code --- rp2040-hal/src/uart/peripheral.rs | 16 +--------------- rp2040-hal/src/uart/reader.rs | 5 +---- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/rp2040-hal/src/uart/peripheral.rs b/rp2040-hal/src/uart/peripheral.rs index 9740bef..878fb0c 100644 --- a/rp2040-hal/src/uart/peripheral.rs +++ b/rp2040-hal/src/uart/peripheral.rs @@ -23,8 +23,6 @@ pub struct UartPeripheral> { device: D, _state: S, pins: P, - config: UartConfig, - effective_baudrate: Baud, } impl> UartPeripheral { @@ -32,8 +30,6 @@ impl> UartPeripheral { UartPeripheral { device: self.device, pins: self.pins, - config: self.config, - effective_baudrate: self.effective_baudrate, _state: state, } } @@ -54,8 +50,6 @@ impl> UartPeripheral { device, _state: Disabled, pins, - config: common_configs::_9600_8_N_1, // placeholder - effective_baudrate: Baud(0), } } @@ -66,7 +60,7 @@ impl> UartPeripheral { frequency: Hertz, ) -> Result, Error> { 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| { // FIFOs are enabled @@ -94,9 +88,7 @@ impl> UartPeripheral { Ok(UartPeripheral { device, - config, pins, - effective_baudrate, _state: Enabled, }) } @@ -193,8 +185,6 @@ impl> UartPeripheral { device: reader.device, _state: Enabled, pins: reader.pins, - config: reader.config, - effective_baudrate: reader.effective_baudrate, } } } @@ -205,8 +195,6 @@ impl> UartPeripheral { let reader = Reader { device: self.device, pins: self.pins, - config: self.config, - effective_baudrate: self.effective_baudrate, }; // Safety: reader and writer will never write to the same address let device_copy = unsafe { Peripherals::steal().UART0 }; @@ -225,8 +213,6 @@ impl> UartPeripheral { let reader = Reader { device: self.device, pins: self.pins, - config: self.config, - effective_baudrate: self.effective_baudrate, }; // Safety: reader and writer will never write to the same address let device_copy = unsafe { Peripherals::steal().UART1 }; diff --git a/rp2040-hal/src/uart/reader.rs b/rp2040-hal/src/uart/reader.rs index 78b8702..e8ab935 100644 --- a/rp2040-hal/src/uart/reader.rs +++ b/rp2040-hal/src/uart/reader.rs @@ -2,11 +2,10 @@ //! //! This module is for receiving data with a UART. -use super::{UartConfig, UartDevice, ValidUartPinout}; +use super::{UartDevice, ValidUartPinout}; use rp2040_pac::uart0::RegisterBlock; use embedded_hal::serial::Read; -use embedded_time::rate::Baud; use nb::Error::*; #[cfg(feature = "eh1_0_alpha")] @@ -167,8 +166,6 @@ pub(crate) fn read_full_blocking( pub struct Reader> { pub(super) device: D, pub(super) pins: P, - pub(super) config: UartConfig, - pub(super) effective_baudrate: Baud, } impl> Reader {