embedded-trainings-2020/embedded-workshop-book/src/supporting-standard-requests.md
2020-07-16 14:07:17 +02:00

1.7 KiB
Raw Blame History

USB-4: Supporting more Standard Requests

After responding to the GET_DESCRIPTOR Device request the host will start sending different requests.

Update the parser in common/usb so that it can handle the following requests:

  1. GET_DESCRIPTOR Configuration, see the section on Handling GET_DESCRIPTOR Configuration Requests
  2. SET_CONFIGURATION, see the section on SET_CONFIGURATION of this course material

The starter common/usb code contains unit tests for these other requests as well as extra Request variants for these requests. All of them have been commented out using a #[cfg(TODO)] attribute which you can remove once you need any new variant or new unit test.

For each green test, extend usb-4.rs to handle the new requests your parser is now able to recognize. Make sure to read the next sections as you're working, since they contain explanations about the concepts used and needed to complete this task.

Keep the cable connected to the J3 port for the rest of the workshop

If you need a reference, you can find solutions to parsing GET_DESCRIPTOR Configuration and SET_CONFIGURATION requests in the following files:

  • advanced/common/usb/solution-get-descriptor-configuration.rs
  • advanced/common/usb/solution-set-configuration.rs

Each file contains just enough code to parse the request in its name and the GET_DESCRIPTOR Device and SET_ADDRESS requests. So you can refer to solution-get-descriptor-configuration.rs without getting "spoiled" about how to parse the SET_CONFIGURATION request.