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 Reply Children
  • Hi Milorad,

    Here are details:
    MDK-ARM Plus Version:5.23
    MDK-Middleware 7.4.0
    Board: SVT31W74
    Microcontroller: S1C31W74

    USB driver full speed.

    Today I made a hack in ARM_USBD_EndpointTransfer() that makes USBD_HID_GetReportTrigger() working again.

    #include "rl_usbd_lib.h"

    extern usbd_data_t usbd0_data;
    int32_t ARM_USBD_EndpointTransfer(uint8_t ep_addr, uint8_t *data, uint32_t num) {

    ...

    usbd0_data.endpoint_active[17] = 0;

    return ARM_DRIVER_OK;
    }

    I do not think this is an appropriate solution and am looking for a real fix.

    Regards,
    Val

  • Hi Val,

    which driver are you using for the USB?
    Which chip have you selected in MDK?

    Best regards, Milorad

  • 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

  • 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