|
|
@@ -1256,6 +1256,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t |
|
|
|
uint32_t fifoemptymsk = 0; |
|
|
|
|
|
|
|
ep = &hpcd->IN_ep[epnum]; |
|
|
|
#if 0 |
|
|
|
len = ep->xfer_len - ep->xfer_count; |
|
|
|
|
|
|
|
if (len > ep->maxpacket) |
|
|
@@ -1285,6 +1286,37 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t |
|
|
|
ep->xfer_count += len; |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
/* dpgeorge: modified above loop to: |
|
|
|
* - allow to write the packet in the case it exactly fills the FIFO |
|
|
|
* - recompute len32b before each check of this value against FIFO free space |
|
|
|
*/ |
|
|
|
for (;;) |
|
|
|
{ |
|
|
|
len = ep->xfer_len - ep->xfer_count; |
|
|
|
if (len <= 0U) |
|
|
|
{ |
|
|
|
/* Finished sending all data */ |
|
|
|
break; |
|
|
|
} |
|
|
|
if (len > ep->maxpacket) |
|
|
|
{ |
|
|
|
len = ep->maxpacket; |
|
|
|
} |
|
|
|
|
|
|
|
len32b = (len + 3U) / 4U; |
|
|
|
if (len32b > (USBx_INEP(epnum)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV)) |
|
|
|
{ |
|
|
|
/* No room left in FIFO */ |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
USB_WritePacket(USBx, ep->xfer_buff, epnum, len, hpcd->Init.dma_enable); |
|
|
|
ep->xfer_buff += len; |
|
|
|
ep->xfer_count += len; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if(len <= 0) |
|
|
|
{ |
|
|
|
fifoemptymsk = 0x1 << epnum; |
|
|
|