Skip to content

Commit 22f7dd4

Browse files
committed
chore(cdc): drop the unused USBD_CDC_ClearBuffer
USBD_CDC_Receive() was its only caller. The helper is not part of the ST USB device middleware, it is local to this core, and the only thing it does is arm the OUT endpoint with a NULL application buffer, which is what made a receive overrun fault the MCU. Remove it so it cannot be reused. This also drops a USE_USBD_COMPOSITE branch that would not compile: it reads a bare classId instead of pdev->classId.
1 parent cd7b8c2 commit 22f7dd4

2 files changed

Lines changed: 0 additions & 20 deletions

File tree

‎libraries/USBDevice/inc/usbd_cdc.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
148148
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
149149
uint32_t length, uint8_t ClassId);
150150
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
151-
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev, uint8_t ClassId);
152151
#else
153152
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
154153
uint32_t length);
155154
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
156-
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev);
157155
#endif /* USE_USBD_COMPOSITE */
158156
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
159157
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);

‎libraries/USBDevice/src/cdc/usbd_cdc.c‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,24 +1019,6 @@ uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
10191019

10201020
return (uint8_t)USBD_OK;
10211021
}
1022-
#ifdef USE_USBD_COMPOSITE
1023-
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev, uint8_t ClassId)
1024-
{
1025-
/* Suspend or Resume USB Out process */
1026-
if (pdev->pClassDataCmsit[classId] != NULL) {
1027-
#else
1028-
uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev)
1029-
{
1030-
/* Suspend or Resume USB Out process */
1031-
if (pdev->pClassDataCmsit[pdev->classId] != NULL) {
1032-
#endif /* USE_USBD_COMPOSITE */
1033-
/* Prepare Out endpoint to receive next packet */
1034-
USBD_LL_PrepareReceive(pdev, CDC_OUT_EP, 0, 0);
1035-
return (uint8_t)USBD_OK;
1036-
} else {
1037-
return (uint8_t)USBD_FAIL;
1038-
}
1039-
}
10401022

10411023
#endif /* USBD_USE_CDC */
10421024
#endif /* USBCON */

0 commit comments

Comments
 (0)