Lines Matching refs:uds_ctx
23 enum usbd_speed usbd_bus_speed(const struct usbd_context *const uds_ctx) in usbd_bus_speed() argument
25 return uds_ctx->status.speed; in usbd_bus_speed()
28 enum usbd_speed usbd_caps_speed(const struct usbd_context *const uds_ctx) in usbd_caps_speed() argument
30 struct udc_device_caps caps = udc_caps(uds_ctx->dev); in usbd_caps_speed()
41 get_device_descriptor(struct usbd_context *const uds_ctx, in get_device_descriptor() argument
46 return uds_ctx->fs_desc; in get_device_descriptor()
48 return uds_ctx->hs_desc; in get_device_descriptor()
55 int usbd_device_set_bcd_usb(struct usbd_context *const uds_ctx, in usbd_device_set_bcd_usb() argument
61 usbd_device_lock(uds_ctx); in usbd_device_set_bcd_usb()
63 if (usbd_is_enabled(uds_ctx)) { in usbd_device_set_bcd_usb()
68 desc = get_device_descriptor(uds_ctx, speed); in usbd_device_set_bcd_usb()
72 usbd_device_unlock(uds_ctx); in usbd_device_set_bcd_usb()
76 int usbd_device_set_vid(struct usbd_context *const uds_ctx, in usbd_device_set_vid() argument
82 usbd_device_lock(uds_ctx); in usbd_device_set_vid()
84 if (usbd_is_enabled(uds_ctx)) { in usbd_device_set_vid()
89 fs_desc = get_device_descriptor(uds_ctx, USBD_SPEED_FS); in usbd_device_set_vid()
92 hs_desc = get_device_descriptor(uds_ctx, USBD_SPEED_HS); in usbd_device_set_vid()
96 usbd_device_unlock(uds_ctx); in usbd_device_set_vid()
100 int usbd_device_set_pid(struct usbd_context *const uds_ctx, in usbd_device_set_pid() argument
106 usbd_device_lock(uds_ctx); in usbd_device_set_pid()
108 if (usbd_is_enabled(uds_ctx)) { in usbd_device_set_pid()
113 fs_desc = get_device_descriptor(uds_ctx, USBD_SPEED_FS); in usbd_device_set_pid()
116 hs_desc = get_device_descriptor(uds_ctx, USBD_SPEED_HS); in usbd_device_set_pid()
120 usbd_device_unlock(uds_ctx); in usbd_device_set_pid()
124 int usbd_device_set_bcd_device(struct usbd_context *const uds_ctx, in usbd_device_set_bcd_device() argument
130 usbd_device_lock(uds_ctx); in usbd_device_set_bcd_device()
132 if (usbd_is_enabled(uds_ctx)) { in usbd_device_set_bcd_device()
137 fs_desc = get_device_descriptor(uds_ctx, USBD_SPEED_FS); in usbd_device_set_bcd_device()
140 hs_desc = get_device_descriptor(uds_ctx, USBD_SPEED_HS); in usbd_device_set_bcd_device()
144 usbd_device_unlock(uds_ctx); in usbd_device_set_bcd_device()
148 int usbd_device_set_code_triple(struct usbd_context *const uds_ctx, in usbd_device_set_code_triple() argument
156 usbd_device_lock(uds_ctx); in usbd_device_set_code_triple()
158 if (usbd_is_enabled(uds_ctx)) { in usbd_device_set_code_triple()
163 desc = get_device_descriptor(uds_ctx, speed); in usbd_device_set_code_triple()
169 usbd_device_unlock(uds_ctx); in usbd_device_set_code_triple()
173 int usbd_wakeup_request(struct usbd_context *const uds_ctx) in usbd_wakeup_request() argument
175 struct udc_device_caps caps = udc_caps(uds_ctx->dev); in usbd_wakeup_request()
178 usbd_device_lock(uds_ctx); in usbd_wakeup_request()
186 if (!uds_ctx->status.rwup || !usbd_is_suspended(uds_ctx)) { in usbd_wakeup_request()
192 ret = udc_host_wakeup(uds_ctx->dev); in usbd_wakeup_request()
195 usbd_device_unlock(uds_ctx); in usbd_wakeup_request()
200 bool usbd_is_suspended(struct usbd_context *uds_ctx) in usbd_is_suspended() argument
202 return uds_ctx->status.suspended; in usbd_is_suspended()
205 int usbd_init(struct usbd_context *const uds_ctx) in usbd_init() argument
214 usbd_device_lock(uds_ctx); in usbd_init()
216 if (uds_ctx->dev == NULL) { in usbd_init()
221 if (usbd_is_initialized(uds_ctx)) { in usbd_init()
227 if (!device_is_ready(uds_ctx->dev)) { in usbd_init()
233 ret = usbd_device_init_core(uds_ctx); in usbd_init()
238 memset(&uds_ctx->ch9_data, 0, sizeof(struct usbd_ch9_data)); in usbd_init()
239 uds_ctx->status.initialized = true; in usbd_init()
242 usbd_device_unlock(uds_ctx); in usbd_init()
248 int usbd_enable(struct usbd_context *const uds_ctx) in usbd_enable() argument
252 usbd_device_lock(uds_ctx); in usbd_enable()
254 if (!usbd_is_initialized(uds_ctx)) { in usbd_enable()
260 if (usbd_is_enabled(uds_ctx)) { in usbd_enable()
266 ret = udc_enable(uds_ctx->dev); in usbd_enable()
272 ret = usbd_init_control_pipe(uds_ctx); in usbd_enable()
274 udc_disable(uds_ctx->dev); in usbd_enable()
278 uds_ctx->status.enabled = true; in usbd_enable()
281 usbd_device_unlock(uds_ctx); in usbd_enable()
285 int usbd_disable(struct usbd_context *const uds_ctx) in usbd_disable() argument
289 if (!usbd_is_enabled(uds_ctx)) { in usbd_disable()
294 usbd_device_lock(uds_ctx); in usbd_disable()
296 ret = usbd_config_set(uds_ctx, 0); in usbd_disable()
301 ret = udc_disable(uds_ctx->dev); in usbd_disable()
306 uds_ctx->status.enabled = false; in usbd_disable()
308 usbd_device_unlock(uds_ctx); in usbd_disable()
313 int usbd_shutdown(struct usbd_context *const uds_ctx) in usbd_shutdown() argument
317 usbd_device_lock(uds_ctx); in usbd_shutdown()
320 ret = usbd_device_shutdown_core(uds_ctx); in usbd_shutdown()
325 uds_ctx->status.initialized = false; in usbd_shutdown()
326 usbd_device_unlock(uds_ctx); in usbd_shutdown()
331 bool usbd_can_detect_vbus(struct usbd_context *const uds_ctx) in usbd_can_detect_vbus() argument
333 const struct udc_device_caps caps = udc_caps(uds_ctx->dev); in usbd_can_detect_vbus()
338 struct usbd_vreq_node *usbd_device_get_vreq(struct usbd_context *const uds_ctx, in usbd_device_get_vreq() argument
343 SYS_DLIST_FOR_EACH_CONTAINER(&uds_ctx->vreqs, vreq_nd, node) { in usbd_device_get_vreq()
352 int usbd_device_register_vreq(struct usbd_context *const uds_ctx, in usbd_device_register_vreq() argument
357 usbd_device_lock(uds_ctx); in usbd_device_register_vreq()
359 if (usbd_is_initialized(uds_ctx)) { in usbd_device_register_vreq()
369 if (!sys_dnode_is_linked(&uds_ctx->vreqs)) { in usbd_device_register_vreq()
371 sys_dlist_init(&uds_ctx->vreqs); in usbd_device_register_vreq()
379 sys_dlist_append(&uds_ctx->vreqs, &vreq_nd->node); in usbd_device_register_vreq()
383 usbd_device_unlock(uds_ctx); in usbd_device_register_vreq()
387 void usbd_device_unregister_all_vreq(struct usbd_context *const uds_ctx) in usbd_device_unregister_all_vreq() argument
392 if (!sys_dnode_is_linked(&uds_ctx->vreqs)) { in usbd_device_unregister_all_vreq()
396 while ((node = sys_dlist_get(&uds_ctx->vreqs))) { in usbd_device_unregister_all_vreq()