Loading...
Searching...
No Matches
USB descriptors

Provides USB protocol descriptors and defines for USB frameworks. More...

Detailed Description

Provides USB protocol descriptors and defines for USB frameworks.

Files

file  descriptor.h
 Definitions for USB protocol messages.
 

Data Structures

struct  usb_descriptor_device_t
 USB device descriptor (USB 2.0 spec table 9-8) More...
 
struct  usb_descriptor_configuration_t
 USB configuration descriptor (USB 2.0 spec table 9-10) More...
 
struct  usb_descriptor_interface_t
 USB interface descriptor (USB 2.0 spec table 9-12) More...
 
struct  usb_descriptor_endpoint_t
 USB endpoint descriptor (USB 2.0 spec table 9-13) More...
 
struct  usb_descriptor_string_t
 USB string descriptor (USB 2.0 spec table 9-16) More...
 
struct  usb_descriptor_interface_association_t
 USB interface association descriptor (Interface Association Descriptors table 9-Z) More...
 
struct  usb_setup_t
 USB setup packet (USB 2.0 spec table 9-2) More...
 

Macros

#define USB_ENDPOINT_DESCRIPTOR_INTERVAL_ISOCHRONOUS   1
 USB isochronous endpoint interval.
 

Functions

static bool usb_setup_is_read (usb_setup_t *pkt)
 getter for setup packet direction
 

USB standard device request codes (USB 2.0 spec table 9-4)

#define USB_SETUP_REQ_GET_STATUS   0x00
 Status request

 
#define USB_SETUP_REQ_CLEAR_FEATURE   0x01
 Clear feature

 
#define USB_SETUP_REQ_SET_FEATURE   0x03
 Set feature

 
#define USB_SETUP_REQ_SET_ADDRESS   0x05
 Set address

 
#define USB_SETUP_REQ_GET_DESCRIPTOR   0x06
 Get descriptor

 
#define USB_SETUP_REQ_SET_DESCRIPTOR   0x07
 Set descriptor

 
#define USB_SETUP_REQ_GET_CONFIGURATION   0x08
 Get configuration

 
#define USB_SETUP_REQ_SET_CONFIGURATION   0x09
 Set configuration

 
#define USB_SETUP_REQ_GET_INTERFACE   0x0a
 Get interface

 
#define USB_SETUP_REQ_SET_INTERFACE   0x0b
 Set interface

 
#define USB_SETUP_REQ_SYNCH_FRAME   0x0c
 Synch frame

 

USB descriptor types (USB 2.0 spec table 9-5)

#define USB_TYPE_DESCRIPTOR_DEVICE   0x01
 Device descriptor

 
#define USB_TYPE_DESCRIPTOR_CONFIGURATION   0x02
 Configuration Descriptor

 
#define USB_TYPE_DESCRIPTOR_STRING   0x03
 String descriptor

 
#define USB_TYPE_DESCRIPTOR_INTERFACE   0x04
 Interface descriptor

 
#define USB_TYPE_DESCRIPTOR_ENDPOINT   0x05
 Endpoint descriptor

 
#define USB_TYPE_DESCRIPTOR_DEV_QUALIFIER   0x06
 Device qualifier

 
#define USB_TYPE_DESCRIPTOR_SPEED_CONFIG   0x07
 Other speed configuration.
 
#define USB_TYPE_DESCRIPTOR_IFACE_POWER   0x08
 Interface power

 
#define USB_TYPE_DESCRIPTOR_INTERFACE_ASSOC   0x0b
 Interface association

 

USB standard feature selectors

#define USB_FEATURE_ENDPOINT_HALT   0x00
 Endpoint halt

 
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP   0x01
 Device remote wakeup.
 
#define USB_FEATURE_TEST_MODE   0x02
 Test mode feature

 

USB configuration attributes

#define USB_CONF_ATTR_RESERVED   0x80
 Reserved bit (always 1)

 
#define USB_CONF_ATTR_SELF_POWERED   0x40
 Self powered device flag

 
#define USB_CONF_ATTR_REM_WAKEUP   0x20
 Remote wake-up flag

 

USB setup packet requests types

#define USB_SETUP_REQUEST_DEVICE2HOST   0x80
 Request direction From device to host if the bit is set

 
#define USB_SETUP_REQUEST_RECIPIENT_MASK   0x1f
 Recipient mask

 
#define USB_SETUP_REQUEST_RECIPIENT_DEVICE   0x00
 Device request

 
#define USB_SETUP_REQUEST_RECIPIENT_INTERFACE   0x01
 Interface request

 
#define USB_SETUP_REQUEST_RECIPIENT_ENDPOINT   0x02
 Endpoint request

 
#define USB_SETUP_REQUEST_RECIPIENT_OTHER   0x03
 Other type request

 
#define USB_SETUP_REQUEST_TYPE_MASK   0x60
 Mask to select the type.
 
#define USB_SETUP_REQUEST_TYPE_STANDARD   0x00
 Standard request

 
#define USB_SETUP_REQUEST_TYPE_CLASS   0x20
 Class request

 
#define USB_SETUP_REQUEST_TYPE_VENDOR   0x40
 Vendor specific request.
 

USB device class numbers

#define USB_CLASS_AUDIO   0x01
 Audio device

 
#define USB_CLASS_CDC_CONTROL   0x02
 CDC control interface

 
#define USB_CLASS_HID   0x03
 Human Interface device

 
#define USB_CLASS_PHYSICAL   0x05
 Physical device class

 
#define USB_CLASS_IMAGE   0x06
 Image device class

 
#define USB_CLASS_PRINTER   0x07
 Printer device class

 
#define USB_CLASS_MASS_STORAGE   0x08
 Mass storage device class

 
#define USB_CLASS_CDC_DATA   0x0a
 CDC data specification

 
#define USB_CLASS_VENDOR   0xff
 Vendor specific class

 

Macro Definition Documentation

◆ USB_CLASS_AUDIO

#define USB_CLASS_AUDIO   0x01

Audio device

Definition at line 109 of file descriptor.h.

◆ USB_CLASS_CDC_CONTROL

#define USB_CLASS_CDC_CONTROL   0x02

CDC control interface

Definition at line 110 of file descriptor.h.

◆ USB_CLASS_CDC_DATA

#define USB_CLASS_CDC_DATA   0x0a

CDC data specification

Definition at line 116 of file descriptor.h.

◆ USB_CLASS_HID

#define USB_CLASS_HID   0x03

Human Interface device

Definition at line 111 of file descriptor.h.

◆ USB_CLASS_IMAGE

#define USB_CLASS_IMAGE   0x06

Image device class

Definition at line 113 of file descriptor.h.

◆ USB_CLASS_MASS_STORAGE

#define USB_CLASS_MASS_STORAGE   0x08

Mass storage device class

Definition at line 115 of file descriptor.h.

◆ USB_CLASS_PHYSICAL

#define USB_CLASS_PHYSICAL   0x05

Physical device class

Definition at line 112 of file descriptor.h.

◆ USB_CLASS_PRINTER

#define USB_CLASS_PRINTER   0x07

Printer device class

Definition at line 114 of file descriptor.h.

◆ USB_CLASS_VENDOR

#define USB_CLASS_VENDOR   0xff

Vendor specific class

Definition at line 117 of file descriptor.h.

◆ USB_CONF_ATTR_REM_WAKEUP

#define USB_CONF_ATTR_REM_WAKEUP   0x20

Remote wake-up flag

Definition at line 77 of file descriptor.h.

◆ USB_CONF_ATTR_RESERVED

#define USB_CONF_ATTR_RESERVED   0x80

Reserved bit (always 1)

Definition at line 75 of file descriptor.h.

◆ USB_CONF_ATTR_SELF_POWERED

#define USB_CONF_ATTR_SELF_POWERED   0x40

Self powered device flag

Definition at line 76 of file descriptor.h.

◆ USB_ENDPOINT_DESCRIPTOR_INTERVAL_ISOCHRONOUS

#define USB_ENDPOINT_DESCRIPTOR_INTERVAL_ISOCHRONOUS   1

USB isochronous endpoint interval.

Definition at line 103 of file descriptor.h.

◆ USB_FEATURE_DEVICE_REMOTE_WAKEUP

#define USB_FEATURE_DEVICE_REMOTE_WAKEUP   0x01

Device remote wakeup.

Definition at line 66 of file descriptor.h.

◆ USB_FEATURE_ENDPOINT_HALT

#define USB_FEATURE_ENDPOINT_HALT   0x00

Endpoint halt

Definition at line 65 of file descriptor.h.

◆ USB_FEATURE_TEST_MODE

#define USB_FEATURE_TEST_MODE   0x02

Test mode feature

Definition at line 67 of file descriptor.h.

◆ USB_SETUP_REQ_CLEAR_FEATURE

#define USB_SETUP_REQ_CLEAR_FEATURE   0x01

Clear feature

Definition at line 34 of file descriptor.h.

◆ USB_SETUP_REQ_GET_CONFIGURATION

#define USB_SETUP_REQ_GET_CONFIGURATION   0x08

Get configuration

Definition at line 39 of file descriptor.h.

◆ USB_SETUP_REQ_GET_DESCRIPTOR

#define USB_SETUP_REQ_GET_DESCRIPTOR   0x06

Get descriptor

Definition at line 37 of file descriptor.h.

◆ USB_SETUP_REQ_GET_INTERFACE

#define USB_SETUP_REQ_GET_INTERFACE   0x0a

Get interface

Definition at line 41 of file descriptor.h.

◆ USB_SETUP_REQ_GET_STATUS

#define USB_SETUP_REQ_GET_STATUS   0x00

Status request

Definition at line 33 of file descriptor.h.

◆ USB_SETUP_REQ_SET_ADDRESS

#define USB_SETUP_REQ_SET_ADDRESS   0x05

Set address

Definition at line 36 of file descriptor.h.

◆ USB_SETUP_REQ_SET_CONFIGURATION

#define USB_SETUP_REQ_SET_CONFIGURATION   0x09

Set configuration

Definition at line 40 of file descriptor.h.

◆ USB_SETUP_REQ_SET_DESCRIPTOR

#define USB_SETUP_REQ_SET_DESCRIPTOR   0x07

Set descriptor

Definition at line 38 of file descriptor.h.

◆ USB_SETUP_REQ_SET_FEATURE

#define USB_SETUP_REQ_SET_FEATURE   0x03

Set feature

Definition at line 35 of file descriptor.h.

◆ USB_SETUP_REQ_SET_INTERFACE

#define USB_SETUP_REQ_SET_INTERFACE   0x0b

Set interface

Definition at line 42 of file descriptor.h.

◆ USB_SETUP_REQ_SYNCH_FRAME

#define USB_SETUP_REQ_SYNCH_FRAME   0x0c

Synch frame

Definition at line 43 of file descriptor.h.

◆ USB_SETUP_REQUEST_DEVICE2HOST

#define USB_SETUP_REQUEST_DEVICE2HOST   0x80

Request direction From device to host if the bit is set

Definition at line 86 of file descriptor.h.

◆ USB_SETUP_REQUEST_RECIPIENT_DEVICE

#define USB_SETUP_REQUEST_RECIPIENT_DEVICE   0x00

Device request

Definition at line 89 of file descriptor.h.

◆ USB_SETUP_REQUEST_RECIPIENT_ENDPOINT

#define USB_SETUP_REQUEST_RECIPIENT_ENDPOINT   0x02

Endpoint request

Definition at line 91 of file descriptor.h.

◆ USB_SETUP_REQUEST_RECIPIENT_INTERFACE

#define USB_SETUP_REQUEST_RECIPIENT_INTERFACE   0x01

Interface request

Definition at line 90 of file descriptor.h.

◆ USB_SETUP_REQUEST_RECIPIENT_MASK

#define USB_SETUP_REQUEST_RECIPIENT_MASK   0x1f

Recipient mask

Definition at line 88 of file descriptor.h.

◆ USB_SETUP_REQUEST_RECIPIENT_OTHER

#define USB_SETUP_REQUEST_RECIPIENT_OTHER   0x03

Other type request

Definition at line 92 of file descriptor.h.

◆ USB_SETUP_REQUEST_TYPE_CLASS

#define USB_SETUP_REQUEST_TYPE_CLASS   0x20

Class request

Definition at line 96 of file descriptor.h.

◆ USB_SETUP_REQUEST_TYPE_MASK

#define USB_SETUP_REQUEST_TYPE_MASK   0x60

Mask to select the type.

Definition at line 94 of file descriptor.h.

◆ USB_SETUP_REQUEST_TYPE_STANDARD

#define USB_SETUP_REQUEST_TYPE_STANDARD   0x00

Standard request

Definition at line 95 of file descriptor.h.

◆ USB_SETUP_REQUEST_TYPE_VENDOR

#define USB_SETUP_REQUEST_TYPE_VENDOR   0x40

Vendor specific request.

Definition at line 97 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_CONFIGURATION

#define USB_TYPE_DESCRIPTOR_CONFIGURATION   0x02

Configuration Descriptor

Definition at line 51 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_DEV_QUALIFIER

#define USB_TYPE_DESCRIPTOR_DEV_QUALIFIER   0x06

Device qualifier

Definition at line 55 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_DEVICE

#define USB_TYPE_DESCRIPTOR_DEVICE   0x01

Device descriptor

Definition at line 50 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_ENDPOINT

#define USB_TYPE_DESCRIPTOR_ENDPOINT   0x05

Endpoint descriptor

Definition at line 54 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_IFACE_POWER

#define USB_TYPE_DESCRIPTOR_IFACE_POWER   0x08

Interface power

Definition at line 57 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_INTERFACE

#define USB_TYPE_DESCRIPTOR_INTERFACE   0x04

Interface descriptor

Definition at line 53 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_INTERFACE_ASSOC

#define USB_TYPE_DESCRIPTOR_INTERFACE_ASSOC   0x0b

Interface association

Definition at line 58 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_SPEED_CONFIG

#define USB_TYPE_DESCRIPTOR_SPEED_CONFIG   0x07

Other speed configuration.

Definition at line 56 of file descriptor.h.

◆ USB_TYPE_DESCRIPTOR_STRING

#define USB_TYPE_DESCRIPTOR_STRING   0x03

String descriptor

Definition at line 52 of file descriptor.h.

Function Documentation

◆ usb_setup_is_read()

static bool usb_setup_is_read ( usb_setup_t pkt)
inlinestatic

getter for setup packet direction

Parameters
[in]pktsetup packet
Returns
nonzero if it is a read request
zero if it is a write request

Definition at line 223 of file descriptor.h.