mirror of https://github.com/ARMmbed/mbed-os.git
Initial work was for unsigned-signed comparison fix. Current work fixes negative number issues
Compile: stm32f7xx_hal_pcd.c
../targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c: In function 'PCD_WriteEmptyTxFifo':
../targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c:1310:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (len > ep->maxpacket)
^
../targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c:1325:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (len > ep->maxpacket)
^
pull/6609/head
parent
a463b075db
commit
430784b084
|
|
@ -1298,50 +1298,56 @@ PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd)
|
||||||
*/
|
*/
|
||||||
static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t epnum)
|
static HAL_StatusTypeDef PCD_WriteEmptyTxFifo(PCD_HandleTypeDef *hpcd, uint32_t epnum)
|
||||||
{
|
{
|
||||||
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
|
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
|
||||||
USB_OTG_EPTypeDef *ep;
|
USB_OTG_EPTypeDef *ep;
|
||||||
int32_t len = 0;
|
uint32_t len;
|
||||||
uint32_t len32b;
|
uint32_t len32b;
|
||||||
uint32_t fifoemptymsk = 0;
|
uint32_t fifoemptymsk = 0U;
|
||||||
|
|
||||||
ep = &hpcd->IN_ep[epnum];
|
ep = &hpcd->IN_ep[epnum];
|
||||||
len = ep->xfer_len - ep->xfer_count;
|
|
||||||
|
|
||||||
if (len > ep->maxpacket)
|
if (ep->xfer_len >= ep->xfer_count)
|
||||||
{
|
|
||||||
len = ep->maxpacket;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
len32b = (len + 3) / 4;
|
|
||||||
|
|
||||||
while ( (USBx_INEP(epnum)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) > len32b &&
|
|
||||||
ep->xfer_count < ep->xfer_len &&
|
|
||||||
ep->xfer_len != 0)
|
|
||||||
{
|
|
||||||
/* Write the FIFO */
|
|
||||||
len = ep->xfer_len - ep->xfer_count;
|
|
||||||
|
|
||||||
if (len > ep->maxpacket)
|
|
||||||
{
|
{
|
||||||
len = ep->maxpacket;
|
len = ep->xfer_len - ep->xfer_count;
|
||||||
|
|
||||||
|
if (len > ep->maxpacket)
|
||||||
|
{
|
||||||
|
len = ep->maxpacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
len32b = (len + 3U) / 4U;
|
||||||
|
|
||||||
|
while (((USBx_INEP(epnum)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) > len32b) &&
|
||||||
|
(ep->xfer_count < ep->xfer_len) &&
|
||||||
|
(ep->xfer_len != 0U))
|
||||||
|
{
|
||||||
|
/* Write the FIFO */
|
||||||
|
if (ep->xfer_len >= ep->xfer_count)
|
||||||
|
{
|
||||||
|
len = ep->xfer_len - ep->xfer_count;
|
||||||
|
|
||||||
|
if (len > ep->maxpacket)
|
||||||
|
{
|
||||||
|
len = ep->maxpacket;
|
||||||
|
}
|
||||||
|
len32b = (len + 3U) / 4U;
|
||||||
|
|
||||||
|
USB_WritePacket(USBx, ep->xfer_buff, epnum, len, hpcd->Init.dma_enable);
|
||||||
|
|
||||||
|
ep->xfer_buff += len;
|
||||||
|
ep->xfer_count += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fifoemptymsk = 0x1U << epnum;
|
||||||
|
/* MBED */
|
||||||
|
atomic_clr_u32(&USBx_DEVICE->DIEPEMPMSK, fifoemptymsk);
|
||||||
|
/* MBED */
|
||||||
}
|
}
|
||||||
len32b = (len + 3) / 4;
|
|
||||||
|
|
||||||
USB_WritePacket(USBx, ep->xfer_buff, epnum, len, hpcd->Init.dma_enable);
|
return HAL_OK;
|
||||||
|
|
||||||
ep->xfer_buff += len;
|
|
||||||
ep->xfer_count += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(len <= 0)
|
|
||||||
{
|
|
||||||
fifoemptymsk = 0x1 << epnum;
|
|
||||||
atomic_clr_u32(&USBx_DEVICE->DIEPEMPMSK, fifoemptymsk); // MBED: changed
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue