MCPcopy Create free account
hub / github.com/apache/nuttx / sim_usbdev_ep0read

Function sim_usbdev_ep0read

arch/sim/src/sim/sim_usbdev.c:482–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480 ****************************************************************************/
481
482static int sim_usbdev_ep0read(struct host_usb_ctrlreq_s *req)
483{
484 struct sim_usbdev_s *priv = &g_sim_usbdev;
485 uint8_t *outdata = NULL;
486 size_t outlen = 0;
487 int ret = -EINVAL;
488
489 if (priv && priv->driver)
490 {
491 /* Save ctrl req */
492
493 sim_usbdev_getctrlreq(&priv->ctrl, req);
494
495 /* Was this an OUT SETUP command? */
496
497 if (USB_REQ_ISOUT(priv->ctrl.type))
498 {
499 outlen = GETUINT16(priv->ctrl.len);
500 outdata = req->data;
501 }
502
503 /* Forward to the control request to the class driver implementation */
504
505 ret = CLASS_SETUP(priv->driver, &priv->usbdev, &priv->ctrl,
506 outdata, outlen);
507 if (ret < 0)
508 {
509 /* Stall on failure */
510
511 usbtrace(TRACE_DEVERROR(SIM_TRACEERR_DISPATCHSTALL), 0);
512 sim_ep_stall(&priv->eps[0].ep, false);
513 }
514 }
515
516 return ret;
517}
518
519/****************************************************************************
520 * Name: sim_usbdev_epread

Callers 1

sim_usbdev_workFunction · 0.85

Calls 3

sim_usbdev_getctrlreqFunction · 0.85
usbtraceFunction · 0.85
sim_ep_stallFunction · 0.85

Tested by

no test coverage detected