0

Using the SPI feature
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Using the SPI feature

by sgoadhouse on Tue Jul 28, 2009 9:34 pm

It seems obvious to me now that the code referenced at the bottom of http://www.ladyada.net/make/usbtinyisp/use.html does not really work. If the zip file had the missing usbdriver.h header file and you used what must be slightly modified hardware (/SS [or RESET] is expected at PB1 in the code instead of where USBtinyISP has it at PB4), then it may work. I decided to dust off my internal programming cobwebs and give it a go at making it work. I used code from avrdude and suggestions in this forum and got it working. Seeing how there are lots of questions in the forum pointing out that the code referenced above does not compile, I wanted to share with you all what I was able to get to work.

This code reads a Microchip SPI EEPROM. You give it the byte offset desired as the first argument on the command line and it reads and returns its byte value. For other SPI EEPROMs, you'll most likely need to change EEPROM_READ_CMD in usbdriver.cpp. Also, you'll need to hook up the RESET line to the chip's /CS or /SS chip select line as well as connecting the SCLK, MISO and MOSI lines as expected.

The makefile has some options so that you can compile on OSX. If you don't have OSX, you'll need to comment out the CFLAGS and LIB variable and uncomment the original ones (see the comments in the makefile). I do not know if the original CFLAGS and LIB values work properly on other systems so you may need to point to where your libusb include files and libraries are. (NOTE: must have libusb (http://libusb.wiki.sourceforge.net/) installed for this code to work).

Here's the code:
USBtinyISP_SPI.zip
http://www.ladyada.net/make/usbtinyisp/use.html modified to work properly. If not running on OSX, need to modify makefile.
(27.28 KiB) Downloaded 962 times
sgoadhouse
 
Posts: 6
Joined: Mon Jul 13, 2009 6:59 pm

Re: Using the SPI feature

by adafruit on Tue Jul 28, 2009 10:13 pm

yay! thanks! i lost my dev environment, i thought usbdriver.h came with libusb, no?
its been years :cry:

adafruit
 
Posts: 12131
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Using the SPI feature

by sgoadhouse on Tue Aug 25, 2009 8:14 pm

Sorry for the slow response ...

I could not find usbdriver.h in libusb, at least not the version I had to work with. I took your usbtiny.h from avrdude and created it. It was missing some defines that I figured out by looking at the usbtiny firmware. It was mainly the numbers for the commands.
sgoadhouse
 
Posts: 6
Joined: Mon Jul 13, 2009 6:59 pm

Re: Using the SPI feature

by Cyberspice on Sat Jan 02, 2010 10:26 am

I've just been looking at the example code in the tarball (as I want to debug code in an ATTiny25 and I don't get much choice with the I/O). The usbdriver.h header is missing from the tarball so most of the defines are missing.

usb.h is the header file for libusb (v0.1, v1.0 has a different API) so you may need to install the libusb-dev package (or equivalent) on Linux for that. Since I'm OS X I'm going to steal it the header from my linux box. I have the library from installing the cross-pack tools.

I'm an embedded software engineer by default and I often have to debug, analyse and extend other people's code so I'm just going to look at avrdude and work out how it works from there. If you'd like a new example I'd be willing to write one.

Melanie
User avatar
Cyberspice
 
Posts: 1
Joined: Thu Jul 23, 2009 7:34 pm
Location: Yorkshire UK / Silicon Valley CA

Re: Using the SPI feature

by nsayer on Sat Jan 24, 2015 5:10 am

I went back to the original source and got his latest firmware. It works perfectly for me.

http://dicks.home.xs4all.nl/avr/usbtiny/

nsayer
 
Posts: 58
Joined: Thu Aug 08, 2013 10:45 am

Please be positive and constructive with your questions and comments.