Skip to content

Commit

Permalink
Merge pull request #9790 from mikeller/fix_f7_usb_zero_lenght_packet
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller committed May 28, 2020
1 parent 3e4b51e commit a72f7aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/vcp_hal/usbd_cdc_interface.c
Expand Up @@ -261,12 +261,19 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
if (hcdc->TxState == 0) {
// endpoint has finished transmitting previous block
if (lastBuffsize) {
bool needZeroLengthPacket = lastBuffsize % 64 == 0;

// move the ring buffer tail based on the previous succesful transmission
UserTxBufPtrOut += lastBuffsize;
if (UserTxBufPtrOut == APP_TX_DATA_SIZE) {
UserTxBufPtrOut = 0;
}
lastBuffsize = 0;

if (needZeroLengthPacket) {
USBD_CDC_SetTxBuffer(&USBD_Device, (uint8_t*)&UserTxBuffer[UserTxBufPtrOut], 0);
return;
}
}
if (UserTxBufPtrOut != UserTxBufPtrIn) {
if (UserTxBufPtrOut > UserTxBufPtrIn) { /* Roll-back */
Expand Down

0 comments on commit a72f7aa

Please sign in to comment.