From ddd6ee6ad22f7609984dd5672c132add489a6c81 Mon Sep 17 00:00:00 2001 From: doryan Date: Sat, 9 Nov 2024 16:48:05 +0400 Subject: [PATCH] fix(field): change size field type from u16 to u8 --- src/types/usb_device.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/types/usb_device.rs b/src/types/usb_device.rs index e80a7c4..fdccbf3 100644 --- a/src/types/usb_device.rs +++ b/src/types/usb_device.rs @@ -14,7 +14,7 @@ use usb_device::{ #[derive(Default, Copy, Clone)] pub(crate) struct USBEndpoint { is_allocated: bool, - size: u16, + size: u8, ep_type: u8, ep_dir: bool, banks: u8, @@ -46,7 +46,16 @@ impl USBEndpoint { #[inline] fn set_size(&mut self, size: u16) { - self.size = size; + self.size = match size { + 8 => 0b000, + 16 => 0b001, + 32 => 0b010, + 64 => 0b011, + 128 => 0b100, + 256 => 0b101, + 512 => 0b110, + _ => unreachable!(), + } } }