Skip to content

Commit 0ca9bcf

Browse files
committed
Isochronous endpoint enum from tuple to struct
1 parent 3959ede commit 0ca9bcf

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/bus.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ impl<B: UsbBus> UsbBusAllocator<B> {
272272
) -> Endpoint<'_, B, D> {
273273
self.alloc(
274274
None,
275-
EndpointType::Isochronous((synchronization, usage)),
275+
EndpointType::Isochronous {
276+
synchronization,
277+
usage,
278+
},
276279
payload_size,
277280
interval,
278281
)

src/endpoint.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ pub enum EndpointType {
6464
/// used only endpoint 0.
6565
Control,
6666
/// Isochronous endpoint. Used for time-critical unreliable data.
67-
Isochronous((IsochronousSynchronizationType, IsochronousUsageType)),
67+
///
68+
/// See USB 2.0 spec section 5.12 "Special Considerations for Isochronous Transfers"
69+
Isochronous {
70+
/// Synchronization model used for the data stream that this endpoint relates to.
71+
synchronization: IsochronousSynchronizationType,
72+
/// Endpoint's role in the synchronization model selected by [Self::Isochronous::synchronization].
73+
usage: IsochronousUsageType,
74+
},
6875
/// Bulk endpoint. Used for large amounts of best-effort reliable data.
6976
Bulk,
7077
/// Interrupt endpoint. Used for small amounts of time-critical reliable data.
@@ -76,14 +83,17 @@ impl EndpointType {
7683
pub fn to_bm_attributes(&self) -> u8 {
7784
match self {
7885
EndpointType::Control => 0b00,
79-
EndpointType::Isochronous((sync_type, usage_type)) => {
80-
let sync_bits = match sync_type {
86+
EndpointType::Isochronous {
87+
synchronization,
88+
usage,
89+
} => {
90+
let sync_bits = match synchronization {
8191
IsochronousSynchronizationType::NoSynchronization => 0b00,
8292
IsochronousSynchronizationType::Asynchronous => 0b01,
8393
IsochronousSynchronizationType::Adaptive => 0b10,
8494
IsochronousSynchronizationType::Synchronous => 0b11,
8595
};
86-
let usage_bits = match usage_type {
96+
let usage_bits = match usage {
8797
IsochronousUsageType::Data => 0b00,
8898
IsochronousUsageType::Feedback => 0b01,
8999
IsochronousUsageType::ImplicitFeedbackData => 0b10,

0 commit comments

Comments
 (0)