Page 1 of 1

Can't send data to device

Posted: Wed May 07, 2008 6:00 pm
by phil
Hi,

I'm stuck at receiving data using the AVR-USB.
My HID is simulating a gamepad with ATMega16 @ 12Mhz.

My Code:

Code: Select all

int test1=0;
int test2,test3;

uchar usbFunctionSetup(uchar data[8])
{
static uchar replyBuf[2];

 usbMsgPtr = replyBuf;
 test1++;
 test2 = data[0];
 test3 = data[1];

 return 0;
}

[...]

usbPoll();
if(usbInterruptIsReady()){
 reportBuffer[0]=test1;
 reportBuffer[1]=test2;
 reportBuffer[2]=test3;
 usbSetInterrupt(reportBuffer,3);
}


So, you see, a very basic program. I just want to send something to my µC, and the device should return it.
For testing I'm using the SimpleHIDWrite Programm from the HidPage (as LibUsb32 causes some trouble with Windows Vista).

My Problem:
It doesn't matter, what I send to the device. "data" will always be "21 09 00 02 00 00 02 00". So test2==21, test3 ==09. test1 increments everytime I send some bytes.

What am I doing wrong
:?

Thanks for your help!

Posted: Thu May 08, 2008 10:55 am
by christian
In usbFunctionSetup(), you receive the setup command, not the data sent to the device. You must implement usbFunctionWrite() to receive the data part. See the Automator example for how this is done in a HID compliant way.

Posted: Thu May 08, 2008 12:34 pm
by phil
:idea:

I got to work right. Thank you so much!