mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
Progress toward composite CDC/ACM+MSC USB device
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4332 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+122
-55
@@ -99,7 +99,7 @@ struct cdcser_dev_s
|
|||||||
FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */
|
FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */
|
||||||
FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */
|
FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */
|
||||||
FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint structure */
|
FAR struct usbdev_ep_s *epbulkout; /* Bulk OUT endpoint structure */
|
||||||
FAR struct usbdev_req_s *ctrlreq; /* Control request */
|
FAR struct usbdev_req_s *ctrlreq; /* Allocoated control request */
|
||||||
struct sq_queue_s reqlist; /* List of write request containers */
|
struct sq_queue_s reqlist; /* List of write request containers */
|
||||||
|
|
||||||
/* Pre-allocated write request containers. The write requests will
|
/* Pre-allocated write request containers. The write requests will
|
||||||
@@ -158,10 +158,8 @@ static void cdcser_resetconfig(FAR struct cdcser_dev_s *priv);
|
|||||||
static int cdcser_epconfigure(FAR struct usbdev_ep_s *ep,
|
static int cdcser_epconfigure(FAR struct usbdev_ep_s *ep,
|
||||||
enum cdcser_epdesc_e epid, uint16_t mxpacket, bool last);
|
enum cdcser_epdesc_e epid, uint16_t mxpacket, bool last);
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_CDCSER_COMPOSITE
|
|
||||||
static int cdcser_setconfig(FAR struct cdcser_dev_s *priv,
|
static int cdcser_setconfig(FAR struct cdcser_dev_s *priv,
|
||||||
uint8_t config);
|
uint8_t config);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Completion event handlers ***********************************************/
|
/* Completion event handlers ***********************************************/
|
||||||
|
|
||||||
@@ -591,7 +589,6 @@ static int cdcser_epconfigure(FAR struct usbdev_ep_s *ep,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_CDCSER_COMPOSITE
|
|
||||||
static int cdcser_setconfig(FAR struct cdcser_dev_s *priv, uint8_t config)
|
static int cdcser_setconfig(FAR struct cdcser_dev_s *priv, uint8_t config)
|
||||||
{
|
{
|
||||||
FAR struct usbdev_req_s *req;
|
FAR struct usbdev_req_s *req;
|
||||||
@@ -725,7 +722,6 @@ errout:
|
|||||||
cdcser_resetconfig(priv);
|
cdcser_resetconfig(priv);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cdcser_ep0incomplete
|
* Name: cdcser_ep0incomplete
|
||||||
@@ -798,7 +794,7 @@ static void cdcser_rdcomplete(FAR struct usbdev_ep_s *ep,
|
|||||||
/* Requeue the read request */
|
/* Requeue the read request */
|
||||||
|
|
||||||
#ifdef CONFIG_CDCSER_BULKREQLEN
|
#ifdef CONFIG_CDCSER_BULKREQLEN
|
||||||
req->len = max(CONFIG_CDCSER_BULKREQLEN, ep->maxpacket);
|
req->len = MAX(CONFIG_CDCSER_BULKREQLEN, ep->maxpacket);
|
||||||
#else
|
#else
|
||||||
req->len = ep->maxpacket;
|
req->len = ep->maxpacket;
|
||||||
#endif
|
#endif
|
||||||
@@ -952,7 +948,7 @@ static int cdcser_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_s
|
|||||||
/* Pre-allocate read requests */
|
/* Pre-allocate read requests */
|
||||||
|
|
||||||
#ifdef CONFIG_CDCSER_BULKREQLEN
|
#ifdef CONFIG_CDCSER_BULKREQLEN
|
||||||
reqlen = max(CONFIG_CDCSER_BULKREQLEN, priv->epbulkout->maxpacket);
|
reqlen = MAX(CONFIG_CDCSER_BULKREQLEN, priv->epbulkout->maxpacket);
|
||||||
#else
|
#else
|
||||||
reqlen = priv->epbulkout->maxpacket;
|
reqlen = priv->epbulkout->maxpacket;
|
||||||
#endif
|
#endif
|
||||||
@@ -974,7 +970,7 @@ static int cdcser_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_s
|
|||||||
/* Pre-allocate write request containers and put in a free list */
|
/* Pre-allocate write request containers and put in a free list */
|
||||||
|
|
||||||
#ifdef CONFIG_CDCSER_BULKREQLEN
|
#ifdef CONFIG_CDCSER_BULKREQLEN
|
||||||
reqlen = max(CONFIG_CDCSER_BULKREQLEN, priv->epbulkin->maxpacket);
|
reqlen = MAX(CONFIG_CDCSER_BULKREQLEN, priv->epbulkin->maxpacket);
|
||||||
#else
|
#else
|
||||||
reqlen = priv->epbulkin->maxpacket;
|
reqlen = priv->epbulkin->maxpacket;
|
||||||
#endif
|
#endif
|
||||||
@@ -998,15 +994,19 @@ static int cdcser_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_s
|
|||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report if we are selfpowered */
|
/* Report if we are selfpowered (unless we are part of a composite device) */
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
#ifdef CONFIG_USBDEV_SELFPOWERED
|
#ifdef CONFIG_USBDEV_SELFPOWERED
|
||||||
DEV_SETSELFPOWERED(dev);
|
DEV_SETSELFPOWERED(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* And pull-up the data line for the soft connect function */
|
/* And pull-up the data line for the soft connect function (unless we are
|
||||||
|
* part of a composite device)
|
||||||
|
*/
|
||||||
|
|
||||||
DEV_CONNECT(dev);
|
DEV_CONNECT(dev);
|
||||||
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
@@ -1194,14 +1194,6 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
case USB_REQ_TYPE_STANDARD:
|
case USB_REQ_TYPE_STANDARD:
|
||||||
{
|
{
|
||||||
/* If the serial device is used in as part of a composite device,
|
|
||||||
* then standard descriptors are handled by logic in the composite
|
|
||||||
* device logic.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_CDCSER_COMPOSITE
|
|
||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
|
||||||
#else
|
|
||||||
switch (ctrl->req)
|
switch (ctrl->req)
|
||||||
{
|
{
|
||||||
case USB_REQ_GETDESCRIPTOR:
|
case USB_REQ_GETDESCRIPTOR:
|
||||||
@@ -1212,14 +1204,26 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
switch (ctrl->value[1])
|
switch (ctrl->value[1])
|
||||||
{
|
{
|
||||||
|
/* If the serial device is used in as part of a composite device,
|
||||||
|
* then the device descriptor is provided by logic in the composite
|
||||||
|
* device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
case USB_DESC_TYPE_DEVICE:
|
case USB_DESC_TYPE_DEVICE:
|
||||||
{
|
{
|
||||||
ret = USB_SIZEOF_DEVDESC;
|
ret = USB_SIZEOF_DEVDESC;
|
||||||
memcpy(ctrlreq->buf, cdcser_getdevdesc(), ret);
|
memcpy(ctrlreq->buf, cdcser_getdevdesc(), ret);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
/* If the serial device is used in as part of a composite device,
|
||||||
|
* then the device qualifier descriptor is provided by logic in the
|
||||||
|
* composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_CDCSER_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||||
case USB_DESC_TYPE_DEVICEQUALIFIER:
|
case USB_DESC_TYPE_DEVICEQUALIFIER:
|
||||||
{
|
{
|
||||||
ret = USB_SIZEOF_QUALDESC;
|
ret = USB_SIZEOF_QUALDESC;
|
||||||
@@ -1228,8 +1232,14 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case USB_DESC_TYPE_OTHERSPEEDCONFIG:
|
case USB_DESC_TYPE_OTHERSPEEDCONFIG:
|
||||||
#endif /* CONFIG_USBDEV_DUALSPEED */
|
#endif
|
||||||
|
|
||||||
|
/* If the serial device is used in as part of a composite device,
|
||||||
|
* then the configuration descriptor is provided by logic in the
|
||||||
|
* composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
case USB_DESC_TYPE_CONFIG:
|
case USB_DESC_TYPE_CONFIG:
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||||
@@ -1239,7 +1249,14 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If the serial device is used in as part of a composite device,
|
||||||
|
* then the language string descriptor is provided by logic in the
|
||||||
|
* composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
case USB_DESC_TYPE_STRING:
|
case USB_DESC_TYPE_STRING:
|
||||||
{
|
{
|
||||||
/* index == language code. */
|
/* index == language code. */
|
||||||
@@ -1247,6 +1264,7 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
ret = cdcser_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
|
ret = cdcser_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@@ -1266,6 +1284,12 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* If the serial device is used in as part of a composite device,
|
||||||
|
* then the overall composite class configuration is managed by logic
|
||||||
|
* in the composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
case USB_REQ_GETCONFIGURATION:
|
case USB_REQ_GETCONFIGURATION:
|
||||||
{
|
{
|
||||||
if (ctrl->type == USB_DIR_IN)
|
if (ctrl->type == USB_DIR_IN)
|
||||||
@@ -1275,14 +1299,15 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case USB_REQ_SETINTERFACE:
|
case USB_REQ_SETINTERFACE:
|
||||||
{
|
{
|
||||||
if (ctrl->type == USB_REQ_RECIPIENT_INTERFACE)
|
if (ctrl->type == USB_REQ_RECIPIENT_INTERFACE &&
|
||||||
|
priv->config == CDCSER_CONFIGID)
|
||||||
{
|
{
|
||||||
if (priv->config == CDCSER_CONFIGID &&
|
if ((index == CDCSER_NOTIFID && value == CDCSER_NOTALTIFID) ||
|
||||||
index == CDCSER_INTERFACEID &&
|
(index == CDCSER_DATAIFID && value == CDCSER_DATAALTIFID))
|
||||||
value == CDCSER_ALTINTERFACEID)
|
|
||||||
{
|
{
|
||||||
cdcser_resetconfig(priv);
|
cdcser_resetconfig(priv);
|
||||||
cdcser_setconfig(priv, priv->config);
|
cdcser_setconfig(priv, priv->config);
|
||||||
@@ -1297,14 +1322,15 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
if (ctrl->type == (USB_DIR_IN|USB_REQ_RECIPIENT_INTERFACE) &&
|
if (ctrl->type == (USB_DIR_IN|USB_REQ_RECIPIENT_INTERFACE) &&
|
||||||
priv->config == CDCSER_CONFIGIDNONE)
|
priv->config == CDCSER_CONFIGIDNONE)
|
||||||
{
|
{
|
||||||
if (index != CDCSER_INTERFACEID)
|
if ((index == CDCSER_NOTIFID && value == CDCSER_NOTALTIFID) ||
|
||||||
{
|
(index == CDCSER_DATAIFID && value == CDCSER_DATAALTIFID))
|
||||||
ret = -EDOM;
|
{
|
||||||
|
*(uint8_t*) ctrlreq->buf = value;
|
||||||
|
ret = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*(uint8_t*) ctrlreq->buf = CDCSER_ALTINTERFACEID;
|
ret = -EDOM;
|
||||||
ret = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1314,7 +1340,6 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1328,7 +1353,8 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
case ACM_GET_LINE_CODING:
|
case ACM_GET_LINE_CODING:
|
||||||
{
|
{
|
||||||
if (ctrl->type == (USB_DIR_IN|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE))
|
if (ctrl->type == (USB_DIR_IN|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE) &&
|
||||||
|
index == CDCSER_NOTIFID)
|
||||||
{
|
{
|
||||||
/* Return the current line status from the private data structure */
|
/* Return the current line status from the private data structure */
|
||||||
|
|
||||||
@@ -1348,11 +1374,12 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
case ACM_SET_LINE_CODING:
|
case ACM_SET_LINE_CODING:
|
||||||
{
|
{
|
||||||
if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE))
|
if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE) &&
|
||||||
|
len == SIZEOF_CDC_LINECODING && index == CDCSER_NOTIFID)
|
||||||
{
|
{
|
||||||
/* Save the new line coding in the private data structure */
|
/* Save the new line coding in the private data structure */
|
||||||
|
|
||||||
memcpy(&priv->linecoding, ctrlreq->buf, min(len, 7));
|
memcpy(&priv->linecoding, ctrlreq->buf, MIN(len, 7));
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
/* If there is a registered callback to receive line status info, then
|
/* If there is a registered callback to receive line status info, then
|
||||||
@@ -1377,7 +1404,8 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
case ACM_SET_CTRL_LINE_STATE:
|
case ACM_SET_CTRL_LINE_STATE:
|
||||||
{
|
{
|
||||||
if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE))
|
if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE) &&
|
||||||
|
index == CDCSER_NOTIFID)
|
||||||
{
|
{
|
||||||
/* Save the control line state in the private data structure. Only bits
|
/* Save the control line state in the private data structure. Only bits
|
||||||
* 0 and 1 have meaning.
|
* 0 and 1 have meaning.
|
||||||
@@ -1406,7 +1434,8 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
case ACM_SEND_BREAK:
|
case ACM_SEND_BREAK:
|
||||||
{
|
{
|
||||||
if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE))
|
if (ctrl->type == (USB_DIR_OUT|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE) &&
|
||||||
|
index == CDCSER_NOTIFID)
|
||||||
{
|
{
|
||||||
/* If there is a registered callback to handle the SendBreak request,
|
/* If there is a registered callback to handle the SendBreak request,
|
||||||
* then callout now.
|
* then callout now.
|
||||||
@@ -1436,7 +1465,7 @@ static int cdcser_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ct
|
|||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ctrlreq->len = min(len, ret);
|
ctrlreq->len = MIN(len, ret);
|
||||||
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
||||||
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -1498,10 +1527,12 @@ static void cdcser_disconnect(FAR struct usbdev_s *dev)
|
|||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
|
|
||||||
/* Perform the soft connect function so that we will we can be
|
/* Perform the soft connect function so that we will we can be
|
||||||
* re-enumerated.
|
* re-enumerated (unless we are part of a composite device)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
DEV_CONNECT(dev);
|
DEV_CONNECT(dev);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1893,21 +1924,27 @@ static bool cdcuart_txempty(FAR struct uart_dev_s *dev)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cdcser_initialize
|
* Name: cdcser_classobject
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Register USB serial port (and USB serial console if so configured).
|
* Register USB serial port (and USB serial console if so configured) and
|
||||||
|
* return the class object.
|
||||||
*
|
*
|
||||||
* Input Parameter:
|
* Input Parameter:
|
||||||
* Device minor number. E.g., minor 0 would correspond to /dev/ttyUSB0.
|
* minor - Device minor number. E.g., minor 0 would correspond to
|
||||||
|
* /dev/ttyUSB0.
|
||||||
|
* classdev - The location to return the CDC serial class' device
|
||||||
|
* instance.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) means that the driver was successfully registered. On any
|
* A pointer to the allocated class object (NULL on failure).
|
||||||
* failure, a negated errno value is retured.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int cdcser_initialize(int minor)
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
|
static
|
||||||
|
#endif
|
||||||
|
int cdcser_classobject(int minor, FAR struct usbdevclass_driver_s **classdev)
|
||||||
{
|
{
|
||||||
FAR struct cdcser_alloc_s *alloc;
|
FAR struct cdcser_alloc_s *alloc;
|
||||||
FAR struct cdcser_dev_s *priv;
|
FAR struct cdcser_dev_s *priv;
|
||||||
@@ -1963,15 +2000,6 @@ int cdcser_initialize(int minor)
|
|||||||
drvr->drvr.ops = &g_driverops;
|
drvr->drvr.ops = &g_driverops;
|
||||||
drvr->dev = priv;
|
drvr->dev = priv;
|
||||||
|
|
||||||
/* Register the USB serial class driver */
|
|
||||||
|
|
||||||
ret = usbdev_register(&drvr->drvr);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16_t)-ret);
|
|
||||||
goto errout_with_alloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Register the USB serial console */
|
/* Register the USB serial console */
|
||||||
|
|
||||||
#ifdef CONFIG_CDCSER_CONSOLE
|
#ifdef CONFIG_CDCSER_CONSOLE
|
||||||
@@ -1993,11 +2021,50 @@ int cdcser_initialize(int minor)
|
|||||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16_t)-ret);
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16_t)-ret);
|
||||||
goto errout_with_class;
|
goto errout_with_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*classdev = &drvr->drvr;
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_class:
|
errout_with_class:
|
||||||
usbdev_unregister(&drvr->drvr);
|
|
||||||
errout_with_alloc:
|
|
||||||
kfree(alloc);
|
kfree(alloc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cdcser_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register USB serial port (and USB serial console if so configured).
|
||||||
|
*
|
||||||
|
* Input Parameter:
|
||||||
|
* Device minor number. E.g., minor 0 would correspond to /dev/ttyUSB0.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) means that the driver was successfully registered. On any
|
||||||
|
* failure, a negated errno value is retured.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
|
int cdcser_initialize(int minor)
|
||||||
|
{
|
||||||
|
FAR struct usbdevclass_driver_s *drvr;
|
||||||
|
FAR struct cdcser_dev_s *priv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Get an instance of the serial driver class object */
|
||||||
|
|
||||||
|
ret = cdcser_classobject(minor, &drvr);
|
||||||
|
if (ret == OK)
|
||||||
|
{
|
||||||
|
/* Register the USB serial class driver */
|
||||||
|
|
||||||
|
ret = usbdev_register(drvr);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16_t)-ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
+33
-11
@@ -72,13 +72,39 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Interface IDs. If the serial driver is built as a component of a composite
|
||||||
|
* device, then the interface IDs may need to be offset.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
|
# undef CONFIG_CDCSER_IFNOBASE
|
||||||
|
# define CONFIG_CDCSER_IFNOBASE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_IFNOBASE
|
||||||
|
# define CONFIG_CDCSER_IFNOBASE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Descriptors **************************************************************/
|
/* Descriptors **************************************************************/
|
||||||
/* These settings are not modifiable via the NuttX configuration */
|
/* These settings are not modifiable via the NuttX configuration */
|
||||||
|
|
||||||
#define CDC_VERSIONNO 0x0110 /* CDC version number 1.10 (BCD) */
|
#define CDC_VERSIONNO 0x0110 /* CDC version number 1.10 (BCD) */
|
||||||
#define CDCSER_CONFIGIDNONE (0) /* Config ID means to return to address mode */
|
#define CDCSER_CONFIGIDNONE (0) /* Config ID means to return to address mode */
|
||||||
#define CDCSER_INTERFACEID (0)
|
|
||||||
#define CDCSER_ALTINTERFACEID (0)
|
/* Interface IDs:
|
||||||
|
*
|
||||||
|
* CDCSER_NINTERFACES Two interfaces
|
||||||
|
* CDCSER_NOTIFID ID of the notifier interface
|
||||||
|
* CDCSER_NOTALTIFID No alternate for the notifier interface
|
||||||
|
* CDCSER_DATAIFID ID of the data interface
|
||||||
|
* CDCSER_DATAALTIFID No alternate for the data interface
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define CDCSER_NINTERFACES (2) /* Number of interfaces in the configuration */
|
||||||
|
#define CDCSER_NOTIFID (CONFIG_CDCSER_IFNOBASE+0)
|
||||||
|
#define CDCSER_NOTALTIFID CDCSER_NOTIFID
|
||||||
|
#define CDCSER_DATAIFID (CONFIG_CDCSER_IFNOBASE+1)
|
||||||
|
#define CDCSER_DATAALTIFID CDCSER_DATAIFID
|
||||||
|
|
||||||
/* Configuration descriptor values */
|
/* Configuration descriptor values */
|
||||||
|
|
||||||
@@ -95,10 +121,6 @@
|
|||||||
#define CDCSER_VERSIONNO (0x0101) /* Device version number 1.1 (BCD) */
|
#define CDCSER_VERSIONNO (0x0101) /* Device version number 1.1 (BCD) */
|
||||||
#define CDCSER_NCONFIGS (1) /* Number of configurations supported */
|
#define CDCSER_NCONFIGS (1) /* Number of configurations supported */
|
||||||
|
|
||||||
/* Configuration descriptor values */
|
|
||||||
|
|
||||||
#define CDCSER_NINTERFACES (2) /* Number of interfaces in the configuration */
|
|
||||||
|
|
||||||
/* String language */
|
/* String language */
|
||||||
|
|
||||||
#define CDCSER_STR_LANGUAGE (0x0409) /* en-us */
|
#define CDCSER_STR_LANGUAGE (0x0409) /* en-us */
|
||||||
@@ -177,14 +199,14 @@
|
|||||||
#define CDCSER_EPINBULK_ATTR (USB_EP_ATTR_XFER_BULK)
|
#define CDCSER_EPINBULK_ATTR (USB_EP_ATTR_XFER_BULK)
|
||||||
|
|
||||||
/* Misc Macros **************************************************************/
|
/* Misc Macros **************************************************************/
|
||||||
/* min/max macros */
|
/* MIN/MAX macros */
|
||||||
|
|
||||||
#ifndef min
|
#ifndef MIN
|
||||||
# define min(a,b) ((a)<(b)?(a):(b))
|
# define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef max
|
#ifndef MAX
|
||||||
# define max(a,b) ((a)>(b)?(a):(b))
|
# define MAX(a,b) ((a)>(b)?(a):(b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Trace values *************************************************************/
|
/* Trace values *************************************************************/
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ static const struct usb_ifdesc_s g_notifdesc =
|
|||||||
{
|
{
|
||||||
USB_SIZEOF_IFDESC, /* len */
|
USB_SIZEOF_IFDESC, /* len */
|
||||||
USB_DESC_TYPE_INTERFACE, /* type */
|
USB_DESC_TYPE_INTERFACE, /* type */
|
||||||
0, /* ifno */
|
CDCSER_NOTIFID, /* ifno */
|
||||||
0, /* alt */
|
CDCSER_NOTALTIFID, /* alt */
|
||||||
1, /* neps */
|
1, /* neps */
|
||||||
USB_CLASS_CDC, /* class */
|
USB_CLASS_CDC, /* class */
|
||||||
CDC_SUBCLASS_ACM, /* subclass */
|
CDC_SUBCLASS_ACM, /* subclass */
|
||||||
@@ -213,8 +213,8 @@ static const struct usb_ifdesc_s g_dataifdesc =
|
|||||||
{
|
{
|
||||||
USB_SIZEOF_IFDESC, /* len */
|
USB_SIZEOF_IFDESC, /* len */
|
||||||
USB_DESC_TYPE_INTERFACE, /* type */
|
USB_DESC_TYPE_INTERFACE, /* type */
|
||||||
1, /* ifno */
|
CDCSER_DATAIFID, /* ifno */
|
||||||
0, /* alt */
|
CDCSER_DATAALTIFID, /* alt */
|
||||||
2, /* neps */
|
2, /* neps */
|
||||||
USB_CLASS_CDC_DATA, /* class */
|
USB_CLASS_CDC_DATA, /* class */
|
||||||
CDC_DATA_SUBCLASS_NONE, /* subclass */
|
CDC_DATA_SUBCLASS_NONE, /* subclass */
|
||||||
|
|||||||
+559
-64
File diff suppressed because it is too large
Load Diff
+131
-3
@@ -50,6 +50,15 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||||
|
|
||||||
|
#ifdef CONFIG_CDCSER_COMPOSITE
|
||||||
|
# include <nuttx/usb/cdc_serial.h>
|
||||||
|
# include "cdcacm.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBSTRG_COMPOSITE
|
||||||
|
# include "msc.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -74,16 +83,16 @@
|
|||||||
#ifndef CONFIG_COMPOSITE_COMPOSITE
|
#ifndef CONFIG_COMPOSITE_COMPOSITE
|
||||||
# ifndef CONFIG_COMPOSITE_VENDORID
|
# ifndef CONFIG_COMPOSITE_VENDORID
|
||||||
# warning "CONFIG_COMPOSITE_VENDORID not defined"
|
# warning "CONFIG_COMPOSITE_VENDORID not defined"
|
||||||
# define CONFIG_COMPOSITE_VENDORID 0x584e
|
# define CONFIG_COMPOSITE_VENDORID 0x03eb
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef CONFIG_COMPOSITE_PRODUCTID
|
# ifndef CONFIG_COMPOSITE_PRODUCTID
|
||||||
# warning "CONFIG_COMPOSITE_PRODUCTID not defined"
|
# warning "CONFIG_COMPOSITE_PRODUCTID not defined"
|
||||||
# define CONFIG_COMPOSITE_PRODUCTID 0x5342
|
# define CONFIG_COMPOSITE_PRODUCTID 0x2022
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef CONFIG_COMPOSITE_VERSIONNO
|
# ifndef CONFIG_COMPOSITE_VERSIONNO
|
||||||
# define CONFIG_COMPOSITE_VERSIONNO (0x0399)
|
# define CONFIG_COMPOSITE_VERSIONNO (0x0101)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef CONFIG_COMPOSITE_VENDORSTR
|
# ifndef CONFIG_COMPOSITE_VENDORSTR
|
||||||
@@ -103,7 +112,112 @@
|
|||||||
#undef CONFIG_COMPOSITE_CONFIGSTR
|
#undef CONFIG_COMPOSITE_CONFIGSTR
|
||||||
#define CONFIG_COMPOSITE_CONFIGSTR "Composite"
|
#define CONFIG_COMPOSITE_CONFIGSTR "Composite"
|
||||||
|
|
||||||
|
/* Constituent devices ******************************************************/
|
||||||
|
|
||||||
|
#undef DEV1_IS_CDCSERIAL
|
||||||
|
#undef DEV1_IS_USBSTRG
|
||||||
|
|
||||||
|
#undef DEV2_IS_CDCSERIAL
|
||||||
|
#undef DEV2_IS_USBSTRG
|
||||||
|
|
||||||
|
/* Pick the first device in the composite. At present, this may only be
|
||||||
|
* the CDC serial device or the mass storage device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_CDCSER_COMPOSITE)
|
||||||
|
# define DEV1_IS_CDCSERIAL 1
|
||||||
|
# define DEV1_MKCFGDESC cdcser_mkcfgdesc
|
||||||
|
# define DEV1_CLASSOBJECT board_cdcclassobject
|
||||||
|
# define DEV1_NCONFIGS CDCSER_NCONFIGS
|
||||||
|
# define DEV1_CONFIGID CDCSER_CONFIGID
|
||||||
|
# define DEV1_FIRSTINTERFACE CONFIG_CDCSER_IFNOBASE
|
||||||
|
# define DEV1_NINTERFACES CDCSER_NINTERFACES
|
||||||
|
# define DEV1_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
||||||
|
# define DEV1_NSTRIDS (CDCSER_LASTSTRID-CONFIG_CDCSER_STRBASE)
|
||||||
|
# define DEV1_CFGDESCSIZE SIZEOF_CDCSER_CFGDESC
|
||||||
|
#elif defined(CONFIG_CDCSER_COMPOSITE)
|
||||||
|
# define DEV1_IS_USBSTRG 1
|
||||||
|
# define DEV1_MKCFGDESC usbstrg_mkcfgdesc
|
||||||
|
# define DEV1_CLASSOBJECT board_mscclassobject
|
||||||
|
# define DEV1_NCONFIGS USBSTRG_NCONFIGS
|
||||||
|
# define DEV1_CONFIGID USBSTRG_CONFIGID
|
||||||
|
# define DEV1_FIRSTINTERFACE CONFIG_USBSTRG_IFNOBASE
|
||||||
|
# define DEV1_NINTERFACES USBSTRG_NINTERFACES
|
||||||
|
# define DEV1_FIRSTSTRID CONFIG_USBSTRG_IFNOBASE
|
||||||
|
# define DEV1_NSTRIDS (USBSTRG_LASTSTRID-CONFIG_USBSTRG_STRBASE)
|
||||||
|
# define DEV1_CFGDESCSIZE SIZEOF_USBSTRG_CFGDESC
|
||||||
|
#else
|
||||||
|
# error "No members of the composite defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Pick the second device in the composite. At present, this may only be
|
||||||
|
* the CDC serial device or the mass storage device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_CDCSERIAL)
|
||||||
|
# define DEV2_IS_CDCSERIAL 1
|
||||||
|
# define DEV2_MKCFGDESC cdcser_mkcfgdesc
|
||||||
|
# define DEV2_CLASSOBJECT board_cdcclassobject
|
||||||
|
# define DEV2_NCONFIGS CDCSER_NCONFIGS
|
||||||
|
# define DEV2_CONFIGID CDCSER_CONFIGID
|
||||||
|
# define DEV2_FIRSTINTERFACE CONFIG_CDCSER_IFNOBASE
|
||||||
|
# define DEV2_NINTERFACES CDCSER_NINTERFACES
|
||||||
|
# define DEV2_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
||||||
|
# define DEV2_NSTRIDS (CDCSER_LASTSTRID-CONFIG_CDCSER_STRBASE)
|
||||||
|
# define DEV2_CFGDESCSIZE SIZEOF_CDCSER_CFGDESC
|
||||||
|
#elif defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_USBSTRG)
|
||||||
|
# define DEV2_IS_USBSTRG 1
|
||||||
|
# define DEV2_MKCFGDESC usbstrg_mkcfgdesc
|
||||||
|
# define DEV2_CLASSOBJECT board_mscclassobject
|
||||||
|
# define DEV2_NCONFIGS USBSTRG_NCONFIGS
|
||||||
|
# define DEV2_CONFIGID USBSTRG_CONFIGID
|
||||||
|
# define DEV2_FIRSTINTERFACE CONFIG_USBSTRG_IFNOBASE
|
||||||
|
# define DEV2_NINTERFACES USBSTRG_NINTERFACES
|
||||||
|
# define DEV2_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
||||||
|
# define DEV2_NSTRIDS (USBSTRG_LASTSTRID-CONFIG_USBSTRG_STRBASE)
|
||||||
|
# define DEV2_CFGDESCSIZE SIZEOF_USBSTRG_CFGDESC
|
||||||
|
#else
|
||||||
|
# error "Insufficient members of the composite defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Verify interface configuration */
|
||||||
|
|
||||||
|
#if DEV1_FIRSTINTERFACE != 0
|
||||||
|
# warning "The first interface number should be zero"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (DEV1_FIRSTINTERFACE + DEV2_NINTERFACES) != DEV2_FIRSTINTERFACE
|
||||||
|
# warning "Interface numbers are not contiguous"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Total size of the configuration descriptor: */
|
||||||
|
|
||||||
|
#define COMPOSITE_CFGDESCSIZE (USB_SIZEOF_CFGDESC + DEV1_CFGDESCSIZE + DEV2_CFGDESCSIZE)
|
||||||
|
|
||||||
|
/* The total number of interfaces */
|
||||||
|
|
||||||
|
#define COMPOSITE_NINTERFACES (DEV1_NINTERFACES + DEV2_NINTERFACES)
|
||||||
|
|
||||||
|
/* Composite configuration ID value */
|
||||||
|
|
||||||
|
#if DEV1_NCONFIGS != 1 || DEV1_CONFIGID != 1
|
||||||
|
# error "DEV1: Only a single configuration is supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEV2_NCONFIGS != 1 || DEV2_CONFIGID != 1
|
||||||
|
# error "DEV2: Only a single configuration is supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Descriptors **************************************************************/
|
/* Descriptors **************************************************************/
|
||||||
|
/* These settings are not modifiable via the NuttX configuration */
|
||||||
|
|
||||||
|
#define COMPOSITE_CONFIGIDNONE (0) /* Config ID = 0 means to return to address mode */
|
||||||
|
#define COMPOSITE_NCONFIGS (1) /* The number of configurations supported */
|
||||||
|
#define COMPOSITE_CONFIGID (1) /* The only supported configuration ID */
|
||||||
|
|
||||||
|
/* String language */
|
||||||
|
|
||||||
|
#define COMPOSITE_STR_LANGUAGE (0x0409) /* en-us */
|
||||||
|
|
||||||
/* Descriptor strings */
|
/* Descriptor strings */
|
||||||
|
|
||||||
@@ -112,6 +226,16 @@
|
|||||||
#define COMPOSITE_SERIALSTRID (3)
|
#define COMPOSITE_SERIALSTRID (3)
|
||||||
#define COMPOSITE_CONFIGSTRID (4)
|
#define COMPOSITE_CONFIGSTRID (4)
|
||||||
|
|
||||||
|
/* Everpresent MIN/MAX macros ***********************************************/
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -120,6 +244,10 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
extern const char g_compvendorstr[];
|
||||||
|
extern const char g_compproductstr[];
|
||||||
|
extern const char g_compserialstr[];
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -44,105 +44,19 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
#include <nuttx/usb/usbdev_trace.h>
|
||||||
|
|
||||||
#include "composite.h"
|
#include "composite.h"
|
||||||
|
|
||||||
#ifdef CONFIG_CDCSER_COMPOSITE
|
|
||||||
# include "cdcacm.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBSTRG_COMPOSITE
|
|
||||||
# include "msc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#undef DEV1_IS_CDCSERIAL
|
|
||||||
#undef DEV1_IS_USBSTRG
|
|
||||||
|
|
||||||
#undef DEV2_IS_CDCSERIAL
|
|
||||||
#undef DEV2_IS_USBSTRG
|
|
||||||
|
|
||||||
/* Pick the first device in the composite. At present, this may only be
|
|
||||||
* the CDC serial device or the mass storage device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(CONFIG_CDCSER_COMPOSITE)
|
|
||||||
# define DEV1_IS_CDCSERIAL 1
|
|
||||||
# define DEV1_MKCFGDESC cdcser_mkcfgdesc
|
|
||||||
# define DEV1_NCONFIGS CDCSER_NCONFIGS
|
|
||||||
# define DEV1_CONFIGID CDCSER_CONFIGID
|
|
||||||
# define DEV1_NINTERFACES CDCSER_NINTERFACES
|
|
||||||
# define DEV1_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
|
||||||
# define DEV1_NSTRIDS (CDCSER_LASTSTRID-CONFIG_CDCSER_STRBASE)
|
|
||||||
# define DEV1_CFGDESCSIZE SIZEOF_CDCSER_CFGDESC
|
|
||||||
#elif defined(CONFIG_CDCSER_COMPOSITE)
|
|
||||||
# define DEV1_IS_USBSTRG 1
|
|
||||||
# define DEV1_MKCFGDESC composite_mkcfgdesc
|
|
||||||
# define DEV1_NCONFIGS USBSTRG_NCONFIGS
|
|
||||||
# define DEV1_CONFIGID USBSTRG_CONFIGID
|
|
||||||
# define DEV1_NINTERFACES USBSTRG_NINTERFACES
|
|
||||||
# define DEV1_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
|
||||||
# define DEV1_NSTRIDS (USBSTRG_LASTSTRID-CONFIG_USBSTRG_STRBASE)
|
|
||||||
# define DEV1_CFGDESCSIZE SIZEOF_USBSTRG_CFGDESC
|
|
||||||
#else
|
|
||||||
# error "No members of the composite defined"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Pick the second device in the composite. At present, this may only be
|
|
||||||
* the CDC serial device or the mass storage device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_CDCSERIAL)
|
|
||||||
# define DEV2_IS_CDCSERIAL 1
|
|
||||||
# define DEV2_MKCFGDESC cdcser_mkcfgdesc
|
|
||||||
# define DEV2_NCONFIGS CDCSER_NCONFIGS
|
|
||||||
# define DEV2_CONFIGID CDCSER_CONFIGID
|
|
||||||
# define DEV2_NINTERFACES CDCSER_NINTERFACES
|
|
||||||
# define DEV2_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
|
||||||
# define DEV2_NSTRIDS (CDCSER_LASTSTRID-CONFIG_CDCSER_STRBASE)
|
|
||||||
# define DEV2_CFGDESCSIZE SIZEOF_CDCSER_CFGDESC
|
|
||||||
#elif defined(CONFIG_CDCSER_COMPOSITE) && !defined(DEV1_IS_USBSTRG)
|
|
||||||
# define DEV2_IS_USBSTRG 1
|
|
||||||
# define DEV2_MKCFGDESC composite_mkcfgdesc
|
|
||||||
# define DEV2_NCONFIGS USBSTRG_NCONFIGS
|
|
||||||
# define DEV2_CONFIGID USBSTRG_CONFIGID
|
|
||||||
# define DEV2_NINTERFACES USBSTRG_NINTERFACES
|
|
||||||
# define DEV2_FIRSTSTRID CONFIG_CDCSER_STRBASE
|
|
||||||
# define DEV2_NSTRIDS (USBSTRG_LASTSTRID-CONFIG_USBSTRG_STRBASE)
|
|
||||||
# define DEV2_CFGDESCSIZE SIZEOF_USBSTRG_CFGDESC
|
|
||||||
#else
|
|
||||||
# error "Insufficient members of the composite defined"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Total size of the configuration descriptor: */
|
|
||||||
|
|
||||||
#define COMPOSITE_CFGDESCSIZE (USB_SIZEOF_CFGDESC + DEV1_CFGDESCSIZE + DEV2_CFGDESCSIZE)
|
|
||||||
|
|
||||||
/* The total number of interfaces */
|
|
||||||
|
|
||||||
#define COMPOSITE_NINTERFACES (DEV1_NINTERFACES + DEV2_NINTERFACES)
|
|
||||||
|
|
||||||
/* Composite configuration ID value */
|
|
||||||
|
|
||||||
#if DEV1_NCONFIGS != 1 || DEV1_CONFIGID != 1
|
|
||||||
# error "DEV1: Only a single configuration is supported"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEV2_NCONFIGS != 1 || DEV2_CONFIGID != 1
|
|
||||||
# error "DEV2: Only a single configuration is supported"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COMPOSITE_NCONFIGS 1
|
|
||||||
#define COMPOSITE_CONFIGID 1
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -258,25 +172,25 @@ int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||||||
|
|
||||||
strdesc->len = 4;
|
strdesc->len = 4;
|
||||||
strdesc->type = USB_DESC_TYPE_STRING;
|
strdesc->type = USB_DESC_TYPE_STRING;
|
||||||
strdesc->data[0] = LSBYTE(USBSTRG_STR_LANGUAGE);
|
strdesc->data[0] = LSBYTE(COMPOSITE_STR_LANGUAGE);
|
||||||
strdesc->data[1] = MSBYTE(USBSTRG_STR_LANGUAGE);
|
strdesc->data[1] = MSBYTE(COMPOSITE_STR_LANGUAGE);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMPOSITE_MANUFACTURERSTRID:
|
case COMPOSITE_MANUFACTURERSTRID:
|
||||||
str = g_vendorstr;
|
str = g_compvendorstr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPOSITE_PRODUCTSTRID:
|
case COMPOSITE_PRODUCTSTRID:
|
||||||
str = g_productstr;
|
str = g_compproductstr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPOSITE_SERIALSTRID:
|
case COMPOSITE_SERIALSTRID:
|
||||||
str = g_serialstr;
|
str = g_compserialstr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPOSITE_CONFIGSTRID:
|
case COMPOSITE_CONFIGSTRID:
|
||||||
str = CONFIG_USBSTRG_CONFIGSTR;
|
str = CONFIG_COMPOSITE_CONFIGSTR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -307,12 +221,10 @@ int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
|
||||||
FAR const struct usb_devdesc_s *composite_getdevdesc(void)
|
FAR const struct usb_devdesc_s *composite_getdevdesc(void)
|
||||||
{
|
{
|
||||||
return &g_devdesc;
|
return &g_devdesc;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: composite_mkcfgdesc
|
* Name: composite_mkcfgdesc
|
||||||
@@ -329,21 +241,28 @@ int16_t composite_mkcfgdesc(uint8_t *buf)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
|
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
|
||||||
|
int16_t len;
|
||||||
|
|
||||||
/* Configuration descriptor -- Copy the canned configuration descriptor. */
|
/* Configuration descriptor -- Copy the canned configuration descriptor. */
|
||||||
|
|
||||||
memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC);
|
||||||
|
len = USB_SIZEOF_CFGDESC;
|
||||||
buf += USB_SIZEOF_CFGDESC;
|
buf += USB_SIZEOF_CFGDESC;
|
||||||
|
|
||||||
/* Copy DEV1/DEV2 configuration descriptors */
|
/* Copy DEV1/DEV2 configuration descriptors */
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||||
buf += DEV1_MKCFGDESC(buf, speed, type);
|
len = DEV1_MKCFGDESC(buf, speed, type);
|
||||||
buf += DEV2_MKCFGDESC(buf, speed, type);
|
buf += len;
|
||||||
|
len = DEV2_MKCFGDESC(buf, speed, type);
|
||||||
|
buf += len;
|
||||||
#else
|
#else
|
||||||
buf += DEV1_MKCFGDESC(buf);
|
len = DEV1_MKCFGDESC(buf);
|
||||||
buf += DEV2_MKCFGDESC(buf);
|
buf += len;
|
||||||
|
len = DEV2_MKCFGDESC(buf);
|
||||||
|
buf += len;
|
||||||
#endif
|
#endif
|
||||||
|
DEBUGASSERT(len == COMPOSITE_CFGDESCSIZE);
|
||||||
|
|
||||||
return COMPOSITE_CFGDESCSIZE;
|
return COMPOSITE_CFGDESCSIZE;
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-19
@@ -335,15 +335,19 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_
|
|||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Report if we are selfpowered */
|
/* Report if we are selfpowered (unless we are part of a composite device) */
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
#ifdef CONFIG_USBDEV_SELFPOWERED
|
#ifdef CONFIG_USBDEV_SELFPOWERED
|
||||||
DEV_SETSELFPOWERED(dev);
|
DEV_SETSELFPOWERED(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* And pull-up the data line for the soft connect function */
|
/* And pull-up the data line for the soft connect function (unless we are
|
||||||
|
* part of a composite device)
|
||||||
|
*/
|
||||||
|
|
||||||
DEV_CONNECT(dev);
|
DEV_CONNECT(dev);
|
||||||
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
@@ -520,14 +524,6 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
* Standard Requests
|
* Standard Requests
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/* If the mass storage device is used in as part of a composite device,
|
|
||||||
* then the configuration descriptor is is handled by logic in the
|
|
||||||
* composite device logic.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBSTRG_COMPOSITE
|
|
||||||
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
|
||||||
#else
|
|
||||||
switch (ctrl->req)
|
switch (ctrl->req)
|
||||||
{
|
{
|
||||||
case USB_REQ_GETDESCRIPTOR:
|
case USB_REQ_GETDESCRIPTOR:
|
||||||
@@ -538,14 +534,26 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
|
|
||||||
switch (ctrl->value[1])
|
switch (ctrl->value[1])
|
||||||
{
|
{
|
||||||
|
/* If the mass storage device is used in as part of a composite
|
||||||
|
* device, then the device descriptor is is provided by logic
|
||||||
|
* in the composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
case USB_DESC_TYPE_DEVICE:
|
case USB_DESC_TYPE_DEVICE:
|
||||||
{
|
{
|
||||||
ret = USB_SIZEOF_DEVDESC;
|
ret = USB_SIZEOF_DEVDESC;
|
||||||
memcpy(ctrlreq->buf, usbstrg_getdevdesc(), ret);
|
memcpy(ctrlreq->buf, usbstrg_getdevdesc(), ret);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
/* If the mass storage device is used in as part of a composite device,
|
||||||
|
* then the device qualifier descriptor is provided by logic in the
|
||||||
|
* composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_USBSTRG_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||||
case USB_DESC_TYPE_DEVICEQUALIFIER:
|
case USB_DESC_TYPE_DEVICEQUALIFIER:
|
||||||
{
|
{
|
||||||
ret = USB_SIZEOF_QUALDESC;
|
ret = USB_SIZEOF_QUALDESC;
|
||||||
@@ -554,8 +562,14 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case USB_DESC_TYPE_OTHERSPEEDCONFIG:
|
case USB_DESC_TYPE_OTHERSPEEDCONFIG:
|
||||||
#endif /* CONFIG_USBDEV_DUALSPEED */
|
#endif
|
||||||
|
|
||||||
|
/* If the mass storage device is used in as part of a composite device,
|
||||||
|
* then the configuration descriptor is provided by logic in the
|
||||||
|
* composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
case USB_DESC_TYPE_CONFIG:
|
case USB_DESC_TYPE_CONFIG:
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||||
@@ -565,7 +579,14 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If the mass storage device is used in as part of a composite device,
|
||||||
|
* then the language string descriptor is provided by logic in the
|
||||||
|
* composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
case USB_DESC_TYPE_STRING:
|
case USB_DESC_TYPE_STRING:
|
||||||
{
|
{
|
||||||
/* index == language code. */
|
/* index == language code. */
|
||||||
@@ -573,6 +594,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
ret = usbstrg_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
|
ret = usbstrg_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@@ -602,6 +624,12 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* If the mass storage device is used in as part of a composite device,
|
||||||
|
* then the overall composite class configuration is managed by logic
|
||||||
|
* in the composite device implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
case USB_REQ_GETCONFIGURATION:
|
case USB_REQ_GETCONFIGURATION:
|
||||||
{
|
{
|
||||||
if (ctrl->type == USB_DIR_IN)
|
if (ctrl->type == USB_DIR_IN)
|
||||||
@@ -611,6 +639,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case USB_REQ_SETINTERFACE:
|
case USB_REQ_SETINTERFACE:
|
||||||
{
|
{
|
||||||
@@ -657,7 +686,6 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -681,7 +709,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
{
|
{
|
||||||
/* Only one interface is supported */
|
/* Only one interface is supported */
|
||||||
|
|
||||||
if (index != USBSTRG_CONFIGID)
|
if (index != USBSTRG_INTERFACEID)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_MSRESETNDX), index);
|
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_MSRESETNDX), index);
|
||||||
ret = -EDOM;
|
ret = -EDOM;
|
||||||
@@ -705,7 +733,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
|
|
||||||
case USBSTRG_REQ_GETMAXLUN: /* Return number LUNs supported */
|
case USBSTRG_REQ_GETMAXLUN: /* Return number LUNs supported */
|
||||||
{
|
{
|
||||||
if (ctrl->type == USBSTRG_TYPE_SETUPIN && value == 0)
|
if (ctrl->type == USBSTRG_TYPE_SETUPIN && value == 0 && len == 1)
|
||||||
{
|
{
|
||||||
/* Only one interface is supported */
|
/* Only one interface is supported */
|
||||||
|
|
||||||
@@ -735,7 +763,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
|
|||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
ctrlreq->len = min(len, ret);
|
ctrlreq->len = MIN(len, ret);
|
||||||
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
ctrlreq->flags = USBDEV_REQFLAGS_NULLPKT;
|
||||||
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
ret = EP_SUBMIT(dev->ep0, ctrlreq);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -800,10 +828,12 @@ static void usbstrg_disconnect(FAR struct usbdev_s *dev)
|
|||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
|
|
||||||
/* Perform the soft connect function so that we will we can be
|
/* Perform the soft connect function so that we will we can be
|
||||||
* re-enumerated.
|
* re-enumerated (unless we are part of a composite device)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
DEV_CONNECT(dev);
|
DEV_CONNECT(dev);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1548,14 +1578,16 @@ int usbstrg_exportluns(FAR void *handle)
|
|||||||
goto errout_with_mutex;
|
goto errout_with_mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the USB storage class driver */
|
/* Register the USB storage class driver (unless we are part of a composite device) */
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
ret = usbdev_register(&drvr->drvr);
|
ret = usbdev_register(&drvr->drvr);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEVREGISTER), (uint16_t)-ret);
|
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEVREGISTER), (uint16_t)-ret);
|
||||||
goto errout_with_mutex;
|
goto errout_with_mutex;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Signal to start the thread */
|
/* Signal to start the thread */
|
||||||
|
|
||||||
@@ -1632,9 +1664,11 @@ void usbstrg_uninitialize(FAR void *handle)
|
|||||||
}
|
}
|
||||||
priv->thread = 0;
|
priv->thread = 0;
|
||||||
|
|
||||||
/* Unregister the driver */
|
/* Unregister the driver (unless we are a part of a composite device */
|
||||||
|
|
||||||
|
#ifndef CONFIG_CDCSER_COMPOSITE
|
||||||
usbdev_unregister(&alloc->drvr.drvr);
|
usbdev_unregister(&alloc->drvr.drvr);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Uninitialize and release the LUNs */
|
/* Uninitialize and release the LUNs */
|
||||||
|
|
||||||
|
|||||||
+40
-10
@@ -71,6 +71,19 @@
|
|||||||
# define CONFIG_USBSTRG_STRBASE (4)
|
# define CONFIG_USBSTRG_STRBASE (4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Interface IDs. If the mass storage driver is built as a component of a
|
||||||
|
* composite device, then the interface IDs may need to be offset.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
|
# undef CONFIG_USBSTRG_IFNOBASE
|
||||||
|
# define CONFIG_USBSTRG_IFNOBASE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_IFNOBASE
|
||||||
|
# define CONFIG_USBSTRG_IFNOBASE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Number of requests in the write queue */
|
/* Number of requests in the write queue */
|
||||||
|
|
||||||
#ifndef CONFIG_USBSTRG_NWRREQS
|
#ifndef CONFIG_USBSTRG_NWRREQS
|
||||||
@@ -296,8 +309,9 @@
|
|||||||
/* Configuration Descriptor */
|
/* Configuration Descriptor */
|
||||||
|
|
||||||
#define USBSTRG_NINTERFACES (1) /* Number of interfaces in the configuration */
|
#define USBSTRG_NINTERFACES (1) /* Number of interfaces in the configuration */
|
||||||
#define USBSTRG_INTERFACEID (0)
|
#define USBSTRG_INTERFACEID (CONFIG_USBSTRG_IFNOBASE+0)
|
||||||
#define USBSTRG_ALTINTERFACEID (0)
|
#define USBSTRG_ALTINTERFACEID USBSTRG_INTERFACEID
|
||||||
|
|
||||||
#define USBSTRG_CONFIGIDNONE (0) /* Config ID means to return to address mode */
|
#define USBSTRG_CONFIGIDNONE (0) /* Config ID means to return to address mode */
|
||||||
#define USBSTRG_CONFIGID (1) /* The only supported configuration ID */
|
#define USBSTRG_CONFIGID (1) /* The only supported configuration ID */
|
||||||
|
|
||||||
@@ -375,14 +389,14 @@
|
|||||||
#define USBSTRG_DRVR_WRITE(l,b,s,n) ((l)->inode->u.i_bops->write((l)->inode,b,s,n))
|
#define USBSTRG_DRVR_WRITE(l,b,s,n) ((l)->inode->u.i_bops->write((l)->inode,b,s,n))
|
||||||
#define USBSTRG_DRVR_GEOMETRY(l,g) ((l)->inode->u.i_bops->geometry((l)->inode,g))
|
#define USBSTRG_DRVR_GEOMETRY(l,g) ((l)->inode->u.i_bops->geometry((l)->inode,g))
|
||||||
|
|
||||||
/* Everpresent min/max macros ***********************************************/
|
/* Everpresent MIN/MAX macros ***********************************************/
|
||||||
|
|
||||||
#ifndef min
|
#ifndef MIN
|
||||||
# define min(a,b) ((a) < (b) ? (a) : (b))
|
# define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef max
|
#ifndef MAX
|
||||||
# define max(a,b) ((a) > (b) ? (a) : (b))
|
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -503,10 +517,26 @@ extern "C"
|
|||||||
|
|
||||||
/* String *******************************************************************/
|
/* String *******************************************************************/
|
||||||
|
|
||||||
EXTERN const char g_vendorstr[];
|
/* Mass storage class vendor/product/serial number strings */
|
||||||
EXTERN const char g_productstr[];
|
|
||||||
EXTERN const char g_serialstr[];
|
|
||||||
|
|
||||||
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
|
EXTERN const char g_mscvendorstr[];
|
||||||
|
EXTERN const char g_mscproductstr[];
|
||||||
|
EXTERN const char g_mscserialstr[];
|
||||||
|
|
||||||
|
/* If we are using a composite device, then vendor/product/serial number strings
|
||||||
|
* are provided by the composite device logic.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#else
|
||||||
|
EXTERN const char g_compvendorstr[];
|
||||||
|
EXTERN const char g_compproductstr[];
|
||||||
|
EXTERN const char g_compserialstr[];
|
||||||
|
|
||||||
|
#define g_mscvendorstr g_compvendorstr
|
||||||
|
#define g_mscproductstr g_compproductstr
|
||||||
|
#define g_mscserialstr g_compserialstr
|
||||||
|
#endif
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|||||||
@@ -213,9 +213,9 @@ static const struct usb_epdesc_s g_hsepbulkindesc =
|
|||||||
/* Strings ******************************************************************/
|
/* Strings ******************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_USBSTRG_COMPOSITE
|
#ifndef CONFIG_USBSTRG_COMPOSITE
|
||||||
const char g_vendorstr[] = CONFIG_USBSTRG_VENDORSTR;
|
const char g_msccendorstr[] = CONFIG_USBSTRG_VENDORSTR;
|
||||||
const char g_productstr[] = CONFIG_USBSTRG_PRODUCTSTR;
|
const char g_mscproductstr[] = CONFIG_USBSTRG_PRODUCTSTR;
|
||||||
const char g_serialstr[] = CONFIG_USBSTRG_SERIALSTR;
|
const char g_mscserialstr[] = CONFIG_USBSTRG_SERIALSTR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -606,17 +606,17 @@ static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv,
|
|||||||
|
|
||||||
memset(response->vendorid, ' ', 8+16+4);
|
memset(response->vendorid, ' ', 8+16+4);
|
||||||
|
|
||||||
len = strlen(g_vendorstr);
|
len = strlen(g_mscvendorstr);
|
||||||
DEBUGASSERT(len <= 8);
|
DEBUGASSERT(len <= 8);
|
||||||
memcpy(response->vendorid, g_vendorstr, len);
|
memcpy(response->vendorid, g_mscvendorstr, len);
|
||||||
|
|
||||||
len = strlen(g_productstr);
|
len = strlen(g_mscproductstr);
|
||||||
DEBUGASSERT(len <= 16);
|
DEBUGASSERT(len <= 16);
|
||||||
memcpy(response->productid, g_productstr, len);
|
memcpy(response->productid, g_mscproductstr, len);
|
||||||
|
|
||||||
len = strlen(g_serialstr);
|
len = strlen(g_mscserialstr);
|
||||||
DEBUGASSERT(len <= 4);
|
DEBUGASSERT(len <= 4);
|
||||||
memcpy(response->productid, g_serialstr, len);
|
memcpy(response->productid, g_mscserialstr, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1545,7 +1545,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv)
|
|||||||
/* Handle the CBW */
|
/* Handle the CBW */
|
||||||
|
|
||||||
usbstrg_dumpdata("SCSCI CBW", (uint8_t*)cbw, USBSTRG_CBW_SIZEOF - USBSTRG_MAXCDBLEN);
|
usbstrg_dumpdata("SCSCI CBW", (uint8_t*)cbw, USBSTRG_CBW_SIZEOF - USBSTRG_MAXCDBLEN);
|
||||||
usbstrg_dumpdata(" CDB", cbw->cdb, min(cbw->cdblen, USBSTRG_MAXCDBLEN));
|
usbstrg_dumpdata(" CDB", cbw->cdb, MIN(cbw->cdblen, USBSTRG_MAXCDBLEN));
|
||||||
|
|
||||||
/* Check for properly formatted CBW? */
|
/* Check for properly formatted CBW? */
|
||||||
|
|
||||||
@@ -2045,7 +2045,7 @@ static int usbstrg_cmdreadstate(FAR struct usbstrg_dev_s *priv)
|
|||||||
src = &priv->iobuffer[lun->sectorsize - priv->nsectbytes];
|
src = &priv->iobuffer[lun->sectorsize - priv->nsectbytes];
|
||||||
dest = &req->buf[priv->nreqbytes];
|
dest = &req->buf[priv->nreqbytes];
|
||||||
|
|
||||||
nbytes = min(CONFIG_USBSTRG_BULKINREQLEN - priv->nreqbytes, priv->nsectbytes);
|
nbytes = MIN(CONFIG_USBSTRG_BULKINREQLEN - priv->nreqbytes, priv->nsectbytes);
|
||||||
|
|
||||||
/* Copy the data from the sector buffer to the USB request and update counts */
|
/* Copy the data from the sector buffer to the USB request and update counts */
|
||||||
|
|
||||||
@@ -2178,7 +2178,7 @@ static int usbstrg_cmdwritestate(FAR struct usbstrg_dev_s *priv)
|
|||||||
src = &req->buf[xfrd - priv->nreqbytes];
|
src = &req->buf[xfrd - priv->nreqbytes];
|
||||||
dest = &priv->iobuffer[priv->nsectbytes];
|
dest = &priv->iobuffer[priv->nsectbytes];
|
||||||
|
|
||||||
nbytes = min(lun->sectorsize - priv->nsectbytes, priv->nreqbytes);
|
nbytes = MIN(lun->sectorsize - priv->nsectbytes, priv->nreqbytes);
|
||||||
|
|
||||||
/* Copy the data from the sector buffer to the USB request and update counts */
|
/* Copy the data from the sector buffer to the USB request and update counts */
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,50 @@ typedef FAR void (*cdcser_callback_t)(enum cdcser_event_e event);
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_cdcclassobject
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If the CDC serial class driver is part of composite device, then
|
||||||
|
* board-specific logic must provide board_cdcclassobject(). In the simplest
|
||||||
|
* case, board_cdcclassobject() is simply a wrapper around cdcser_classobject()
|
||||||
|
* that provides the correct device minor number.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* classdev - The location to return the CDC serial class' device
|
||||||
|
* instance.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 on success; a negated errno on failure
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_CDCSER_COMPOSITE)
|
||||||
|
EXTERN int board_cdcclassobject(FAR struct usbdevclass_driver_s **classdev);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cdcser_classobject
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register USB serial port (and USB serial console if so configured) and
|
||||||
|
* return the class object.
|
||||||
|
*
|
||||||
|
* Input Parameter:
|
||||||
|
* minor - Device minor number. E.g., minor 0 would correspond to
|
||||||
|
* /dev/ttyUSB0.
|
||||||
|
* classdev - The location to return the CDC serial class' device
|
||||||
|
* instance.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* A pointer to the allocated class object (NULL on failure).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_CDCSER_COMPOSITE)
|
||||||
|
int cdcser_classobject(int minor, FAR struct usbdevclass_driver_s **classdev);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cdcser_initialize
|
* Name: cdcser_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -167,11 +167,13 @@
|
|||||||
|
|
||||||
/* Invoked on USB suspend. */
|
/* Invoked on USB suspend. */
|
||||||
|
|
||||||
#define CLASS_SUSPEND(drvr,dev) (drvr)->ops->suspend ? (drvr)->ops->suspend(dev) : (void)
|
#define CLASS_SUSPEND(drvr,dev) \
|
||||||
|
do { if ((drvr)->ops->suspend) (drvr)->ops->suspend(dev); } while (0)
|
||||||
|
|
||||||
/* Invoked on USB resume */
|
/* Invoked on USB resume */
|
||||||
|
|
||||||
#define CLASS_RESUME(drvr,dev) (drvr)->ops->resume ? (drvr)->ops->resume(dev) : (void)
|
#define CLASS_RESUME(drvr,dev) \
|
||||||
|
do { if ((drvr)->ops->resume) (drvr)->ops->resume(dev); } while (0)
|
||||||
|
|
||||||
/* Device speeds */
|
/* Device speeds */
|
||||||
|
|
||||||
@@ -353,6 +355,33 @@ EXTERN int usbdev_unregister(FAR struct usbdevclass_driver_s *driver);
|
|||||||
|
|
||||||
EXTERN int usbdev_serialinitialize(int minor);
|
EXTERN int usbdev_serialinitialize(int minor);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_mscclassobject
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If the mass storage class driver is part of composite device, then
|
||||||
|
* its instantiation and configuration is a multi-step, board-specific,
|
||||||
|
* process (See comments for usbstrg_configure below). In this case,
|
||||||
|
* board-specific logic must provide board_mscclassobject().
|
||||||
|
*
|
||||||
|
* board_mscclassobject() is called from the composite driver. It must
|
||||||
|
* encapsulate the instantiation and configuration of the mass storage
|
||||||
|
* class and the return the mass storage device's class driver instance
|
||||||
|
* to the composite dirver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* classdev - The location to return the mass storage class' device
|
||||||
|
* instance.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 on success; a negated errno on failure
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_USBSTRG_COMPOSITE)
|
||||||
|
EXTERN int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbstrg_configure
|
* Name: usbstrg_configure
|
||||||
*
|
*
|
||||||
@@ -434,6 +463,24 @@ EXTERN int usbstrg_unbindlun(FAR void *handle, unsigned int lunno);
|
|||||||
|
|
||||||
EXTERN int usbstrg_exportluns(FAR void *handle);
|
EXTERN int usbstrg_exportluns(FAR void *handle);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cdcser_classobject
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* .
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* handle - The handle returned by a previous call to usbstrg_configure().
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 on success; a negated errno on failure
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_USBSTRG_COMPOSITE)
|
||||||
|
EXTERN int usbstrg_classobject(FAR void *handle, FAR struct usbdevclass_driver_s **classdev);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbstrg_uninitialize
|
* Name: usbstrg_uninitialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -225,6 +225,25 @@
|
|||||||
|
|
||||||
/* USB Storage driver class events ******************************************/
|
/* USB Storage driver class events ******************************************/
|
||||||
|
|
||||||
|
#define USBCOMPOSITE_TRACEERR_REQRESULT 0x0001
|
||||||
|
#define USBCOMPOSITE_TRACEERR_ALLOCCTRLREQ 0x0002
|
||||||
|
#define USBCOMPOSITE_TRACEERR_INVALIDARG 0x0003
|
||||||
|
#define USBCOMPOSITE_TRACEERR_EP0NOTBOUND 0x0004
|
||||||
|
#define COMPOSITE_TRACEERR_SETUPINVALIDARGS 0x0005
|
||||||
|
#define COMPOSITE_TRACEERR_EP0NOTBOUND2 0x0006
|
||||||
|
#define COMPOSITE_TRACEERR_GETUNKNOWNDESC 0x0007
|
||||||
|
#define COMPOSITE_TRACEERR_UNSUPPORTEDSTDREQ 0x0008
|
||||||
|
#define COMPOSITE_TRACEERR_EPRESPQ 0x0009
|
||||||
|
#define USBCOMPOSITE_TRACEERR_ALLOCDEVSTRUCT 0x000a
|
||||||
|
#define USBCOMPOSITE_TRACEERR_CLASSOBJECT 0x000b
|
||||||
|
#define USBCOMPOSITE_TRACEERR_DEVREGISTER 0x000c
|
||||||
|
#define USBCOMPOSITE_TRACEERR_INVALIDARG 0x000d
|
||||||
|
#define USBCOMPOSITE_TRACEERR_INVALIDARG 0x000f
|
||||||
|
#define USBCOMPOSITE_TRACEERR_INVALIDARG 0x0010
|
||||||
|
#define USBCOMPOSITE_TRACEERR_INVALIDARG 0x0011
|
||||||
|
|
||||||
|
/* USB Storage driver class events ******************************************/
|
||||||
|
|
||||||
/* State transitions */
|
/* State transitions */
|
||||||
|
|
||||||
#define USBSTRG_CLASSSTATE_IDLECMDPARSE 0x0001
|
#define USBSTRG_CLASSSTATE_IDLECMDPARSE 0x0001
|
||||||
|
|||||||
Reference in New Issue
Block a user