@@ -793,18 +793,19 @@ void usb_irqhandler(void) {
793
793
if ((gintsts & USB_OTG_GINTSTS_RXFLVL ) != 0 ) {
794
794
// 1. Read the Receive status pop register
795
795
volatile unsigned int rxst = USBx -> GRXSTSP ;
796
+ int status = (rxst & USB_OTG_GRXSTSP_PKTSTS ) >> 17 ;
796
797
797
798
#ifdef DEBUG_USB
798
799
puts (" RX FIFO:" );
799
800
puth (rxst );
800
801
puts (" status: " );
801
- puth (( rxst & USB_OTG_GRXSTSP_PKTSTS ) >> 17 );
802
+ puth (status );
802
803
puts (" len: " );
803
804
puth ((rxst & USB_OTG_GRXSTSP_BCNT ) >> 4 );
804
805
puts ("\n" );
805
806
#endif
806
807
807
- if ((( rxst & USB_OTG_GRXSTSP_PKTSTS ) >> 17 ) == STS_DATA_UPDT ) {
808
+ if (status == STS_DATA_UPDT ) {
808
809
int endpoint = (rxst & USB_OTG_GRXSTSP_EPNUM );
809
810
int len = (rxst & USB_OTG_GRXSTSP_BCNT ) >> 4 ;
810
811
(void )USB_ReadPacket (& usbdata , len );
@@ -822,13 +823,15 @@ void usb_irqhandler(void) {
822
823
if (endpoint == 3 ) {
823
824
usb_cb_ep3_out (usbdata , len , 1 );
824
825
}
825
- } else if ((( rxst & USB_OTG_GRXSTSP_PKTSTS ) >> 17 ) == STS_SETUP_UPDT ) {
826
+ } else if (status == STS_SETUP_UPDT ) {
826
827
(void )USB_ReadPacket (& setup , 8 );
827
828
#ifdef DEBUG_USB
828
829
puts (" setup " );
829
830
hexdump (& setup , 8 );
830
831
puts ("\n" );
831
832
#endif
833
+ } else {
834
+ // status is neither STS_DATA_UPDT or STS_SETUP_UPDT, skip
832
835
}
833
836
}
834
837
@@ -903,6 +906,8 @@ void usb_irqhandler(void) {
903
906
puts ("OUTEP3 error " );
904
907
puth (USBx_OUTEP (3 )-> DOEPINT );
905
908
puts ("\n" );
909
+ } else {
910
+ // USBx_OUTEP(3)->DOEPINT is 0, ok to skip
906
911
}
907
912
908
913
if ((USBx_OUTEP (0 )-> DOEPINT & USB_OTG_DIEPINT_XFRC ) != 0 ) {
0 commit comments