@@ -371,9 +371,13 @@ struct sam_usbdev_s
371
371
* of valid dat in the buffer is given by ctrlreg.len[]. For the
372
372
* case of EP0 SETUP IN transaction, the normal request mechanism is
373
373
* 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.
374
377
*/
375
378
376
- uint8_t ep0out [SAM_EP0_MAXPACKET ];
379
+ uint8_t ep0out [4 * SAM_EP0_MAXPACKET ];
380
+ uint16_t ep0datlen ;
377
381
};
378
382
379
383
/****************************************************************************
@@ -2637,10 +2641,6 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
2637
2641
{
2638
2642
uint16_t len ;
2639
2643
2640
- /* Yes.. back to the IDLE state */
2641
-
2642
- privep -> epstate = UDPHS_EPSTATE_IDLE ;
2643
-
2644
2644
/* Get the size of the packet that we just received */
2645
2645
2646
2646
pktsize = (uint16_t )
@@ -2650,27 +2650,32 @@ static void sam_ep_interrupt(struct sam_usbdev_s *priv, int epno)
2650
2650
/* Get the size that we expected to receive */
2651
2651
2652
2652
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 )
2654
2661
{
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.
2657
2664
*/
2658
2665
2659
- sam_ep0_read (priv -> ep0out , len );
2666
+ privep -> epstate = UDPHS_EPSTATE_IDLE ;
2667
+
2660
2668
sam_putreg (UDPHS_EPTSTA_RXRDYTXKL , SAM_UDPHS_EPTCLRSTA (epno ));
2661
2669
2662
2670
/* And handle the EP0 SETUP now. */
2663
2671
2664
2672
sam_ep0_setup (priv );
2673
+ priv -> ep0datlen = 0 ;
2665
2674
}
2666
2675
else
2667
2676
{
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. */
2672
2678
2673
- sam_ep_stall (& privep -> ep , false);
2674
2679
sam_putreg (UDPHS_EPTSTA_RXRDYTXKL , SAM_UDPHS_EPTCLRSTA (epno ));
2675
2680
}
2676
2681
}
0 commit comments