<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/6633" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2012-05-09T10:48:13+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/6633</id>

		<entry>
		<author><name><![CDATA[dreamyy5]]></name></author>
		<updated>2012-05-09T10:48:13+02:00</updated>

		<published>2012-05-09T10:48:13+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=6633&amp;p=21560#p21560</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=6633&amp;p=21560#p21560"/>
		<title type="html"><![CDATA[Problems of V-USB HID joystick]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=6633&amp;p=21560#p21560"><![CDATA[
Hi,<br /><br />I'm tyring to create a  Data Acquisition device based on V-USB. I tired to describe my device as an HID joystick. Then I can transfer my date through axises information.<br /><br />Here is the problem, I do not know how to transfer my data through axises information. <br />here is my main.c:<br /><div class="codebox"><p>Code: </p><pre><code>char usbHidReportDescriptor&#91;69&#93; = {<br />    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)<br />    0x15, 0x00,                    // LOGICAL_MINIMUM (0)<br />    0x09, 0x04,                    // USAGE (Joystick)<br />    0xa1, 0x01,                    // COLLECTION (Application)<br />    0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)<br />    0x05, 0x01,                    //   USAGE_PAGE (Generic Desktop)<br />    0x09, 0x01,                    //   USAGE (Pointer)<br />    0xa1, 0x00,                    //   COLLECTION (Physical)<br />    0x09, 0x30,                    //     USAGE (X)<br />    0x09, 0x31,                    //     USAGE (Y)<br />    0x09, 0x32,                    //     USAGE (Z)<br />   0x09, 0x33,                    //     USAGE (U)<br />    0x95, 0x04,                    //     REPORT_COUNT (4)<br />    0x81, 0x02,                    //     INPUT (Data,Var,Abs)<br />    0xc0,                          //   END_COLLECTION<br />    0x09, 0x39,                    //   USAGE (Hat switch)<br />    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)<br />    0x25, 0x03,                    //   LOGICAL_MAXIMUM (3)<br />    0x35, 0x00,                    //   PHYSICAL_MINIMUM (0)<br />    0x46, 0x0e, 0x01,              //   PHYSICAL_MAXIMUM (270)<br />    0x65, 0x14,                    //   UNIT (Eng Rot:Angular Pos)<br />    0x75, 0x04,                    //   REPORT_SIZE (4)<br />    0x95, 0x01,                    //   REPORT_COUNT (1)<br />    0x81, 0x02,                    //   INPUT (Data,Var,Abs)<br />    0x05, 0x09,                    //   USAGE_PAGE (Button)<br />    0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)<br />    0x29, 0x04,                    //   USAGE_MAXIMUM (Button 4)<br />    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)<br />    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)<br />    0x75, 0x01,                    //   REPORT_SIZE (1)<br />    0x95, 0x04,                    //   REPORT_COUNT (4)<br />    0x55, 0x00,                    //   UNIT_EXPONENT (0)<br />    0x65, 0x00,                    //   UNIT (None)<br />    0x81, 0x02,                    //   INPUT (Data,Var,Abs)<br />    0xc0                           // END_COLLECTION<br />};<br /><br />unsigned int array&#91;8&#93;={0}; <br />//unsigned int value; <br /><br />void adc_init() <br />{ <br />  ADMUX=0x00; <br />  ADCSRA=0x00; <br />  ADMUX = (1&lt;&lt;REFS0)|(1&lt;&lt;REFS1);       <br />  ADCSRA|=(1&lt;&lt;ADEN)|(1&lt;&lt;ADPS1)|(1&lt;&lt;ADPS0)|(1&lt;&lt;ADFR);     <br />} <br /><br /><br />unsigned int ReadADC(unsigned char channel)   <br />{   <br />  unsigned int ad;  <br /><br />  ADMUX   &amp;= 0xF8; <br />  ADMUX   |= channel;             // Select channel   <br />  ADCSRA |= (1&lt;&lt;ADSC);           // Start conversion   <br />  while (!(ADCSRA &amp; (1&lt;&lt;ADIF)));     // Check if converstion is ready   <br />  ADCSRA|= (1&lt;&lt;ADIF) ;           // Clear Conversion ready flag by setting the bit   <br />  ad = ADCL;                 // Read 8 low bits first (important)   <br />  ad += (unsigned int)ADCH &lt;&lt; 8;       // Read 2 high bits and multiply with 256   <br />  return ad;   <br />} <br /><br />static uchar reportBuffer&#91;4&#93;={0,0,0,0};<br />uchar usbFunctionSetup(uchar data&#91;8&#93;)<br />{<br />    reportBuffer&#91;0&#93; = data&#91;2&#93;;<br />   reportBuffer&#91;1&#93; = data&#91;3&#93;;<br />   reportBuffer&#91;2&#93; = data&#91;4&#93;;<br />   reportBuffer&#91;3&#93; = data&#91;5&#93;;<br />   usbMsgPtr=reportBuffer;<br />   return 4;<br />}<br /><br /><br />int main(void)<br />{    <br />  unsigned char i; <br />  unsigned int dat; <br />  //unsigned char PC;<br />  DDRA=0xff; <br />  DDRC=0xff; <br />  DDRF=0x00;  <br />   <br />  adc_init();  <br /><br />usbInit();<br />sei();<br /><br />  <br /><br />for(;;) <br />  {  <br />     <br />    for(i=0;i&lt;1;i++)<br />    {  <br />       <br />    dat=ReadADC(i);         <br />    array &#91; i &#93;=dat;         <br />    } <br />    usbPoll();<br />   usbSetInterrupt(reportBuffer, sizeof(reportBuffer));<br />   } <br /><br />} <br /></code></pre></div><br /><br />Any ideas, anyone? thank you!!<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=6589">dreamyy5</a> — Wed May 09, 2012 10:48 am</p><hr />
]]></content>
	</entry>
	</feed>
