mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 05:45:31 +03:00
Small fix for VCP port buffer send incomplete
This commit is contained in:
parent
e40942366e
commit
669b8e7239
2 changed files with 9 additions and 11 deletions
|
@ -90,7 +90,6 @@ static void usbVcpWriteBuf(serialPort_t *instance, void *data, int count)
|
||||||
{
|
{
|
||||||
UNUSED(instance);
|
UNUSED(instance);
|
||||||
|
|
||||||
|
|
||||||
if (!(usbIsConnected() && usbIsConfigured())) {
|
if (!(usbIsConnected() && usbIsConfigured())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -120,12 +119,12 @@ static bool usbVcpFlush(vcpPort_t *port)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t txed;
|
uint8_t txed = 0;
|
||||||
uint32_t start = millis();
|
uint32_t start = millis();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
txed = CDC_Send_DATA(port->txBuf, count);
|
txed += CDC_Send_DATA(&port->txBuf[txed], count-txed);
|
||||||
} while (txed != count && (millis() - start < USB_TIMEOUT));
|
} while (txed < count && (millis() - start < USB_TIMEOUT));
|
||||||
|
|
||||||
return txed == count;
|
return txed == count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ uint32_t CDC_Send_DATA(uint8_t *ptrBuffer, uint8_t sendLength)
|
||||||
* this function.
|
* this function.
|
||||||
* @param Buf: Buffer of data to be sent
|
* @param Buf: Buffer of data to be sent
|
||||||
* @param Len: Number of data to be sent (in bytes)
|
* @param Len: Number of data to be sent (in bytes)
|
||||||
* @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL
|
* @retval Result of the operation: USBD_OK if all operations are OK else VCP_FAIL
|
||||||
*/
|
*/
|
||||||
static uint16_t VCP_DataTx(uint8_t* Buf, uint32_t Len)
|
static uint16_t VCP_DataTx(uint8_t* Buf, uint32_t Len)
|
||||||
{
|
{
|
||||||
|
@ -191,18 +191,17 @@ uint8_t usbAvailable(void)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
uint32_t CDC_Receive_DATA(uint8_t* recvBuf, uint32_t len)
|
uint32_t CDC_Receive_DATA(uint8_t* recvBuf, uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t ch = 0;
|
uint32_t count = 0;
|
||||||
|
|
||||||
while (usbAvailable() && ch < len) {
|
while (usbAvailable() && count < len) {
|
||||||
recvBuf[ch] = usbData.buffer[usbData.bufferOutPosition];
|
recvBuf[count] = usbData.buffer[usbData.bufferOutPosition];
|
||||||
usbData.bufferOutPosition = (usbData.bufferOutPosition + 1) % USB_RX_BUFSIZE;
|
usbData.bufferOutPosition = (usbData.bufferOutPosition + 1) % USB_RX_BUFSIZE;
|
||||||
ch++;
|
count++;
|
||||||
receiveLength--;
|
receiveLength--;
|
||||||
}
|
}
|
||||||
return ch;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief VCP_DataRx
|
* @brief VCP_DataRx
|
||||||
* Data received over USB OUT endpoint are sent over CDC interface
|
* Data received over USB OUT endpoint are sent over CDC interface
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue