Skip to content
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

TARGET_STM: fix unterminated multi-packet USB transaction #15465

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 10 additions & 2 deletions targets/TARGET_STM/USBPhy_STM32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,19 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
{
USBPhyHw *priv = ((USBPhyHw *)(hpcd->pData));
uint8_t endpoint = LOG_IN_TO_EP(epnum);
priv->epComplete[EP_TO_IDX(endpoint)] = 1;
uint8_t &epComplete = priv->epComplete[EP_TO_IDX(endpoint)];

if (epnum) {
priv->events->in(endpoint);
if (epComplete == 2 && hpcd->IN_ep[epnum].xfer_count == hpcd->IN_ep[epnum].maxpacket) {
/* transmit zero-length packet to avoid ongoing multi-packet transaction */
epComplete = 3;
HAL_PCD_EP_Transmit(hpcd, epnum, NULL, 0);
} else {
epComplete = 1;
priv->events->in(endpoint);
}
} else {
epComplete = 1;
priv->events->ep0_in();
}
}
Expand Down