A class driver typically performs the following operations:
- Connect to the USB stack (usbd_connect()) and provide two callbacks: one for insertion and
one for removal.
- In the insertion callback:
- Connect to the USB device (usbd_attach()).
- Get descriptors (usbd_descriptor()).
- Select the configuration (usbd_select_config())
and interface (usbd_select_interface()).
- Set up communications pipes to the appropriate endpoint (usbd_open_pipe()).
- In the removal callback, detach from the USB device (usbd_detach()).
- Set up all data communications (e.g. reading and writing data, sending and receiving control information, etc.)
via the usbd_setup_*() functions (usbd_setup_bulk(), usbd_setup_interrupt(), etc.).
- Initiate data transfer using the usbd_io() function (with completion callbacks if required).
Note:
In this context, the term "pipe" is a
USB-specific term that has nothing to do with
standard POSIX "pipes" (as used, for example,
in the command line ls | more). In USB
terminology, a "pipe" is simply a handle;
something that identifies a connection to an endpoint.