drivers: usb_dc_stm32: Reinitialize the write semaphores on bus reset
If the user attempts to send data before the USB connection is established (see the HID sample for an example of such code), the DataInCallback never gets called which leaves the write semaphore in a taken state forever. Signed-off-by: Josef Gajdusek <atx@atx.name>
This commit is contained in:
parent
29ffcae80c
commit
f01a7250f0
1 changed files with 9 additions and 0 deletions
|
@ -880,12 +880,21 @@ int usb_dc_reset(void)
|
||||||
|
|
||||||
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
|
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
LOG_DBG("");
|
LOG_DBG("");
|
||||||
|
|
||||||
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_IN, EP0_MPS, EP_TYPE_CTRL);
|
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_IN, EP0_MPS, EP_TYPE_CTRL);
|
||||||
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_OUT, EP0_MPS,
|
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_OUT, EP0_MPS,
|
||||||
EP_TYPE_CTRL);
|
EP_TYPE_CTRL);
|
||||||
|
|
||||||
|
/* The DataInCallback will never be called at this point for any pending
|
||||||
|
* transactions. Reset the IN semaphores to prevent perpetual locked state.
|
||||||
|
* */
|
||||||
|
for (i = 0; i < DT_USB_NUM_BIDIR_ENDPOINTS; i++) {
|
||||||
|
k_sem_give(&usb_dc_stm32_state.in_ep_state[i].write_sem);
|
||||||
|
}
|
||||||
|
|
||||||
if (usb_dc_stm32_state.status_cb) {
|
if (usb_dc_stm32_state.status_cb) {
|
||||||
usb_dc_stm32_state.status_cb(USB_DC_RESET, NULL);
|
usb_dc_stm32_state.status_cb(USB_DC_RESET, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue