HID Data Transfert without eeprom_write_block/eeprom_read_bl

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
honupata
Posts: 14
Joined: Sat Sep 24, 2011 1:53 am

HID Data Transfert without eeprom_write_block/eeprom_read_bl

Post by honupata » Sat Sep 24, 2011 2:06 am

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.
Last edited by honupata on Sat May 12, 2012 5:28 am, edited 1 time in total.

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

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

Post by Daid » Mon Sep 26, 2011 10:04 am

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.

honupata
Posts: 14
Joined: Sat Sep 24, 2011 1:53 am

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

Post by honupata » Sat May 12, 2012 5:17 am

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 */
}

Post Reply