raiden00pl commented on code in PR #9508:
URL: https://github.com/apache/nuttx/pull/9508#discussion_r1225251814
##########
arch/arm/src/nrf53/nrf53_usbd.c:
##########
@@ -1943,70 +1990,135 @@ static void nrf53_endepoutinterrupt(struct
nrf53_usbdev_s *priv)
static int nrf53_usbinterrupt(int irq, void *context, void *arg)
{
- struct nrf53_usbdev_s *priv = &g_usbdev;
+ struct nrf53_usbdev_s *priv = &g_usbdev;
+ struct nrf53_ep_s *privep = NULL;
+ uint32_t irqnow = 0;
+ uint32_t offset = 0;
+ int i = 0;
usbtrace(TRACE_INTENTRY(NRF53_TRACEINTID_USB), 0);
+ /* Handle all events */
+
+ for (i = 0; i < USBD_INT_ALL_NUM; i++)
+ {
+ /* Get EVENT offset */
+
+ offset = NRF53_USBD_EVENTS_USBRESET + 0x04 * i;
+
+ /* Get EVENT state */
+
+ irqnow |= nrf53_getreg(offset) << i;
+
+ /* Clear EVENT */
+
+ nrf53_putreg(0, offset);
+ }
+
/* USB reset interrupt */
- if (nrf53_getreg(NRF53_USBD_EVENTS_USBRESET))
+ if (irqnow & USBD_INT_USBRESET)
{
usbtrace(TRACE_INTDECODE(NRF53_TRACEINTID_DEVRESET), 0);
nrf53_usbreset(priv);
- nrf53_putreg(0, NRF53_USBD_EVENTS_USBRESET);
goto intout;
}
#ifdef CONFIG_USBDEV_SOFINTERRUPT
/* Handle SOF */
- if (nrf53_getreg(NRF53_USBD_EVENTS_SOF))
+ if (irqnow & USBD_INT_SOF)
{
usbtrace(TRACE_INTDECODE(NRF53_TRACEINTID_SOF), 0);
- nrf53_putreg(0, NRF53_USBD_EVENTS_SOF);
}
#endif
/* Handle USBEVENT */
- if (nrf53_getreg(NRF53_USBD_EVENTS_USBEVENT))
+ if (irqnow & USBD_INT_USBEVENT)
{
usbtrace(TRACE_INTDECODE(NRF53_TRACEINTID_USBEVENT), 0);
nrf53_eventinterrupt(priv);
- nrf53_putreg(0, NRF53_USBD_EVENTS_USBEVENT);
+ }
+
+ /* DMA transfer complete */
+
+ if (irqnow & NRF53_USBD_DMAIRQ)
+ {
+ nrf53_startdma_ack(priv);
}
/* Handle EP0SETUP */
- if (nrf53_getreg(NRF53_USBD_EVENTS_EP0SETUP))
+ if (irqnow & USBD_INT_EP0SETUP)
{
usbtrace(TRACE_INTDECODE(NRF53_TRACEINTID_EP0SETUP), 0);
nrf53_ep0setupinterrupt(priv);
- nrf53_putreg(0, NRF53_USBD_EVENTS_EP0SETUP);
}
/* Handle EP0DATADONE */
- if (nrf53_getreg(NRF53_USBD_EVENTS_EP0DATADONE))
+ if (irqnow & USBD_INT_EP0DATADONE)
{
usbtrace(TRACE_INTDECODE(NRF53_TRACEINTID_EP0DATADONE), 0);
nrf53_ep0datainterrupt(priv);
- nrf53_putreg(0, NRF53_USBD_EVENTS_EP0DATADONE);
}
+ /* Handle ENDEPOUT */
+
+ nrf53_endepoutinterrupt(priv, irqnow);
+
+ /* Handle ENDEPIN */
+
+ nrf53_endepininterrupt(priv, irqnow);
+
/* Handle EPDATA */
- if (nrf53_getreg(NRF53_USBD_EVENTS_EPDATA))
+ if (irqnow & USBD_INT_EPDATA)
{
usbtrace(TRACE_INTDECODE(NRF53_TRACEINTID_EPDATA), 0);
nrf53_epdatainterrupt(priv);
- nrf53_putreg(0, NRF53_USBD_EVENTS_EPDATA);
}
- /* Handle all END events */
+ /* Try to handle waiting OUT DMA requests */
- nrf53_endepininterrupt(priv);
- nrf53_endepoutinterrupt(priv);
+ if (priv->dmanow == false)
+ {
+ if (priv->dmaepoutwait)
+ {
+ for (i = 0; i < NRF53_NENDPOINTS; i++)
+ {
+ if (priv->dmaepoutwait & (1 << i))
+ {
+ priv->dmaepoutwait &= ~(1 << i);
+
+ privep = &priv->epout[i];
+ nrf53_epout_handle(priv, privep);
+ break;
+ }
+ }
+ }
+ }
+
+ /* Try to handle waiting IN DMA requests */
+
+ if (priv->dmanow == false)
Review Comment:
same as above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]