Small fix for VCP port buffer send incomplete
This commit is contained in:
parent
e40942366e
commit
669b8e7239
|
@ -90,7 +90,6 @@ static void usbVcpWriteBuf(serialPort_t *instance, void *data, int count)
|
|||
{
|
||||
UNUSED(instance);
|
||||
|
||||
|
||||
if (!(usbIsConnected() && usbIsConfigured())) {
|
||||
return;
|
||||
}
|
||||
|
@ -120,12 +119,12 @@ static bool usbVcpFlush(vcpPort_t *port)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint32_t txed;
|
||||
uint8_t txed = 0;
|
||||
uint32_t start = millis();
|
||||
|
||||
do {
|
||||
txed = CDC_Send_DATA(port->txBuf, count);
|
||||
} while (txed != count && (millis() - start < USB_TIMEOUT));
|
||||
txed += CDC_Send_DATA(&port->txBuf[txed], count-txed);
|
||||
} while (txed < count && (millis() - start < USB_TIMEOUT));
|
||||
|
||||
return txed == count;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ uint32_t CDC_Send_DATA(uint8_t *ptrBuffer, uint8_t sendLength)
|
|||
* this function.
|
||||
* @param Buf: Buffer of data to be sent
|
||||
* @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)
|
||||
{
|
||||
|
@ -191,18 +191,17 @@ uint8_t usbAvailable(void)
|
|||
*******************************************************************************/
|
||||
uint32_t CDC_Receive_DATA(uint8_t* recvBuf, uint32_t len)
|
||||
{
|
||||
uint32_t ch = 0;
|
||||
uint32_t count = 0;
|
||||
|
||||
while (usbAvailable() && ch < len) {
|
||||
recvBuf[ch] = usbData.buffer[usbData.bufferOutPosition];
|
||||
while (usbAvailable() && count < len) {
|
||||
recvBuf[count] = usbData.buffer[usbData.bufferOutPosition];
|
||||
usbData.bufferOutPosition = (usbData.bufferOutPosition + 1) % USB_RX_BUFSIZE;
|
||||
ch++;
|
||||
count++;
|
||||
receiveLength--;
|
||||
}
|
||||
return ch;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief VCP_DataRx
|
||||
* Data received over USB OUT endpoint are sent over CDC interface
|
||||
|
|
Loading…
Reference in New Issue