mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Merge pull request #9790 from mikeller/fix_f7_usb_zero_lenght_packet
This commit is contained in:
commit
7d6e577803
1 changed files with 7 additions and 0 deletions
|
@ -261,12 +261,19 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||||
if (hcdc->TxState == 0) {
|
if (hcdc->TxState == 0) {
|
||||||
// endpoint has finished transmitting previous block
|
// endpoint has finished transmitting previous block
|
||||||
if (lastBuffsize) {
|
if (lastBuffsize) {
|
||||||
|
bool needZeroLengthPacket = lastBuffsize % 64 == 0;
|
||||||
|
|
||||||
// move the ring buffer tail based on the previous succesful transmission
|
// move the ring buffer tail based on the previous succesful transmission
|
||||||
UserTxBufPtrOut += lastBuffsize;
|
UserTxBufPtrOut += lastBuffsize;
|
||||||
if (UserTxBufPtrOut == APP_TX_DATA_SIZE) {
|
if (UserTxBufPtrOut == APP_TX_DATA_SIZE) {
|
||||||
UserTxBufPtrOut = 0;
|
UserTxBufPtrOut = 0;
|
||||||
}
|
}
|
||||||
lastBuffsize = 0;
|
lastBuffsize = 0;
|
||||||
|
|
||||||
|
if (needZeroLengthPacket) {
|
||||||
|
USBD_CDC_SetTxBuffer(&USBD_Device, (uint8_t*)&UserTxBuffer[UserTxBufPtrOut], 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (UserTxBufPtrOut != UserTxBufPtrIn) {
|
if (UserTxBufPtrOut != UserTxBufPtrIn) {
|
||||||
if (UserTxBufPtrOut > UserTxBufPtrIn) { /* Roll-back */
|
if (UserTxBufPtrOut > UserTxBufPtrIn) { /* Roll-back */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue