mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-01-09 15:55:37 +00:00
advanced/common/usb/lib.rs: cleanup– rm GET_DESCRIPTOR handling, suggest outline
This commit is contained in:
parent
351cce7c16
commit
a72886059f
1 changed files with 8 additions and 19 deletions
|
@ -52,27 +52,17 @@ impl Request {
|
|||
) -> Result<Self, ()> {
|
||||
// see table 9-4 (USB specification)
|
||||
const SET_ADDRESS: u8 = 5;
|
||||
const GET_DESCRIPTOR: u8 = 6; // todo deleteme
|
||||
|
||||
// TODO löschen und durch instructions ersetzen
|
||||
if bmrequesttype == 0b10000000 && brequest == GET_DESCRIPTOR {
|
||||
// see table 9-5
|
||||
const DEVICE: u8 = 1;
|
||||
/* TODO implement another branch handling GET_DESCRIPTOR requests: */
|
||||
|
||||
let desc_ty = (wvalue >> 8) as u8;
|
||||
let desc_index = wvalue as u8;
|
||||
let langid = windex;
|
||||
|
||||
if desc_ty == DEVICE && desc_index == 0 && langid == 0 {
|
||||
Ok(Request::GetDescriptor {
|
||||
descriptor: Descriptor::Device,
|
||||
length: wlength,
|
||||
})
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
} else if bmrequesttype == 0b00000000 && brequest == SET_ADDRESS {
|
||||
/* 1. get descriptor type and descriptor index from wValue */
|
||||
|
||||
/* 2. confirm that the descriptor
|
||||
- is of type DEVICE and
|
||||
- has descriptor index 0 (i.e. it is the first implemented descriptor for this type) and
|
||||
- has wIndex 0 (i.e. no language ID since it's not a string descriptor)
|
||||
*/
|
||||
if bmrequesttype == 0b00000000 && brequest == SET_ADDRESS {
|
||||
// Set the device address for all future accesses.
|
||||
// Needed to successfully init when using Apple devices.
|
||||
if wvalue < 128 && windex == 0 && wlength == 0 {
|
||||
|
@ -85,7 +75,6 @@ impl Request {
|
|||
} else {
|
||||
Err(())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue