USB to SPI with ATMEL16

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ardiansyah_mrit
Posts: 10
Joined: Sun Oct 09, 2011 6:14 am
Contact:

USB to SPI with ATMEL16

Post by ardiansyah_mrit » Sun Oct 09, 2011 6:23 am

hey.. morning all :D
can you help me about that topic??
i'm using v-usb to create that project but i don't know how to use the frimware in v-usb.. :cry:
i'm want to write / read eeprom via usb using SPI protocol.
please help me this my final project in my education... :(

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: USB to SPI with ATMEL16

Post by maxi » Sun Oct 09, 2011 8:29 pm

Something like this perhaps http://www.recursion.jp/avrcdc/cdc-spi.html?

There is a version for mega8, shouldn't be too difficult to compile for mega16.

ardiansyah_mrit
Posts: 10
Joined: Sun Oct 09, 2011 6:14 am
Contact:

Re: USB to SPI with ATMEL16

Post by ardiansyah_mrit » Mon Oct 10, 2011 5:26 am

thank's form reply :) , but i'm still confius about that. :(
i want to write and read the eeprom (AT93c465) via USB from my PC.
i'm using v-usb last update, in the source i'm confused how to edit the source so i can write and read the eeprom (AT93c46) from PC via USB PORT using SPI comunication in ATMEGA16..

please help me on the source bellow :
main.c on D:\vusb-20100715\examples\hid-data\firmware
uchar usbFunctionRead(uchar *data, uchar len)
{
if(len > bytesRemaining)
len = bytesRemaining;
eeprom_read_block(data, (uchar *)0 + currentAddress, len); //how to change this line, so i can read the EEPROM from PC via USB Port
currentAddress += len;
bytesRemaining -= len;
return len;
}

/* 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)
{
if(bytesRemaining == 0)
return 1; /* end of transfer */
if(len > bytesRemaining)
len = bytesRemaining;
eeprom_write_block(data, (uchar *)0 + currentAddress, len); //how to change this line, so i can write the EEPROM from PC via USB Port
currentAddress += len;
bytesRemaining -= len;
return bytesRemaining == 0; /* return 1 if this was the last chunk */
}


and this my block diagram of my project :
PC to ATMEGA16 using USB, ATMEGA to EEPROM (AT93C46) module using SPI PORT

Post Reply