libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
Generic USB Control Requests

Generic USB Control Requests More...

Functions

static void stall_transaction (usbd_device *usbd_dev)
 
static bool needs_zlp (uint16_t len, uint16_t wLength, uint8_t ep_size)
 If we're replying with some data, but less than the host is expecting, then we normally just do a short transfer. More...
 
int usbd_register_control_callback (usbd_device *usbd_dev, uint8_t type, uint8_t type_mask, usbd_control_callback callback)
 Registers a control callback. More...
 
static void usb_control_send_chunk (usbd_device *usbd_dev)
 
static int usb_control_recv_chunk (usbd_device *usbd_dev)
 
static enum usbd_request_return_codes usb_control_request_dispatch (usbd_device *usbd_dev, struct usb_setup_data *req)
 
static void usb_control_setup_read (usbd_device *usbd_dev, struct usb_setup_data *req)
 
static void usb_control_setup_write (usbd_device *usbd_dev, struct usb_setup_data *req)
 

Detailed Description

Generic USB Control Requests

Version
1.0.0
Author
© 2010 Gareth McMullin garet.nosp@m.h@bl.nosp@m.acksp.nosp@m.here.nosp@m..co.n.nosp@m.z
Date
10 March 2013

LGPL License Terms libopencm3 License

Function Documentation

◆ needs_zlp()

static bool needs_zlp ( uint16_t  len,
uint16_t  wLength,
uint8_t  ep_size 
)
static

If we're replying with some data, but less than the host is expecting, then we normally just do a short transfer.

But if it's short, but a multiple of the endpoint max packet size, we need an explicit ZLP.

Parameters
lenhow much data we want to transfer
wLengthhow much the host asked for
ep_size
Returns

Definition at line 62 of file usb_control.c.

Referenced by usb_control_setup_read().

Here is the caller graph for this function:

◆ stall_transaction()

static void stall_transaction ( usbd_device usbd_dev)
static

Definition at line 47 of file usb_control.c.

References usbd_dev, and usbd_ep_stall_set().

Referenced by _usbd_control_in(), _usbd_control_out(), usb_control_recv_chunk(), usb_control_setup_read(), and usb_control_setup_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_control_recv_chunk()

static int usb_control_recv_chunk ( usbd_device usbd_dev)
static

Definition at line 121 of file usb_control.c.

References stall_transaction(), usbd_dev, and usbd_ep_read_packet().

Referenced by _usbd_control_out().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_control_request_dispatch()

static enum usbd_request_return_codes usb_control_request_dispatch ( usbd_device usbd_dev,
struct usb_setup_data req 
)
static

Definition at line 142 of file usb_control.c.

References _usbd_standard_request(), usb_setup_data::bmRequestType, usbd_dev, USBD_REQ_HANDLED, and USBD_REQ_NOTSUPP.

Referenced by _usbd_control_out(), and usb_control_setup_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_control_send_chunk()

static void usb_control_send_chunk ( usbd_device usbd_dev)
static

Definition at line 93 of file usb_control.c.

References usbd_dev, and usbd_ep_write_packet().

Referenced by _usbd_control_in(), and usb_control_setup_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_control_setup_read()

static void usb_control_setup_read ( usbd_device usbd_dev,
struct usb_setup_data req 
)
static

Definition at line 173 of file usb_control.c.

References needs_zlp(), stall_transaction(), usb_control_request_dispatch(), usb_control_send_chunk(), usbd_dev, usbd_ep_write_packet(), and usb_setup_data::wLength.

Referenced by _usbd_control_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usb_control_setup_write()

static void usb_control_setup_write ( usbd_device usbd_dev,
struct usb_setup_data req 
)
static

Definition at line 198 of file usb_control.c.

References stall_transaction(), usbd_dev, usbd_ep_nak_set(), and usb_setup_data::wLength.

Referenced by _usbd_control_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usbd_register_control_callback()

int usbd_register_control_callback ( usbd_device usbd_dev,
uint8_t  type,
uint8_t  type_mask,
usbd_control_callback  callback 
)

Registers a control callback.

Since the list of user control callbacks is cleared every time device configuration is set (inside usb_standard_set_configuration()), control callback registration must happen inside (or after) the config callback. The specified callback will be called if (type == (bmRequestType & type_mask)).

See also
usbd_register_set_config_callback
Parameters
usbd_devthe usb device handle returned from usbd_init
typeHandled request type
type_maskMask to apply before matching request type
callbackyour desired callback function
Returns
0 if successful

Definition at line 73 of file usb_control.c.

References usbd_dev.

Referenced by msc_set_config().

Here is the caller graph for this function: