3.28. usb
— Universal Serial Bus¶
Source code: src/drivers/usb.h, src/drivers/usb.c
Defines
-
REQUEST_TYPE_DATA_MASK
(0x80)¶
-
REQUEST_TYPE_DATA_DIRECTION_HOST_TO_DEVICE
(0x00)¶
-
REQUEST_TYPE_DATA_DIRECTION_DEVICE_TO_HOST
(0x80)¶
-
REQUEST_TYPE_TYPE_MASK
(0x60)¶
-
REQUEST_TYPE_TYPE_STANDARD
(0x00)¶
-
REQUEST_TYPE_TYPE_CLASS
(0x20)¶
-
REQUEST_TYPE_TYPE_VENDOR
(0x40)¶
-
REQUEST_TYPE_RECIPIENT_MASK
(0x0f)¶
-
REQUEST_TYPE_RECIPIENT_DEVICE
(0x00)¶
-
REQUEST_TYPE_RECIPIENT_INTERFACE
(0x01)¶
-
REQUEST_TYPE_RECIPIENT_ENDPOINT
(0x02)¶
-
REQUEST_TYPE_RECIPIENT_OTHER
(0x03)¶
-
REQUEST_GET_STATUS
0¶
-
REQUEST_SET_ADDRESS
5¶
-
REQUEST_GET_DESCRIPTOR
6¶
-
REQUEST_SET_CONFIGURATION
9¶
-
DESCRIPTOR_TYPE_DEVICE
1¶
-
DESCRIPTOR_TYPE_CONFIGURATION
2¶
-
DESCRIPTOR_TYPE_STRING
3¶
-
DESCRIPTOR_TYPE_INTERFACE
4¶
-
DESCRIPTOR_TYPE_ENDPOINT
5¶
-
DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION
11¶
-
DESCRIPTOR_TYPE_RPIPE
34¶
-
DESCRIPTOR_TYPE_CDC
36¶
-
USB_CLASS_USE_INTERFACE
0x00 /* Device. */¶
-
USB_CLASS_AUDIO
0x01 /* Interface. */¶
-
USB_CLASS_CDC_CONTROL
0x02 /* Both. */¶
-
USB_CLASS_HID
0x03 /* Interface. */¶
-
USB_CLASS_PHYSICAL
0x05 /* Interface. */¶
-
USB_CLASS_IMAGE
0x06 /* Interface. */¶
-
USB_CLASS_PRINTER
0x07 /* Interface. */¶
-
USB_CLASS_MASS_STORAGE
0x08 /* Interface. */¶
-
USB_CLASS_HUB
0x09 /* Device. */¶
-
USB_CLASS_CDC_DATA
0x0a /* Interface. */¶
-
USB_CLASS_SMART_CARD
0x0b /* Interface. */¶
-
USB_CLASS_CONTENT_SECURITY
0x0d /* Interface. */¶
-
USB_CLASS_VIDEO
0x0e /* Interface. */¶
-
USB_CLASS_PERSONAL_HEALTHCARE
0x0f /* Interface. */¶
-
USB_CLASS_AUDIO_VIDEO_DEVICES
0x10 /* Interface. */¶
-
USB_CLASS_BILLBOARD_DEVICE_CLASS
0x11 /* Device. */¶
-
USB_CLASS_DIAGNOSTIC_DEVICE
0xdc /* Both. */¶
-
USB_CLASS_WIRELESS_CONTROLLER
0xe0 /* Interface. */¶
-
USB_CLASS_MISCELLANEOUS
0xef /* Both. */¶
-
USB_CLASS_APPLICATION_SPECIFIC
0xfe /* Interface. */¶
-
USB_CLASS_VENDOR_SPECIFIC
0xff /* Both. */¶
-
ENDPOINT_ENDPOINT_ADDRESS_DIRECTION
(address) (((address) >> 7) & 0x1)¶
-
ENDPOINT_ENDPOINT_ADDRESS_NUMBER
(address) (((address) >> 0) & 0xf)¶
-
ENDPOINT_ATTRIBUTES_USAGE_TYPE
(attributes) (((attributes) >> 4) & 0x3)¶
-
ENDPOINT_ATTRIBUTES_SYNCHRONISATION_TYPE
(attributes) (((attributes) >> 2) & 0x3)¶
-
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE
(attributes) (((attributes) >> 0) & 0x3)¶
-
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_CONTROL
0¶
-
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_ISOCHRONOUS
1¶
-
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_BULK
2¶
-
ENDPOINT_ATTRIBUTES_TRANSFER_TYPE_INTERRUPT
3¶
-
CONFIGURATION_ATTRIBUTES_BUS_POWERED
0x80¶
-
USB_CDC_LINE_CODING
0x20¶
-
USB_CDC_CONTROL_LINE_STATE
0x22¶
-
USB_CDC_SEND_BREAK
0x23¶
-
USB_MESSAGE_TYPE_ADD
0¶
-
USB_MESSAGE_TYPE_REMOVE
1¶
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::@20::@21 usb_setup_t::clear_feature
-
uint16_t
zero0
¶
-
uint16_t
zero1
¶
-
struct usb_setup_t::@20::@22 usb_setup_t::get_configuration
-
uint8_t
descriptor_index
¶
-
uint8_t
descriptor_type
¶
-
uint16_t
language_id
¶
-
struct usb_setup_t::@20::@23 usb_setup_t::get_descriptor
-
uint16_t
device_address
¶
-
uint16_t
zero
¶
-
struct usb_setup_t::@20::@24 usb_setup_t::set_address
-
uint16_t
configuration_value
¶
-
struct usb_setup_t::@20::@25 usb_setup_t::set_configuration
-
uint16_t
value
¶
-
uint16_t
index
¶
-
struct usb_setup_t::@20::@26 usb_setup_t::base
-
union usb_setup_t::@20 usb_setup_t::u
-
uint16_t
length
¶
-
uint8_t
-
struct
usb_descriptor_header_t
¶
-
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
¶
-
uint8_t
-
struct
usb_descriptor_configuration_t
¶
-
struct
usb_descriptor_interface_t
¶
-
struct
usb_descriptor_endpoint_t
¶
-
struct
usb_descriptor_string_t
¶
-
struct
usb_descriptor_interface_association_t
¶
-
struct
usb_descriptor_cdc_header_t
¶
-
struct
usb_descriptor_cdc_acm_t
¶
-
struct
usb_descriptor_cdc_union_t
¶
-
struct
usb_descriptor_cdc_call_management_t
¶
-
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_descriptor_header_t
-
struct
usb_cdc_line_info_t
¶
-
struct
usb_message_add_t
¶
-
union
usb_message_t
¶