This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USBD_HID_GetReportTrigger problem: works only once

I am writing USB HID Device driver for ARM M0+ and got a problem with sending data from device to host. The device can send data only on the first call of USBD_HID_GetReportTrigger(). The all others calls of USBD_HID_GetReportTrigger() does nothing, it does not call back ARM_USBD_EndpointTransfer(). If I directly call ARM_USBD_EndpointTransfer(0x81, &but, 1) from main() then device can send data to host as many times as requested, no problem. I can see in memory two bits of difference in MDK usbd_config_0.o module (one is in usbd0_data->endpoint_active[17] and another looks like in usbd_driver_semaphore_cb_mem). If clear those two bits in MDK memory after USBD_HID_GetReportTrigger() got stuck then USBD_HID_GetReportTrigger() can call ARM_USBD_EndpointTransfer() again.

Parents
  • Hi Val,

    sorry I saw now that you are actually writing an USB Device driver yourself, excellent.

    Well, what your driver is probably missing is that it needs to call a callback SignalEndpointEvent from the IRQ when endpoint transfer has finished (or failed). And that callback is provided to driver as a parameter to USBD_Initialize function when it is called from middle layer.

    Best regards, Milorad

Reply
  • Hi Val,

    sorry I saw now that you are actually writing an USB Device driver yourself, excellent.

    Well, what your driver is probably missing is that it needs to call a callback SignalEndpointEvent from the IRQ when endpoint transfer has finished (or failed). And that callback is provided to driver as a parameter to USBD_Initialize function when it is called from middle layer.

    Best regards, Milorad

Children
  • Hi Milorad,

    I think you talking about ARM_USBD_EVENT_IN and I have a call of SignalEndpointEvent(num, ARM_USBD_EVENT_IN) in IRQ routine and it gets called. I even tried another delayed extra call of it but it did NOT help. And it did not clear usbd0_data.endpoint_active[17].

    Milorad, any idea what could be wrong?

    Can I have the source code of USB core?

    Regards,
    Val

  • Hi Val,

    I actually have a good idea what could be wrong.
    For IN endpoints you have to call SignalEndpointEvent with first parameter ORed with 0x80.
    Meaning for Endpoint 1 IN, you should call SignalEndpointEvent(0x81, ARM_USBD_EVENT_IN).

    Best regards, Milorad