<?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>Zephyr USB Feature reports</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95801/zephyr-usb-feature-reports</link><description>Does Zephyr support USB feature reports? I see examples in Devzone, but they look like they are pre-Zephyr. If an example exists using Zephyr, please include a link. 
 Thanks for your help.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Feb 2023 09:08:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95801/zephyr-usb-feature-reports" /><item><title>RE: Zephyr USB Feature reports</title><link>https://devzone.nordicsemi.com/thread/409075?ContentTypeID=1</link><pubDate>Thu, 09 Feb 2023 09:08:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91145348-4773-440f-b175-b9dfbdefedaa</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Ray,&lt;/p&gt;
&lt;p&gt;This could also be of use to you:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/services/usb/hid.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/services/usb/hid.html&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As you have mentioned, please continue with your project and don&amp;#39;t hesitate to contact in case of further queries.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr USB Feature reports</title><link>https://devzone.nordicsemi.com/thread/408675?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 17:00:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e209d74f-7089-4b8c-b495-2bfd948c8e9e</guid><dc:creator>rdolejs</dc:creator><description>&lt;p&gt;Hi Priyanka,&lt;/p&gt;
&lt;p&gt;I reviewed the source code for the nRF_Deskop application you mention and other source code in the Nordic library. I was able to find and copy the required sections of code to get basic USB feature report communication to work. The code below will send and receive blocks of eight bytes. If you have any updates I should include in the code please let me know. I will continue with the project and let you know if I have any further issues with USB feature reports.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Ray&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static const struct hid_ops ops = {
	.get_report   = get_report,
	.set_report   = set_report,
	.int_in_ready = in_ready_cb,
};

static const uint8_t hid_report_desc[] = HID_REPORT_DESC();


usb_hid_register_device(hid0_dev, hid_report_desc,
	sizeof(hid_kbd_report_desc), &amp;amp;ops);


static int get_report(const struct device *dev, struct usb_setup_packet *setup, int32_t *len_to_set, uint8_t **data)
{
	uint8_t request_value[2];

	sys_put_le16(setup-&amp;gt;wValue, request_value);

	switch (request_value[1]) 
	{
		case REPORT_TYPE_FEATURE:
		{
			size_t length = setup-&amp;gt;wLength;
			uint8_t *buf = *data;

			*len_to_set = length;

			// Data from PC
			LOG_DBG(&amp;quot;length=%d data=%02x %02x %02x %02x %02x %02x %02x %02x&amp;quot;, setup-&amp;gt;wLength, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);

			return 0;

			break;
		}

		case REPORT_TYPE_INPUT:
		{
			LOG_DBG(&amp;quot;input report&amp;quot;);
			break;
		}

		default:
		{
			/* Should not happen. */
			break;
		}
	}
	
	return -ENOTSUP;
}

static int set_report(const struct device *dev, struct usb_setup_packet *setup, int32_t *len, uint8_t **data)
{
	uint8_t request_value[2];

	sys_put_le16(setup-&amp;gt;wValue, request_value);

	switch (request_value[1]) 
	{
		case REPORT_TYPE_FEATURE:
		{
			size_t length = setup-&amp;gt;wLength;
			uint8_t *buf = *data;

			// Send eight 0x55 bytes
			memset(buf, 0x55, 8);

			// Data to PC
			LOG_DBG(&amp;quot;length=%d data=%02x %02x %02x %02x %02x %02x %02x %02x&amp;quot;, setup-&amp;gt;wLength, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);

			return 0;

			break;
		}

		case REPORT_TYPE_OUTPUT:
		{
			LOG_DBG(&amp;quot;output report&amp;quot;);
			break;
		}

		default:
		{
			/* Should not happen. */
			break;
		}
	}

	return -ENOTSUP;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr USB Feature reports</title><link>https://devzone.nordicsemi.com/thread/405636?ContentTypeID=1</link><pubDate>Thu, 19 Jan 2023 10:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60d14dbe-efea-4aad-91f0-a8f2b7d3ab35</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Ray,&lt;/p&gt;
&lt;p&gt;Zephyr does support USB feature reports.&amp;nbsp;You ca maybe refer the nRF_Desktop application which uses one HID feature report:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/nrf_desktop/README.html#hid-data-handling"&gt;HID Data Handling&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/nrf_desktop/README.html#hid-feature-reports"&gt;HID feature report&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.2.0/applications/nrf_desktop/configuration/common/hid_report_desc.c#L21"&gt;HID feature report desc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>