diff --git a/arch/arm/src/stm32/stm32_usbdev.c b/arch/arm/src/stm32/stm32_usbdev.c index 7c4035b6fce7788c4d62cbbbc34b6d7efbae6d58..4bc37f10fff77506540160d24065f1ed1eb6984b 100644 --- a/arch/arm/src/stm32/stm32_usbdev.c +++ b/arch/arm/src/stm32/stm32_usbdev.c @@ -72,19 +72,6 @@ # define CONFIG_USBDEV_EP0_MAXSIZE 64 #endif -#ifndef CONFIG_USBDEV_MAXPOWER -# define CONFIG_USBDEV_MAXPOWER 100 /* mA */ -#endif - -#define USB_SLOW_INT USBDEV_DEVINT_EPSLOW -#define USB_DEVSTATUS_INT USBDEV_DEVINT_DEVSTAT - -#ifdef CONFIG_STM32_USBDEV_EPFAST_INTERRUPT -# define USB_FAST_INT USBDEV_DEVINT_EPFAST -#else -# define USB_FAST_INT 0 -#endif - #ifndef CONFIG_USB_PRI # define CONFIG_USB_PRI NVIC_SYSH_PRIORITY_DEFAULT #endif @@ -1479,10 +1466,10 @@ static void stm32_epdone(struct stm32_usbdev_s *priv, ubyte epno) /* Handle write requests */ - priv->rxstatus = USB_EPR_STATRX_NAK; + priv->txstatus = USB_EPR_STATTX_NAK; stm32_wrrequest(priv, privep); - /* Set the new RX status */ + /* Set the new TX status */ stm32_seteptxstatus(epno, priv->txstatus); } @@ -1529,7 +1516,9 @@ static void stm32_ep0setup(struct stm32_usbdev_s *priv) int nbytes = 0; /* Assume zero-length packet */ int ret; - /* Terminate any pending requests */ + /* Terminate any pending requests (doesn't work if the pending request + * was a zero-length transfer!) + */ while (!stm32_rqempty(ep0)) { @@ -1960,7 +1949,7 @@ static void stm32_ep0in(struct stm32_usbdev_s *priv) if (priv->devstate == DEVSTATE_WRREQUEST) { - stm32_wrrequest(priv, &priv->eplist[EP0]); + stm32_wrrequest(priv, &priv->eplist[EP0]); } /* No.. Are we processing the completion of a status response? */ @@ -2643,9 +2632,7 @@ static int stm32_epconfigure(struct usbdev_ep_s *ep, if (USB_ISEPIN(desc->addr)) { - /* The full, logical EP number includes direction (which is zero - * for IN endpoints. - */ + /* The full, logical EP number includes direction */ ep->eplog = USB_EPIN(epno); @@ -2768,6 +2755,7 @@ static int stm32_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req) struct stm32_ep_s *privep = (struct stm32_ep_s *)ep; struct stm32_usbdev_s *priv; irqstate_t flags; + ubyte epno; int ret = OK; #ifdef CONFIG_DEBUG @@ -2793,6 +2781,7 @@ static int stm32_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req) /* Handle the request from the class driver */ + epno = USB_EPNO(ep->eplog); req->result = -EINPROGRESS; req->xfrd = 0; flags = irqsave(); @@ -2811,18 +2800,23 @@ static int stm32_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req) * IN functionality. */ - else if (USB_ISEPIN(ep->eplog) || USB_EPNO(ep->eplog) == EP0) + else if (USB_ISEPIN(ep->eplog) || epno == EP0) { /* Add the new request to the request queue for the IN endpoint */ stm32_rqenqueue(privep, privreq); - usbtrace(TRACE_INREQQUEUED(USB_EPNO(ep->eplog)), req->len); + usbtrace(TRACE_INREQQUEUED(epno), req->len); /* If the IN endpoint FIFO is available, then transfer the data now */ if (!privep->txbusy) { - ret = stm32_wrrequest(priv, privep); + priv->txstatus = USB_EPR_STATTX_NAK; + ret = stm32_wrrequest(priv, privep); + + /* Set the new TX status */ + + stm32_seteptxstatus(epno, priv->txstatus); } } @@ -2834,14 +2828,19 @@ static int stm32_epsubmit(struct usbdev_ep_s *ep, struct usbdev_req_s *req) privep->txnullpkt = 0; stm32_rqenqueue(privep, privreq); - usbtrace(TRACE_OUTREQQUEUED(USB_EPNO(ep->eplog)), req->len); + usbtrace(TRACE_OUTREQQUEUED(epno), req->len); /* This there a incoming data pending the availability of a request? */ if (priv->rxpending) { - ret = stm32_rdrequest(priv, privep); + priv->rxstatus = USB_EPR_STATRX_VALID; + ret = stm32_rdrequest(priv, privep); priv->rxpending = 0; + + /* Set the new RX status */ + + stm32_seteprxstatus(epno, priv->rxstatus); } } diff --git a/configs/stm3210e-eval/RIDE/defconfig b/configs/stm3210e-eval/RIDE/defconfig index ba379a9cdbc9819becf7609b44e315fbafde330f..c033645a1327359feb5dff35a25f7b595edbb359 100755 --- a/configs/stm3210e-eval/RIDE/defconfig +++ b/configs/stm3210e-eval/RIDE/defconfig @@ -552,7 +552,7 @@ CONFIG_USBDEV_TRACE_NRECORDS=128 CONFIG_USBSER=n CONFIG_USBSER_EPINTIN=1 CONFIG_USBSER_EPBULKOUT=2 -CONFIG_USBSER_EPBULKIN=5 +CONFIG_USBSER_EPBULKIN=3 CONFIG_USBSER_NWRREQS=4 CONFIG_USBSER_NRDREQS=4 CONFIG_USBSER_VENDORID=0x067b diff --git a/configs/stm3210e-eval/nsh/defconfig b/configs/stm3210e-eval/nsh/defconfig index db7576335b98e4d698bc555ad462b831522ee7d9..1e0dfbf8d1a464e5a49f94b2047e53f20def71a8 100755 --- a/configs/stm3210e-eval/nsh/defconfig +++ b/configs/stm3210e-eval/nsh/defconfig @@ -561,7 +561,7 @@ CONFIG_USBDEV_TRACE_NRECORDS=128 CONFIG_USBSER=n CONFIG_USBSER_EPINTIN=1 CONFIG_USBSER_EPBULKOUT=2 -CONFIG_USBSER_EPBULKIN=5 +CONFIG_USBSER_EPBULKIN=3 CONFIG_USBSER_NWRREQS=4 CONFIG_USBSER_NRDREQS=4 CONFIG_USBSER_VENDORID=0x067b diff --git a/configs/stm3210e-eval/ostest/defconfig b/configs/stm3210e-eval/ostest/defconfig index 572eb3a15f996fbce16e88a601f949ed27f044f9..e0f99db7b0b98cbc502df6b6eec19adf5a292d92 100755 --- a/configs/stm3210e-eval/ostest/defconfig +++ b/configs/stm3210e-eval/ostest/defconfig @@ -563,7 +563,7 @@ CONFIG_USBDEV_TRACE_NRECORDS=128 CONFIG_USBSER=n CONFIG_USBSER_EPINTIN=1 CONFIG_USBSER_EPBULKOUT=2 -CONFIG_USBSER_EPBULKIN=5 +CONFIG_USBSER_EPBULKIN=3 CONFIG_USBSER_NWRREQS=4 CONFIG_USBSER_NRDREQS=4 CONFIG_USBSER_VENDORID=0x067b diff --git a/configs/stm3210e-eval/usbserial/defconfig b/configs/stm3210e-eval/usbserial/defconfig index ed6d2b71e8da973a8aa1cc16dbcb5e4eccc423d3..18dba1d55181b99528f3532a2dc430e7d53d652c 100755 --- a/configs/stm3210e-eval/usbserial/defconfig +++ b/configs/stm3210e-eval/usbserial/defconfig @@ -564,7 +564,7 @@ CONFIG_USBDEV_TRACE_NRECORDS=128 CONFIG_USBSER=y CONFIG_USBSER_EPINTIN=1 CONFIG_USBSER_EPBULKOUT=2 -CONFIG_USBSER_EPBULKIN=5 +CONFIG_USBSER_EPBULKIN=3 CONFIG_USBSER_NWRREQS=4 CONFIG_USBSER_NRDREQS=4 CONFIG_USBSER_VENDORID=0x067b