PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
USB device controller drivers

Interface for USB device controller drivers. More...

Data Structures

struct  pbl_udc_ops
 Driver operations. More...
 
struct  pbl_udc
 USB device controller. More...
 

Macros

#define PBL_UDC_STATE_DEFINE(sym)
 Define the runtime state of a controller.
 
#define PBL_UDC_INIT(sym, _name, _parent, _ops, _num_eps, _max_speed, _caps, _vbus_charger)
 Initializer of a controller.
 

Functions

void pbl_udc_event (const struct pbl_udc *udc, enum pbl_udc_event evt, const uint8_t *setup)
 Report a bus event, from the controller's interrupt.
 
void pbl_udc_vbus_changed (const struct pbl_udc *udc, bool present)
 Report USB power coming or going, from thread context, for a controller that senses it.
 
void pbl_udc_xfer_done (const struct pbl_udc *udc, uint8_t ep, int ret)
 Report the end of a transfer, from the controller's interrupt.
 

Detailed Description

Interface for USB device controller drivers.

A driver embeds a struct pbl_udc in its instance, sets it up with PBL_UDC_STATE_DEFINE() and PBL_UDC_INIT(), and implements the struct pbl_udc_ops the class calls.


Data Structure Documentation

◆ pbl_udc

struct pbl_udc

USB device controller.

Data Fields
uint8_t caps Capabilities, as PBL_UDC_CAP_EP_ONE_DIR.
struct pbl_device dev Device.
enum pbl_udc_speed max_speed Fastest speed the controller and its PHY run at.
uint8_t num_eps Number of endpoints in each direction, endpoint 0 included.
const struct pbl_udc_ops * ops Driver operations.
struct pbl_udc_state * state Runtime state.
const struct pbl_charger * vbus_charger Charger on the connector's VBUS, or NULL when the board does not sense USB power.

Macro Definition Documentation

◆ PBL_UDC_INIT

#define PBL_UDC_INIT (   sym,
  _name,
  _parent,
  _ops,
  _num_eps,
  _max_speed,
  _caps,
  _vbus_charger 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_udc_dev_init, _parent, &pbl_udc_class), \
.ops = (_ops), \
.state = &sym##_udc_state, \
.num_eps = (_num_eps), \
.max_speed = (_max_speed), \
.caps = (_caps), \
.vbus_charger = (_vbus_charger), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153

Initializer of a controller.

Parameters
symSymbol of the controller.
_nameName.
_parentParent device, or NULL.
_opsDriver operations.
_num_epsNumber of endpoints in each direction.
_max_speedFastest speed, one of pbl_udc_speed.
_capsCapabilities, as PBL_UDC_CAP_EP_ONE_DIR, or 0.
_vbus_chargerCharger on the connector's VBUS, or NULL.

◆ PBL_UDC_STATE_DEFINE

#define PBL_UDC_STATE_DEFINE (   sym)
Value:
static struct pbl_udc_state sym##_udc_state
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132

Define the runtime state of a controller.

Parameters
symSymbol of the controller.

Function Documentation

◆ pbl_udc_event()

void pbl_udc_event ( const struct pbl_udc *  udc,
enum pbl_udc_event  evt,
const uint8_t *  setup 
)

Report a bus event, from the controller's interrupt.

Parameters
udcController.
evtEvent.
setupFor PBL_UDC_EVENT_SETUP, the 8 bytes of the setup packet.

◆ pbl_udc_vbus_changed()

void pbl_udc_vbus_changed ( const struct pbl_udc *  udc,
bool  present 
)

Report USB power coming or going, from thread context, for a controller that senses it.

The controller reports power absent from its init when it is.

Parameters
udcController.
presentWhether USB power is present.

◆ pbl_udc_xfer_done()

void pbl_udc_xfer_done ( const struct pbl_udc *  udc,
uint8_t  ep,
int  ret 
)

Report the end of a transfer, from the controller's interrupt.

Parameters
udcController.
epEndpoint address.
retBytes moved, or a negative errno.