|
|
@@ -1809,7 +1809,6 @@ static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd)
|
|
|
|
|
|
if (((wEPVal & USB_EP_SETUP) == 0U) && ((wEPVal & USB_EP_RX_STRX) != USB_EP_RX_VALID))
|
|
|
{
|
|
|
- PCD_SET_EP_RX_CNT(hpcd->Instance, PCD_ENDP0, ep->maxpacket);
|
|
|
PCD_SET_EP_RX_STATUS(hpcd->Instance, PCD_ENDP0, USB_EP_RX_VALID);
|
|
|
}
|
|
|
}
|
|
|
@@ -1930,7 +1929,7 @@ static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd)
|
|
|
/* Manage Single Buffer Transaction */
|
|
|
if ((wEPVal & USB_EP_KIND) == 0U)
|
|
|
{
|
|
|
- /* multi-packet on the NON control IN endpoint */
|
|
|
+ /* Multi-packet on the NON control IN endpoint */
|
|
|
TxPctSize = (uint16_t)PCD_GET_EP_TX_CNT(hpcd->Instance, ep->num);
|
|
|
|
|
|
if (ep->xfer_len > TxPctSize)
|
|
|
@@ -2006,7 +2005,7 @@ static uint16_t HAL_PCD_EP_DB_Receive(PCD_HandleTypeDef *hpcd,
|
|
|
|
|
|
if (ep->xfer_len == 0U)
|
|
|
{
|
|
|
- /* set NAK to OUT endpoint since double buffer is enabled */
|
|
|
+ /* Set NAK to OUT endpoint since double buffer is enabled */
|
|
|
PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_NAK);
|
|
|
}
|
|
|
|
|
|
@@ -2038,11 +2037,11 @@ static uint16_t HAL_PCD_EP_DB_Receive(PCD_HandleTypeDef *hpcd,
|
|
|
|
|
|
if (ep->xfer_len == 0U)
|
|
|
{
|
|
|
- /* set NAK on the current endpoint */
|
|
|
+ /* Set NAK on the current endpoint */
|
|
|
PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_NAK);
|
|
|
}
|
|
|
|
|
|
- /*Need to FreeUser Buffer*/
|
|
|
+ /* Need to FreeUser Buffer */
|
|
|
if ((wEPVal & USB_EP_DTOG_TX) == 0U)
|
|
|
{
|
|
|
PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 0U);
|
|
|
@@ -2092,6 +2091,12 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, 0U);
|
|
|
PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, 0U);
|
|
|
|
|
|
+ if (ep->type == EP_TYPE_BULK)
|
|
|
+ {
|
|
|
+ /* Set Bulk endpoint in NAK state */
|
|
|
+ PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_NAK);
|
|
|
+ }
|
|
|
+
|
|
|
/* TX COMPLETE */
|
|
|
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
|
|
|
hpcd->DataInStageCallback(hpcd, ep->num);
|
|
|
@@ -2103,10 +2108,12 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
{
|
|
|
PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U);
|
|
|
}
|
|
|
+
|
|
|
+ return HAL_OK;
|
|
|
}
|
|
|
else /* Transfer is not yet Done */
|
|
|
{
|
|
|
- /* need to Free USB Buff */
|
|
|
+ /* Need to Free USB Buffer */
|
|
|
if ((wEPVal & USB_EP_DTOG_RX) != 0U)
|
|
|
{
|
|
|
PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U);
|
|
|
@@ -2137,7 +2144,7 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
}
|
|
|
|
|
|
/* Write remaining Data to Buffer */
|
|
|
- /* Set the Double buffer counter for pma buffer1 */
|
|
|
+ /* Set the Double buffer counter for pma buffer0 */
|
|
|
PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, len);
|
|
|
|
|
|
/* Copy user buffer to USB PMA */
|
|
|
@@ -2165,6 +2172,12 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
PCD_SET_EP_DBUF0_CNT(hpcd->Instance, ep->num, ep->is_in, 0U);
|
|
|
PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, 0U);
|
|
|
|
|
|
+ if (ep->type == EP_TYPE_BULK)
|
|
|
+ {
|
|
|
+ /* Set Bulk endpoint in NAK state */
|
|
|
+ PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_NAK);
|
|
|
+ }
|
|
|
+
|
|
|
/* TX COMPLETE */
|
|
|
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
|
|
|
hpcd->DataInStageCallback(hpcd, ep->num);
|
|
|
@@ -2177,10 +2190,12 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
{
|
|
|
PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U);
|
|
|
}
|
|
|
+
|
|
|
+ return HAL_OK;
|
|
|
}
|
|
|
else /* Transfer is not yet Done */
|
|
|
{
|
|
|
- /* need to Free USB Buff */
|
|
|
+ /* Need to Free USB Buffer */
|
|
|
if ((wEPVal & USB_EP_DTOG_RX) == 0U)
|
|
|
{
|
|
|
PCD_FREE_USER_BUFFER(hpcd->Instance, ep->num, 1U);
|
|
|
@@ -2210,7 +2225,7 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
ep->xfer_fill_db = 0;
|
|
|
}
|
|
|
|
|
|
- /* Set the Double buffer counter for pmabuffer1 */
|
|
|
+ /* Set the Double buffer counter for pma buffer1 */
|
|
|
PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, len);
|
|
|
|
|
|
/* Copy the user buffer to USB PMA */
|
|
|
@@ -2219,7 +2234,7 @@ static HAL_StatusTypeDef HAL_PCD_EP_DB_Transmit(PCD_HandleTypeDef *hpcd,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*enable endpoint IN*/
|
|
|
+ /* Enable endpoint IN */
|
|
|
PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_VALID);
|
|
|
|
|
|
return HAL_OK;
|