USB Host

I am not having any luck with setting up a USB host. Maybe I need to ask simple questions like how to import the libraries from here, https://github.com/felis/USB_Host_Shield_2.0, and go from there, because I haven't had any luck all day. Charley

For example, this is one sketch i have tried

/* MAX3421E USB Host controller SPI test /
/
This sketch tests SPI communication between Arduino and MAX3421E USB host controller */
#include <spi.h>
#include <max3421e.h>

void setup();
void loop();

byte i;
byte j = 0;
byte gpinpol_copy;

MAX3421E Max;

void setup()
{
Serial.begin( 9600 );
Max.powerOn();
delay(200);
}

void loop()
{
gpinpol_copy = Max.regRd( rGPINPOL );
Serial.println(“SPI test. Each ‘.’ indicates 64K transferred. Press any key to stop.”);
while( Serial.available() == 0 ) {
for( i = 0; i < 255; i++ ) {
Max.regWr( rGPINPOL, i );
if( Max.regRd( rGPINPOL ) != i ) {
Serial.println(“SPI transmit/receive mismatch”);
}
}//for( i = 0; i < 255; i++
j++;
if( j == 0 ) {
Serial.print(".");
}
}//while( Serial.available() == 0
Max.regWr( rGPINPOL, gpinpol_copy );
Serial.println("\r\nStopped.");
while( 1 ); //stop here
}

This is a list of errors while trying to compile it

sketch_nov06a.cpp:3:17: error: spi.h: No such file or directory
In file included from sketch_nov06a.cpp:4:
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:135: error: missing terminating ’ character
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:137: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:137: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:137: error: stray ‘\221’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:138: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:138: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:138: error: stray ‘\223’ in program
In file included from sketch_nov06a.cpp:4:
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:250:133: error: invalid suffix “d7d482914” on integer constant
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:558: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:558: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:635: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:635: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:648: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:668: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:668: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:688: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:688: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:706: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:706: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:773: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:773: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:796: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:796: error: stray ‘#’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:803: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:803: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:803: error: stray ‘\220’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:807: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:807: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:807: error: stray ‘\222’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:811: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:811: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:811: error: stray ‘\221’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:815: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:815: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:815: error: stray ‘\223’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:825: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:825: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:825: error: stray ‘\220’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:829: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:829: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:829: error: stray ‘\222’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:833: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:833: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:833: error: stray ‘\221’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:837: error: stray ‘\342’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:837: error: stray ‘\206’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:837: error: stray ‘\223’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:880:3: error: invalid preprocessing directive #This
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:881: error: stray ‘##’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:882: error: stray ‘##’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:882: error: stray ‘##’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:882: error: stray ‘##’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:899:10: error: invalid suffix “a” on integer constant
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:900:10: error: invalid suffix “b” on integer constant
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:906:11: error: invalid suffix “a” on integer constant
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:907:11: error: invalid suffix “b” on integer constant
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:923: error: missing terminating ’ character
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:934: error: stray ‘' in program C:\Arduino\arduino-0022\libraries\Max/max3421e.h:934: error: stray '’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:934: error: stray ‘' in program C:\Arduino\arduino-0022\libraries\Max/max3421e.h:937: error: stray '$' in program C:\Arduino\arduino-0022\libraries\Max/max3421e.h:940: error: stray '’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:940: error: stray ‘' in program C:\Arduino\arduino-0022\libraries\Max/max3421e.h:940: error: stray '’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:956: error: stray ‘' in program C:\Arduino\arduino-0022\libraries\Max/max3421e.h:956: error: stray '’ in program
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:4: error: expected unqualified-id before ‘<’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:117: error: expected constructor, destructor, or type conversion before ‘<’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:144: error: expected unqualified-id before ‘<’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:593: error: expected constructor, destructor, or type conversion before ‘<’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:634: error: expected unqualified-id before numeric constant
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:643: error: expected unqualified-id before ‘<’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:668: error: function definition does not declare parameters
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:668: error: expected unqualified-id before ‘>’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:688: error: function definition does not declare parameters
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:688: error: expected unqualified-id before ‘>’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:706: error: function definition does not declare parameters
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:706: error: expected unqualified-id before ‘>’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:773: error: function definition does not declare parameters
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:773: error: expected unqualified-id before ‘>’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:796: error: function definition does not declare parameters
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:796: error: expected unqualified-id before ‘>’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:881: error: expected constructor, destructor, or type conversion before ‘&’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:881: error: ‘tag’ does not name a type
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:882: error: expected constructor, destructor, or type conversion before ‘&’ token
C:\Arduino\arduino-0022\libraries\Max/max3421e.h:882: error: expected constructor, destructor, or type conversion before ‘<’ token

rameses32:
#include <spi.h>
#include <max3421e.h>

spi.h is not the same as SPI.h

Thank you for that, that removed one error, but I'm still no closer to getting a working USB host, I have tried all of the Sketches from Circuits@Home web page, all with the same result when I compile them, hundreds of errors. They must work, so I am definitely doing something wrong but for the life of me I can't figure out what. I downloaded the USB Host Shield library 2.0 and put in in a folder I called USB in the libraries folder, I am running the newest version of Arduino software.

Any help is greatly appreciated as I am at wits end here.

I don't know what Circuits@home is. When asking questions about existing projects or products, it is also more helpful to provide links. Most people are the forum aren't familiar with every web page that says "Arduino" some where on it.

The path in the error looks weird to me: "C:\Arduino\arduino-0022\libraries\Max/max3421e.h:"

I don't understand why the slashes are different. I'm not sure if that is the problem or just how the Arduino IDE handles being on windows. Where did you download the files from for the MAX3421, and how did you unzip it?

Problem solved, I knew I was doing something wrong, I was putting the files in the wrong place, I was putting them in the libraries folder in Arduino instead of where my sketches are stored, I created a libraries folder in My Documents\Arduino and placed the files there and everything works perfectly now. Thanks for all the help Charley

Have you got any programs to compile clean yet?

I can't find any code to compile for the USB Shield that compiles clean.

There are some "Warnings" that show up as the code compiles but if you see the compiled size at the end of a verify or it downloads at the end of a compile then the sketch is OK.

There is an option on the Circuitsathome GitHub location to download as ZIP.

I put all my files under Libraries (you will have to name the subdirectory...) and played with some of the samples - the one to run first is board_qc and if you attach a mouse of keyboard it will respond.

You MUST hook up the 6 pin ICSP header or wire those connections to the correct Arduino pins.