<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: USB HID Report ID - KL27Z / KL25Z / Kinetis - generic hid example in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-HID-Report-ID-KL27Z-KL25Z-Kinetis-generic-hid-example/m-p/1272564#M60459</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please refer this link. &lt;A href="https://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/" target="_self"&gt;hid-reporter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;BTW, you can use hid descriptor to generate the reporter. You can download here. &lt;A href="https://www.usb.org/document-library/hid-descriptor-tool" target="_self"&gt;hid_descriptor_tool&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;
&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 days after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
    <pubDate>Thu, 06 May 2021 02:39:19 GMT</pubDate>
    <dc:creator>nxf56274</dc:creator>
    <dc:date>2021-05-06T02:39:19Z</dc:date>
    <item>
      <title>USB HID Report ID - KL27Z / KL25Z / Kinetis - generic hid example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-HID-Report-ID-KL27Z-KL25Z-Kinetis-generic-hid-example/m-p/1271656#M60446</link>
      <description>&lt;P&gt;Problem regarding getting the USB HID generic example to work with a report id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started a new empty project with the "KL27Z" SDK and initialzied the USB Middleware via the "Config Tool". There I selected the generic HID example and just shorted the descriptor a little bit.&lt;/P&gt;&lt;P&gt;This is how my descriptor looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;uint8_t g_UsbDeviceInterface0HidGenericReportDescriptor[] = {
    0x05U, 0x81U,  /* Usage Page (Vendor defined) */ 
    0x09U, 0x82U,  /* Usage (Vendor defined) */ 
    0xA1U, 0x01U,  /* Collection (Application) */ 
    0x09U, 0x01U,  /* Usage (Vendor defined) */ 
    0x15U, 0x00U,  /* Logical Minimum (0) */ 
    0x26U, 0xFFU, 0x00U,  /* Logical Maximum (255) */ 
    0x75U, 0x08U,  /* Report Size (8U) */ 
    0x95U, 0x08U,  /* Report Count (8U) */ 
    0x81U, 0x02U,  /* Input(Data, Variable, Absolute) */ 
    0x09U, 0x01U,  /* Usage (Vendor defined) */ 
    0x91U, 0x02U,  /* Output(Data, Variable, Absolute) */ 
    0xC0U,  /* End collection, */ 
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I just used the example code to return the received values to the host:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;static usb_status_t USB_DeviceHidGenericAction(void)
{
    for (int i = 0; i &amp;lt; USB_INTERFACE_0_HID_GENERIC_OUTPUT_REPORT_LENGTH; i++)

    {
        s_UsbDeviceHidGeneric.inBuffer[i] = s_UsbDeviceHidGeneric.outBuffer[i];
    }

    USB_DeviceHidSend(s_UsbDeviceComposite-&amp;gt;interface0HidGenericHandle, USB_INTERFACE_0_HID_GENERIC_SETTING_0_EP_1_INTERRUPT_IN,
        (uint8_t *)s_UsbDeviceHidGeneric.inBuffer,
        USB_INTERFACE_0_HID_GENERIC_INPUT_REPORT_LENGTH);

    return USB_DeviceHidRecv(s_UsbDeviceComposite-&amp;gt;interface0HidGenericHandle, USB_INTERFACE_0_HID_GENERIC_SETTING_0_EP_1_INTERRUPT_OUT,
        (uint8_t *)s_UsbDeviceHidGeneric.outBuffer,
        USB_INTERFACE_0_HID_GENERIC_OUTPUT_REPORT_LENGTH);
}


usb_status_t USB_DeviceInterface0HidGenericCallback(class_handle_t handle, uint32_t event, void *param)
{
    usb_status_t error = kStatus_USB_Error;

    switch (event)
    {
        case kUSB_DeviceHidEventSendResponse:
            break;
        case kUSB_DeviceHidEventRecvResponse:
            if (s_UsbDeviceComposite-&amp;gt;attach)
            {
                return USB_DeviceHidGenericAction();
            }
            break;
        case kUSB_DeviceHidEventGetReport:
        case kUSB_DeviceHidEventSetReport:
        case kUSB_DeviceHidEventRequestReportBuffer:
            error = kStatus_USB_InvalidRequest;
            break;
        case kUSB_DeviceHidEventGetIdle:
        case kUSB_DeviceHidEventGetProtocol:
        case kUSB_DeviceHidEventSetIdle:
        case kUSB_DeviceHidEventSetProtocol:
            break;
        default:
            break;
    }

    return error;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I confirmed that it works with a small python script.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then i wanted to change it so I that the report uses a report id.&lt;BR /&gt;I changed the descriptor and it now looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;uint8_t g_UsbDeviceInterface0HidGenericReportDescriptor[] = {
    0x05U, 0x81U,  /* Usage Page (Vendor defined) */ 
    0x09U, 0x82U,  /* Usage (Vendor defined) */ 
    0xA1U, 0x01U,  /* Collection (Application) */ 
    0x09U, 0x01U,  /* Usage (Vendor defined) */ 
    0x85U, 0x02U,  /* Report ID (2) */
    0x15U, 0x00U,  /* Logical Minimum (0) */ 
    0x26U, 0xFFU, 0x00U,  /* Logical Maximum (255) */ 
    0x75U, 0x08U,  /* Report Size (8U) */ 
    0x95U, 0x08U,  /* Report Count (8U) */ 
    0x81U, 0x02U,  /* Input(Data, Variable, Absolute) */ 
    0x09U, 0x01U,  /* Usage (Vendor defined) */ 
    0x91U, 0x02U,  /* Output(Data, Variable, Absolute) */ 
    0xC0U,  /* End collection, */ 
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But now the devices does not send back the bytes when I run the python script.&lt;BR /&gt;If I set a breakpoint in the "&lt;EM&gt;USB_DeviceHidGenericAction()&lt;/EM&gt;" function it stops there and calls the "&lt;EM&gt;USB_DeviceHidSend()&lt;/EM&gt;" function.&lt;/P&gt;&lt;P&gt;Do I have to insert the report id somwhere in the message and how would I do it.&lt;BR /&gt;I tried to just set &lt;EM&gt;s_UsbDeviceHidGeneric.inBuffer[0]&lt;/EM&gt; to the report id but that didn't worked.&lt;/P&gt;&lt;P&gt;I'm new to this, never done something with USB before and the SDK is really overwhelming.&lt;/P&gt;&lt;P&gt;Help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 10:37:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-HID-Report-ID-KL27Z-KL25Z-Kinetis-generic-hid-example/m-p/1271656#M60446</guid>
      <dc:creator>Eras</dc:creator>
      <dc:date>2021-05-04T10:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: USB HID Report ID - KL27Z / KL25Z / Kinetis - generic hid example</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-HID-Report-ID-KL27Z-KL25Z-Kinetis-generic-hid-example/m-p/1272564#M60459</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please refer this link. &lt;A href="https://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/" target="_self"&gt;hid-reporter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;BTW, you can use hid descriptor to generate the reporter. You can download here. &lt;A href="https://www.usb.org/document-library/hid-descriptor-tool" target="_self"&gt;hid_descriptor_tool&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;
&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 days after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 02:39:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/USB-HID-Report-ID-KL27Z-KL25Z-Kinetis-generic-hid-example/m-p/1272564#M60459</guid>
      <dc:creator>nxf56274</dc:creator>
      <dc:date>2021-05-06T02:39:19Z</dc:date>
    </item>
  </channel>
</rss>

