Skip to content

STM32 PCD negative numbers issue #6609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2018
Merged
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
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
{
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
USB_OTG_EPTypeDef *ep = NULL;
int32_t len = 0;
uint32_t len;
uint32_t len32b = 0U;
uint32_t fifoemptymsk = 0U;

Expand Down Expand Up @@ -1185,7 +1185,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
ep->xfer_count += len;
}

if(len <= 0)
if (ep->xfer_count >= ep->xfer_len)
{
fifoemptymsk = 0x01U << epnum;
USBx_DEVICE->DIEPEMPMSK &= ~fifoemptymsk;
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
{
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
USB_OTG_EPTypeDef *ep;
int32_t len = 0U;
uint32_t len;
uint32_t len32b;
uint32_t fifoemptymsk = 0U;

Expand Down Expand Up @@ -1247,7 +1247,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
ep->xfer_count += len;
}

if(len <= 0U)
if (ep->xfer_count >= ep->xfer_len)
{
fifoemptymsk = 0x1U << epnum;
atomic_clr_u32(&USBx_DEVICE->DIEPEMPMSK, fifoemptymsk);
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
{
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
USB_OTG_EPTypeDef *ep;
int32_t len = 0U;
uint32_t len;
uint32_t len32b;
uint32_t fifoemptymsk = 0U;

Expand Down Expand Up @@ -1345,7 +1345,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
ep->xfer_count += len;
}

if(len <= 0U)
if (ep->xfer_count >= ep->xfer_len)
{
fifoemptymsk = 0x1U << epnum;
/* MBED */
Expand Down
6 changes: 3 additions & 3 deletions targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd)

// MBED: added
if(hpcd->State == HAL_PCD_STATE_RESET)
{
{
/* Allocate lock resource and initialize it */
hpcd->Lock = HAL_UNLOCKED;
for (i = 0; i < hpcd->Init.dev_endpoints ; i++)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
{
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
USB_OTG_EPTypeDef *ep;
int32_t len = 0;
uint32_t len;
uint32_t len32b;
uint32_t fifoemptymsk = 0;

Expand Down Expand Up @@ -1334,7 +1334,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
ep->xfer_count += len;
}

if(len <= 0)
if (ep->xfer_count >= ep->xfer_len)
{
fifoemptymsk = 0x1 << epnum;
atomic_clr_u32(&USBx_DEVICE->DIEPEMPMSK, fifoemptymsk); // MBED: changed
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
{
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
USB_OTG_EPTypeDef *ep = NULL;
int32_t len = 0U;
uint32_t len;
uint32_t len32b = 0;
uint32_t fifoemptymsk = 0;

Expand Down Expand Up @@ -1462,7 +1462,7 @@ static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t
ep->xfer_count += len;
}

if(len <= 0)
if (ep->xfer_count >= ep->xfer_len)
{
fifoemptymsk = 0x1 << epnum;
// Added for MBED PR #3062
Expand Down