From 8be4ff21a9e29adc8a8e9cbafaac26fbf73ce549 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Wed, 8 Jan 2025 11:27:18 +0100 Subject: [PATCH] feat: Remove nb stuff from usb_serial_jtag --- esp-hal/src/usb_serial_jtag.rs | 113 --------------------------------- 1 file changed, 113 deletions(-) diff --git a/esp-hal/src/usb_serial_jtag.rs b/esp-hal/src/usb_serial_jtag.rs index c366e9907..b6d8682c0 100644 --- a/esp-hal/src/usb_serial_jtag.rs +++ b/esp-hal/src/usb_serial_jtag.rs @@ -198,28 +198,6 @@ where Ok(()) } - /// Write data to the serial output in a non-blocking manner - /// Requires manual flushing (automatically flushed every 64 bytes) - pub fn write_byte_nb(&mut self, word: u8) -> Option<()> { - let reg_block = USB_DEVICE::register_block(); - - if reg_block - .ep1_conf() - .read() - .serial_in_ep_data_free() - .bit_is_set() - { - // the FIFO is not full - unsafe { - reg_block.ep1().write(|w| w.rdwr_byte().bits(word)); - } - - Some(()) - } else { - None - } - } - /// Flush the output FIFO and block until it has been sent pub fn flush_tx(&mut self) -> Result<(), Error> { let reg_block = USB_DEVICE::register_block(); @@ -231,18 +209,6 @@ where Ok(()) } - - /// Flush the output FIFO but don't block if it isn't ready immediately - pub fn flush_tx_nb(&mut self) -> Option<()> { - let reg_block = USB_DEVICE::register_block(); - reg_block.ep1_conf().modify(|_, w| w.wr_done().set_bit()); - - if reg_block.ep1_conf().read().bits() & 0b011 == 0b000 { - None - } else { - Some(()) - } - } } impl<'d, Dm> UsbSerialJtagRx<'d, Dm> @@ -407,22 +373,11 @@ where self.tx.write_bytes(data) } - /// Write data to the serial output in a non-blocking manner - /// Requires manual flushing (automatically flushed every 64 bytes) - pub fn write_byte_nb(&mut self, word: u8) -> Option<()> { - self.tx.write_byte_nb(word) - } - /// Flush the output FIFO and block until it has been sent pub fn flush_tx(&mut self) -> Result<(), Error> { self.tx.flush_tx() } - /// Flush the output FIFO but don't block if it isn't ready immediately - pub fn flush_tx_nb(&mut self) -> Option<()> { - self.tx.flush_tx_nb() - } - /// Read a single byte but don't block if it isn't ready immediately pub fn read_byte(&mut self) -> Option { self.rx.read_byte() @@ -543,74 +498,6 @@ where } } -impl embedded_hal_nb::serial::ErrorType for UsbSerialJtag<'_, Dm> -where - Dm: DriverMode, -{ - type Error = Error; -} - -impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagTx<'_, Dm> -where - Dm: DriverMode, -{ - type Error = Error; -} - -impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagRx<'_, Dm> -where - Dm: DriverMode, -{ - type Error = Error; -} - -impl embedded_hal_nb::serial::Read for UsbSerialJtag<'_, Dm> -where - Dm: DriverMode, -{ - fn read(&mut self) -> embedded_hal_nb::nb::Result { - embedded_hal_nb::serial::Read::read(&mut self.rx) - } -} - -impl embedded_hal_nb::serial::Read for UsbSerialJtagRx<'_, Dm> -where - Dm: DriverMode, -{ - fn read(&mut self) -> embedded_hal_nb::nb::Result { - self.read_byte() - .ok_or(embedded_hal_nb::nb::Error::WouldBlock) - } -} - -impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_, Dm> -where - Dm: DriverMode, -{ - fn write(&mut self, word: u8) -> embedded_hal_nb::nb::Result<(), Self::Error> { - embedded_hal_nb::serial::Write::write(&mut self.tx, word) - } - - fn flush(&mut self) -> embedded_hal_nb::nb::Result<(), Self::Error> { - embedded_hal_nb::serial::Write::flush(&mut self.tx) - } -} - -impl embedded_hal_nb::serial::Write for UsbSerialJtagTx<'_, Dm> -where - Dm: DriverMode, -{ - fn write(&mut self, word: u8) -> embedded_hal_nb::nb::Result<(), Self::Error> { - self.write_byte_nb(word) - .ok_or(embedded_hal_nb::nb::Error::WouldBlock) - } - - fn flush(&mut self) -> embedded_hal_nb::nb::Result<(), Self::Error> { - self.flush_tx_nb() - .ok_or(embedded_hal_nb::nb::Error::WouldBlock) - } -} - #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] impl embedded_io::ErrorType for UsbSerialJtag<'_, Dm>