#include <avr/pgmspace.h>
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <address.h>
#include <hidboot.h>
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>
class MouseRptParser : public MouseReportParser
{
protected:
virtual void OnMouseMove (MOUSEINFO *mi);
virtual void OnLeftButtonUp (MOUSEINFO *mi);
virtual void OnLeftButtonDown (MOUSEINFO *mi);
virtual void OnRightButtonUp (MOUSEINFO *mi);
virtual void OnRightButtonDown (MOUSEINFO *mi);
virtual void OnMiddleButtonUp (MOUSEINFO *mi);
virtual void OnMiddleButtonDown (MOUSEINFO *mi);
};
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
{
  Serial.print("dx=");
  Serial.print(mi->dX, DEC);
  Serial.print(" dy=");
  Serial.println(mi->dY, DEC);
};
void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
{
  Serial.println("L Butt Up");
};
void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
{
  Serial.println("L Butt Dn");
};
void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
{
  Serial.println("R Butt Up");
};
void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
{
  Serial.println("R Butt Dn");
};
void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
{
  Serial.println("M Butt Up");
};
void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
{
  Serial.println("M Butt Dn");
};
USBÂ Â Usb;
USBHub  Hub(&Usb);
HIDBoot<HID_PROTOCOL_MOUSE>Â Â Mouse(&Usb);
uint32_t next_time;
MouseRptParser               Prs;
void setup()
{
  Serial.begin( 115200 );
  Serial.println("Start");
  if (Usb.Init() == -1)
    Serial.println("OSC did not start.");
  Â
  delay( 200 );
Â
  next_time = millis() + 5000;
Â
  Mouse.SetReportParser(0,(HIDReportParser*)&Prs);
}
void loop()
{
 Usb.Task();
}
The only output I get is the initial "Start".
I did a little research and found that the Method Usb.getUsbTaskState gives me an error code 19, which is related to an error called "USB_DETACHED_SUBSTATE_ILLEGAL".
There are lots of ways to configure that shield. How have you configured it (solder bridges)? Have you connected the ICSP header? Can you make a photo of your finished shield on place on the Mega and post it here?
I did a little research and found that the Method Usb.getUsbTaskState gives me an error code 19, which is related to an error called "USB_DETACHED_SUBSTATE_ILLEGAL".
This at least means that a communication with the shield takes place (this is from a register value of 0x0C).
I dont have anything configured at all ('cause I didn't find instructions).
This is OK, because the standard configuration is for 5V and SS->pin10, INT->pin9, which seems to be the default for the Mega board anyway. On the picture you haven't connected anything to the shield. What kind of device are you testing with?
I've tested it with everything I could find here. USB-Sticks, Keyboards, Mice and my Android-Smartphone. Of course I used the example Sketches related to my device (Mass Storage, HID, ADK). But the error code appears always. Even if there is no device connected. As long as the shield is connected and powered up I get this error code.
Btw. Thanks for trying to help. You're the first one that does
Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision invalid. Value returned: FF
Unrecoverable error - test halted!!
0x55 pattern is transmitted via SPI
Press RESET to restart test
The SPI interface is not working, likely due to bad soldering of 2x3 header. You need to double-check the solder job here - remove the flux and use a magnifier. Also, check continuity between boards. If you have an oscilloscope, this article shows how to troubleshoot SPI on USB host shield -> https://www.circuitsathome.com/mcu/arduino/usb-shield/troubleshooting-arduino-usb-host-shield
Mhm. I checked the solderings. They are fine. The connection between the pins on the shield and the pins on the board are also established. So you are saying the shield's hardware is broken? or the ICSP on my Arduino?
I'm not saying it's broken. What I can see is SPI is not receiving, I can't say which direction is not working or even if a clock is reaching the MAX3421E, all I see is all ones instead on number 03. To troubleshoot further you need an oscilloscope with >10MHz BW.
You can send the shield back, I'll test it and replace it if defective. But I almost never see defective SPI and very often see bad soldering.
Mhm. Ya. Well I checked the solderings. If I'm not completely incompetent (which is possible, but I don't think so ) the solderings are okay.
And since I neither have an oscilloscope nor am from America (Germany) I think I just have to accept that it doesn't work. -.- Maybe I'll try to send it back to my supplier (lipoly)..