Page 1 of 1

HID Data Transfert without eeprom_write_block/eeprom_read_bl

Posted: Sat Sep 24, 2011 2:06 am
by honupata
Hi,

I just update vusb-for-arduino (http://code.google.com/p/vusb-for-arduino/
) with the latest version of V-USB(20100715) (only the HID Data part).
The vusb-for-arduino example sketch works fine with the C command line hidtool.exe provided as example (see attachment http://arduino.cc/forum/index.php/topic ... #msg549623) :D

My goal is to do a gmail notifier http://www.justblair.co.uk/the-attiny45 ... ifier.html but with a Atmega328 a the Arduino IDE

Here is where I need help:
The comunication between the firmware hid-data\main.c and the Arduino is done by implementing a data store of 128 bytes in EEPROM (eeprom_write_block/eeprom_read_block). I really want to avoid using the EEPROM (it is slow and the lifespan is limited at 100000 writes).

I don’t know enought C to implement a differrent way to transfer the data between the VUSB\hid-data\main.c and the Arduino (Can an array in the RAM passed between the hid-data\main.c and Arduino do the job) ?

Thank you for your help.

Re: V-USB(20100715) with Arduino - HID Data

Posted: Mon Sep 26, 2011 10:04 am
by Daid
Take a look at how the arduino serial driver does it, it also keeps a buffer for data, you could do the same thing. And this is more a general C/Arduino question so the avr-freaks forums might serve you better.

Re: V-USB(20100715) with Arduino - HID Data

Posted: Sat May 12, 2012 5:17 am
by honupata
FYI,

Here is how I did it:

char buffer[128];

uchar usbFunctionRead(uchar *data, uchar len)
{
if(len > bytesRemaining) // len is max chunk size
len = bytesRemaining; // send an incomplete chunk
bytesRemaining -= len;
uchar i;
for(i = 0; i < len; i++)
data[i] = buffer[currentAddress++]; // copy the data to the buffer
return len; // return real chunk size
}

/* usbFunctionWrite() is called when the host sends a chunk of data to the
* device. For more information see the documentation in usbdrv/usbdrv.h.
*/
uchar usbFunctionWrite(uchar *data, uchar len)
{
uchar i;
for(i=0;i<len;i++)
buffer[currentAddress+i]=*(data+i);
currentAddress += len;
bytesRemaining -= len;
return bytesRemaining == 0; /* return 1 if this was the last chunk */
}