as per title, if you have a thread suspended in synchronous usb call and another thread invokes usbStop, the thread which is suspended will never be woken.
The following code works as a workaround in application code, but I believe this should be incorporated into usbStop itself.
usbStop(usbp);
osalSysLock();
for (unsigned i = 1; i <= (unsigned)USB_MAX_ENDPOINTS; i++) {
if (usbp->epc[i] != NULL) {
if (usbp->epc[i]->in_state != NULL) {
osalThreadResumeS(&usbp->epc[i]->in_state->thread, MSG_RESET);
}
if (usbp->epc[i]->out_state != NULL) {
osalThreadResumeS(&usbp->epc[i]->out_state->thread, MSG_RESET);
}
}
}
osalOsRescheduleS();
osalSysUnlock();
It doesn't look like I can edit above, so I will fix the issue here:
EP0 should be included in the loop, as even though the default implementation in chibios does not use synchronous transfers on ep0, it is possible (and I actually do it) to override the ep0 config and implement synchronous transfers on ep0
Hi,
Thanks for the patch, applied with a small change in order to wakeup threads atomically.
Giovanni
Perfect, thanks. I have applied this patch to my project and can confirm it works as expected. Consider this issue closed.
Many thanks for your hard work on this wonderful project.
however, I just realized that this will break builds with USB_USE_WAIT disabled.
Here is my proposed change.
I included one extra line to set epc to NULL, similar to usbDisableEndpointsI, just for sanity sake.
I totally missed that too. Fixed in repo.
Giovanni