Skip to content

Commit b336585

Browse files
TimJTixiaoxiang781216
authored andcommitted
Fix sam_udphs to allow RNDIS to work
Update sam_udphs.c
1 parent 9638187 commit b336585

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

arch/arm/src/sama5/sam_udphs.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,13 @@ struct sam_usbdev_s
371371
* of valid dat in the buffer is given by ctrlreg.len[]. For the
372372
* case of EP0 SETUP IN transaction, the normal request mechanism is
373373
* used and the class driver provides the buffering.
374+
*
375+
* A buffer 4* the EP0_MAXPACKETSIZE is used to allow for data that
376+
* is sent in consecutive packets although for the same transaction.
374377
*/
375378

376-
uint8_t ep0out[SAM_EP0_MAXPACKET];
379+
uint8_t ep0out[4 * SAM_EP0_MAXPACKET];
380+
uint16_t ep0datlen;
377381
};
378382

379383
/****************************************************************************
@@ -2637,10 +2641,6 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
26372641
{
26382642
uint16_t len;
26392643

2640-
/* Yes.. back to the IDLE state */
2641-
2642-
privep->epstate = UDPHS_EPSTATE_IDLE;
2643-
26442644
/* Get the size of the packet that we just received */
26452645

26462646
pktsize = (uint16_t)
@@ -2650,27 +2650,32 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
26502650
/* Get the size that we expected to receive */
26512651

26522652
len = GETUINT16(priv->ctrl.len);
2653-
if (len == pktsize)
2653+
2654+
/* Copy the OUT data from the EP0 FIFO into the EP0 buffer. */
2655+
2656+
sam_ep0_read(priv->ep0out + priv->ep0datlen, pktsize);
2657+
2658+
priv->ep0datlen += pktsize;
2659+
2660+
if (priv->ep0datlen == len)
26542661
{
2655-
/* Copy the OUT data from the EP0 FIFO into a special EP0
2656-
* buffer and clear RXRDYTXKL in order to receive more data.
2662+
/* Back to the IDLE state and clear RXRDYTXKL
2663+
* in order to receive more data.
26572664
*/
26582665

2659-
sam_ep0_read(priv->ep0out, len);
2666+
privep->epstate = UDPHS_EPSTATE_IDLE;
2667+
26602668
sam_putreg(UDPHS_EPTSTA_RXRDYTXKL, SAM_UDPHS_EPTCLRSTA(epno));
26612669

26622670
/* And handle the EP0 SETUP now. */
26632671

26642672
sam_ep0_setup(priv);
2673+
priv->ep0datlen = 0;
26652674
}
26662675
else
26672676
{
2668-
usbtrace(TRACE_DEVERROR(SAM_TRACEERR_EP0SETUPOUTSIZE),
2669-
pktsize);
2670-
2671-
/* STALL and discard received data. */
2677+
/* Clear RXRDYTXKL in order to receive more data. */
26722678

2673-
sam_ep_stall(&privep->ep, false);
26742679
sam_putreg(UDPHS_EPTSTA_RXRDYTXKL, SAM_UDPHS_EPTCLRSTA(epno));
26752680
}
26762681
}

0 commit comments

Comments
 (0)