dmitrystu / libusb_stm32

Lightweight USB device Stack for STM32 microcontrollers
Apache License 2.0
713 stars 163 forks source link

Interrupt Endpoint callbacks missing #1

Closed xcvista closed 6 years ago

xcvista commented 7 years ago

I am trying to build a HID device, which calls for a pair of Interrupt endpoints. However the endpoint callbacks are not being called at all, although on the host side the system is trying to INTERRUPT IN.

What is amiss here? Is there something I need to be aware of?

Here is my code. I am using an interrupt-driven stack so this file is pretty self-contained.

dmitrystu commented 7 years ago

Well. Endpoint TX event raises after TX completion. Therefore you should transmit 1'st packet asynchronously. Try to send zero-length packet to IN endpoint just after endpoint configuration.

        usbd_ep_config(dev, USB_RXD_EP, USB_EPTYPE_INTERRUPT, USB_PKT_SZ);
        usbd_ep_config(dev, USB_TXD_EP, USB_EPTYPE_INTERRUPT, USB_PKT_SZ);
        usbd_reg_endpoint(dev, USB_RXD_EP, usb_rx);
        usbd_reg_endpoint(dev, USB_TXD_EP, usb_tx);
        usbd_ep_write(dev, USB_TXD_EP, 0, 0);
        return usbd_ack;

Also you can send your own packet instead ZLP.

xcvista commented 7 years ago

@dmitrystu Thanks. I added the write and it worked. Another problem is about reenumeration. Why it isn't quite working?

dmitrystu commented 7 years ago

At this moment i have no idea what's happens. I will try your code ASAP. Could you explain me how i can reproduce this problem?

xcvista commented 7 years ago

Feed it a bad descriptor or refuse it the HID Report Descriptor, and Windows will start reenumerating.

dmitrystu commented 7 years ago

Found bug in OTG_FS driver that freeze MCU on USB bus reset when endpoints is configured (reenumeration), No similar problems found for other drivers. See "dev" branch.