<?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>LPCXpresso IDEのトピックRe: Adapting LPC1343 usbhid example to multi-byte transfers</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Adapting-LPC1343-usbhid-example-to-multi-byte-transfers/m-p/538515#M6067</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by deBoogle on Tue May 21 04:48:01 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi There,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am currently attempting to do the same thing and seem to be hitting the same wall.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you get your problem solved and if so what advice can you offer a USB newbie?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:26:00 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:26:00Z</dc:date>
    <item>
      <title>Adapting LPC1343 usbhid example to multi-byte transfers</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Adapting-LPC1343-usbhid-example-to-multi-byte-transfers/m-p/538514#M6066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by davidsmoot on Mon May 21 16:22:16 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to exchange HID reports between a USB host and my code running on a LPC1343 using the HID protocol.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to be able to define the size and structure of these messages to be an arbitrary number of bitfields and bytes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I started with the example "USBHid" project.&amp;nbsp; I think I understand that code.&amp;nbsp; It exchanges a single byte in each direction.&amp;nbsp; It defines the output from the host as "LED" bitfields and the input to the host as "Button" bitfields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I want to hack together an example project that defines my own HID packet structure.&amp;nbsp; I copied the HID demo code base, modified it, and tested it.&amp;nbsp; It compiles but I get errors when I plug in the USB connection about the USB device failing to start even before I try to exchange data.&amp;nbsp; So here I am, asking for help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my first attempt at coding a USB interface.&amp;nbsp; Any suggestions about debug tools / techniques?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it worked, I expect my code to accept an "OutReport" of 4 bytes from the host, copy those four bytes to an "InReport", and append a counter byte to the end of the InReport.&amp;nbsp; But for now I get a USB error in the windows device manager of "Failed to start (10)"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm guessing I probably screwed up the syntax of the HID_ReportDescriptor byte array when I modified it.&amp;nbsp; The original byte array definition:&lt;/SPAN&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/* HID Report Descriptor */
const uint8_t HID_ReportDescriptor[] = {
&amp;nbsp; HID_UsagePageVendor(0x00),
&amp;nbsp; HID_Usage(0x01),
&amp;nbsp; HID_Collection(HID_Application),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_UsagePage(HID_USAGE_PAGE_BUTTON),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_UsageMin(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_UsageMax(3),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_LogicalMin(0),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_LogicalMax(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_ReportCount(3),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_ReportSize(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_Input(HID_Data | HID_Variable | HID_Absolute),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_ReportCount(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_ReportSize(5),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_Input(HID_Constant),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_UsagePage(HID_USAGE_PAGE_LED),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_LogicalMin(0),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_LogicalMax(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_ReportCount(8),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_ReportSize(1),
&amp;nbsp;&amp;nbsp;&amp;nbsp; HID_Output(HID_Data | HID_Variable | HID_Absolute),
&amp;nbsp; HID_EndCollection,
};&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My attempt at a custom version:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/* HID Report Descriptor */
const uint8_t HID_ReportDescriptor[] = {
HID_UsagePageVendor(0x00),
HID_Usage(0x01),
HID_Collection(HID_Application),
HID_UsagePageVendor(0xC5),
HID_UsageMin(1),
HID_UsageMax(4),
HID_LogicalMin(0),
HID_LogicalMax(1),
HID_ReportCount(4),
HID_ReportSize(1),
HID_Input(HID_Data | HID_Variable | HID_Absolute),
HID_ReportCount(1),
HID_ReportSize(4),
HID_Input(HID_Constant),
HID_UsageMin(1),
HID_UsageMax(4),
HID_LogicalMin(0),
HID_LogicalMax(255),
HID_ReportCount(4),
HID_ReportSize(4),
HID_Input(HID_Data | HID_Variable | HID_Absolute),
HID_UsageMin(1),
HID_UsageMax(5),
HID_LogicalMin(0),
HID_LogicalMax(1),
HID_ReportCount(5),
HID_ReportSize(1),
HID_Output(HID_Data | HID_Variable | HID_Absolute),
HID_ReportCount(1),
HID_ReportSize(3),
HID_Output(HID_Constant),
HID_UsageMin(1),
HID_UsageMax(3),
HID_LogicalMin(0),
HID_LogicalMax(255),
HID_ReportCount(3),
HID_ReportSize(3),
HID_Output(HID_Data | HID_Variable | HID_Absolute),
HID_EndCollection,
};&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code above is intended to define an input report to the host with 4 variable bitfields followed by 4 constant bitfields followed by 4 bytes of unsigned data for a total of 5 bytes from NXP to USB host.&amp;nbsp; Conversely, the output from host to NXP should have 5 variable bitfields followed by three constant bitfields followed by 3 unsigned bytes for a total of 4 bytes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition to modifying the descriptor code above, I did the following changes to try to adapt the "usbhid" example to my goal:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Added defines for the number of bytes in an InReport and OutReport.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; Modified definition of InReport and OutReport variables to be byte arrays instead of single bytes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; Modified code that copies from InReport variable to output buffer to copy the additional bytes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4.&amp;nbsp; Modified the code that copies data from the buffer from the host into the OutReport variable to copy the extra bytes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5.&amp;nbsp; Modified the GetInReport Function to simply increment a static counter each time it is called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6.&amp;nbsp; Modified the SetOutReport to copy its contents into the InReport structure.&amp;nbsp; The hope was to simply have all bytes from host echoed back to the host with the addition of the one extra byte of incrementing counter mentioned above. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think maybe I am failing to correctly modify the "SetupPacket" but I can't figure out where I would do that.&amp;nbsp; My code is attached in a zip, it is just a minimally modified version of the "usbhid" example for LPC1343.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or guidance appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;David&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:25:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Adapting-LPC1343-usbhid-example-to-multi-byte-transfers/m-p/538514#M6066</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adapting LPC1343 usbhid example to multi-byte transfers</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Adapting-LPC1343-usbhid-example-to-multi-byte-transfers/m-p/538515#M6067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by deBoogle on Tue May 21 04:48:01 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi There,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am currently attempting to do the same thing and seem to be hitting the same wall.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you get your problem solved and if so what advice can you offer a USB newbie?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:26:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Adapting-LPC1343-usbhid-example-to-multi-byte-transfers/m-p/538515#M6067</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:26:00Z</dc:date>
    </item>
  </channel>
</rss>

