From 55b940fe748575799b42585f92e9c62cc61b643f Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 11 Jan 2023 04:09:13 +0800 Subject: [PATCH] tiny bit of cleanup & docs --- services/usb-device-xous/src/main_hw.rs | 2 -- .../src/scsi/commands/read_format_capacities.rs | 4 ++-- .../firmware/usbd_scsi/src/scsi/scsi.rs | 14 ++++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/usb-device-xous/src/main_hw.rs b/services/usb-device-xous/src/main_hw.rs index 1c9f01a2e..278be67eb 100644 --- a/services/usb-device-xous/src/main_hw.rs +++ b/services/usb-device-xous/src/main_hw.rs @@ -342,9 +342,7 @@ pub(crate) fn main_hw() -> ! { if matches!(view, Views::MassStorage) { if ums_device.poll(&mut [&mut ums]) { log::debug!("ums device had something to do!") - //Some(fido_class.interface::, _>()) } - continue; } diff --git a/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/commands/read_format_capacities.rs b/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/commands/read_format_capacities.rs index b8c607ef6..bf501dbfb 100644 --- a/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/commands/read_format_capacities.rs +++ b/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/commands/read_format_capacities.rs @@ -12,10 +12,10 @@ pub struct ReadFormatCapacitiesCommand { #[pkd(7, 5, 1, 1)] pub logical_unit_number: u8, - + #[pkd(7, 0, 7, 8)] pub allocation_length: u16, - + #[pkd(7, 0, 9, 9)] pub control: Control, } diff --git a/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/scsi.rs b/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/scsi.rs index afc0e7714..e5f5e2405 100644 --- a/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/scsi.rs +++ b/services/usb-device-xous/stm32-usb.rs/firmware/usbd_scsi/src/scsi/scsi.rs @@ -407,15 +407,16 @@ impl Scsi<'_, B, BD> { self.request_sense_response.additional_sense_code = additional_sense_code; } + /// Update is called by the IRQ handler, whenever a new event is available on one of + /// the endpoints allocated to the USB mass storage device. fn update(&mut self) -> Result<(), Error> { - // Send anything that's already queued - //accept_would_block( - // self.inner.write() - // .map_err(|e| e.into()) - //)?; let mut i = 0; + // This loop will automatically re-poll for read data after a single update + // originating from an incoming IRQ. This is necessary because when a new packet + // comes in while processing the current packet, a second IRQ is not fired. + // + // The loop exits if it polls twice and finds no new packets pending. loop { - // print!("p{}", i); // Read new data if available match accept_would_block( self.inner.read() @@ -435,6 +436,7 @@ impl Scsi<'_, B, BD> { self.inner.write() .map_err(|e| e.into()) )?; + // exit the loop if we blocked more than twice if i > 1 { break; }