Merge pull request #134 from ferrous-systems/descriptor_docs

Book: Improve docs for GET_DESCRIPTOR Configuration requests
This commit is contained in:
Jorge Aparicio 2021-01-29 15:21:26 +01:00 committed by GitHub
commit 7fc3241124
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 10 deletions

View file

@ -54,13 +54,15 @@ impl Request {
const SET_ADDRESS: u8 = 5;
// TODO implement another branch handling GET_DESCRIPTOR requests:
// 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)
//
// 1. get descriptor type and descriptor index from `wValue`
//
// 2. confirm that
// - the descriptor type is DEVICE, i.e. of value 1 and
// - the descriptor index is 0 (i.e. it is the first implemented descriptor for this type) and
// - `wIndex` is 0 (i.e. no language ID since it's not a string descriptor)
//
// For more details, see https://embedded-trainings.ferrous-systems.com/setup-stage.html
if bmrequesttype == 0b00000000 && brequest == SET_ADDRESS {
// Set the device address for all future accesses.

View file

@ -2,6 +2,16 @@
When the host issues a GET_DESCRIPTOR *Configuration* request the device needs to respond with the requested configuration descriptor *plus* all the interface and endpoint descriptors associated to that configuration descriptor during the DATA stage.
A GET_DESCRIPTOR Configuration request is a GET_DESCRIPTOR request where the descriptor type encoded in the high bit of `wValue` is CONFIGURATION.
As a reminder, all GET_DESCRIPTOR request types are share the following properties:
Let's look into all the concepts required to respond to this request.
- `bmRequestType` is **0b10000000**
- `bRequest` is **6** (i.e. the GET_DESCRIPTOR Request Code, defined in table 9-4 of the [USB specification][usb_spec])
A GET_DESCRIPTOR *Configuration* request is determined the high bit of its `wValue` field:
- The high bit of `wValue` is **2** (i.e. the `CONFIGURATION` descriptor type, defined in table 9-5 of the [USB specification][usb_spec])
[usb_spec]: https://www.usb.org/document-library/usb-20-specification
In the next sections, let's look into all the concepts required to respond to this request.

View file

@ -17,7 +17,7 @@ The definition of `Descriptor::Configuration` as well as the associated test has
❗️ Keep the cable connected to the J3 port for the rest of the workshop
Start with the GET_DESCRIPTOR request, which is described in detail in section 9.4.3 of the [USB specification][usb_spec]. All the constants we'll be using are also described in Tables 9-3, 9-4 and 9-5 of the USB spec.
Start with the GET_DESCRIPTOR request, which is described in detail in section 9.4.3 of the [USB specification][usb_spec]. All the constants we'll be using are also described in Tables 9-3, 9-4 and 9-5 of the same document.
[usb_spec]: https://www.usb.org/document-library/usb-20-specification