Skip to content

Commit f337aa5

Browse files
committed
Maxpacket not really used in the code, it's const, not variable
1 parent 33bedf6 commit f337aa5

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ typedef struct {
225225
uint32_t is_used;
226226
uint32_t total_length;
227227
uint32_t rem_length;
228-
uint32_t maxpacket;
229228
} USBD_EndpointTypeDef;
230229

231230
/* USB Device handle structure */

system/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c

+7-10
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
295295
pep = &pdev->ep_out[0];
296296

297297
if (pdev->ep0_state == USBD_EP0_DATA_OUT) {
298-
if (pep->rem_length > pep->maxpacket) {
299-
pep->rem_length -= pep->maxpacket;
298+
if (pep->rem_length > USB_MAX_EP0_SIZE) {
299+
pep->rem_length -= USB_MAX_EP0_SIZE;
300300

301301
USBD_CtlContinueRx(pdev,
302302
pdata,
303-
(uint16_t)MIN(pep->rem_length, pep->maxpacket));
303+
(uint16_t)MIN(pep->rem_length, USB_MAX_EP0_SIZE));
304304
} else {
305305
if ((pdev->pClass->EP0_RxReady != NULL) &&
306306
(pdev->dev_state == USBD_STATE_CONFIGURED)) {
@@ -344,17 +344,17 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum,
344344
pep = &pdev->ep_in[0];
345345

346346
if (pdev->ep0_state == USBD_EP0_DATA_IN) {
347-
if (pep->rem_length > pep->maxpacket) {
348-
pep->rem_length -= pep->maxpacket;
347+
if (pep->rem_length > USB_MAX_EP0_SIZE) {
348+
pep->rem_length -= USB_MAX_EP0_SIZE;
349349

350350
USBD_CtlContinueSendData(pdev, pdata, (uint16_t)pep->rem_length);
351351

352352
/* Prepare endpoint for premature end of transfer */
353353
USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
354354
} else {
355355
/* last packet is MPS multiple, so send ZLP packet */
356-
if ((pep->total_length % pep->maxpacket == 0U) &&
357-
(pep->total_length >= pep->maxpacket) &&
356+
if ((pep->total_length % USB_MAX_EP0_SIZE == 0U) &&
357+
(pep->total_length >= USB_MAX_EP0_SIZE) &&
358358
(pep->total_length < pdev->ep0_data_len)) {
359359
USBD_CtlContinueSendData(pdev, NULL, 0U);
360360
pdev->ep0_data_len = 0U;
@@ -410,13 +410,10 @@ USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
410410
USBD_LL_OpenEP(pdev, 0x00U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
411411
pdev->ep_out[0x00U & 0xFU].is_used = 1U;
412412

413-
pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE;
414-
415413
/* Open EP0 IN */
416414
USBD_LL_OpenEP(pdev, 0x80U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
417415
pdev->ep_in[0x80U & 0xFU].is_used = 1U;
418416

419-
pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE;
420417
/* Upon Reset call user call back */
421418
pdev->dev_state = USBD_STATE_DEFAULT;
422419
pdev->ep0_state = USBD_EP0_IDLE;

0 commit comments

Comments
 (0)