Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usbd.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
14#ifndef ZEPHYR_INCLUDE_USBD_H_
15#define ZEPHYR_INCLUDE_USBD_H_
16
17#include <zephyr/device.h>
18#include <zephyr/usb/bos.h>
19#include <zephyr/usb/usb_ch9.h>
20#include <zephyr/usb/usbd_msg.h>
23#include <zephyr/sys/slist.h>
24#include <zephyr/logging/log.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
40/*
41 * The USB Unicode bString is encoded in UTF16LE, which means it takes up
42 * twice the amount of bytes than the same string encoded in ASCII7.
43 * Use this macro to determine the length of the bString array.
44 *
45 * bString length without null character:
46 * bString_length = (sizeof(initializer_string) - 1) * 2
47 * or:
48 * bString_length = sizeof(initializer_string) * 2 - 2
49 */
50#define USB_BSTRING_LENGTH(s) (sizeof(s) * 2 - 2)
51
52/*
53 * The length of the string descriptor (bLength) is calculated from the
54 * size of the two octets bLength and bDescriptorType plus the
55 * length of the UTF16LE string:
56 *
57 * bLength = 2 + bString_length
58 * bLength = 2 + sizeof(initializer_string) * 2 - 2
59 * bLength = sizeof(initializer_string) * 2
60 * Use this macro to determine the bLength of the string descriptor.
61 */
62#define USB_STRING_DESCRIPTOR_LENGTH(s) (sizeof(s) * 2)
63
67enum usbd_str_desc_utype {
68 USBD_DUT_STRING_LANG,
69 USBD_DUT_STRING_MANUFACTURER,
70 USBD_DUT_STRING_PRODUCT,
71 USBD_DUT_STRING_SERIAL_NUMBER,
72 USBD_DUT_STRING_CONFIG,
73 USBD_DUT_STRING_INTERFACE,
74};
75
76enum usbd_bos_desc_utype {
77 USBD_DUT_BOS_NONE,
78};
88 enum usbd_str_desc_utype utype : 8;
90 unsigned int ascii7 : 1;
92 unsigned int use_hwinfo : 1;
93};
94
100 enum usbd_bos_desc_utype utype : 8;
101};
102
123
142
143/* TODO: Kconfig option USBD_NUMOF_INTERFACES_MAX? */
144#define USBD_NUMOF_INTERFACES_MAX 16U
145
157
158
178
190
196 unsigned int initialized : 1;
198 unsigned int enabled : 1;
200 unsigned int suspended : 1;
202 unsigned int rwup : 1;
205};
206
207struct usbd_context;
208
220typedef void (*usbd_msg_cb_t)(struct usbd_context *const ctx,
221 const struct usbd_msg *const msg);
222
253
263
265#define USBD_CCTX_REGISTERED 0
266
267struct usbd_class_data;
268
274 void (*feature_halt)(struct usbd_class_data *const c_data,
275 uint8_t ep, bool halted);
276
278 void (*update)(struct usbd_class_data *const c_data,
279 uint8_t iface, uint8_t alternate);
280
282 int (*control_to_dev)(struct usbd_class_data *const c_data,
283 const struct usb_setup_packet *const setup,
284 const struct net_buf *const buf);
285
287 int (*control_to_host)(struct usbd_class_data *const c_data,
288 const struct usb_setup_packet *const setup,
289 struct net_buf *const buf);
290
292 int (*request)(struct usbd_class_data *const c_data,
293 struct net_buf *buf, int err);
294
296 void (*suspended)(struct usbd_class_data *const c_data);
297
299 void (*resumed)(struct usbd_class_data *const c_data);
300
302 void (*sof)(struct usbd_class_data *const c_data);
303
305 void (*enable)(struct usbd_class_data *const c_data);
306
308 void (*disable)(struct usbd_class_data *const c_data);
309
311 int (*init)(struct usbd_class_data *const c_data);
312
314 void (*shutdown)(struct usbd_class_data *const c_data);
315
317 void *(*get_desc)(struct usbd_class_data *const c_data,
318 const enum usbd_speed speed);
319};
320
326 const char *name;
330 const struct usbd_class_api *api;
334 void *priv;
335};
336
345struct usbd_class_node {
347 sys_snode_t node;
349 struct usbd_class_data *const c_data;
353 uint32_t ep_assigned;
357 uint32_t ep_active;
359 uint32_t iface_bm;
362};
363
376static inline struct usbd_context *usbd_class_get_ctx(const struct usbd_class_data *const c_data)
377{
378 return c_data->uds_ctx;
379}
380
391static inline void *usbd_class_get_private(const struct usbd_class_data *const c_data)
392{
393 return c_data->priv;
394}
395
416#define USBD_DEVICE_DEFINE(device_name, udc_dev, vid, pid) \
417 static struct usb_device_descriptor \
418 fs_desc_##device_name = { \
419 .bLength = sizeof(struct usb_device_descriptor), \
420 .bDescriptorType = USB_DESC_DEVICE, \
421 .bcdUSB = sys_cpu_to_le16(USB_SRN_2_0), \
422 .bDeviceClass = USB_BCC_MISCELLANEOUS, \
423 .bDeviceSubClass = 2, \
424 .bDeviceProtocol = 1, \
425 .bMaxPacketSize0 = USB_CONTROL_EP_MPS, \
426 .idVendor = vid, \
427 .idProduct = pid, \
428 .bcdDevice = sys_cpu_to_le16(USB_BCD_DRN), \
429 .iManufacturer = 0, \
430 .iProduct = 0, \
431 .iSerialNumber = 0, \
432 .bNumConfigurations = 0, \
433 }; \
434 static struct usb_device_descriptor \
435 hs_desc_##device_name = { \
436 .bLength = sizeof(struct usb_device_descriptor), \
437 .bDescriptorType = USB_DESC_DEVICE, \
438 .bcdUSB = sys_cpu_to_le16(USB_SRN_2_0), \
439 .bDeviceClass = USB_BCC_MISCELLANEOUS, \
440 .bDeviceSubClass = 2, \
441 .bDeviceProtocol = 1, \
442 .bMaxPacketSize0 = 64, \
443 .idVendor = vid, \
444 .idProduct = pid, \
445 .bcdDevice = sys_cpu_to_le16(USB_BCD_DRN), \
446 .iManufacturer = 0, \
447 .iProduct = 0, \
448 .iSerialNumber = 0, \
449 .bNumConfigurations = 0, \
450 }; \
451 static STRUCT_SECTION_ITERABLE(usbd_context, device_name) = { \
452 .name = STRINGIFY(device_name), \
453 .dev = udc_dev, \
454 .fs_desc = &fs_desc_##device_name, \
455 .hs_desc = &hs_desc_##device_name, \
456 }
457
475#define USBD_CONFIGURATION_DEFINE(name, attrib, power, desc_nd) \
476 static struct usb_cfg_descriptor \
477 cfg_desc_##name = { \
478 .bLength = sizeof(struct usb_cfg_descriptor), \
479 .bDescriptorType = USB_DESC_CONFIGURATION, \
480 .wTotalLength = 0, \
481 .bNumInterfaces = 0, \
482 .bConfigurationValue = 1, \
483 .iConfiguration = 0, \
484 .bmAttributes = USB_SCD_RESERVED | (attrib), \
485 .bMaxPower = (power), \
486 }; \
487 BUILD_ASSERT((power) < 256, "Too much power"); \
488 static struct usbd_config_node name = { \
489 .desc = &cfg_desc_##name, \
490 .str_desc_nd = desc_nd, \
491 }
492
506#define USBD_DESC_LANG_DEFINE(name) \
507 static uint16_t langid_##name = sys_cpu_to_le16(0x0409); \
508 static struct usbd_desc_node name = { \
509 .str = { \
510 .idx = 0, \
511 .utype = USBD_DUT_STRING_LANG, \
512 }, \
513 .ptr = &langid_##name, \
514 .bLength = sizeof(struct usb_string_descriptor), \
515 .bDescriptorType = USB_DESC_STRING, \
516 }
517
529#define USBD_DESC_STRING_DEFINE(d_name, d_string, d_utype) \
530 static uint8_t ascii_##d_name[USB_BSTRING_LENGTH(d_string)] = d_string; \
531 static struct usbd_desc_node d_name = { \
532 .str = { \
533 .utype = d_utype, \
534 .ascii7 = true, \
535 }, \
536 .ptr = &ascii_##d_name, \
537 .bLength = USB_STRING_DESCRIPTOR_LENGTH(d_string), \
538 .bDescriptorType = USB_DESC_STRING, \
539 }
540
552#define USBD_DESC_MANUFACTURER_DEFINE(d_name, d_string) \
553 USBD_DESC_STRING_DEFINE(d_name, d_string, USBD_DUT_STRING_MANUFACTURER)
554
566#define USBD_DESC_PRODUCT_DEFINE(d_name, d_string) \
567 USBD_DESC_STRING_DEFINE(d_name, d_string, USBD_DUT_STRING_PRODUCT)
568
579#define USBD_DESC_SERIAL_NUMBER_DEFINE(d_name) \
580 static struct usbd_desc_node d_name = { \
581 .str = { \
582 .utype = USBD_DUT_STRING_SERIAL_NUMBER, \
583 .ascii7 = true, \
584 .use_hwinfo = true, \
585 }, \
586 .bDescriptorType = USB_DESC_STRING, \
587 }
588
598#define USBD_DESC_CONFIG_DEFINE(d_name, d_string) \
599 USBD_DESC_STRING_DEFINE(d_name, d_string, USBD_DUT_STRING_CONFIG)
600
611#define USBD_DESC_BOS_DEFINE(name, len, subset) \
612 static struct usbd_desc_node name = { \
613 .bos = { \
614 .utype = USBD_DUT_BOS_NONE, \
615 }, \
616 .ptr = subset, \
617 .bLength = len, \
618 .bDescriptorType = USB_DESC_BOS, \
619 }
620
632#define USBD_DEFINE_CLASS(class_name, class_api, class_priv, class_v_reqs) \
633 static struct usbd_class_data class_name = { \
634 .name = STRINGIFY(class_name), \
635 .api = class_api, \
636 .v_reqs = class_v_reqs, \
637 .priv = class_priv, \
638 }; \
639 static STRUCT_SECTION_ITERABLE_ALTERNATE( \
640 usbd_class_fs, usbd_class_node, class_name##_fs) = { \
641 .c_data = &class_name, \
642 }; \
643 static STRUCT_SECTION_ITERABLE_ALTERNATE( \
644 usbd_class_hs, usbd_class_node, class_name##_hs) = { \
645 .c_data = &class_name, \
646 }
647
653#define VENDOR_REQ_DEFINE(_reqs, _len) \
654 { \
655 .reqs = (const uint8_t *)(_reqs), \
656 .len = (_len), \
657 }
658
663#define USBD_VENDOR_REQ(_reqs...) \
664 VENDOR_REQ_DEFINE(((uint8_t []) { _reqs }), \
665 sizeof((uint8_t []) { _reqs }))
666
667
679 struct usbd_desc_node *dn);
680
688uint8_t usbd_str_desc_get_idx(const struct usbd_desc_node *const desc_nd);
689
697void usbd_remove_descriptor(struct usbd_desc_node *const desc_nd);
698
709 const enum usbd_speed speed,
710 struct usbd_config_node *cd);
711
734 const char *name,
735 const enum usbd_speed speed, uint8_t cfg);
736
754 const enum usbd_speed speed, uint8_t cfg);
755
771 const char *name,
772 const enum usbd_speed speed, uint8_t cfg);
773
787 const enum usbd_speed speed, uint8_t cfg);
788
797int usbd_msg_register_cb(struct usbd_context *const uds_ctx,
798 const usbd_msg_cb_t cb);
799
813int usbd_init(struct usbd_context *uds_ctx);
814
824int usbd_enable(struct usbd_context *uds_ctx);
825
835int usbd_disable(struct usbd_context *uds_ctx);
836
846int usbd_shutdown(struct usbd_context *const uds_ctx);
847
856int usbd_ep_set_halt(struct usbd_context *uds_ctx, uint8_t ep);
857
866int usbd_ep_clear_halt(struct usbd_context *uds_ctx, uint8_t ep);
867
876bool usbd_ep_is_halted(struct usbd_context *uds_ctx, uint8_t ep);
877
889struct net_buf *usbd_ep_buf_alloc(const struct usbd_class_data *const c_data,
890 const uint8_t ep, const size_t size);
891
902int usbd_ep_ctrl_enqueue(struct usbd_context *const uds_ctx,
903 struct net_buf *const buf);
904
915int usbd_ep_enqueue(const struct usbd_class_data *const c_data,
916 struct net_buf *const buf);
917
926int usbd_ep_dequeue(struct usbd_context *uds_ctx, const uint8_t ep);
927
938int usbd_ep_buf_free(struct usbd_context *uds_ctx, struct net_buf *buf);
939
947bool usbd_is_suspended(struct usbd_context *uds_ctx);
948
955
963enum usbd_speed usbd_bus_speed(const struct usbd_context *const uds_ctx);
964
972enum usbd_speed usbd_caps_speed(const struct usbd_context *const uds_ctx);
973
983int usbd_device_set_bcd_usb(struct usbd_context *const uds_ctx,
984 const enum usbd_speed speed, const uint16_t bcd);
985
994int usbd_device_set_vid(struct usbd_context *const uds_ctx,
995 const uint16_t vid);
996
1005int usbd_device_set_pid(struct usbd_context *const uds_ctx,
1006 const uint16_t pid);
1007
1017 const uint16_t bcd);
1018
1031 const enum usbd_speed speed,
1032 const uint8_t base_class,
1033 const uint8_t subclass, const uint8_t protocol);
1034
1045int usbd_config_attrib_rwup(struct usbd_context *const uds_ctx,
1046 const enum usbd_speed speed,
1047 const uint8_t cfg, const bool enable);
1048
1059int usbd_config_attrib_self(struct usbd_context *const uds_ctx,
1060 const enum usbd_speed speed,
1061 const uint8_t cfg, const bool enable);
1062
1073int usbd_config_maxpower(struct usbd_context *const uds_ctx,
1074 const enum usbd_speed speed,
1075 const uint8_t cfg, const uint8_t power);
1076
1089bool usbd_can_detect_vbus(struct usbd_context *const uds_ctx);
1090
1095#ifdef __cplusplus
1096}
1097#endif
1098
1099#endif /* ZEPHYR_INCLUDE_USBD_H_ */
long atomic_t
Definition atomic_types.h:15
struct _dnode sys_dnode_t
Doubly-linked list node structure.
Definition dlist.h:54
struct _dnode sys_dlist_t
Doubly-linked list structure.
Definition dlist.h:50
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
int usbd_ep_clear_halt(struct usbd_context *uds_ctx, uint8_t ep)
Clear endpoint halt.
int usbd_device_set_vid(struct usbd_context *const uds_ctx, const uint16_t vid)
Set USB device descriptor value idVendor.
int usbd_ep_dequeue(struct usbd_context *uds_ctx, const uint8_t ep)
Remove all USB device controller requests from endpoint queue.
int usbd_ep_set_halt(struct usbd_context *uds_ctx, uint8_t ep)
Halt endpoint.
int usbd_enable(struct usbd_context *uds_ctx)
Enable the USB device support and registered class instances.
int usbd_unregister_class(struct usbd_context *uds_ctx, const char *name, const enum usbd_speed speed, uint8_t cfg)
Unregister an USB class instance.
int usbd_unregister_all_classes(struct usbd_context *uds_ctx, const enum usbd_speed speed, uint8_t cfg)
Unregister all available USB class instances.
int usbd_config_attrib_rwup(struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t cfg, const bool enable)
Setup USB device configuration attribute Remote Wakeup.
void(* usbd_msg_cb_t)(struct usbd_context *const ctx, const struct usbd_msg *const msg)
Callback type definition for USB device message delivery.
Definition usbd.h:220
static void * usbd_class_get_private(const struct usbd_class_data *const c_data)
Get class implementation private data.
Definition usbd.h:391
int usbd_msg_register_cb(struct usbd_context *const uds_ctx, const usbd_msg_cb_t cb)
Register USB notification message callback.
usbd_speed
USB device speed.
Definition usbd.h:182
void usbd_remove_descriptor(struct usbd_desc_node *const desc_nd)
Remove USB string descriptor.
int usbd_add_descriptor(struct usbd_context *uds_ctx, struct usbd_desc_node *dn)
Add common USB descriptor.
int usbd_wakeup_request(struct usbd_context *uds_ctx)
Initiate the USB remote wakeup (TBD)
int usbd_shutdown(struct usbd_context *const uds_ctx)
Shutdown the USB device support.
int usbd_register_all_classes(struct usbd_context *uds_ctx, const enum usbd_speed speed, uint8_t cfg)
Register all available USB class instances.
int usbd_device_set_pid(struct usbd_context *const uds_ctx, const uint16_t pid)
Set USB device descriptor value idProduct.
int usbd_register_class(struct usbd_context *uds_ctx, const char *name, const enum usbd_speed speed, uint8_t cfg)
Register an USB class instance.
int usbd_config_maxpower(struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t cfg, const uint8_t power)
Setup USB device configuration power consumption.
bool usbd_can_detect_vbus(struct usbd_context *const uds_ctx)
Check that the controller can detect the VBUS state change.
int usbd_add_configuration(struct usbd_context *uds_ctx, const enum usbd_speed speed, struct usbd_config_node *cd)
Add a USB device configuration.
bool usbd_is_suspended(struct usbd_context *uds_ctx)
Checks whether the USB device controller is suspended.
struct net_buf * usbd_ep_buf_alloc(const struct usbd_class_data *const c_data, const uint8_t ep, const size_t size)
Allocate buffer for USB device request.
int usbd_init(struct usbd_context *uds_ctx)
Initialize USB device.
int usbd_device_set_code_triple(struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t base_class, const uint8_t subclass, const uint8_t protocol)
Set USB device descriptor code triple Base Class, SubClass, and Protocol.
int usbd_ep_buf_free(struct usbd_context *uds_ctx, struct net_buf *buf)
Free USB device request buffer.
int usbd_config_attrib_self(struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint8_t cfg, const bool enable)
Setup USB device configuration attribute Self-powered.
bool usbd_ep_is_halted(struct usbd_context *uds_ctx, uint8_t ep)
Checks whether the endpoint is halted.
usbd_ch9_state
USB device support middle layer runtime state.
Definition usbd.h:152
int usbd_ep_ctrl_enqueue(struct usbd_context *const uds_ctx, struct net_buf *const buf)
Queue USB device control request.
int usbd_disable(struct usbd_context *uds_ctx)
Disable the USB device support.
enum usbd_speed usbd_caps_speed(const struct usbd_context *const uds_ctx)
Get highest speed supported by the controller.
int usbd_ep_enqueue(const struct usbd_class_data *const c_data, struct net_buf *const buf)
Queue USB device request.
uint8_t usbd_str_desc_get_idx(const struct usbd_desc_node *const desc_nd)
Get USB string descriptor index from descriptor node.
enum usbd_speed usbd_bus_speed(const struct usbd_context *const uds_ctx)
Get actual device speed.
int usbd_device_set_bcd_usb(struct usbd_context *const uds_ctx, const enum usbd_speed speed, const uint16_t bcd)
Set USB device descriptor value bcdUSB.
#define USBD_NUMOF_INTERFACES_MAX
Definition usbd.h:144
static struct usbd_context * usbd_class_get_ctx(const struct usbd_class_data *const c_data)
Get the USB device runtime context under which the class is registered.
Definition usbd.h:376
int usbd_device_set_bcd_device(struct usbd_context *const uds_ctx, const uint16_t bcd)
Set USB device descriptor value bcdDevice.
@ USBD_SPEED_SS
Device supports or is connected to a super speed bus.
Definition usbd.h:188
@ USBD_SPEED_FS
Device supports or is connected to a full speed bus.
Definition usbd.h:184
@ USBD_SPEED_HS
Device supports or is connected to a high speed bus
Definition usbd.h:186
@ USBD_STATE_CONFIGURED
Definition usbd.h:155
@ USBD_STATE_DEFAULT
Definition usbd.h:153
@ USBD_STATE_ADDRESS
Definition usbd.h:154
state
Definition parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
Mutex Structure.
Definition kernel.h:2994
Network buffer representation.
Definition net_buf.h:1006
uint16_t size
Amount of data that this buffer can store.
Definition net_buf.h:1038
USB Setup Data packet defined in spec.
Definition usb_ch9.h:40
USBD BOS Device Capability descriptor data.
Definition usbd.h:98
enum usbd_bos_desc_utype utype
Descriptor usage type (not bDescriptorType)
Definition usbd.h:100
Vendor Requests Table.
Definition usbd.h:257
const uint8_t * reqs
Array of vendor requests supported by the class.
Definition usbd.h:259
uint8_t len
Length of the array.
Definition usbd.h:261
USB device support middle layer runtime data.
Definition usbd.h:162
int ctrl_type
Control type, internally used for stage verification.
Definition usbd.h:166
uint8_t configuration
USB device stack selected configuration.
Definition usbd.h:172
uint32_t ep_halt
Halted endpoints bitmap.
Definition usbd.h:170
bool post_status
Post status stage work required, e.g.
Definition usbd.h:174
enum usbd_ch9_state state
Protocol state of the USB device stack.
Definition usbd.h:168
struct usb_setup_packet setup
Setup packet, up-to-date for the respective control request.
Definition usbd.h:164
uint8_t alternate[16U]
Array to track interfaces alternate settings.
Definition usbd.h:176
USB device support class instance API.
Definition usbd.h:272
void(* feature_halt)(struct usbd_class_data *const c_data, uint8_t ep, bool halted)
Feature halt state update handler.
Definition usbd.h:274
void(* update)(struct usbd_class_data *const c_data, uint8_t iface, uint8_t alternate)
Configuration update handler.
Definition usbd.h:278
void(* sof)(struct usbd_class_data *const c_data)
Start of Frame.
Definition usbd.h:302
void(* suspended)(struct usbd_class_data *const c_data)
USB power management handler suspended.
Definition usbd.h:296
void(* shutdown)(struct usbd_class_data *const c_data)
Shutdown of the class implementation.
Definition usbd.h:314
int(* request)(struct usbd_class_data *const c_data, struct net_buf *buf, int err)
Endpoint request completion event handler.
Definition usbd.h:292
int(* init)(struct usbd_class_data *const c_data)
Initialization of the class implementation.
Definition usbd.h:311
int(* control_to_dev)(struct usbd_class_data *const c_data, const struct usb_setup_packet *const setup, const struct net_buf *const buf)
USB control request handler to device.
Definition usbd.h:282
void(* enable)(struct usbd_class_data *const c_data)
Class associated configuration is selected.
Definition usbd.h:305
int(* control_to_host)(struct usbd_class_data *const c_data, const struct usb_setup_packet *const setup, struct net_buf *const buf)
USB control request handler to host.
Definition usbd.h:287
void(* resumed)(struct usbd_class_data *const c_data)
USB power management handler resumed.
Definition usbd.h:299
void(* disable)(struct usbd_class_data *const c_data)
Class associated configuration is disabled.
Definition usbd.h:308
USB device support class data.
Definition usbd.h:324
void * priv
Pointer to private data.
Definition usbd.h:334
struct usbd_context * uds_ctx
Pointer to USB device stack context structure.
Definition usbd.h:328
const struct usbd_cctx_vendor_req * v_reqs
Supported vendor request table, can be NULL.
Definition usbd.h:332
const struct usbd_class_api * api
Pointer to device support class API.
Definition usbd.h:330
const char * name
Name of the USB device class instance.
Definition usbd.h:326
Device configuration node.
Definition usbd.h:132
sys_snode_t node
slist node struct
Definition usbd.h:134
sys_slist_t class_list
List of registered classes (functions)
Definition usbd.h:140
struct usbd_desc_node * str_desc_nd
Optional pointer to string descriptor node.
Definition usbd.h:138
void * desc
Pointer to configuration descriptor.
Definition usbd.h:136
USB device support runtime context.
Definition usbd.h:229
void * fs_desc
Pointer to Full-Speed device descriptor.
Definition usbd.h:249
void * hs_desc
Pointer to High-Speed device descriptor.
Definition usbd.h:251
usbd_msg_cb_t msg_cb
Notification message recipient callback.
Definition usbd.h:237
struct usbd_status status
Status of the USB device support.
Definition usbd.h:247
sys_slist_t hs_configs
slist to manage High-Speed device configurations
Definition usbd.h:245
struct usbd_ch9_data ch9_data
Middle layer runtime data.
Definition usbd.h:239
const struct device * dev
Pointer to UDC device.
Definition usbd.h:235
sys_slist_t fs_configs
slist to manage Full-Speed device configurations
Definition usbd.h:243
struct k_mutex mutex
Access mutex.
Definition usbd.h:233
const char * name
Name of the USB device.
Definition usbd.h:231
sys_dlist_t descriptors
slist to manage descriptors like string, BOS
Definition usbd.h:241
Descriptor node.
Definition usbd.h:109
uint8_t bDescriptorType
Descriptor type.
Definition usbd.h:121
sys_dnode_t node
slist node struct
Definition usbd.h:111
const void *const ptr
Opaque pointer to a descriptor payload.
Definition usbd.h:117
uint8_t bLength
Descriptor size in bytes.
Definition usbd.h:119
struct usbd_str_desc_data str
Definition usbd.h:113
struct usbd_bos_desc_data bos
Definition usbd.h:114
USB device message.
Definition usbd_msg.h:82
USB device support status.
Definition usbd.h:194
unsigned int rwup
USB remote wake-up feature is enabled.
Definition usbd.h:202
unsigned int enabled
USB device support is enabled.
Definition usbd.h:198
enum usbd_speed speed
USB device speed.
Definition usbd.h:204
unsigned int initialized
USB device support is initialized.
Definition usbd.h:196
unsigned int suspended
USB device is suspended.
Definition usbd.h:200
Used internally to keep descriptors in order.
Definition usbd.h:84
uint8_t idx
Descriptor index, required for string descriptors.
Definition usbd.h:86
enum usbd_str_desc_utype utype
Descriptor usage type (not bDescriptorType)
Definition usbd.h:88
unsigned int use_hwinfo
Device stack obtains SerialNumber using the HWINFO API.
Definition usbd.h:92
unsigned int ascii7
The string descriptor is in ASCII7 format.
Definition usbd.h:90
Byte order helpers.
Buffers for USB device support.
USB Chapter 9 structures and definitions.
USB support message types and structure.