Fixed problem with USB VCP when sending packets with a length of a multiple of 64 bytes.

This commit is contained in:
mikeller 2020-05-10 04:10:20 +12:00
parent 9bace5b9d1
commit c793adbd86
1 changed files with 7 additions and 0 deletions

View File

@ -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 */