Quantcast
Channel: Infineon Forums
Viewing all articles
Browse latest Browse all 9892

USBD app could be freeze when disconnecting the cable

$
0
0
Hi,

USBD app 4.0.14 on XMC4xxx could be freeze in a infinite loop.

The problem is in the file
Dave/Model/APPS/USBD/v4_0_14/Template/usb/core/xmc4000/usbd_endpoint_stream_xmc4000.c:
in function
Endpoint_Write_Stream_x():
...
93: while (Length)
94: {
95: if (ep->InInUse)
96: {
97: continue;
98: }
...

When trasmits a packet could happen the controller is busy because reading, so the driver wait
until rx finished.
Problem occurs when the driver is in this state and the user unplug the cable from the board.
InInUse flag is blocked to 1 and USBD is freeze in a infinite loop in this while().

I fix the problem adding a control that checks if USB_DeviceState is Unattached.
This stops the transfer and return an ENDPOINT_RWSTREAM_DeviceDisconnected error.

while (Length)
{
if (USB_DeviceState == (uint8_t)DEVICE_STATE_Unattached)
{
return ENDPOINT_RWSTREAM_DeviceDisconnected;
}
if (ep->InInUse)
{
continue;
}

In attachment the patch....

Is this fix okay to be merged to the next USBD app version?

Regards,
Matteo,
Sirius Electronic Systems

Viewing all articles
Browse latest Browse all 9892

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>