PebbleOS v4.47.0-757-g12b6c531f
Loading...
Searching...
No Matches
USB device

The device side of USB, on the board's USB device controller, its UDC role. More...

Modules

 USB serial port
 A serial port over USB, CDC ACM, as a UART: a board's roles can give it to the console.
 
 USB firmware upgrade
 Device Firmware Upgrade 1.1, in DFU mode: a host downloads an image to a flash partition and uploads it back, as with dfu-util.
 

Data Structures

struct  pbl_usbd_function
 A function of the device: a class, on interfaces and endpoints of its own. More...
 

Macros

#define PBL_USBD_FUNCTION_DEFINE(name)
 Define a function of the device.
 

Functions

int pbl_usbd_enable (void)
 Connect the device to the bus, once: the controller first, if it is not up yet.
 
uint16_t pbl_usbd_bulk_mps (void)
 Maximum packet size of the bulk endpoints, at the speed the bus runs.
 

Detailed Description

The device side of USB, on the board's USB device controller, its UDC role.

The device has one configuration, made of the functions defined with PBL_USBD_FUNCTION_DEFINE(), in the order of their names. Each function gives its interface and endpoint descriptors, with its interface numbers and endpoint addresses: the functions of a device do not share any. The stack sets the maximum packet size of their bulk endpoints for the bus speed, enables their endpoints when the host configures the device, and hands them the class requests to their interfaces and the end of the transfers on their endpoints. Everything the stack calls runs from the controller's interrupt.

An interface can have alternate settings: its interface descriptor is followed by others with the same interface number and a higher bAlternateSetting, each with its own endpoints. Two settings may use the same endpoint addresses. Configuring the device selects setting 0 of every interface; SET_INTERFACE then disables the endpoints of the current setting, enables those of the new one and calls pbl_usbd_function::set_alt.

A function names its strings with its own indices, from 1, in the iInterface field of its interface descriptors and the iFunction field of its interface association descriptor: index n is pbl_usbd_function::strings[n - 1]. The stack gives them indices of the device when it sends the configuration descriptor. Strings in class-specific descriptors are not mapped.

Macro Definition Documentation

◆ PBL_USBD_FUNCTION_DEFINE

#define PBL_USBD_FUNCTION_DEFINE (   name)
Value:
static const struct pbl_usbd_function pbl_usbd_function_##name PBL_ITERABLE_SECTION( \
const struct pbl_usbd_function, usbd_functions, #name)
#define PBL_ITERABLE_SECTION(type, tag, key)
Add the object to an iterable section, a table gathered at link time from any file.
Definition section.h:124
A function of the device: a class, on interfaces and endpoints of its own.
Definition usbd.h:40

Define a function of the device.

Parameters
nameName, which also orders the functions.

Function Documentation

◆ pbl_usbd_bulk_mps()

uint16_t pbl_usbd_bulk_mps ( void  )

Maximum packet size of the bulk endpoints, at the speed the bus runs.

Returns
64 at full speed, 512 at high speed.

◆ pbl_usbd_enable()

int pbl_usbd_enable ( void  )

Connect the device to the bus, once: the controller first, if it is not up yet.

Returns
0, or a negative errno, as -ENODEV when the controller failed.