2.25. usb — Universal Serial Bus

Source code: src/drivers/usb.h, src/drivers/usb.c


Defines

REQUEST_TYPE_DATA_MASK
REQUEST_TYPE_DATA_DIRECTION_HOST_TO_DEVICE
REQUEST_TYPE_DATA_DIRECTION_DEVICE_TO_HOST
REQUEST_TYPE_TYPE_MASK
REQUEST_TYPE_TYPE_STANDARD
REQUEST_TYPE_TYPE_CLASS
REQUEST_TYPE_TYPE_VENDOR
REQUEST_TYPE_RECIPIENT_MASK
REQUEST_TYPE_RECIPIENT_DEVICE
REQUEST_TYPE_RECIPIENT_INTERFACE
REQUEST_TYPE_RECIPIENT_ENDPOINT
REQUEST_TYPE_RECIPIENT_OTHER
REQUEST_GET_STATUS
REQUEST_SET_ADDRESS
REQUEST_GET_DESCRIPTOR
REQUEST_SET_CONFIGURATION
DESCRIPTOR_TYPE_DEVICE
DESCRIPTOR_TYPE_CONFIGURATION
DESCRIPTOR_TYPE_STRING
DESCRIPTOR_TYPE_INTERFACE
DESCRIPTOR_TYPE_ENDPOINT
DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION
DESCRIPTOR_TYPE_RPIPE
DESCRIPTOR_TYPE_CDC
USB_CLASS_USE_INTERFACE
USB_CLASS_AUDIO
USB_CLASS_CDC_CONTROL
USB_CLASS_HID
USB_CLASS_PHYSICAL
USB_CLASS_IMAGE
USB_CLASS_PRINTER
USB_CLASS_MASS_STORAGE
USB_CLASS_HUB
USB_CLASS_CDC_DATA
USB_CLASS_SMART_CARD
USB_CLASS_CONTENT_SECURITY
USB_CLASS_VIDEO
USB_CLASS_PERSONAL_HEALTHCARE
USB_CLASS_AUDIO_VIDEO_DEVICES
USB_CLASS_BILLBOARD_DEVICE_CLASS
USB_CLASS_DIAGNOSTIC_DEVICE
USB_CLASS_WIRELESS_CONTROLLER
USB_CLASS_MISCELLANEOUS
USB_CLASS_APPLICATION_SPECIFIC
USB_CLASS_VENDOR_SPECIFIC
ENDPOINT_ENDPOINT_ADDRESS_DIRECTION(address)
ENDPOINT_ENDPOINT_ADDRESS_NUMBER(address)
ENDPOINT_ATTRIBUTES_USAGE_TYPE(attributes)
ENDPOINT_ATTRIBUTES_SYNCHRONISATION_TYPE(attributes)
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE(attributes)
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_CONTROL
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_ISOCHRONOUS
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_BULK
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_INTERRUPT
CONFIGURATION_ATTRIBUTES_BUS_POWERED
USB_CDC_LINE_CODING
USB_CDC_CONTROL_LINE_STATE
USB_CDC_SEND_BREAK
USB_MESSAGE_TYPE_ADD
USB_MESSAGE_TYPE_REMOVE

Functions

int usb_format_descriptors(void *out_p, uint8_t *buf_p, size_t size)

Format the descriptors and write them to given channel.

Return
zero(0) or negative error code.
Parameters
  • out_p: Output channel.
  • buf_p: Pointer to the descriptors to format.
  • size: Number of bytes in the descriptors buffer.

struct usb_descriptor_configuration_t *usb_desc_get_configuration(uint8_t *desc_p, size_t size, int configuration)

Get the configuration descriptor for given configuration index.

Return
Configuration or NULL on failure.
Parameters
  • buf_p: Pointer to the descriptors.
  • size: Number of bytes in the descriptors buffer.
  • configuration: Configuration to find.

struct usb_descriptor_interface_t *usb_desc_get_interface(uint8_t *desc_p, size_t size, int configuration, int interface)

Get the interface descriptor for given configuration and interface index.

Return
Interface or NULL on failure.
Parameters
  • buf_p: Pointer to the descriptors.
  • size: Number of bytes in the descriptors buffer.
  • configuration: Configuration to find.
  • interface: Interface to find.

struct usb_descriptor_endpoint_t *usb_desc_get_endpoint(uint8_t *desc_p, size_t size, int configuration, int interface, int endpoint)

Get the endpoint descriptor for given configuration, interface and endpoint index.

Return
Endpoint or NULL on failure.
Parameters
  • buf_p: Pointer to the descriptors.
  • size: Number of bytes in the descriptors buffer.
  • configuration: Configuration to find.
  • interface: Interface to find.
  • endpoint: Endpoint to find.

int usb_desc_get_class(uint8_t *buf_p, size_t size, int configuration, int interface)

Get the interface class.

Return
Parameters
  • buf_p: Pointer to the descriptors.
  • size: Number of bytes in the descriptors buffer.
  • configuration: Configuration to find.
  • interface: Interface to find.

Variables

struct usb_device_t usb_device[USB_DEVICE_MAX]
struct usb_setup_t

Public Members

uint8_t request_type
uint8_t request
uint16_t feature_selector
uint16_t zero_interface_endpoint
struct usb_setup_t::@15::@16 usb_setup_t::clear_feature
uint16_t zero0
uint16_t zero1
struct usb_setup_t::@15::@17 usb_setup_t::get_configuration
uint8_t descriptor_index
uint8_t descriptor_type
uint16_t language_id
struct usb_setup_t::@15::@18 usb_setup_t::get_descriptor
uint16_t device_address
uint16_t zero
struct usb_setup_t::@15::@19 usb_setup_t::set_address
uint16_t configuration_value
struct usb_setup_t::@15::@20 usb_setup_t::set_configuration
uint16_t value
uint16_t index
struct usb_setup_t::@15::@21 usb_setup_t::base
union usb_setup_t::@15 usb_setup_t::u
uint16_t length
struct usb_descriptor_header_t

Public Members

uint8_t length
uint8_t descriptor_type
struct usb_descriptor_device_t

Public Members

uint8_t length
uint8_t descriptor_type
uint16_t bcd_usb
uint8_t device_class
uint8_t device_subclass
uint8_t device_protocol
uint8_t max_packet_size_0
uint16_t id_vendor
uint16_t id_product
uint16_t bcd_device
uint8_t manufacturer
uint8_t product
uint8_t serial_number
uint8_t num_configurations
struct usb_descriptor_configuration_t

Public Members

uint8_t length
uint8_t descriptor_type
uint16_t total_length
uint8_t num_interfaces
uint8_t configuration_value
uint8_t configuration
uint8_t configuration_attributes
uint8_t max_power
struct usb_descriptor_interface_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t interface_number
uint8_t alternate_setting
uint8_t num_endpoints
uint8_t interface_class
uint8_t interface_subclass
uint8_t interface_protocol
uint8_t interface
struct usb_descriptor_endpoint_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t endpoint_address
uint8_t attributes
uint16_t max_packet_size
uint8_t interval
struct usb_descriptor_string_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t string[256]
struct usb_descriptor_interface_association_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t first_interface
uint8_t interface_count
uint8_t function_class
uint8_t function_subclass
uint8_t function_protocol
uint8_t function
struct usb_descriptor_cdc_header_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t sub_type
uint16_t bcd
struct usb_descriptor_cdc_acm_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t sub_type
uint8_t capabilities
struct usb_descriptor_cdc_union_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t sub_type
uint8_t master_interface
uint8_t slave_interface
struct usb_descriptor_cdc_call_management_t

Public Members

uint8_t length
uint8_t descriptor_type
uint8_t sub_type
uint8_t capabilities
uint8_t data_interface
union usb_descriptor_t

Public Members

struct usb_descriptor_header_t header
struct usb_descriptor_device_t device
struct usb_descriptor_configuration_t configuration
struct usb_descriptor_interface_t interface
struct usb_descriptor_endpoint_t endpoint
struct usb_descriptor_string_t string
struct usb_cdc_line_info_t

Public Members

uint32_t dte_rate
uint8_t char_format
uint8_t parity_type
uint8_t data_bits
struct usb_message_header_t

Public Members

int type
struct usb_message_add_t

Public Members

struct usb_message_header_t header
int device
union usb_message_t

Public Members

struct usb_message_header_t header
struct usb_message_add_t add