Skip to content

Commit 1cca1e7

Browse files
author
Josuah Demangeon
committed
usb: host: class: implement more of the class/data struct fields
Add a "struct usbh_class_api" for the host implementation, and move all the function poitners to it, as it is done for the device support. Add more fields to the host struct usbh_class_data mirrorring the device side struct, including the API pointer. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 32c2756 commit 1cca1e7

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

include/zephyr/usb/usbh.h

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct usbh_context {
6161
struct usb_device *root;
6262
/** Allocated device addresses bit array */
6363
struct sys_bitarray *addr_ba;
64+
/** List of registered classes (functions) */
65+
sys_slist_t class_list;
6466
};
6567

6668
#define USBH_CONTROLLER_DEFINE(device_name, uhc_dev) \
@@ -84,28 +86,45 @@ struct usbh_code_triple {
8486
uint8_t proto;
8587
};
8688

89+
struct usbh_class_data;
90+
8791
/**
88-
* @brief USB host class data and class instance API
92+
* @brief USB host class instance API
8993
*/
90-
struct usbh_class_data {
91-
/** Class code supported by this instance */
92-
struct usbh_code_triple code;
93-
94+
struct usbh_class_api {
9495
/** Initialization of the class implementation */
95-
/* int (*init)(struct usbh_context *const uhs_ctx); */
96+
int (*init)(struct usbh_class_data *cdata);
9697
/** Request completion event handler */
97-
int (*request)(struct usbh_context *const uhs_ctx,
98-
struct uhc_transfer *const xfer, int err);
98+
int (*request)(struct usbh_class_data *cdata,
99+
struct uhc_transfer *const xfer, int err);
99100
/** Device connected handler */
100-
int (*connected)(struct usbh_context *const uhs_ctx);
101+
int (*connected)(struct usbh_class_data *cdata,
102+
void *desc_start_addr,
103+
void *desc_end_addr);
101104
/** Device removed handler */
102-
int (*removed)(struct usbh_context *const uhs_ctx);
105+
int (*removed)(struct usbh_class_data *cdata);
103106
/** Bus remote wakeup handler */
104-
int (*rwup)(struct usbh_context *const uhs_ctx);
107+
int (*rwup)(struct usbh_class_data *cdata);
105108
/** Bus suspended handler */
106-
int (*suspended)(struct usbh_context *const uhs_ctx);
109+
int (*suspended)(struct usbh_class_data *cdata);
107110
/** Bus resumed handler */
108-
int (*resumed)(struct usbh_context *const uhs_ctx);
111+
int (*resumed)(struct usbh_class_data *cdata);
112+
};
113+
114+
/**
115+
* @brief USB host class instance data
116+
*/
117+
struct usbh_class_data {
118+
/** Name of the USB host class instance */
119+
const char *name;
120+
/** Pointer to USB host stack context structure */
121+
struct usbh_context *uhs_ctx;
122+
/** Class code supported by this instance */
123+
struct usbh_code_triple code;
124+
/** Pointer to host support class API */
125+
struct usbh_class_api *api;
126+
/** Pointer to private data */
127+
void *priv;
109128
};
110129

111130
/**

0 commit comments

Comments
 (0)