#[repr(u8)]pub enum Speed {
Low = 0,
Full = 1,
High = 2,
Wireless = 3,
SuperSpeed = 4,
SuperSpeedPlus = 5,
}Expand description
USB 设备速度
Variants§
Implementations§
Source§impl Speed
impl Speed
Sourcepub fn from_usb2_hub_status(raw: u16) -> Self
pub fn from_usb2_hub_status(raw: u16) -> Self
从 USB 2.0 Hub wPortStatus 解析速度
根据 USB 2.0 规范(第 11.24.2.7 节):
- Bit 9 (0x0200): Low Speed
- Bit 10 (0x0400): High Speed
- Bit 11 (0x0800): SuperSpeed (USB 3.0)
- 默认: Full Speed
Sourcepub fn from_xhci_portsc(speed_value: u8) -> Self
pub fn from_xhci_portsc(speed_value: u8) -> Self
从 xHCI PORTSC PortSpeed 字段解析速度
根据 xHCI 规范(第 4.19.2 节):
- 1 = Full Speed
- 2 = Low Speed
- 3 = High Speed
- 4 = SuperSpeed
- 5 = SuperSpeedPlus
Sourcepub fn to_xhci_slot_value(&self) -> u8
pub fn to_xhci_slot_value(&self) -> u8
转换为 xHCI Slot Context 速度值
根据 xHCI 规范(第 6.2.2 节)Slot Context Speed 字段:
- 1 = Full Speed
- 2 = Low Speed
- 3 = High Speed
- 4 = Super Speed
Sourcepub fn to_xhci_portsc_value(&self) -> u8
pub fn to_xhci_portsc_value(&self) -> u8
Convert to the raw PORTSC.PortSpeed encoding used by xHCI registers.
Values follow xHCI 4.19.2: 1=FS, 2=LS, 3=HS, 4=SS, 5=SS+.
Sourcepub fn requires_tt(&self, hub_speed: Self) -> bool
pub fn requires_tt(&self, hub_speed: Self) -> bool
判断是否需要 Transaction Translator
根据 xHCI 规范:
- LS/FS 设备连接在 HS Hub 上需要 TT
Sourcepub fn is_low_or_full_speed(&self) -> bool
pub fn is_low_or_full_speed(&self) -> bool
判断设备是否为 Low Speed 或 Full Speed
Trait Implementations§
impl Copy for Speed
impl Eq for Speed
impl StructuralPartialEq for Speed
Auto Trait Implementations§
impl Freeze for Speed
impl RefUnwindSafe for Speed
impl Send for Speed
impl Sync for Speed
impl Unpin for Speed
impl UnwindSafe for Speed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more