Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions libraries/USBDevice/inc/usbd_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,10 @@ uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
uint32_t length, uint8_t ClassId);
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev, uint8_t ClassId);
#else
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
uint32_t length);
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);
#endif /* USE_USBD_COMPOSITE */
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
Expand Down
18 changes: 0 additions & 18 deletions libraries/USBDevice/src/cdc/usbd_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,24 +1019,6 @@ uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)

return (uint8_t)USBD_OK;
}
#ifdef USE_USBD_COMPOSITE
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev, uint8_t ClassId)
{
/* Suspend or Resume USB Out process */
if (pdev->pClassDataCmsit[classId] != NULL) {
#else
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev)
{
/* Suspend or Resume USB Out process */
if (pdev->pClassDataCmsit[pdev->classId] != NULL) {
#endif /* USE_USBD_COMPOSITE */
/* Prepare Out endpoint to receive next packet */
USBD_LL_PrepareReceive(pdev, CDC_OUT_EP, 0, 0);
return (uint8_t)USBD_OK;
} else {
return (uint8_t)USBD_FAIL;
}
}

#endif /* USBD_USE_CDC */
#endif /* USBCON */
Expand Down
13 changes: 9 additions & 4 deletions libraries/USBDevice/src/cdc/usbd_cdc_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,15 @@ static int8_t USBD_CDC_Receive(uint8_t *Buf, uint32_t *Len)
/* It always contains required amount of free space for writing */
CDC_ReceiveQueue_CommitBlock(&ReceiveQueue, (uint16_t)(*Len));
receivePended = false;
/* If enough space in the queue for a full buffer then continue receive */
if (!CDC_resume_receive()) {
USBD_CDC_ClearBuffer(&hUSBD_Device_CDC);
}
/*
* If there is enough space in the queue for a full packet, continue receive.
* Else leave the OUT endpoint unarmed: it then NAKs and the host retries.
* USBSerial::read() and the readBytes() family call CDC_resume_receive()
* after dequeuing, so the endpoint is armed again with a valid block as soon
* as the sketch drains data. Arming it with a NULL buffer instead makes the
* low level driver copy the retried packet to address 0.
*/
(void)CDC_resume_receive();
return ((int8_t)USBD_OK);
}

Expand Down