libusb & 128 bytes data transfer
Posted: Wed Oct 07, 2009 5:14 pm
Hi!
Now I'm trying to transfer data between my device and PC using libusb and custom requests.
I can send 128 bytes from the device to computer already, but I'm in doubt about sending this array of data back to AVR.
Would it be right if I use this construction to receieve data (avr-side)?
What code should I use in the host application?
Now I'm trying to transfer data between my device and PC using libusb and custom requests.
I can send 128 bytes from the device to computer already, but I'm in doubt about sending this array of data back to AVR.
Would it be right if I use this construction to receieve data (avr-side)?
Code: Select all
#define CUSTOM_RQ_SET_ALL 2 // request to set data array
#define USB_BUFFER_REPORT_LEN 128 // data array len
static uchar wholeData[USB_BUFFER_REPORT_LEN] // this array should be filled with data
uchar usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (void *)data;
if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR)
{
// Trying to get data from PC
if(rq->bRequest == CUSTOM_RQ_SET_ALL)
{
uchar i;
for (i=0; i<USB_BUFFER_REPORT_LEN; i++)
{
wholeData[i] = rq->wValue.bytes[i];
}
}
}
return 0;
}
What code should I use in the host application?