mirror of https://github.com/ARMmbed/mbed-os.git
Abort the current USB transfer when stalling
It is undefined behavior if stalling and unstalling clears an ongoing transfer. Abort any ongoing transfers explicitly when stalling and unstalling so the behavior is consistent across devices.pull/9768/head
parent
c76d80e36e
commit
dbe41c3659
|
@ -1151,6 +1151,10 @@ void USBDevice::endpoint_stall(usb_ep_t endpoint)
|
|||
info->flags |= ENDPOINT_STALLED;
|
||||
_phy->endpoint_stall(endpoint);
|
||||
|
||||
if (info->pending) {
|
||||
endpoint_abort(endpoint);
|
||||
}
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
@ -1172,6 +1176,10 @@ void USBDevice::endpoint_unstall(usb_ep_t endpoint)
|
|||
return;
|
||||
}
|
||||
|
||||
if (info->pending) {
|
||||
endpoint_abort(endpoint);
|
||||
}
|
||||
|
||||
info->flags &= ~ENDPOINT_STALLED;
|
||||
_phy->endpoint_unstall(endpoint);
|
||||
|
||||
|
|
|
@ -178,6 +178,9 @@ public:
|
|||
/**
|
||||
* Stall an endpoint
|
||||
*
|
||||
* If there is an ongoing transfer on this endpoint then it will
|
||||
* be aborted.
|
||||
*
|
||||
* @param endpoint Endpoint to stall
|
||||
* @note You cannot stall endpoint 0 with this function
|
||||
* @note This endpoint must already have been setup with endpoint_add
|
||||
|
@ -187,6 +190,10 @@ public:
|
|||
/**
|
||||
* Unstall an endpoint
|
||||
*
|
||||
* Unstalling an endpoint resets data toggle back to DATA0.
|
||||
* Additionally, if there is an ongoing transfer on this endpoint
|
||||
* it will be aborted.
|
||||
*
|
||||
* @param endpoint Endpoint to unstall
|
||||
* @note This endpoint must already have been setup with endpoint_add
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue