Skip to content

Commit 2881772

Browse files
committed
stmhal: Replace magic number 3 with CDC_IN_EP define.
1 parent 3f2f289 commit 2881772

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

stmhal/usbd_cdc_interface.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,11 @@ void USBD_CDC_HAL_TIM_PeriodElapsedCallback(void) {
265265
if (UserTxBufPtrOut != UserTxBufPtrOutShadow) {
266266
// We have sent data and are waiting for the low-level USB driver to
267267
// finish sending it over the USB in-endpoint.
268-
if (UserTxBufPtrWaitCount < 10) {
268+
// We have a 15 * 10ms = 150ms timeout
269+
if (UserTxBufPtrWaitCount < 15) {
269270
PCD_HandleTypeDef *hpcd = hUSBDDevice.pData;
270271
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
271-
if (USBx_INEP(3)->DIEPTSIZ & USB_OTG_DIEPTSIZ_XFRSIZ) {
272+
if (USBx_INEP(CDC_IN_EP & 0x7f)->DIEPTSIZ & USB_OTG_DIEPTSIZ_XFRSIZ) {
272273
// USB in-endpoint is still reading the data
273274
UserTxBufPtrWaitCount++;
274275
return;

stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#define MSC_IN_EP (0x81)
1414
#define MSC_OUT_EP (0x01)
1515

16+
// Need to define here for usbd_cdc_interface.c (it needs CDC_IN_EP)
17+
#define CDC_IN_EP (0x83)
18+
#define CDC_OUT_EP (0x03)
19+
#define CDC_CMD_EP (0x82)
20+
1621
// only CDC_MSC and CDC_HID are available
1722
#define USBD_MODE_CDC (0x01)
1823
#define USBD_MODE_MSC (0x02)

stmhal/usbdev/class/cdc_msc_hid/src/usbd_cdc_msc_hid.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#define USB_CDC_MSC_CONFIG_DESC_SIZ (98)
55
#define USB_CDC_HID_CONFIG_DESC_SIZ (100)
66
#define CDC_IFACE_NUM (1)
7-
#define CDC_IN_EP (0x83)
8-
#define CDC_OUT_EP (0x03)
9-
#define CDC_CMD_EP (0x82)
107
#define MSC_IFACE_NUM (0)
118
#define HID_IFACE_NUM_WITH_CDC (0)
129
#define HID_IFACE_NUM_WITH_MSC (1)

0 commit comments

Comments
 (0)