Composite: Final review for coding style before merge
This commit is contained in:
parent
e6af1b9994
commit
28eb253401
@ -213,6 +213,7 @@ static bool cdcuart_txempty(FAR struct uart_dev_s *dev);
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* USB class device *********************************************************/
|
||||
|
||||
static const struct usbdevclass_driverops_s g_driverops =
|
||||
@ -277,7 +278,8 @@ static const struct uart_ops_s g_uartops =
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbuf,
|
||||
static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv,
|
||||
FAR uint8_t *reqbuf,
|
||||
uint16_t reqlen)
|
||||
{
|
||||
FAR uart_dev_t *serdev = &priv->serdev;
|
||||
@ -289,7 +291,9 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Transfer bytes while we have bytes available and there is room in the request */
|
||||
/* Transfer bytes while we have bytes available and there is room in the
|
||||
* request.
|
||||
*/
|
||||
|
||||
while (xmit->head != xmit->tail && nbytes < reqlen)
|
||||
{
|
||||
@ -304,8 +308,8 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
||||
}
|
||||
}
|
||||
|
||||
/* When all of the characters have been sent from the buffer
|
||||
* disable the "TX interrupt".
|
||||
/* When all of the characters have been sent from the buffer disable the
|
||||
* "TX interrupt".
|
||||
*/
|
||||
|
||||
if (xmit->head == xmit->tail)
|
||||
@ -313,8 +317,8 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
||||
uart_disabletxint(serdev);
|
||||
}
|
||||
|
||||
/* If any bytes were removed from the buffer, inform any waiters
|
||||
* there there is space available.
|
||||
/* If any bytes were removed from the buffer, inform any waiters that
|
||||
* there is space available.
|
||||
*/
|
||||
|
||||
if (nbytes)
|
||||
@ -331,9 +335,9 @@ static uint16_t cdcacm_fillrequest(FAR struct cdcacm_dev_s *priv, uint8_t *reqbu
|
||||
*
|
||||
* Description:
|
||||
* This function obtains write requests, transfers the TX data into the
|
||||
* request, and submits the requests to the USB controller. This continues
|
||||
* until either (1) there are no further packets available, or (2) there is
|
||||
* no further data to send.
|
||||
* request, and submits the requests to the USB controller. This
|
||||
* continues until either (1) there are no further packets available, or
|
||||
* (2) there is no further data to send.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -361,9 +365,9 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
|
||||
ep = priv->epbulkin;
|
||||
|
||||
/* Loop until either (1) we run out or write requests, or (2) cdcacm_fillrequest()
|
||||
* is unable to fill the request with data (i.e., until there is no more data
|
||||
* to be sent).
|
||||
/* Loop until either (1) we run out or write requests, or (2)
|
||||
* cdcacm_fillrequest() is unable to fill the request with data (i.e.,
|
||||
* until there is no more data to be sent).
|
||||
*/
|
||||
|
||||
uinfo("head=%d tail=%d nwrq=%d empty=%d\n",
|
||||
@ -427,7 +431,7 @@ static int cdcacm_sndpacket(FAR struct cdcacm_dev_s *priv)
|
||||
****************************************************************************/
|
||||
|
||||
static inline int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
uint8_t *reqbuf, uint16_t reqlen)
|
||||
FAR uint8_t *reqbuf, uint16_t reqlen)
|
||||
{
|
||||
FAR uart_dev_t *serdev = &priv->serdev;
|
||||
FAR struct uart_buffer_s *recv = &serdev->recv;
|
||||
@ -438,11 +442,12 @@ static inline int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
uinfo("head=%d tail=%d nrdq=%d reqlen=%d\n",
|
||||
priv->serdev.recv.head, priv->serdev.recv.tail, priv->nrdq, reqlen);
|
||||
|
||||
/* Get the next head index. During the time that RX interrupts are disabled, the
|
||||
* the serial driver will be extracting data from the circular buffer and modifying
|
||||
* recv.tail. During this time, we should avoid modifying recv.head; Instead we will
|
||||
* use a shadow copy of the index. When interrupts are restored, the real recv.head
|
||||
* will be updated with this index.
|
||||
/* Get the next head index. During the time that RX interrupts are
|
||||
* disabled, the the serial driver will be extracting data from the
|
||||
* circular buffer and modifying recv.tail. During this time, we should
|
||||
* avoid modifying recv.head; Instead we will use a shadow copy of the
|
||||
* index. When interrupts are restored, the real recv.head will be
|
||||
* updated with this index.
|
||||
*/
|
||||
|
||||
if (priv->rxenabled)
|
||||
@ -454,9 +459,9 @@ static inline int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
currhead = priv->rxhead;
|
||||
}
|
||||
|
||||
/* Pre-calculate the head index and check for wrap around. We need to do this
|
||||
* so that we can determine if the circular buffer will overrun BEFORE we
|
||||
* overrun the buffer!
|
||||
/* Pre-calculate the head index and check for wrap around. We need to do
|
||||
* this so that we can determine if the circular buffer will overrun
|
||||
* BEFORE we overrun the buffer!
|
||||
*/
|
||||
|
||||
nexthead = currhead + 1;
|
||||
@ -465,17 +470,17 @@ static inline int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
nexthead = 0;
|
||||
}
|
||||
|
||||
/* Then copy data into the RX buffer until either: (1) all of the data has been
|
||||
* copied, or (2) the RX buffer is full.
|
||||
/* Then copy data into the RX buffer until either: (1) all of the data has
|
||||
* been copied, or (2) the RX buffer is full.
|
||||
*
|
||||
* NOTE: If the RX buffer becomes full, then we have overrun the serial driver
|
||||
* and data will be lost. This is the correct behavior for a proper emulation
|
||||
* of a serial link. It should not NAK, it should drop data like a physical
|
||||
* serial port.
|
||||
* NOTE: If the RX buffer becomes full, then we have overrun the serial
|
||||
* driver and data will be lost. This is the correct behavior for a
|
||||
* proper emulation of a serial link. It should not NAK, it should drop
|
||||
* data like a physical serial port.
|
||||
*
|
||||
* If you don't like that behavior. DO NOT change it here. Instead, you should
|
||||
* finish the implementation of RX flow control which is the only proper way
|
||||
* to throttle a serial device.
|
||||
* If you don't like that behavior. DO NOT change it here. Instead, you
|
||||
* should finish the implementation of RX flow control which is the only
|
||||
* proper way to throttle a serial device.
|
||||
*/
|
||||
|
||||
while (nexthead != recv->tail && nbytes < reqlen)
|
||||
@ -529,6 +534,7 @@ static inline int cdcacm_recvpacket(FAR struct cdcacm_dev_s *priv,
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RXOVERRUN), 0);
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -577,6 +583,7 @@ static void cdcacm_freereq(FAR struct usbdev_ep_s *ep,
|
||||
{
|
||||
EP_FREEBUFFER(ep, req->buf);
|
||||
}
|
||||
|
||||
EP_FREEREQ(ep, req);
|
||||
}
|
||||
}
|
||||
@ -765,7 +772,8 @@ static int cdcacm_setconfig(FAR struct cdcacm_dev_s *priv, uint8_t config)
|
||||
ret = EP_SUBMIT(priv->epbulkout, req);
|
||||
if (ret != OK)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT),
|
||||
(uint16_t)-ret);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@ -853,7 +861,8 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
return;
|
||||
|
||||
default: /* Some other error occurred */
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED),
|
||||
(uint16_t)-req->result);
|
||||
break;
|
||||
};
|
||||
|
||||
@ -863,7 +872,8 @@ static void cdcacm_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
ret = EP_SUBMIT(ep, req);
|
||||
if (ret != OK)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT),
|
||||
(uint16_t)-req->result);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
@ -928,7 +938,8 @@ static void cdcacm_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
|
||||
default: /* Some other error occurred */
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16_t)-req->result);
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED),
|
||||
(uint16_t)-req->result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1209,6 +1220,7 @@ static void cdcacm_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
flags = enter_critical_section();
|
||||
DEBUGASSERT(priv->nwrq == CONFIG_CDCACM_NWRREQS);
|
||||
|
||||
while (!sq_empty(&priv->reqlist))
|
||||
{
|
||||
reqcontainer = (struct cdcacm_req_s *)sq_remfirst(&priv->reqlist);
|
||||
@ -1278,6 +1290,7 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
ctrlreq = priv->ctrlreq;
|
||||
|
||||
/* Extract the little-endian 16-bit values to host order */
|
||||
@ -1291,23 +1304,24 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_STANDARD)
|
||||
{
|
||||
/***********************************************************************
|
||||
/**********************************************************************
|
||||
* Standard Requests
|
||||
***********************************************************************/
|
||||
**********************************************************************/
|
||||
|
||||
switch (ctrl->req)
|
||||
{
|
||||
case USB_REQ_GETDESCRIPTOR:
|
||||
{
|
||||
/* The value field specifies the descriptor type in the MS byte and the
|
||||
* descriptor index in the LS byte (order is little endian)
|
||||
/* The value field specifies the descriptor type in the MS byte
|
||||
* and the descriptor index in the LS byte (order is little
|
||||
* endian)
|
||||
*/
|
||||
|
||||
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.
|
||||
/* 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_CDCACM_COMPOSITE
|
||||
@ -1319,9 +1333,9 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
break;
|
||||
#endif
|
||||
|
||||
/* 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 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_CDCACM_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
@ -1335,16 +1349,17 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
case USB_DESC_TYPE_OTHERSPEEDCONFIG:
|
||||
#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.
|
||||
/* 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_CDCACM_COMPOSITE
|
||||
case USB_DESC_TYPE_CONFIG:
|
||||
{
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
ret = cdcacm_mkcfgdesc(ctrlreq->buf, dev->speed, ctrl->req);
|
||||
ret = cdcacm_mkcfgdesc(ctrlreq->buf, dev->speed,
|
||||
ctrl->req);
|
||||
#else
|
||||
ret = cdcacm_mkcfgdesc(ctrlreq->buf, 0);
|
||||
#endif
|
||||
@ -1352,9 +1367,9 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
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.
|
||||
/* 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_CDCACM_COMPOSITE
|
||||
@ -1362,7 +1377,10 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
{
|
||||
/* index == language code. */
|
||||
|
||||
ret = cdcacm_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
|
||||
ret =
|
||||
cdcacm_mkstrdesc(ctrl->value[0],
|
||||
(FAR struct usb_strdesc_s *)
|
||||
ctrlreq->buf);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@ -1449,14 +1467,14 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
else if ((ctrl->type & USB_REQ_TYPE_MASK) == USB_REQ_TYPE_CLASS)
|
||||
{
|
||||
/***********************************************************************
|
||||
/**********************************************************************
|
||||
* CDC ACM-Specific Requests
|
||||
***********************************************************************/
|
||||
**********************************************************************/
|
||||
|
||||
switch (ctrl->req)
|
||||
{
|
||||
/* ACM_GET_LINE_CODING requests current DTE rate, stop-bits, parity, and
|
||||
* number-of-character bits. (Optional)
|
||||
/* ACM_GET_LINE_CODING requests current DTE rate, stop-bits, parity,
|
||||
* and number-of-character bits. (Optional)
|
||||
*/
|
||||
|
||||
case ACM_GET_LINE_CODING:
|
||||
@ -1464,9 +1482,12 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
if (ctrl->type == (USB_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_RECIPIENT_INTERFACE) &&
|
||||
index == priv->devdesc.ifnobase)
|
||||
{
|
||||
/* Return the current line status from the private data structure */
|
||||
/* Return the current line status from the private data
|
||||
* structure.
|
||||
*/
|
||||
|
||||
memcpy(ctrlreq->buf, &priv->linecoding, SIZEOF_CDC_LINECODING);
|
||||
memcpy(ctrlreq->buf, &priv->linecoding,
|
||||
SIZEOF_CDC_LINECODING);
|
||||
ret = SIZEOF_CDC_LINECODING;
|
||||
}
|
||||
else
|
||||
@ -1487,10 +1508,10 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
len == SIZEOF_CDC_LINECODING && /* dataout && len == outlen && */
|
||||
index == priv->devdesc.ifnobase)
|
||||
{
|
||||
/* Save the new line coding in the private data structure. NOTE:
|
||||
* that this is conditional now because not all device controller
|
||||
* drivers supported provision of EP0 OUT data with the setup
|
||||
* command.
|
||||
/* Save the new line coding in the private data structure.
|
||||
* NOTE: that this is conditional now because not all device
|
||||
* controller drivers supported provision of EP0 OUT data
|
||||
* with the setup command.
|
||||
*/
|
||||
|
||||
if (dataout && len <= SIZEOF_CDC_LINECODING) /* REVISIT */
|
||||
@ -1502,8 +1523,8 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
ret = 0;
|
||||
|
||||
/* If there is a registered callback to receive line status info, then
|
||||
* callout now.
|
||||
/* If there is a registered callback to receive line status
|
||||
* info, then callout now.
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
@ -1518,8 +1539,8 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
break;
|
||||
|
||||
/* ACM_SET_CTRL_LINE_STATE: RS-232 signal used to tell the DCE device the
|
||||
* DTE device is now present. (Optional)
|
||||
/* ACM_SET_CTRL_LINE_STATE: RS-232 signal used to tell the DCE
|
||||
* device the DTE device is now present. (Optional)
|
||||
*/
|
||||
|
||||
case ACM_SET_CTRL_LINE_STATE:
|
||||
@ -1527,15 +1548,16 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
if (ctrl->type == (USB_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_RECIPIENT_INTERFACE) &&
|
||||
index == priv->devdesc.ifnobase)
|
||||
{
|
||||
/* Save the control line state in the private data structure. Only bits
|
||||
* 0 and 1 have meaning. Respond with a zero length packet.
|
||||
/* Save the control line state in the private data
|
||||
* structure. Only bits 0 and 1 have meaning. Respond with
|
||||
* a zero length packet.
|
||||
*/
|
||||
|
||||
priv->ctrlline = value & 3;
|
||||
ret = 0;
|
||||
|
||||
/* If there is a registered callback to receive control line status info,
|
||||
* then callout now.
|
||||
/* If there is a registered callback to receive control line
|
||||
* status info, then callout now.
|
||||
*/
|
||||
|
||||
if (priv->callback)
|
||||
@ -1557,8 +1579,9 @@ static int cdcacm_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
if (ctrl->type == (USB_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_RECIPIENT_INTERFACE) &&
|
||||
index == priv->devdesc.ifnobase)
|
||||
{
|
||||
/* If there is a registered callback to handle the SendBreak request,
|
||||
* then callout now. Respond with a zero length packet.
|
||||
/* If there is a registered callback to handle the SendBreak
|
||||
* request, then callout now. Respond with a zero length
|
||||
* packet.
|
||||
*/
|
||||
|
||||
ret = 0;
|
||||
@ -1931,9 +1954,9 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
/* CAIOC_NOTIFY
|
||||
* Send a serial state to the host via the Interrupt IN endpoint.
|
||||
* Argument: int. This includes the current state of the carrier detect,
|
||||
* DSR, break, and ring signal. See "Table 69: UART State Bitmap Values"
|
||||
* and CDC_UART_definitions in include/nuttx/usb/cdc.h.
|
||||
* Argument: int. This includes the current state of the carrier
|
||||
* detect, DSR, break, and ring signal. See "Table 69: UART State
|
||||
* Bitmap Values" and CDC_UART_definitions in include/nuttx/usb/cdc.h.
|
||||
*/
|
||||
|
||||
case CAIOC_NOTIFY:
|
||||
@ -1946,7 +1969,8 @@ static int cdcuart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
* 1. Format and send a request header with:
|
||||
*
|
||||
* bmRequestType:
|
||||
* USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_RECIPIENT_INTERFACE
|
||||
* USB_REQ_DIR_IN | USB_REQ_TYPE_CLASS |
|
||||
* USB_REQ_RECIPIENT_INTERFACE
|
||||
* bRequest: ACM_SERIAL_STATE
|
||||
* wValue: 0
|
||||
* wIndex: 0
|
||||
@ -2175,6 +2199,7 @@ static void cdcuart_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||
priv->rxhead = serdev->recv.head;
|
||||
priv->rxenabled = false;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
@ -2332,7 +2357,9 @@ int cdcacm_classobject(int minor, FAR struct usbdev_description_s *devdesc,
|
||||
|
||||
/* Allocate the structures needed */
|
||||
|
||||
alloc = (FAR struct cdcacm_alloc_s *)kmm_malloc(sizeof(struct cdcacm_alloc_s));
|
||||
alloc = (FAR struct cdcacm_alloc_s *)
|
||||
kmm_malloc(sizeof(struct cdcacm_alloc_s));
|
||||
|
||||
if (!alloc)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCDEVSTRUCT), 0);
|
||||
@ -2380,12 +2407,12 @@ int cdcacm_classobject(int minor, FAR struct usbdev_description_s *devdesc,
|
||||
/* Initialize the USB class driver structure */
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
drvr->drvr.speed = USB_SPEED_HIGH;
|
||||
drvr->drvr.speed = USB_SPEED_HIGH;
|
||||
#else
|
||||
drvr->drvr.speed = USB_SPEED_FULL;
|
||||
drvr->drvr.speed = USB_SPEED_FULL;
|
||||
#endif
|
||||
drvr->drvr.ops = &g_driverops;
|
||||
drvr->dev = priv;
|
||||
drvr->drvr.ops = &g_driverops;
|
||||
drvr->dev = priv;
|
||||
|
||||
/* Register the USB serial console */
|
||||
|
||||
|
@ -267,10 +267,12 @@ int cdcacm_copy_epdesc(enum cdcacm_epdesc_e epid,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf, struct usbdev_description_s *devdesc,
|
||||
uint8_t speed, uint8_t type);
|
||||
int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf,
|
||||
FAR struct usbdev_description_s *devdesc,
|
||||
uint8_t speed, uint8_t type);
|
||||
#else
|
||||
int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf, struct usbdev_description_s *devdesc);
|
||||
int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf,
|
||||
FAR struct usbdev_description_s *devdesc);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -60,7 +60,6 @@
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/* The internal version of the class driver */
|
||||
|
||||
struct composite_driver_s
|
||||
@ -113,6 +112,7 @@ static void composite_resume(FAR struct usbdevclass_driver_s *driver,
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* USB class device *********************************************************/
|
||||
|
||||
static const struct usbdevclass_driverops_s g_driverops =
|
||||
@ -257,7 +257,9 @@ static void composite_freereq(FAR struct usbdev_ep_s *ep,
|
||||
static int composite_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
FAR struct usbdev_s *dev)
|
||||
{
|
||||
FAR struct composite_dev_s *priv = ((FAR struct composite_driver_s *)driver)->dev;
|
||||
FAR struct composite_dev_s *priv =
|
||||
((FAR struct composite_driver_s *)driver)->dev;
|
||||
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
@ -591,10 +593,9 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to the setup command if (1) data was returned, and (2) the request was
|
||||
* NOT successfully dispatched to the component class driver. On an error return
|
||||
* value (ret < 0), the USB driver will stall EP0.
|
||||
/* Respond to the setup command if (1) data was returned, and (2) the
|
||||
* request was NOT successfully dispatched to the component class driver.
|
||||
* On an error return value (ret < 0), the USB driver will stall EP0.
|
||||
*/
|
||||
|
||||
if (ret >= 0 && !dispatched)
|
||||
@ -839,9 +840,10 @@ FAR void *composite_initialize(uint8_t ndevices,
|
||||
memcpy(&priv->device[i].compdesc, &pdevices[i],
|
||||
sizeof(struct composite_devdesc_s));
|
||||
|
||||
ret = priv->device[i].compdesc.classobject(priv->device[i].compdesc.minor,
|
||||
&priv->device[i].compdesc.devdesc,
|
||||
&priv->device[i].dev);
|
||||
ret =
|
||||
priv->device[i].compdesc.classobject(priv->device[i].compdesc.minor,
|
||||
&priv->device[i].compdesc.devdesc,
|
||||
&priv->device[i].dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_CLASSOBJECT),
|
||||
|
@ -63,6 +63,7 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
/* Packet sizes */
|
||||
|
||||
@ -107,13 +108,13 @@
|
||||
#ifdef CONFIG_USBDEV_SELFPOWERED
|
||||
# define COMPOSITE_SELFPOWERED USB_CONFIG_ATTR_SELFPOWER
|
||||
#else
|
||||
# define COMPOSITE_SELFPOWERED (0)
|
||||
# define COMPOSITE_SELFPOWERED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBDEV_REMOTEWAKEUP
|
||||
# define COMPOSITE_REMOTEWAKEUP USB_CONFIG_ATTR_WAKEUP
|
||||
#else
|
||||
# define COMPOSITE_REMOTEWAKEUP (0)
|
||||
# define COMPOSITE_REMOTEWAKEUP (0)
|
||||
#endif
|
||||
|
||||
#define NUM_DEVICES_TO_HANDLE (4)
|
||||
@ -162,7 +163,6 @@ struct composite_devobj_s
|
||||
FAR struct usbdevclass_driver_s *dev;
|
||||
};
|
||||
|
||||
|
||||
/* This structure describes the internal state of the driver */
|
||||
|
||||
struct composite_dev_s
|
||||
@ -170,7 +170,7 @@ struct composite_dev_s
|
||||
FAR struct usbdev_s *usbdev; /* usbdev driver pointer */
|
||||
uint8_t config; /* Configuration number */
|
||||
FAR struct usbdev_req_s *ctrlreq; /* Allocated control request */
|
||||
uint8_t ndevices; /* num devices in this composite device */
|
||||
uint8_t ndevices; /* Num devices in this composite device */
|
||||
int cfgdescsize; /* Total size of the configuration descriptor: */
|
||||
int ninterfaces; /* The total number of interfaces in this composite device */
|
||||
|
||||
@ -220,10 +220,11 @@ FAR const struct usb_devdesc_s *composite_getdevdesc(void);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, uint8_t *buf,
|
||||
uint8_t speed, uint8_t type);
|
||||
int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv,
|
||||
FAR uint8_t *buf, uint8_t speed, uint8_t type);
|
||||
#else
|
||||
int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, uint8_t *buf);
|
||||
int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv,
|
||||
FAR uint8_t *buf);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -246,6 +246,7 @@ static void usbmsc_freereq(FAR struct usbdev_ep_s *ep, struct usbdev_req_s *req)
|
||||
/****************************************************************************
|
||||
* Class Driver Interfaces
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_bind
|
||||
*
|
||||
@ -267,7 +268,7 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
/* Bind the structures */
|
||||
|
||||
priv->usbdev = dev;
|
||||
priv->usbdev = dev;
|
||||
|
||||
/* Save the reference to our private data structure in EP0 so that it
|
||||
* can be recovered in ep0 completion events (Unless we are part of
|
||||
@ -355,7 +356,8 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
for (i = 0; i < CONFIG_USBMSC_NWRREQS; i++)
|
||||
{
|
||||
reqcontainer = &priv->wrreqs[i];
|
||||
reqcontainer->req = usbmsc_allocreq(priv->epbulkin, CONFIG_USBMSC_BULKINREQLEN);
|
||||
reqcontainer->req = usbmsc_allocreq(priv->epbulkin,
|
||||
CONFIG_USBMSC_BULKINREQLEN);
|
||||
if (reqcontainer->req == NULL)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_WRALLOCREQ),
|
||||
@ -487,7 +489,9 @@ static void usbmsc_unbind(FAR struct usbdevclass_driver_s *driver,
|
||||
flags = enter_critical_section();
|
||||
while (!sq_empty(&priv->wrreqlist))
|
||||
{
|
||||
reqcontainer = (struct usbmsc_req_s *)sq_remfirst(&priv->wrreqlist);
|
||||
reqcontainer = (struct usbmsc_req_s *)
|
||||
sq_remfirst(&priv->wrreqlist);
|
||||
|
||||
if (reqcontainer->req != NULL)
|
||||
{
|
||||
usbmsc_freereq(priv->epbulkin, reqcontainer->req);
|
||||
@ -574,9 +578,9 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
|
||||
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.
|
||||
/* 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_USBMSC_COMPOSITE
|
||||
@ -588,9 +592,9 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
break;
|
||||
#endif
|
||||
|
||||
/* 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 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_USBMSC_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
@ -613,7 +617,8 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
case USB_DESC_TYPE_CONFIG:
|
||||
{
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
ret = usbmsc_mkcfgdesc(ctrlreq->buf, dev->speed, ctrl->value[1]);
|
||||
ret = usbmsc_mkcfgdesc(ctrlreq->buf, dev->speed,
|
||||
ctrl->value[1]);
|
||||
#else
|
||||
ret = usbmsc_mkcfgdesc(ctrlreq->buf);
|
||||
#endif
|
||||
@ -621,9 +626,9 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
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.
|
||||
/* 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_USBMSC_COMPOSITE
|
||||
@ -631,7 +636,8 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
{
|
||||
/* index == language code. */
|
||||
|
||||
ret = usbmsc_mkstrdesc(ctrl->value[0], (struct usb_strdesc_s *)ctrlreq->buf);
|
||||
ret = usbmsc_mkstrdesc(ctrl->value[0],
|
||||
(struct usb_strdesc_s *)ctrlreq->buf);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@ -649,7 +655,9 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
{
|
||||
if (ctrl->type == 0)
|
||||
{
|
||||
/* Signal the worker thread to instantiate the new configuration */
|
||||
/* Signal the worker thread to instantiate the new
|
||||
* configuration.
|
||||
*/
|
||||
|
||||
priv->theventset |= USBMSC_EVENT_CFGCHANGE;
|
||||
priv->thvalue = value;
|
||||
@ -664,9 +672,9 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
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.
|
||||
/* 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_USBMSC_COMPOSITE
|
||||
@ -694,8 +702,8 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
priv->theventset |= USBMSC_EVENT_IFCHANGE;
|
||||
usbmsc_scsi_signal(priv);
|
||||
|
||||
/* Return here... the response will be provided later by the
|
||||
* worker thread.
|
||||
/* Return here... the response will be provided later by
|
||||
* the worker thread.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
@ -756,13 +764,15 @@ static int usbmsc_setup(FAR struct usbdevclass_driver_s *driver,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Signal to stop the current operation and reinitialize state */
|
||||
/* Signal to stop the current operation and reinitialize
|
||||
* state.
|
||||
*/
|
||||
|
||||
priv->theventset |= USBMSC_EVENT_RESET;
|
||||
usbmsc_scsi_signal(priv);
|
||||
|
||||
/* Return here... the response will be provided later by the
|
||||
* worker thread.
|
||||
/* Return here... the response will be provided later by
|
||||
* the worker thread.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
@ -896,6 +906,7 @@ static void usbmsc_disconnect(FAR struct usbdevclass_driver_s *driver,
|
||||
/****************************************************************************
|
||||
* Initialization/Un-Initialization
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_lununinitialize
|
||||
****************************************************************************/
|
||||
@ -917,6 +928,7 @@ static void usbmsc_lununinitialize(struct usbmsc_lun_s *lun)
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Internal Interfaces
|
||||
****************************************************************************/
|
||||
@ -1018,7 +1030,8 @@ int usbmsc_setconfig(FAR struct usbmsc_dev_s *priv, uint8_t config)
|
||||
ret = EP_SUBMIT(priv->epbulkout, req);
|
||||
if (ret < 0)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_RDSUBMIT), (uint16_t)-ret);
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_RDSUBMIT),
|
||||
(uint16_t)-ret);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
@ -1067,7 +1080,8 @@ void usbmsc_resetconfig(FAR struct usbmsc_dev_s *priv)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbmsc_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req)
|
||||
void usbmsc_wrcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
FAR struct usbmsc_dev_s *priv;
|
||||
FAR struct usbmsc_req_s *privreq;
|
||||
@ -1127,7 +1141,8 @@ void usbmsc_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbmsc_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req)
|
||||
void usbmsc_rdcomplete(FAR struct usbdev_ep_s *ep,
|
||||
FAR struct usbdev_req_s *req)
|
||||
{
|
||||
FAR struct usbmsc_dev_s *priv;
|
||||
FAR struct usbmsc_req_s *privreq;
|
||||
@ -1290,6 +1305,7 @@ static inline void usbmsc_sync_wait(FAR struct usbmsc_dev_s *priv)
|
||||
/****************************************************************************
|
||||
* User Interfaces
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_configure
|
||||
*
|
||||
@ -1494,10 +1510,10 @@ int usbmsc_bindlun(FAR void *handle, FAR const char *drvrpath,
|
||||
|
||||
memset(lun, 0, sizeof(struct usbmsc_lun_s));
|
||||
|
||||
/* Allocate an I/O buffer big enough to hold one hardware sector. SCSI commands
|
||||
* are processed one at a time so all LUNs may share a single I/O buffer. The
|
||||
* I/O buffer will be allocated so that is it as large as the largest block
|
||||
* device sector size
|
||||
/* Allocate an I/O buffer big enough to hold one hardware sector. SCSI
|
||||
* commands are processed one at a time so all LUNs may share a single I/O
|
||||
* buffer. The I/O buffer will be allocated so that is it as large as the
|
||||
* largest block device sector size
|
||||
*/
|
||||
|
||||
if (!priv->iobuffer)
|
||||
@ -1513,8 +1529,9 @@ int usbmsc_bindlun(FAR void *handle, FAR const char *drvrpath,
|
||||
}
|
||||
else if (priv->iosize < geo.geo_sectorsize)
|
||||
{
|
||||
void *tmp;
|
||||
tmp = (FAR uint8_t *)kmm_realloc(priv->iobuffer, geo.geo_sectorsize);
|
||||
FAR void *tmp;
|
||||
|
||||
tmp = (FAR void *)kmm_realloc(priv->iobuffer, geo.geo_sectorsize);
|
||||
if (!tmp)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_REALLOCIOBUFFER), geo.geo_sectorsize);
|
||||
@ -1669,7 +1686,8 @@ int usbmsc_exportluns(FAR void *handle)
|
||||
usbmsc_scsi_main, NULL);
|
||||
if (priv->thpid <= 0)
|
||||
{
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_THREADCREATE), (uint16_t)errno);
|
||||
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_THREADCREATE),
|
||||
(uint16_t)errno);
|
||||
goto errout_with_lock;
|
||||
}
|
||||
|
||||
@ -1720,7 +1738,7 @@ errout_with_lock:
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
int usbmsc_classobject(FAR void *handle,
|
||||
FAR struct usbdev_description_s *devdesc,
|
||||
FAR struct usbdev_description_s *devdesc,
|
||||
FAR struct usbdevclass_driver_s **classdev)
|
||||
{
|
||||
FAR struct usbmsc_alloc_s *alloc = (FAR struct usbmsc_alloc_s *)handle;
|
||||
@ -1767,9 +1785,6 @@ void usbmsc_uninitialize(FAR void *handle)
|
||||
FAR struct usbmsc_alloc_s *alloc = (FAR struct usbmsc_alloc_s *)handle;
|
||||
FAR struct usbmsc_dev_s *priv;
|
||||
irqstate_t flags;
|
||||
#if 0
|
||||
void *value;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
|
@ -57,6 +57,7 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
/* If the USB mass storage device is configured as part of a composite device
|
||||
* then both CONFIG_USBDEV_COMPOSITE and CONFIG_USBMSC_COMPOSITE must be
|
||||
@ -339,9 +340,12 @@
|
||||
|
||||
/* Block driver helpers *****************************************************/
|
||||
|
||||
#define USBMSC_DRVR_READ(l,b,s,n) ((l)->inode->u.i_bops->read((l)->inode,b,s,n))
|
||||
#define USBMSC_DRVR_WRITE(l,b,s,n) ((l)->inode->u.i_bops->write((l)->inode,b,s,n))
|
||||
#define USBMSC_DRVR_GEOMETRY(l,g) ((l)->inode->u.i_bops->geometry((l)->inode,g))
|
||||
#define USBMSC_DRVR_READ(l,b,s,n) \
|
||||
((l)->inode->u.i_bops->read((l)->inode,b,s,n))
|
||||
#define USBMSC_DRVR_WRITE(l,b,s,n) \
|
||||
((l)->inode->u.i_bops->write((l)->inode,b,s,n))
|
||||
#define USBMSC_DRVR_GEOMETRY(l,g) \
|
||||
((l)->inode->u.i_bops->geometry((l)->inode,g))
|
||||
|
||||
/* Everpresent MIN/MAX macros ***********************************************/
|
||||
|
||||
@ -376,7 +380,7 @@ struct usbmsc_req_s
|
||||
|
||||
struct usbmsc_lun_s
|
||||
{
|
||||
struct inode *inode; /* Inode structure of open'ed block driver */
|
||||
FAR struct inode *inode; /* Inode structure of open'ed block driver */
|
||||
uint8_t readonly:1; /* Media is read-only */
|
||||
uint8_t locked:1; /* Media removal is prevented */
|
||||
uint16_t sectorsize; /* The size of one sector */
|
||||
@ -495,11 +499,11 @@ EXTERN const char g_compserialstr[];
|
||||
|
||||
EXTERN FAR struct usbmsc_dev_s *g_usbmsc_handoff;
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_scsi_lock
|
||||
*
|
||||
* Description:
|
||||
@ -509,54 +513,54 @@ EXTERN FAR struct usbmsc_dev_s *g_usbmsc_handoff;
|
||||
|
||||
void usbmsc_scsi_lock(FAR struct usbmsc_dev_s *priv);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_scsi_unlock
|
||||
*
|
||||
* Description:
|
||||
* Relinquish exclusive access to SCSI state data.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#define usbmsc_scsi_unlock(priv) sem_post(&priv->thlock)
|
||||
|
||||
/************************************************************************************
|
||||
/*****************************************************************************
|
||||
* Name: usbmsc_scsi_signal
|
||||
*
|
||||
* Description:
|
||||
* Signal the SCSI worker thread that SCSI events need service.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void usbmsc_scsi_signal(FAR struct usbmsc_dev_s *priv);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_synch_signal
|
||||
*
|
||||
* Description:
|
||||
* ACK controlling tasks request for synchronization.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#define usbmsc_synch_signal(priv) sem_post(&priv->thsynch)
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_mkstrdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct a string descriptor
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
struct usb_strdesc_s;
|
||||
int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_getdevdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw device descriptor
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_USBMSC_COMPOSITE
|
||||
FAR const struct usb_devdesc_s *usbmsc_getdevdesc(void);
|
||||
@ -576,13 +580,13 @@ int usbmsc_copy_epdesc(enum usbmsc_epdesc_e epid,
|
||||
FAR struct usbdev_description_s *devdesc,
|
||||
bool hispeed);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_mkcfgdesc
|
||||
*
|
||||
* Description:
|
||||
* Construct the configuration descriptor
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_DUALSPEED
|
||||
int16_t usbmsc_mkcfgdesc(FAR uint8_t *buf, FAR struct usbdev_description_s *devdesc,
|
||||
@ -591,13 +595,13 @@ int16_t usbmsc_mkcfgdesc(FAR uint8_t *buf, FAR struct usbdev_description_s *devd
|
||||
int16_t usbmsc_mkcfgdesc(FAR uint8_t *buf, FAR struct usbdev_description_s *devdesc);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_getqualdesc
|
||||
*
|
||||
* Description:
|
||||
* Return a pointer to the raw qual descriptor
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_USBMSC_COMPOSITE) && defined(CONFIG_USBDEV_DUALSPEED)
|
||||
FAR const struct usb_qualdesc_s *usbmsc_getqualdesc(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* include/nuttx/usb/usbmsc.h
|
||||
*
|
||||
* Copyright (C) 2008-2010, 2012, 2017 Gregory Nutt. All rights reserved.
|
||||
@ -37,14 +37,14 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_USB_USBMSC_H
|
||||
#define __INCLUDE_NUTTX_USB_USBMSC_H
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -52,28 +52,28 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/* Informations about the device needed in usbdev_description_s */
|
||||
|
||||
#define USBMSC_CONFIGID (1) /* The only supported configuration ID */
|
||||
#define USBMSC_NENDPOINTS (2) /* Number of endpoints in the interface */
|
||||
#define USBMSC_CONFIGID (1) /* The only supported configuration ID */
|
||||
#define USBMSC_NENDPOINTS (2) /* Number of endpoints in the interface */
|
||||
|
||||
#define USBMSC_EP_BULKIN_IDX (0)
|
||||
#define USBMSC_EP_BULKOUT_IDX (1)
|
||||
#define USBMSC_EP_BULKIN_IDX (0)
|
||||
#define USBMSC_EP_BULKOUT_IDX (1)
|
||||
|
||||
#define USBMSC_NCONFIGS (1) /* Number of configurations supported */
|
||||
#define USBMSC_NINTERFACES (1) /* Number of interfaces in the configuration */
|
||||
#define USBMSC_NCONFIGS (1) /* Number of configurations supported */
|
||||
#define USBMSC_NINTERFACES (1) /* Number of interfaces in the configuration */
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
@ -84,11 +84,11 @@ extern "C"
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_configure
|
||||
*
|
||||
* Description:
|
||||
@ -108,18 +108,19 @@ extern "C"
|
||||
* 0 on success; a negated errno on failure. The returned handle value is
|
||||
* an untyped equivalent to the usbmsc_classobject().
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
int usbmsc_configure(unsigned int nluns, FAR void **handle);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_bindlun
|
||||
*
|
||||
* Description:
|
||||
* Bind the block driver specified by drvrpath to a USB storage LUN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle returned by a previous call to usbmsc_configure().
|
||||
* handle - The handle returned by a previous call to
|
||||
* usbmsc_configure().
|
||||
* drvrpath - the full path to the block driver
|
||||
* startsector - A sector offset into the block driver to the start of the
|
||||
* partition on drvrpath (0 if no partitions)
|
||||
@ -130,12 +131,12 @@ int usbmsc_configure(unsigned int nluns, FAR void **handle);
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
int usbmsc_bindlun(FAR void *handle, FAR const char *drvrpath, unsigned int lunno,
|
||||
off_t startsector, size_t nsectors, bool readonly);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_unbindlun
|
||||
*
|
||||
* Description:
|
||||
@ -148,16 +149,16 @@ int usbmsc_bindlun(FAR void *handle, FAR const char *drvrpath, unsigned int lunn
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
int usbmsc_unbindlun(FAR void *handle, unsigned int lunno);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_exportluns
|
||||
*
|
||||
* Description:
|
||||
* After all of the LUNs have been bound, this function may be called in order to
|
||||
* export those LUNs in the USB storage device.
|
||||
* After all of the LUNs have been bound, this function may be called in
|
||||
* order to export those LUNs in the USB storage device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle returned by a previous call to usbmsc_configure().
|
||||
@ -165,13 +166,13 @@ int usbmsc_unbindlun(FAR void *handle, unsigned int lunno);
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_USBDEV_COMPOSITE) || !defined(CONFIG_USBMSC_COMPOSITE)
|
||||
int usbmsc_exportluns(FAR void *handle);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_classobject
|
||||
*
|
||||
* Description:
|
||||
@ -184,7 +185,7 @@ int usbmsc_exportluns(FAR void *handle);
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_USBMSC_COMPOSITE)
|
||||
struct usbdevclass_driver_s;
|
||||
@ -192,13 +193,13 @@ int usbmsc_classobject(FAR void *handle, FAR struct usbdev_description_s *devdes
|
||||
FAR struct usbdevclass_driver_s **classdev);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Un-initialize the USB storage class driver. The handle is the USB MSC
|
||||
* class' device object. This is the same value as returned by usbmsc_classobject
|
||||
* (typed) or by usbmsc_configure (untyped).
|
||||
* class' device object. This is the same value as returned by
|
||||
* usbmsc_classobject (typed) or by usbmsc_configure (untyped).
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - The handle returned by a previous call to usbmsc_configure()
|
||||
@ -207,11 +208,11 @@ int usbmsc_classobject(FAR void *handle, FAR struct usbdev_description_s *devdes
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
***********************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
void usbmsc_uninitialize(FAR void *handle);
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: usbmsc_get_composite_devdesc
|
||||
*
|
||||
* Description:
|
||||
@ -224,7 +225,7 @@ void usbmsc_uninitialize(FAR void *handle);
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_USBMSC_COMPOSITE)
|
||||
struct composite_devdesc_s;
|
||||
|
Loading…
Reference in New Issue
Block a user