Control Commands for USB Devices

Last modified by Microchip on 2023/11/09 08:55

USB provides the host the ability to send control commands to standard devices as well as hubs. Devices receive the control commands on endpoint 0.

Setup Packet

Each control request starts with an 8-byte setup packet.

FieldSize
(bytes)
Description
bmRequestType1Specifies the type of request and the recipient. See the following table for the details of bmRequest.
bRequest1The command to be executed. The values of bRequest are listed in the descriptions of the request types.
wValue2Command parameter, if needed.
wIndex2Command parameter, if needed.
wLength2Number of additional bytes to transfer if the instruction has a data phase.

usb setup packet

Back to Top

bmRequest type


Bit FieldPurposeValue
D0 - D4Recipient0 - Device
1 - Endpoint
2 - Interface
3 - Other
4- 31 Reserved
D5 - D6Type of Request0 - Standard
1 - Class
2 - Vendor
3 - Reserved
D7Direction0 - Host to Device
1 - Device to Host

Many commands require no additional data and are completed by the device within 50 ms of sending the setup packet. Requests which require a data phase must be completed by the device within 500 ms of the packet being sent.

There are four types of control commands:

  • Device Requests
  • Interface Requests
  • Endpoint Requests
  • Hub Requests

Back to Top

Device Requests

bmRequestTypebRequestDescription
1000 0000bGET_STATUS
( 0 )
Returns the status of the device. Primarily used to determine if the device is capable of Remote Wake-up, and whether or not the device is Self or Bus-powered.
0000 0000bCLEAR_FEATURE
(01)
Disables either the DEVICE_REMOTE_WAKEUP or the TEST_MODE feature.
0000 0000bSET_FEATURE
(03)
Enables either the DEVICE_REMOTE_WAKEUP or the TEST_MODE feature.
0000 0000bSET_ADDRESS
(05)
During enumeration this instruction is used to assign an address (1 -127) to the device.
1000 0000bGET_DESCRIPTOR
(06)
Returns the descriptor table selected by the wValue parameter.
0000 0000bSET_DESCRIPTOR
(07)
Sets the specified descriptor value.
1000 0000bGET_CONFIGURATION
(08)
Returns the index value for the active device configuration.
0000 0000bSET_CONFIGURATION
(09)
Cause the specified device configuration to become active.

Back to Top

Interface Requests

bmRequestTypebRequestDescription
1000 0001bGET_STATUS
(0)
Returns the status of the interface. Currently both returned bytes are reserved for future use.
0000 0001bCLEAR_FEATURE
(01)
Disables an interface feature.
0000 0001bSET_FEATURE
(03)
Enables the specified interface feature.
1000 0001bGET_INTERFACE
(0A)
Retrieve the index for the currently active interface.
0000 0001bSET_INTERFACE
(11)
Indicated with interface to activate.

Back to Top

Endpoint Requests

bmRequestTypebRequestDescription
1000 0010bGET_STATUS
(0)
Returns the status of the endpoint.
0000 0010bCLEAR_FEATURE
(01)
Disables an endpoint feature.
0000 0010bSET_FEATURE
(03)
Enable endpoint feature.
1000 0010bSYNCH_FRAME
(12)
Used to report endpoint synchronization frame.

Back to Top

Hub Requests

  • Get Hub Status (GET_STATUS)
  • Get Port Status (GET_STATUS)
  • Clear Hub Feature (CLEAR_FEATURE)
  • Clear Port Feature (CLEAR_FEATURE)
  • Get Bus State (GET_STATE) obsolete since USB 2.0
  • Set Hub Feature (SET_FEATURE)
  • Set Port Feature (SET_FEATURE)
  • Get Hub Descriptor (GET_DESCRIPTOR)
  • Set Hub Descriptor (SET_DESCRIPTOR)
  • Clear TT Buffer (CLEAR_TT_BUFFER)
  • Reset TT (RESET_TT)
  • Get TT State (GET_TT_STATE)
  • Stop TT (STOP_TT)

Back to Top