Fix GenID 3.10 issue on STM32L4.
This commit is contained in:
		@@ -1032,21 +1032,7 @@ static void handle_rxflvl_irq(uint8_t rhport) {
 | 
				
			|||||||
      // XFRC complete is additionally generated when
 | 
					      // XFRC complete is additionally generated when
 | 
				
			||||||
      // - setup packet is received
 | 
					      // - setup packet is received
 | 
				
			||||||
      // - complete the data stage of control write is complete
 | 
					      // - complete the data stage of control write is complete
 | 
				
			||||||
      if ((epnum == 0) && (bcnt == 0) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) {
 | 
					      // It will be handled in handle_epout_irq()
 | 
				
			||||||
        uint32_t doepint = epout->doepint;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (doepint & (DOEPINT_STPKTRX | DOEPINT_OTEPSPR)) {
 | 
					 | 
				
			||||||
          // skip this "no-data" transfer complete event
 | 
					 | 
				
			||||||
          // Note: STPKTRX will be clear later by setup received handler
 | 
					 | 
				
			||||||
          uint32_t clear_flags = DOEPINT_XFRC;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          if (doepint & DOEPINT_OTEPSPR) clear_flags |= DOEPINT_OTEPSPR;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          epout->doepint = clear_flags;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          // TU_LOG(DWC2_DEBUG, "  FIX extra transfer complete on setup/data compete\r\n");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:    // Invalid
 | 
					    default:    // Invalid
 | 
				
			||||||
@@ -1073,15 +1059,16 @@ static void handle_epout_irq(uint8_t rhport) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        xfer_ctl_t* xfer = XFER_CTL_BASE(n, TUSB_DIR_OUT);
 | 
					        xfer_ctl_t* xfer = XFER_CTL_BASE(n, TUSB_DIR_OUT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(dma_enabled(rhport)) {
 | 
				
			||||||
          if (doepint & DOEPINT_STUP) {
 | 
					          if (doepint & DOEPINT_STUP) {
 | 
				
			||||||
            // STPKTRX is only available for version from 3_00a
 | 
					            // STPKTRX is only available for version from 3_00a
 | 
				
			||||||
          if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) {
 | 
					            if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid > DWC2_CORE_REV_3_00a)) {
 | 
				
			||||||
              epout->doepint = DOEPINT_STPKTRX;
 | 
					              epout->doepint = DOEPINT_STPKTRX;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          } else if (doepint & DOEPINT_OTEPSPR) {
 | 
					          } else if (doepint & DOEPINT_OTEPSPR) {
 | 
				
			||||||
            epout->doepint = DOEPINT_OTEPSPR;
 | 
					            epout->doepint = DOEPINT_OTEPSPR;
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
          if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) {
 | 
					            if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid > DWC2_CORE_REV_3_00a)) {
 | 
				
			||||||
              epout->doepint = DOEPINT_STPKTRX;
 | 
					              epout->doepint = DOEPINT_STPKTRX;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              // EP0 can only handle one packet
 | 
					              // EP0 can only handle one packet
 | 
				
			||||||
@@ -1089,7 +1076,6 @@ static void handle_epout_irq(uint8_t rhport) {
 | 
				
			|||||||
                // Schedule another packet to be received.
 | 
					                // Schedule another packet to be received.
 | 
				
			||||||
                edpt_schedule_packets(rhport, n, TUSB_DIR_OUT, 1, ep0_pending[TUSB_DIR_OUT]);
 | 
					                edpt_schedule_packets(rhport, n, TUSB_DIR_OUT, 1, ep0_pending[TUSB_DIR_OUT]);
 | 
				
			||||||
              } else {
 | 
					              } else {
 | 
				
			||||||
              if(dma_enabled(rhport)) {
 | 
					 | 
				
			||||||
                // Fix packet length
 | 
					                // Fix packet length
 | 
				
			||||||
                uint16_t remain = (epout->doeptsiz & DOEPTSIZ_XFRSIZ_Msk) >> DOEPTSIZ_XFRSIZ_Pos;
 | 
					                uint16_t remain = (epout->doeptsiz & DOEPTSIZ_XFRSIZ_Msk) >> DOEPTSIZ_XFRSIZ_Pos;
 | 
				
			||||||
                xfer->total_len -= remain;
 | 
					                xfer->total_len -= remain;
 | 
				
			||||||
@@ -1097,8 +1083,24 @@ static void handle_epout_irq(uint8_t rhport) {
 | 
				
			|||||||
                if(n == 0 && xfer->total_len == 0) {
 | 
					                if(n == 0 && xfer->total_len == 0) {
 | 
				
			||||||
                  dma_stpkt_rx(rhport);
 | 
					                  dma_stpkt_rx(rhport);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                dcd_event_xfer_complete(rhport, n, xfer->total_len, XFER_RESULT_SUCCESS, true);
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid == DWC2_CORE_REV_3_10a)) {
 | 
				
			||||||
 | 
					            epout->doepint = DOEPINT_STPKTRX;
 | 
				
			||||||
 | 
					          } else {
 | 
				
			||||||
 | 
					            if ((doepint & DOEPINT_OTEPSPR) && (dwc2->gsnpsid == DWC2_CORE_REV_3_10a)) {
 | 
				
			||||||
 | 
					              epout->doepint = DOEPINT_OTEPSPR;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // EP0 can only handle one packet
 | 
				
			||||||
 | 
					            if ((n == 0) && ep0_pending[TUSB_DIR_OUT]) {
 | 
				
			||||||
 | 
					              // Schedule another packet to be received.
 | 
				
			||||||
 | 
					              edpt_schedule_packets(rhport, n, TUSB_DIR_OUT, 1, ep0_pending[TUSB_DIR_OUT]);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
              dcd_event_xfer_complete(rhport, n, xfer->total_len, XFER_RESULT_SUCCESS, true);
 | 
					              dcd_event_xfer_complete(rhport, n, xfer->total_len, XFER_RESULT_SUCCESS, true);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@@ -1108,10 +1110,10 @@ static void handle_epout_irq(uint8_t rhport) {
 | 
				
			|||||||
      // SETUP packet Setup Phase done.
 | 
					      // SETUP packet Setup Phase done.
 | 
				
			||||||
      if (doepint & DOEPINT_STUP) {
 | 
					      if (doepint & DOEPINT_STUP) {
 | 
				
			||||||
        epout->doepint = DOEPINT_STUP;
 | 
					        epout->doepint = DOEPINT_STUP;
 | 
				
			||||||
        if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) {
 | 
					        if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid > DWC2_CORE_REV_3_00a)) {
 | 
				
			||||||
          epout->doepint = DOEPINT_STPKTRX;
 | 
					          epout->doepint = DOEPINT_STPKTRX;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if(dma_enabled(rhport) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) {
 | 
					        if(dma_enabled(rhport) && (dwc2->gsnpsid > DWC2_CORE_REV_3_00a)) {
 | 
				
			||||||
          dma_stpkt_rx(rhport);
 | 
					          dma_stpkt_rx(rhport);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user