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

Custom HID device on nRF52840.

I develop my own device on nRF52840 which will be HID device. And I have made my own HID descriptor of device:

#define APP_USBD_HID_MY_REPORT_2(bcnt) {    \
    0x06, 0x00, 0xff,              /* 	USAGE_PAGE (Generic Desktop)*/  \
    0x09, 0x01,       /*USAGE (Vendor Usage 1)                      */  \
      /*System Parameters*/                                             \
    0xa1, 0x01,                    /* COLLECTION (Application)     */   \
    /*IDDI1 - out*/                                                   \
    0x85, 0x01,                    /*   OUT REPORT_ID (1)*/                 \
    0x09, 0x01,                    /*   USAGE (Vendor Usage 1)*/        \
    0x15, 0x00,                    /*   LOGICAL_MINIMUM (0)*/           \
    0x25, 0x01,                    /*   LOGICAL_MAXIMUM (1)*/           \
    0x75, 62,                      /*   REPORT_SIZE (8)*/               \
    0x95, 0x08, 	           /*   REPORT_COUNT (4)*/              \
    0xb1, 0x82,                    /*   FEATURE (Data,Var,Abs,Vol)*/    \
    0x85, 0x01,                    /*   REPORT_ID (1)*/                 \
    0x09, 0x01,                    /*   USAGE (Vendor Usage 1)*/        \
    0x91, 0x82,                    /*   OUTPUT (Data,Var,Abs,Vol)*/     \
    /*IDDI2 - out*/                                                   \
    0x85, 0x02,                    /*   OUT REPORT_ID (1)*/                 \
    0x09, 0x01,                    /*   USAGE (Vendor Usage 1)*/        \
    0x15, 0x00,                    /*   LOGICAL_MINIMUM (0)*/           \
    0x25, 0x01,                    /*   LOGICAL_MAXIMUM (1)*/           \
    0x75, 5,                      /*   REPORT_SIZE (8)*/               \
    0x95, 0x08, 	           /*   REPORT_COUNT (4)*/              \
    0xb1, 0x82,                    /*   FEATURE (Data,Var,Abs,Vol)*/    \
    0x85, 0x02,                    /*   REPORT_ID (1)*/                 \
    0x09, 0x01,                    /*   USAGE (Vendor Usage 1)*/        \
    0x91, 0x82,                    /*   OUTPUT (Data,Var,Abs,Vol)*/     \
                                                                        \
    0x85, 0x01,                    /*   IN REPORT_ID 1*/     \
    0x09, 0x02,                    \
    0x75, 0x08,                    /*REPORT_SIZE*/ \
    0x95, 0x08,	                   \
    0x81, 0x82,                    \
      0xC0    /*     END_COLLECTION	             */                 \
};

And if I send data with function from example:

        ret = app_usbd_hid_generic_in_report_set(
            &m_app_hid_generic,
            report,
            sizeof(report));

And nothing comes, because In report ID = 1, but this function sends data with ID=0.

How can I define ID for this function? Or may be there is another function to send data with specifying ID?

My descriptor works in another MCU and here I want to do the similar. I can not specify my own ID=0, because this ID is incorrect and device is defined with "!" in Device Manager.

Parents
  • Hi,

    if you include report ID to your HID descriptor, the first byte of report data should be report ID, the real data starts from the second byte.

    Your descriptor looks somewhat messy, and you didn't define REPORT_COUNT and REPORT_SIZE for your output report. I would suggest to try a working descriptor from example, then extend it with report ID and change as your app needs.

Reply
  • Hi,

    if you include report ID to your HID descriptor, the first byte of report data should be report ID, the real data starts from the second byte.

    Your descriptor looks somewhat messy, and you didn't define REPORT_COUNT and REPORT_SIZE for your output report. I would suggest to try a working descriptor from example, then extend it with report ID and change as your app needs.

Children
Related