Skip to content

Commit 37f36a7

Browse files
author
Cruz Monrreal
authored
Merge pull request #6609 from pauluap/compiler_warning_pcd_unsigned_signed
STM32 PCD negative numbers issue
2 parents c867934 + 20f11bc commit 37f36a7

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_pcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
11521152
{
11531153
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
11541154
USB_OTG_EPTypeDef *ep = NULL;
1155-
int32_t len = 0;
1155+
uint32_t len;
11561156
uint32_t len32b = 0U;
11571157
uint32_t fifoemptymsk = 0U;
11581158

@@ -1185,7 +1185,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
11851185
ep->xfer_count += len;
11861186
}
11871187

1188-
if(len <= 0)
1188+
if (ep->xfer_count >= ep->xfer_len)
11891189
{
11901190
fifoemptymsk = 0x01U << epnum;
11911191
USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk;

targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_pcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
12131213
{
12141214
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
12151215
USB_OTG_EPTypeDef *ep;
1216-
int32_t len = 0U;
1216+
uint32_t len;
12171217
uint32_t len32b;
12181218
uint32_t fifoemptymsk = 0U;
12191219

@@ -1247,7 +1247,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
12471247
ep->xfer_count += len;
12481248
}
12491249

1250-
if(len <= 0U)
1250+
if (ep->xfer_count >= ep->xfer_len)
12511251
{
12521252
fifoemptymsk = 0x1U << epnum;
12531253
atomic_clr_u32(&USBx_DEVICE->DIEPEMPMSK, fifoemptymsk);

targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_pcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
13111311
{
13121312
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
13131313
USB_OTG_EPTypeDef *ep;
1314-
int32_t len = 0U;
1314+
uint32_t len;
13151315
uint32_t len32b;
13161316
uint32_t fifoemptymsk = 0U;
13171317

@@ -1345,7 +1345,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
13451345
ep->xfer_count += len;
13461346
}
13471347

1348-
if(len <= 0U)
1348+
if (ep->xfer_count >= ep->xfer_len)
13491349
{
13501350
fifoemptymsk = 0x1U << epnum;
13511351
/* MBED */

targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd)
145145

146146
// MBED: added
147147
if(hpcd->State == HAL_PCD_STATE_RESET)
148-
{
148+
{
149149
/* Allocate lock resource and initialize it */
150150
hpcd->Lock = HAL_UNLOCKED;
151151
for (i = 0; i < hpcd->Init.dev_endpoints ; i++)
@@ -1300,7 +1300,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
13001300
{
13011301
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
13021302
USB_OTG_EPTypeDef *ep;
1303-
int32_t len = 0;
1303+
uint32_t len;
13041304
uint32_t len32b;
13051305
uint32_t fifoemptymsk = 0;
13061306

@@ -1334,7 +1334,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
13341334
ep->xfer_count += len;
13351335
}
13361336

1337-
if(len <= 0)
1337+
if (ep->xfer_count >= ep->xfer_len)
13381338
{
13391339
fifoemptymsk = 0x1 << epnum;
13401340
atomic_clr_u32(&USBx_DEVICE->DIEPEMPMSK, fifoemptymsk); // MBED: changed

targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_pcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
14281428
{
14291429
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
14301430
USB_OTG_EPTypeDef *ep = NULL;
1431-
int32_t len = 0U;
1431+
uint32_t len;
14321432
uint32_t len32b = 0;
14331433
uint32_t fifoemptymsk = 0;
14341434

@@ -1462,7 +1462,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
14621462
ep->xfer_count += len;
14631463
}
14641464

1465-
if(len <= 0)
1465+
if (ep->xfer_count >= ep->xfer_len)
14661466
{
14671467
fifoemptymsk = 0x1 << epnum;
14681468
// Added for MBED PR #3062

0 commit comments

Comments
 (0)