Skip to content

Commit

Permalink
Clean up USB spec references.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpallant committed Mar 6, 2024
1 parent 5bdc3a0 commit d3d3dfe
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions exercise-book/src/nrf52-usb-device-descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

After receiving a `GET_DESCRIPTOR` request during the __SETUP__ stage, the device needs to respond with the actual *descriptor* data during the __DATA__ stage. In our Rust application, this descriptor will be generated using some library code and serialised into an array of bytes which we can give to the USBD peripheral.

A descriptor is a binary encoded data structure sent by the device to the host. The device descriptor, in particular, contains information about the device, like its product and vendor identifiers and how many *configurations* it has. The format of the device descriptor is specified in section 9.6.1, Device, of the [USB specification][usb_spec].
A descriptor is a binary encoded data structure sent by the device to the host. The device descriptor, in particular, contains information about the device, like its product and vendor identifiers and how many *configurations* it has. The format of the device descriptor is specified in Section 9.6.1 of the [USB specification].

[usb_spec]: ./nrf52-usb-usb-specification.md
[USB specification]: ./nrf52-usb-usb-specification.md

As far as the enumeration process goes, the most relevant fields of the device descriptor are the number of configurations and `bcdUSB`, the version of the USB specification the devices adheres to. In `bcdUSB` you should report compatibility with USB 2.0.

Expand Down
4 changes: 2 additions & 2 deletions exercise-book/src/nrf52-usb-getting-device-configured.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Now modify the `usb-descriptors` command within the `xtask` package to "open" th

## SET_CONFIGURATION

The SET_CONFIGURATION request is sent by the host to configure the device. Its configuration according to section 9.4.7. of the [USB specification][usb_spec] is:
The SET_CONFIGURATION request is sent by the host to configure the device. Its configuration according to Section 9.4.7 of the [USB specification] is:

- `bmrequesttype` is **0b00000000**
- `brequest` is **9** (i.e. the SET_CONFIGURATION Request Code, see table 9-4 in the USB spec)
- `wValue` contains the requested configuration value
- `wIndex` and `wLength` are 0, there is no `wData`

[usb_spec]: ./nrf52-usb-usb-specification.md
[USB specification]: ./nrf52-usb-usb-specification.md

✅ To handle a SET_CONFIGURATION, do the following:

Expand Down
5 changes: 2 additions & 3 deletions exercise-book/src/nrf52-usb-setup-stage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In this step of the exercise, we only need to parse DEVICE descriptor requests.
- the wIndex is **0** for our purposes
- ❗️you need to fetch the descriptor type from the high byte of `wValue`, and the descriptor index from the the low byte of `wValue`

Check section 9.4.3 of the [USB specification][usb_spec] for a very detailed description of the requests. All the constants we'll be using are also described in Tables 9-3, 9-4 and 9-5 of the same document. Or, you can refer to [Chapter 6 of USB In a Nutshell](https://www.beyondlogic.org/usbnutshell/usb6.shtml).
Check Section 9.4.3 of the [USB specification] for a very detailed description of the requests. All the constants we'll be using are also described in Tables 9-3, 9-4 and 9-5 of the same document. Or, you can refer to [Chapter 6 of USB In a Nutshell](https://www.beyondlogic.org/usbnutshell/usb6.shtml).

You should return `Err(Error::xxx)` if the properties aren't met.

Expand All @@ -77,7 +77,6 @@ You should return `Err(Error::xxx)` if the properties aren't met.
- use bit shifts (`>>`) and casts (`as u8`) to get the high/low bytes of `wValue`

You will also find this information in the `// TODO implement ...` comment in the `Request::parse()` function of `lib.rs` file.
> NOTE: If you'd like to learn more, take a look at Section 9.4.3 Get Descriptor of the USB specification.

See [`nrf52-code/usb-lib-solutions/get-device/src/lib.rs`](../../nrf52-code/usb-lib-solutions/get-device/src/lib.rs) for a solution.

Expand Down Expand Up @@ -115,5 +114,5 @@ Goal reached; move to the next section
You can find a solution to this step in [`nrf52-code/usb-app-solutions/src/bin/usb-2.rs`](../../nrf52-code/usb-app-solutions/src/bin/usb-2.rs).

[usb_spec]: ./nrf52-usb-usb-specification.md
[USB specification]: ./nrf52-usb-usb-specification.md
[usb_2]: ../../nrf52-code/usb-app/src/bin/usb-2.rs
6 changes: 3 additions & 3 deletions exercise-book/src/nrf52-usb-supporting-standard-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ When the host issues a GET_DESCRIPTOR *Configuration* request the device needs t
As a reminder, all GET_DESCRIPTOR request types share the following properties:

- `bmRequestType` is **0b10000000**
- `bRequest` is **6** (i.e. the GET_DESCRIPTOR Request Code, defined in table 9-4 of the [USB specification][usb_spec])
- `bRequest` is **6** (i.e. the GET_DESCRIPTOR Request Code, defined in Table 9-4 of the [USB specification])

A GET_DESCRIPTOR *Configuration* request is determined by the high byte of its `wValue` field:

- The high byte of `wValue` is **2** (i.e. the `CONFIGURATION` descriptor type, defined in table 9-5 of the [USB specification][usb_spec])
- The high byte of `wValue` is **2** (i.e. the `CONFIGURATION` descriptor type, defined in Table 9-5 of the [USB specification])

[usb_spec]: ./nrf52-usb-usb-specification.md
[USB specification]: ./nrf52-usb-usb-specification.md

✅ Update the parser in [`nrf52-code/usb-lib`](../../nrf52-code/usb-lib) to handle `SET_CONFIGURATION` requests.

Expand Down
2 changes: 1 addition & 1 deletion exercise-book/src/nrf52-usb-usb-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Going back to our [enumeration steps](./nrf52-usb-usb-enumeration.md), we are ex

For detailed information about endpoints check Section 5.3.1 *Device Endpoints*, in the [USB 2.0 specification][usb_spec]. Or you can look at [Chapter 3 of USB In a Nutshell](https://www.beyondlogic.org/usbnutshell/usb3.shtml#Endpoints).

[usb_spec]: ./nrf52-usb-usb-specification.md
[USB specification]: ./nrf52-usb-usb-specification.md

0 comments on commit d3d3dfe

Please sign in to comment.