Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usbd_vreq_node Struct Reference

USBD vendor request node. More...

#include <usbd.h>

Data Fields

sys_dnode_t node
 Node information for the dlist.
 
const uint8_t code
 Vendor code (bRequest value)
 
int(* to_host )(const struct usbd_context *const ctx, const struct usb_setup_packet *const setup, struct net_buf *const buf)
 Vendor request callback for device-to-host direction.
 
int(* to_dev )(const struct usbd_context *const ctx, const struct usb_setup_packet *const setup, const struct net_buf *const buf)
 Vendor request callback for host-to-device direction.
 

Detailed Description

USBD vendor request node.

Vendor request node is identified by the vendor code and is used to register callbacks to handle the vendor request with the receiving device. When the device stack receives a request with type Vendor and recipient Device, and bRequest value equal to the vendor request code, it will call the vendor callbacks depending on the direction of the request.

Example callback code fragment:

static int foo_to_host_cb(const struct usbd_context *const ctx,
const struct usb_setup_packet *const setup,
struct net_buf *const buf)
{
if (setup->wIndex == WEBUSB_REQ_GET_URL) {
if (index != SAMPLE_WEBUSB_LANDING_PAGE) {
return -ENOTSUP;
}
net_buf_add_mem(buf, &webusb_origin_url,
MIN(net_buf_tailroom(buf), sizeof(webusb_origin_url)));
return 0;
}
return -ENOTSUP;
}
static void * net_buf_add_mem(struct net_buf *buf, const void *mem, size_t len)
Copies the given number of bytes to the end of the buffer.
Definition net_buf.h:1633
static size_t net_buf_tailroom(const struct net_buf *buf)
Check buffer tailroom.
Definition net_buf.h:2496
#define MIN(a, b)
Obtain the minimum of two values.
Definition util.h:401
#define ENOTSUP
Unsupported value.
Definition errno.h:114
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Network buffer representation.
Definition net_buf.h:1006
USB Setup Data packet defined in spec.
Definition usb_ch9.h:40
uint16_t wValue
Definition usb_ch9.h:46
uint16_t wIndex
Definition usb_ch9.h:47
USB device support runtime context.
Definition usbd.h:281
#define USB_GET_DESCRIPTOR_INDEX(wValue)
Macro to obtain descriptor index from USB_SREQ_GET_DESCRIPTOR request.
Definition usb_ch9.h:284

Field Documentation

◆ code

const uint8_t usbd_vreq_node::code

Vendor code (bRequest value)

◆ node

sys_dnode_t usbd_vreq_node::node

Node information for the dlist.

◆ to_dev

int(* usbd_vreq_node::to_dev) (const struct usbd_context *const ctx, const struct usb_setup_packet *const setup, const struct net_buf *const buf)

Vendor request callback for host-to-device direction.

◆ to_host

int(* usbd_vreq_node::to_host) (const struct usbd_context *const ctx, const struct usb_setup_packet *const setup, struct net_buf *const buf)

Vendor request callback for device-to-host direction.


The documentation for this struct was generated from the following file: