diff --git a/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs b/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs index 277856cc2..2ca9fbb0d 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs @@ -69,8 +69,12 @@ pub const FS_MAX_PKT_SIZE: usize = 64; pub const HS_MAX_PKT_SIZE: usize = 512; pub(crate) fn enable_mass_storage_eps(this: &mut CorigineUsb, ep_num: u8) { - this.ep_enable(ep_num, USB_RECV, HS_MAX_PKT_SIZE as _, EpType::BulkOutbound); - this.ep_enable(ep_num, USB_SEND, HS_MAX_PKT_SIZE as _, EpType::BulkInbound); + let mps = match this.get_speed() { + PortSpeed::Fs => FS_MAX_PKT_SIZE, + _ => HS_MAX_PKT_SIZE, + }; + this.ep_enable(ep_num, USB_RECV, mps as _, EpType::BulkOutbound); + this.ep_enable(ep_num, USB_SEND, mps as _, EpType::BulkInbound); } // Call from USB_REQ_SET_CONFIGURATION after setting device state to Configured @@ -78,12 +82,20 @@ pub(crate) fn enable_composite_eps(this: &mut CorigineUsb) { // MSD endpoints enable_mass_storage_eps(this, 1); + let int_mps = match this.get_speed() { + PortSpeed::Fs => FS_INT_MPS, + _ => HS_INT_MPS, + }; // CDC notification IN (interrupt) - this.ep_enable(2, USB_SEND, HS_INT_MPS as _, EpType::IntrInbound); + this.ep_enable(2, USB_SEND, int_mps as _, EpType::IntrInbound); + let bulk_mps = match this.get_speed() { + PortSpeed::Fs => FS_BULK_MPS, + _ => HS_BULK_MPS, + }; // CDC data bulk OUT and IN - this.ep_enable(3, USB_RECV, HS_BULK_MPS as _, EpType::BulkOutbound); - this.ep_enable(3, USB_SEND, HS_BULK_MPS as _, EpType::BulkInbound); + this.ep_enable(3, USB_RECV, bulk_mps as _, EpType::BulkOutbound); + this.ep_enable(3, USB_SEND, bulk_mps as _, EpType::BulkInbound); } pub fn get_descriptor_request(this: &mut CorigineUsb, value: u16, _index: usize, length: usize) { diff --git a/baremetal/src/platform/bao1x/usb/handlers.rs b/baremetal/src/platform/bao1x/usb/handlers.rs index bc3921a7b..6a9e6dcd8 100644 --- a/baremetal/src/platform/bao1x/usb/handlers.rs +++ b/baremetal/src/platform/bao1x/usb/handlers.rs @@ -9,12 +9,20 @@ pub static TX_IDLE: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicB // Call from USB_REQ_SET_CONFIGURATION after setting device state to Configured pub(crate) fn enable_serial_eps(this: &mut CorigineUsb) { + let int_mps = match this.get_speed() { + PortSpeed::Fs => FS_INT_MPS, + _ => HS_INT_MPS, + }; // CDC notification IN (interrupt) - this.ep_enable(2, USB_SEND, HS_INT_MPS as _, EpType::IntrInbound); + this.ep_enable(2, USB_SEND, int_mps as _, EpType::IntrInbound); + let bulk_mps = match this.get_speed() { + PortSpeed::Fs => FS_BULK_MPS, + _ => HS_BULK_MPS, + }; // CDC data bulk OUT and IN - this.ep_enable(3, USB_RECV, HS_BULK_MPS as _, EpType::BulkOutbound); - this.ep_enable(3, USB_SEND, HS_BULK_MPS as _, EpType::BulkInbound); + this.ep_enable(3, USB_RECV, bulk_mps as _, EpType::BulkOutbound); + this.ep_enable(3, USB_SEND, bulk_mps as _, EpType::BulkInbound); } pub fn get_descriptor_request(this: &mut CorigineUsb, value: u16, _index: usize, length: usize) {