This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 adding out endpoint to usbd_hid_generic example in SDK 15

Hello Nordic experts,

I am trying to add an output endpoint to the usbd_hid_generic example in nRF5_SDK_15.0.0_a53641a. I exactly followed the suggestions in 

https://devzone.nordicsemi.com/f/nordic-q-a/36145/nrf52840-usbd_hid_generic-endpoint-out-error

However, when I monitor the usb with Bus Hound, there is no sign of Endpoint 1 OUT. Please have a look at the attached photo. Can you please help me to understand what I am doing wrong?

Moreover, in the attached photo, you can see that (34) USB Input Device does not have any sub-port/branch, while for the usbd_hid_generic without any modification, there was a sub-port similar to (20) in the attached photo.

Thanks

  • To be more precise, these are the changes I made to the usbd_hid_generic example in main.c:

    /**
    * @brief HID generic class endpoint number.
    * */
    #define HID_GENERIC_EPIN NRF_DRV_USBD_EPIN1
    #define HID_GENERIC_EPOUT NRF_DRV_USBD_EPOUT1

    #define REPORT_OUT_MAXSIZE 63

    #define ENDPOINT_LIST() \
    ( \
    HID_GENERIC_EPIN,HID_GENERIC_EPOUT \
    )

    #define USBD_GENERIC_REPORT_DESCRIPTOR { \
    0x06, 0xD0, 0xF1 , /*USAGE_PAGE (FIDO Alliance) */ \
    0x09, 0x01 , /* USAGE (U2F HID Authenticator Device) */ \
    0xa1, 0x01 , /* COLLECTION (Application) */ \
    0x09, 0x20 , /*   USAGE (Input Report Data) */ \
    0x15, 0x00 , /*   LOGICAL_MINIMUM (0) */ \
    0x26, 0xff, 0x00 , /*   LOGICAL_MAXIMUM (255) */ \
    0x75, 0x08 , /*   REPORT_SIZE (8) */ \
    0x95, 0x40 , /*   REPORT_COUNT (64) */ \
    0x81, 0x02 , /*   INPUT (Data,Var,Abs) */ \
    0x09, 0x21 , /*   USAGE(Output Report Data) */ \
    0x15, 0x00 , /*   LOGICAL_MINIMUM (0) */ \
    0x26, 0xff, 0x00 , /*   LOGICAL_MAXIMUM (255) */ \
    0x75, 0x08 , /*   REPORT_SIZE (8) */ \
    0x95, 0x40 , /*   REPORT_COUNT (64) */ \
    0x91, 0x02 , /*   OUTPUT (Data,Var,Abs) */ \
    0xc0 , /* END_COLLECTION */ \
    }

    APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(mouse_desc,USBD_GENERIC_REPORT_DESCRIPTOR);

    /**
    * @brief Global HID generic instance
    */
    APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid_generic,
    HID_GENERIC_INTERFACE,
    hid_user_ev_handler,
    ENDPOINT_LIST(),
    reps,
    REPORT_IN_QUEUE_SIZE,
    REPORT_OUT_MAXSIZE,
    APP_USBD_HID_SUBCLASS_NONE, 
    APP_USBD_HID_PROTO_GENERIC);

  • Hi,

     

    Sorry for the late reply, I can confirm that I see the same thing and it took a bit of time to find the source of the issue.

    This is a bug from our side, where line 452 in app_usbd_hid_generic.c loops over "i" instead of "j".

    If you change it to this, it should work as expected:

    p_cur_ep = app_usbd_class_iface_ep_get(p_cur_iface, j);

     

    Could you try this and report back?

     

    Kind regards,

    Håkon

  • Great, this resolves the issue. Thanks a lot. 

  • Hi,

      I am facing the same related issues,when i change the USBD_GENERIC_REPORT_DESCRIPTOR  to as shown as below:

    #define USBD_GENERIC_REPORT_DESCRIPTOR {                        \
          0x06, 0x01, 0xFF,    /*      Usage Page (unk)         */ \
          0x09, 0x01,          /*   Usage (0x01)                */ \
          0xA1, 0x01,          /*   Collection (Application)    */ \
          0xA1, 0x02,          /*     Collection (Logical)      */ \
          0x85, 0x5B,          /*       Report ID (0x5B)        */ \
          0x09, 0x14,          /*       Usage (0x14)            */ \
          0x15, 0x80,          /*       Logical Minimum (-128)  */ \
          0x25, 0x7F,          /*       Logical Maximum (127)   */ \
          0x75, 0x08,          /*       Report Size (8)         */ \
          0x95, 0x3F,          /*       Report Count (63)       */ \
          0x81, 0x22,          /*       Input (Var, PrefState)  */ \
          0xC0,                /*     End Collection            */ \
          0xA1, 0x02,          /*     Collection (Logical)      */ \
          0x85, 0x5C,          /*       Report ID (0x5C)        */ \
          0x09, 0x14,          /*       Usage (0x14)            */ \
          0x15, 0x80,          /*       Logical Minimum (-128)  */ \
          0x25, 0x7F,          /*       Logical Maximum (127)   */ \
          0x75, 0x08,          /*       Report Size (8)         */ \
          0x95, 0x3F,          /*       Report Count (63)       */ \
          0x81, 0x22,          /*       Input (Var, PrefState)  */ \
          0xC0,                /*     End Collection            */ \
          0xA1, 0x02,          /*     Collection (Logical)      */ \
          0x85, 0x5D,          /*       Report ID (0x5D)        */ \
          0x09, 0x14,          /*       Usage (0x14)            */ \
          0x15, 0x80,          /*       Logical Minimum (-128)  */ \
          0x25, 0x7F,          /*       Logical Maximum (127)   */ \
          0x75, 0x08,          /*       Report Size (8)         */ \
          0x95, 0x3F,          /*       Report Count (63)       */ \
          0x81, 0x22,          /*       Input (Var, PrefState)  */ \
          0xC0,                /*     End Collection            */ \
          0xA1, 0x02,          /*     Collection (Logical)      */ \
          0x85, 0x5E,          /*       Report ID (0x5E)        */ \
          0x09, 0x14,          /*       Usage (0x14)            */ \
          0x15, 0x80,          /*       Logical Minimum (-128)  */ \
          0x25, 0x7F,          /*       Logical Maximum (127)   */ \
          0x75, 0x08,          /*       Report Size (8)         */ \
          0x95, 0x1F,          /*       Report Count (31)       */ \
          0x91, 0x22,          /*       Output (Var, PrefState) */ \
          0xC0,                /*  End Collection               */ \
          0xC0                /*End Collection                 */ \
    }

    it can't work well,can u give me some suggestions?thanks.

Related