<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NRF52840 consumer device USBD HID setup</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102112/nrf52840-consumer-device-usbd-hid-setup</link><description>Hi Im new to nordic. 
 Currently Im porting a project from ESP32 to nrf52840 dongle as a USB HID device. 
 I have to set up a HID comsumer device to control the media function (volume +/-, mute, play pause... etc) 
 But I cant find any example doing this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Jul 2023 01:45:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102112/nrf52840-consumer-device-usbd-hid-setup" /><item><title>RE: NRF52840 consumer device USBD HID setup</title><link>https://devzone.nordicsemi.com/thread/437963?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2023 01:45:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61bf52dd-ea17-4fca-a2f0-e789b1d71bad</guid><dc:creator>Sherman Lee</dc:creator><description>&lt;p&gt;After several trial &amp;amp; error, my final descriptor go like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define APP_USBD_HID_CONSUMER_REPORT_DSC {                                      \
    0x05, 0x0C,       /* Usage Page (desktop)                           */      \
    0x09, 0x01,       /* Usage (Consumer Control)                       */      \
    0xA1, 0x01,       /* Collection (Application)                       */      \
    0x15, 0x00,       /* Logical minimum (0)                            */      \
    0x25, 0x01,       /* Logical maximum (1)                            */      \
    0x75, 0x01, 	  /* Report Size (1)								*/      \
    0x95, 0x07, 	  /* Report Count (7)								*/      \
    0x09, 0xE9, 	  /* Usage (Volume Up)                      bit 0	*/      \
    0x09, 0xEA, 	  /* Usage (Volume Down) 					bit 1	*/      \
    0x09, 0xE2, 	  /* Usage (Mute)							bit 2	*/      \
    0x09, 0xB7, 	  /* Usage (Stop)                           bit 3	*/      \
    0x09, 0xCD,       /* Usage (Play/Pause)                     bit 4	*/      \
    0x09, 0xB6,       /* Usage (Scan Previous Track)			bit 5	*/      \
    0x09, 0xB5,       /* Usage (Scan Next Track)				bit 6	*/      \
    0x81, 0x02, 	  /* Input (Data, Variable, Absolute)               */      \
    0x75, 0x01, 	  /* Report Size (1)								*/      \
    0x95, 0x01, 	  /* Report Count (1)								*/      \
    0x81, 0x03, 	  /* Input (Constant)								*/      \
    0xC0,             /* End Collection                                 */      \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As I dont need power and AC function so I shrinked the data to 7 bits and padded 1 bits to make a byte&lt;/p&gt;
&lt;p&gt;The report in function simplifed as follow&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void ctrl_hid_media_command(uint8_t u8_report) {
    // Send the HID report
    ret_code_t err_code = app_usbd_hid_generic_in_report_set(&amp;amp;m_app_hid_consumer, &amp;amp;u8_report, sizeof(u8_report));
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And it finally works!&lt;/p&gt;
&lt;p&gt;Thanks for everyone who gave help.&lt;/p&gt;
&lt;p&gt;And admin plz close this ticket. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 consumer device USBD HID setup</title><link>https://devzone.nordicsemi.com/thread/437842?ContentTypeID=1</link><pubDate>Mon, 24 Jul 2023 11:19:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07c47023-5981-4967-89fd-3864d0e104a2</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;For the nRF5 SDK, see &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/examples_usb.html?cp=9_1_4_6_50"&gt;nRF5 SDK USB examples&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 consumer device USBD HID setup</title><link>https://devzone.nordicsemi.com/thread/437776?ContentTypeID=1</link><pubDate>Mon, 24 Jul 2023 03:55:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e6fa969-1822-4fe4-9820-5bfc3ab86c93</guid><dc:creator>Sherman Lee</dc:creator><description>&lt;p&gt;I hv study some info and constructed a descriptor like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define APP_USBD_HID_CONSUMER_REPORT_DSC {                                      \
    0x05, 0x0C,       /* Usage Page (Consumer)                          */      \
    0x09, 0x01,       /* Usage (Consumer Control)                       */      \
    0xA1, 0x01,       /* Collection (Application)                       */      \
    0x85, 0x00,       /*   Report Id (0)                                */      \
    0x15, 0x00,       /*   Logical minimum (0)                          */      \
    0x25, 0x01,       /*   Logical maximum (1)                          */      \
    0x09, 0xE9, 	  /*   Usage (Volume Up)					bit 0	*/      \
    0x09, 0xEA, 	  /*   Usage (Volume Down) 					bit 1	*/      \
    0x09, 0xE2, 	  /*   Usage (Mute)							bit 2	*/      \
    0x09, 0x30, 	  /*   Usage (Power)						bit 3	*/      \
    0x0A, 0x23,0x02,  /*   Usage (AC Home) 						bit 4	*/      \
    0x0A, 0x24,0x02,  /*   Usage (AC Back) 						bit 5	*/      \
    0x09, 0xCD,       /*   Usage (Play/Pause)					bit 6	*/      \
    0x09, 0xB6,       /*   Usage (Scan Previous Track)			bit 7	*/      \
    0x09, 0xB5,       /*   Usage (Scan Next Track)				bit 8	*/      \
    0x75, 0x01, 	/*	 Report Size (1)									*/  \
    0x95, 0x09, 	/*	 Report Count (9)									*/  \
    0x81, 0x02, 	/*	 Input (Data, Variable, Absolute)					*/  \
    0x75, 0x01, 	/*	 Report Size (1)									*/  \
    0x95, 0x07, 	/*	 Report Count (7)									*/  \
    0x81, 0x01, 	/*	 Input (Constant)									*/  \
    0xC0,              /* End Collection                                    */  \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I set up the HID using generic API&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(consumer_desc, APP_USBD_HID_CONSUMER_REPORT_DSC);
static const app_usbd_hid_subclass_desc_t * reps[] = {&amp;amp;consumer_desc};

APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid_consumer,
                                APP_USBD_INTERFACE_COMSUER,
                                hid_consumer_user_ev_handler,
                                (NRF_DRV_USBD_EPIN3),
                                reps,
                                REPORT_IN_QUEUE_SIZE,
                                REPORT_OUT_MAXSIZE,
                                REPORT_FEATURE_MAXSIZE,
                                APP_USBD_HID_SUBCLASS_BOOT,
                                APP_USBD_HID_PROTO_GENERIC);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And the report should look like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;typedef struct {
    uint8_t u8_id;
    uint8_t u8p_btn[2];
}hid_report_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After append the HID&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;app_usbd_class_inst_t const * class_inst_consumer;
class_inst_consumer = &amp;amp;m_app_hid_consumer.base;
err_code = app_usbd_class_append(class_inst_consumer);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I send out the report by this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;hid_report_t report;

report.u8_id = 0;
report.u8_btn[0] = 0x01;    // should be volume +
report.u8_btn[1] = 0x00;

ret_code_t err_code = app_usbd_hid_generic_in_report_set(&amp;amp;m_app_hid_consumer, u8p_report, sizeof(u8p_report));
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Computer recongize the dongle as HID, but no respond after sending the report&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which part I missed or have to correct in order to make this work?&lt;br /&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 consumer device USBD HID setup</title><link>https://devzone.nordicsemi.com/thread/437758?ContentTypeID=1</link><pubDate>Sun, 23 Jul 2023 09:12:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e864f52-36f3-4611-9524-829de53b9130</guid><dc:creator>Sherman Lee</dc:creator><description>&lt;p&gt;Im not using Zephyr. Is there another example I could follow with softdevice? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 consumer device USBD HID setup</title><link>https://devzone.nordicsemi.com/thread/437677?ContentTypeID=1</link><pubDate>Fri, 21 Jul 2023 12:56:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e611598-744d-4d59-a459-63a9e40f1789</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/subsys/usb/hid/README.html"&gt;USB HID Sample Application&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>