Skip to content

Commit 6ebbd8c

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. Add more fields to "struct usbh_class_data". Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 839f0b6 commit 6ebbd8c

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

include/zephyr/usb/usbh.h

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,45 @@ struct usbh_code_triple {
8484
uint8_t proto;
8585
};
8686

87+
struct usbh_class_data;
88+
8789
/**
88-
* @brief USB host class data and class instance API
90+
* @brief USB host class instance API
91+
*/
92+
struct usbh_class_api {
93+
/** Initialization of the class implementation */
94+
int (*init)(struct usbh_class_data *const c_data);
95+
/** Request completion event handler */
96+
int (*request)(struct usbh_class_data *const c_data,
97+
struct uhc_transfer *const xfer, int err);
98+
/** Device connected handler */
99+
int (*connected)(struct usbh_class_data *const c_data,
100+
void *const desc_start_addr,
101+
void *const desc_end_addr);
102+
/** Device removed handler */
103+
int (*removed)(struct usbh_class_data *const c_data);
104+
/** Bus remote wakeup handler */
105+
int (*rwup)(struct usbh_class_data *const c_data);
106+
/** Bus suspended handler */
107+
int (*suspended)(struct usbh_class_data *const c_data);
108+
/** Bus resumed handler */
109+
int (*resumed)(struct usbh_class_data *const c_data);
110+
};
111+
112+
/**
113+
* @brief USB host class instance data
89114
*/
90115
struct usbh_class_data {
116+
/** Name of the USB host class instance */
117+
const char *name;
118+
/** Pointer to USB host stack context structure */
119+
struct usbh_context *uhs_ctx;
91120
/** Class code supported by this instance */
92121
struct usbh_code_triple code;
93-
94-
/** Initialization of the class implementation */
95-
/* int (*init)(struct usbh_context *const uhs_ctx); */
96-
/** Request completion event handler */
97-
int (*request)(struct usbh_context *const uhs_ctx,
98-
struct uhc_transfer *const xfer, int err);
99-
/** Device connected handler */
100-
int (*connected)(struct usbh_context *const uhs_ctx);
101-
/** Device removed handler */
102-
int (*removed)(struct usbh_context *const uhs_ctx);
103-
/** Bus remote wakeup handler */
104-
int (*rwup)(struct usbh_context *const uhs_ctx);
105-
/** Bus suspended handler */
106-
int (*suspended)(struct usbh_context *const uhs_ctx);
107-
/** Bus resumed handler */
108-
int (*resumed)(struct usbh_context *const uhs_ctx);
122+
/** Pointer to host support class API */
123+
struct usbh_class_api *api;
124+
/** Pointer to private data */
125+
void *priv;
109126
};
110127

111128
/**

0 commit comments

Comments
 (0)