pic_usb.h defines req_Set_Interface. However in pic_usb.c it is not used as it should be in usb_handle_standard_request. As a result the (Linux at least) USB stack waits a couple of seconds when trying to close a USB connection as it does not receive a reply to the request and has to wait for a timeout to occur.
According to the USB 2.0 specification a correct way to handle this request if only one interface is being used would be to stall endpoint0. A more generic approach to possible not implemented standard requests would be to stall endpoint0 in the default clause of the usb_handle_standard_request function.
The correct solution is:
Code: Select all
void usb_handle_standard_request(setup_data_packet sdp)
{
switch (sdp.bRequest)
{
case req_Get_Descriptor:
... cut some lines...
case req_Get_Status:
#ifdef USB_SELF_POWERED
usb_send_one_byte(1);
#else
usb_send_one_byte(0); // bus powered
#endif
break;
// add the lines below
case req_Set_Interface:
usb_stall_ep0();
break;
Code: Select all
void usb_handle_standard_request(setup_data_packet sdp)
{
switch (sdp.bRequest)
{
case req_Get_Descriptor:
... cut some lines...
default:
// add the line below
usb_stall_ep0();
Jac