Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[bug report] In SDK 15 can't use more than one endpoint in USB HID

USB device don't recognized by system if we try to use more than one endpoint in app_usbd_hid_generic library:

APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid,
                                INTERFACE_NUMBER,
                                hid_ev_handler,
                                (HID_IN_ENDPOINT, HID_OUT_ENDPOINT),
                                hid_reports,
                                HID_IN_QUEUE_SIZE,
                                HID_OUT_MAXSIZE,
                                APP_USBD_HID_SUBCLASS_BOOT,
                                APP_USBD_HID_PROTO_MOUSE);

This code, but with one endpoint(in or out) works as expected:

APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid,
                              ...
                                (HID_IN_ENDPOINT),
                           ...);

After changing loop variable to "j" in components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c our code works fine even with 2 endpoints.

static bool hid_generic_feed_descriptors(app_usbd_class_descriptor_ctx_t  * p_ctx,
                                         app_usbd_class_inst_t const      * p_inst,
                                         uint8_t                          * p_buff,
                                         size_t                             max_size)
{

    ...

    for (i = 0; i < ifaces; i++)
    {

        ...

        static uint8_t endpoints = 0;
        endpoints = app_usbd_class_iface_ep_count_get(p_cur_iface);

        for (j = 0; j < endpoints; j++)
        {

            ...

            p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, i);              <<=== wrong loop variable
            
            ...

        }
    }

    APP_USBD_CLASS_DESCRIPTOR_END();
}

Parents Reply Children
No Data
Related