Add support for serial class driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@968 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
913014a3e1
commit
539369d52d
@ -707,7 +707,7 @@ static int lpc214x_wrrequest(struct lpc214x_ep_s *privep)
|
|||||||
privreq = (struct lpc214x_req_s *)sq_peek(&privep->reqlist);
|
privreq = (struct lpc214x_req_s *)sq_peek(&privep->reqlist);
|
||||||
if (!privreq)
|
if (!privreq)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ static int lpc214x_rdrequest(struct lpc214x_ep_s *privep)
|
|||||||
privreq = (struct lpc214x_req_s *)sq_peek(&privep->reqlist);
|
privreq = (struct lpc214x_req_s *)sq_peek(&privep->reqlist);
|
||||||
if (!privreq)
|
if (!privreq)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NULLREQUEST), 0);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,7 +791,7 @@ static int lpc214x_rdrequest(struct lpc214x_ep_s *privep)
|
|||||||
nbytesread = lpc214x_epread(privep->epphy, buf, privep->ep.maxpacket);
|
nbytesread = lpc214x_epread(privep->epphy, buf, privep->ep.maxpacket);
|
||||||
if (nbytesread < 0)
|
if (nbytesread < 0)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_EPREAD), nbytesread);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_EPREAD), nbytesread);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1320,7 +1320,7 @@ static inline void lpc214x_ep0setup(struct lpc214x_usbdev_s *priv)
|
|||||||
|
|
||||||
if (priv->stalled)
|
if (priv->stalled)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||||
lpc214x_epstall(&ep0->ep, FALSE);
|
lpc214x_epstall(&ep0->ep, FALSE);
|
||||||
lpc214x_epstall(&ep0->ep, FALSE);
|
lpc214x_epstall(&ep0->ep, FALSE);
|
||||||
}
|
}
|
||||||
@ -1383,7 +1383,7 @@ static inline void lpc214x_ep0dataoutinterrupt(struct lpc214x_usbdev_s *priv)
|
|||||||
|
|
||||||
if (priv->stalled)
|
if (priv->stalled)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||||
ep0 = &priv->eplist[LPC214X_EP0_OUT];
|
ep0 = &priv->eplist[LPC214X_EP0_OUT];
|
||||||
lpc214x_epstall(&ep0->ep, FALSE);
|
lpc214x_epstall(&ep0->ep, FALSE);
|
||||||
lpc214x_epstall(&ep0->ep, FALSE);
|
lpc214x_epstall(&ep0->ep, FALSE);
|
||||||
@ -1443,7 +1443,7 @@ static inline void lpc214x_ep0dataininterrupt(struct lpc214x_usbdev_s *priv)
|
|||||||
|
|
||||||
if (priv->stalled)
|
if (priv->stalled)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_STALLED), priv->ep0state);
|
||||||
ep0 = &priv->eplist[LPC214X_EP0_IN];
|
ep0 = &priv->eplist[LPC214X_EP0_IN];
|
||||||
lpc214x_epstall(&ep0->ep, FALSE);
|
lpc214x_epstall(&ep0->ep, FALSE);
|
||||||
lpc214x_epstall(&ep0->ep, FALSE);
|
lpc214x_epstall(&ep0->ep, FALSE);
|
||||||
@ -1806,7 +1806,7 @@ static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, ubyte epphy,
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!priv || epphy < 2)
|
if (!priv || epphy < 2)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1817,7 +1817,7 @@ static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, ubyte epphy,
|
|||||||
|
|
||||||
if (!dmadesc)
|
if (!dmadesc)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NODMADESC), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NODMADESC), 0);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1825,7 +1825,7 @@ static int lpc214x_dmasetup(struct lpc214x_usbdev_s *priv, ubyte epphy,
|
|||||||
|
|
||||||
if ((dmadesc->status & USB_DMADESC_STATUSMASK) == USB_DMADESC_BEINGSERVICED)
|
if ((dmadesc->status & USB_DMADESC_STATUSMASK) == USB_DMADESC_BEINGSERVICED)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_DMABUSY), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_DMABUSY), 0);
|
||||||
return -EBUSY; /* Shouldn't happen */
|
return -EBUSY; /* Shouldn't happen */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1991,7 +1991,7 @@ static int lpc214x_epdisable(FAR struct usbdev_ep_s *ep)
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!ep)
|
if (!ep)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2033,7 +2033,7 @@ static FAR struct usbdev_req_s *lpc214x_epallocreq(FAR struct usbdev_ep_s *ep)
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!ep)
|
if (!ep)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2042,7 +2042,7 @@ static FAR struct usbdev_req_s *lpc214x_epallocreq(FAR struct usbdev_ep_s *ep)
|
|||||||
privreq = (FAR struct lpc214x_req_s *)malloc(sizeof(struct lpc214x_req_s));
|
privreq = (FAR struct lpc214x_req_s *)malloc(sizeof(struct lpc214x_req_s));
|
||||||
if (!privreq)
|
if (!privreq)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_ALLOCFAIL), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_ALLOCFAIL), 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2065,7 +2065,7 @@ static void lpc214x_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!ep || !req)
|
if (!ep || !req)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2145,7 +2145,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!req || !req->callback || !req->buf || !ep)
|
if (!req || !req->callback || !req->buf || !ep)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2154,7 +2154,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
|||||||
|
|
||||||
if (!priv->driver || priv->usbdev.speed == USB_SPEED_UNKNOWN)
|
if (!priv->driver || priv->usbdev.speed == USB_SPEED_UNKNOWN)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NOTCONFIGURED), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NOTCONFIGURED), 0);
|
||||||
return -ESHUTDOWN;
|
return -ESHUTDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2166,7 +2166,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
|||||||
flags = irqsave();
|
flags = irqsave();
|
||||||
if (req->len == 0 && (privep->in || privep->epphy == 3))
|
if (req->len == 0 && (privep->in || privep->epphy == 3))
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NULLPACKET), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NULLPACKET), 0);
|
||||||
sq_addlast(&privreq->sqe, &privep->reqlist);
|
sq_addlast(&privreq->sqe, &privep->reqlist);
|
||||||
goto success_notransfer;
|
goto success_notransfer;
|
||||||
}
|
}
|
||||||
@ -2202,7 +2202,7 @@ static int lpc214x_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BADREQUEST), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BADREQUEST), 0);
|
||||||
ret = ERROR;
|
ret = ERROR;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
@ -2239,7 +2239,7 @@ static int lpc214x_epcancel(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!ep || !req)
|
if (!ep || !req)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2303,7 +2303,7 @@ static FAR struct usbdev_ep_s *lcp214x_allocep(FAR struct usbdev_s *dev, ubyte e
|
|||||||
{
|
{
|
||||||
if (epphy >= LPC214X_NLOGENDPOINTS)
|
if (epphy >= LPC214X_NLOGENDPOINTS)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BADEPNO), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BADEPNO), 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2339,7 +2339,7 @@ static FAR struct usbdev_ep_s *lcp214x_allocep(FAR struct usbdev_s *dev, ubyte e
|
|||||||
|
|
||||||
case USB_EP_ATTR_XFER_CONTROL: /* Control endpoint -- not a valid choice */
|
case USB_EP_ATTR_XFER_CONTROL: /* Control endpoint -- not a valid choice */
|
||||||
default:
|
default:
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BADEPTYPE), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BADEPTYPE), 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2375,7 +2375,7 @@ static FAR struct usbdev_ep_s *lcp214x_allocep(FAR struct usbdev_s *dev, ubyte e
|
|||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_NOEP), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_NOEP), 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2473,7 +2473,7 @@ static int lpc214x_selfpowered(struct usbdev_s *dev, boolean selfpowered)
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2554,7 +2554,7 @@ void up_usbinitialize(void)
|
|||||||
|
|
||||||
if (irq_attach(LPC214X_USB_IRQ, lpc214x_usbinterrupt) != 0)
|
if (irq_attach(LPC214X_USB_IRQ, lpc214x_usbinterrupt) != 0)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_IRQREGISTRATION), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_IRQREGISTRATION), 0);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2597,7 +2597,7 @@ void up_usbuninitialize(void)
|
|||||||
usbtrace(TRACE_DEVUNINIT, 0);
|
usbtrace(TRACE_DEVUNINIT, 0);
|
||||||
if (priv->driver)
|
if (priv->driver)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_DRIVERREGISTERED), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_DRIVERREGISTERED), 0);
|
||||||
usbdev_unregister(priv->driver);
|
usbdev_unregister(priv->driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2640,13 +2640,13 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
if (!driver || !driver->ops->bind || !driver->ops->unbind ||
|
if (!driver || !driver->ops->bind || !driver->ops->unbind ||
|
||||||
!driver->ops->disconnect || !driver->ops->setup)
|
!driver->ops->disconnect || !driver->ops->setup)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_usbdev.driver)
|
if (g_usbdev.driver)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_DRIVER), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_DRIVER), 0);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2660,7 +2660,7 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
|
|||||||
ret = CLASS_BIND(driver, &g_usbdev.usbdev);
|
ret = CLASS_BIND(driver, &g_usbdev.usbdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_BINDFAILED), (uint16)-ret);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BINDFAILED), (uint16)-ret);
|
||||||
g_usbdev.driver = NULL;
|
g_usbdev.driver = NULL;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -2683,7 +2683,7 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
|
|||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (driver != g_usbdev.driver)
|
if (driver != g_usbdev.driver)
|
||||||
{
|
{
|
||||||
usbtrace(TRACE_ERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_INVALIDPARMS), 0);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user