Giter Site home page Giter Site logo

usb_host_shield_2.0's Introduction

USB Host Library Rev. 2.0

The code is released under the GNU General Public License.


Summary

This is Revision 2.0 of MAX3421E-based USB Host Shield Library for AVR's.

Project main web site is: https://chome.nerpa.tech/arduino_usb_host_shield_projects/.

Some information can also be found at: http://blog.tkjelectronics.dk/.

The shield can be purchased from TKJ Electronics: http://shop.tkjelectronics.dk/product_info.php?products_id=43.

USB Host Shield

For more information about the hardware see the Hardware Manual.

Developed By

Table of Contents

How to include the library

Arduino Library Manager

First install Arduino IDE version 1.6.2 or newer, then simply use the Arduino Library Manager to install the library.

Please see the following page for instructions: http://www.arduino.cc/en/Guide/Libraries#toc3.

Manual installation

First download the library by clicking on the following link: https://github.com/felis/USB_Host_Shield_2.0/archive/master.zip.

Then uncompress the zip folder and rename the directory to "USB_Host_Shield_20", as any special characters are not supported by the Arduino IDE.

Now open up the Arduino IDE and open "File>Preferences". There you will see the location of your sketchbook. Open that directory and create a directory called "libraries" inside that directory. Now move the "USB_Host_Shield_20" directory to the "libraries" directory.

The final structure should look like this:

  • Arduino/
    • libraries/
      • USB_Host_Shield_20/

Now quit the Arduino IDE and reopen it.

Now you should be able to go open all the examples codes by navigating to "File>Examples>USB_Host_Shield_20" and then select the example you will like to open.

For more information visit the following sites: http://arduino.cc/en/Guide/Libraries and https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use.

How to use the library

Documentation

Documentation for the library can be found at the following link: https://felis.github.io/USB_Host_Shield_2.0/.

Enable debugging

By default serial debugging is disabled. To turn it on simply change ENABLE_UHS_DEBUGGING to 1 in settings.h like so:

#define ENABLE_UHS_DEBUGGING 1

Boards

Currently the following boards are supported by the library:

  • All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.)
  • Arduino Due, Intel Galileo, Intel Galileo 2, and Intel Edison
    • Note that the Intel Galileo uses pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the hardware manual for more information.
    • Note native USB host is not supported on any of these platforms. You will have to use the shield for now.
  • Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, Teensy 3.x, Teensy LC and Teensy 4.x)
    • Note if you are using the Teensy 3.x you should download this SPI library as well: https://github.com/xxxajk/spi4teensy3. You should then add #include <spi4teensy3.h> to your .ino file.
  • Balanduino
  • Sanguino
  • Black Widdow
  • Any board supported by MightyCore
  • RedBearLab nRF51822
  • Adafruit Feather nRF52840 Express
  • SEEED XIAO nRF52840 Sense
    • Note it uses pin 7 and 5 for SS and INT respectively
  • Digilent chipKIT
  • STM32F4
  • ESP8266 is supported using the ESP8266 Arduino core
    • Note it uses pin 15 and 5 for SS and INT respectively
    • Also please be aware that:
      • GPIO16 is NOT usable, as it will be used for some other purposes. For example, reset the SoC itself from sleep mode.
      • GPIO6 to 11 is also NOT usable, as they are used to connect SPI flash chip and it is used for storing the executable binary content.
  • ESP32 is supported using the arduino-esp32
    • GPIO5 : SS, GPIO17 : INT, GPIO18 : SCK, GPIO19 : MISO, GPIO23 : MOSI

The following boards need to be activated manually in settings.h:

  • Arduino Mega ADK
    • If you are using Arduino 1.5.5 or newer there is no need to activate the Arduino Mega ADK manually
  • Black Widdow

Simply set the corresponding value to 1 instead of 0.

The BTD library is a general purpose library for an ordinary Bluetooth dongle. This library make it easy to add support for different Bluetooth services like a PS3 or a Wii controller or SPP which is a virtual serial port via Bluetooth. Some different examples can be found in the example directory.

The BTD library also makes it possible to use multiple services at once, the following example sketch is an example of this: PS3SPP.ino.

The Bluetooth HID library allows you to connect HID devices via Bluetooth to the USB Host Shield.

Currently HID mice and keyboards are supported.

It uses the standard Boot protocol by default, but it is also able to use the Report protocol as well. You would simply have to call setProtocolMode() and then parse HID_RPT_PROTOCOL as an argument. You will then have to modify the parser for your device. See the example: BTHID.ino for more information.

The PS4 library also uses this class to handle all Bluetooth communication.

For information see the following blog post: http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/.

SPP stands for "Serial Port Profile" and is a Bluetooth protocol that implements a virtual comport which allows you to send data back and forth from your computer/phone to your Arduino via Bluetooth. It has been tested successfully on Windows, Mac OS X, Linux, and Android.

Take a look at the SPP.ino example for more information.

More information can be found at these blog posts:

To implement the SPP protocol I used a Bluetooth sniffing tool called PacketLogger developed by Apple. It enables me to see the Bluetooth communication between my Mac and any device.

PS5 Library

The PS5 library is split up into the PS5BT and the PS5USB library. These allow you to use the Sony PS5 controller via Bluetooth and USB.

The PS5BT.ino and PS5USB.ino examples shows how to easily read the buttons, joysticks, touchpad and IMU on the controller via Bluetooth and USB respectively. It is also possible to control the rumble, lightbar, microphone LED and player LEDs on the controller. Furthermore the new haptic trigger effects are also supported.

To pair with the PS5 controller via Bluetooth you need create the PS5BT instance like so: PS5BT PS5(&Btd, PAIR); and then hold down the Create button and then hold down the PS without releasing the Create button. The PS5 controller will then start to blink blue indicating that it is in pairing mode.

It should then automatically pair the dongle with your controller. This only have to be done once.

Thanks to Joseph Duchesne for the initial USB code.

The driver is based on the official Sony driver for Linux: https://patchwork.kernel.org/project/linux-input/cover/[email protected]/.

Also thanks to Ludwig Füchsl's https://github.com/Ohjurot/DualSense-Windows for his work on the haptic triggers.

PS4 Library

The PS4 library is split up into the PS4BT and the PS4USB library. These allow you to use the Sony PS4 controller via Bluetooth and USB.

The PS4BT.ino and PS4USB.ino examples shows how to easily read the buttons, joysticks, touchpad and IMU on the controller via Bluetooth and USB respectively. It is also possible to control the rumble and light on the controller and get the battery level.

Before you can use the PS4 controller via Bluetooth you will need to pair with it.

Simply create the PS4BT instance like so: PS4BT PS4(&Btd, PAIR); and then hold down the Share button and then hold down the PS without releasing the Share button. The PS4 controller will then start to blink rapidly indicating that it is in pairing mode.

It should then automatically pair the dongle with your controller. This only have to be done once.

For information see the following blog post: http://blog.tkjelectronics.dk/2014/01/ps4-controller-now-supported-by-the-usb-host-library/.

Also check out this excellent Wiki by Frank Zhao about the PS4 controller: http://eleccelerator.com/wiki/index.php?title=DualShock_4 and this Linux driver: https://github.com/chrippa/ds4drv.

Several guides on how to use the PS4 library has been written by Dr. James E. Barger and are available at the following link: https://sites.google.com/view/crosswaystation/ps4-tutorials.

PS3 Library

These libraries consist of the PS3BT and PS3USB. These libraries allows you to use a Dualshock 3, Navigation or a Motion controller with the USB Host Shield both via Bluetooth and USB.

In order to use your Playstation controller via Bluetooth you have to set the Bluetooth address of the dongle internally to your PS3 Controller. This can be achieved by first plugging in the Bluetooth dongle and wait a few seconds. Now plug in the controller via USB and wait until the LEDs start to flash. The library has now written the Bluetooth address of the dongle to the PS3 controller.

Finally simply plug in the Bluetooth dongle again and press PS on the PS3 controller. After a few seconds it should be connected to the dongle and ready to use.

Note: You will have to plug in the Bluetooth dongle before connecting the controller, as the library needs to read the address of the dongle. Alternatively you could set it in code like so: PS3BT.ino#L20.

For more information about the PS3 protocol see the official wiki: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information.

Also take a look at the blog posts:

A special thanks go to the following people:

  1. Richard Ibbotson who made this excellent guide: http://chome.nerpa.tech/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part
  2. Tomoyuki Tanaka for releasing his code for the Arduino USB Host shield connected to the wiimote: http://chome.nerpa.tech/mcu/rc-car-controlled-by-wii-remote-on-arduino

Also a big thanks all the people behind these sites about the Motion controller:

Xbox Libraries

The library supports both the original Xbox controller via USB and the Xbox 360 controller both via USB and wirelessly.

Xbox library

The XBOXOLD class implements support for the original Xbox controller via USB.

All the information are from the following sites:

Xbox 360 Library

The library support one Xbox 360 via USB or up to four Xbox 360 controllers wirelessly by using a Xbox 360 wireless receiver.

To use it via USB use the XBOXUSB library or to use it wirelessly use the XBOXRECV library.

Note that a Wireless controller can NOT be used via USB!

Examples code can be found in the examples directory.

Also see the following blog posts:

All the information regarding the Xbox 360 controller protocol are form these sites:

Xbox ONE Library

A Xbox ONE controller is supported via USB in the XBOXONE class. It is heavily based on the 360 library above. In addition to cross referencing the above, information on the protocol was found at:

Xbox ONE S Library

A Xbox ONE controller is supported via Bluetooth in the XBOXONESBT class.

Special thanks to HisashiKato for his help: #252 (comment).

The Wii library support the Wiimote, but also the Nunchuch and Motion Plus extensions via Bluetooth. The Wii U Pro Controller and Wii Balance Board are also supported via Bluetooth.

First you have to pair with the controller, this is done automatically by the library if you create the instance like so:

WII Wii(&Btd, PAIR);

And then press 1 & 2 at once on the Wiimote or the SYNC buttons if you are using a Wii U Pro Controller or a Wii Balance Board.

After that you can simply create the instance like so:

WII Wii(&Btd);

Then just press any button on the Wiimote and it will then connect to the dongle.

Take a look at the example for more information: Wii.ino.

Also take a look at the blog post:

The Wii IR camera can also be used, but you will have to activate the code for it manually as it is quite large. Simply set ENABLE_WII_IR_CAMERA to 1 in settings.h.

The WiiIRCamera.ino example shows how it can be used.

All the information about the Wii controllers are from these sites:

Switch Pro Library

The Switch Pro library is split up into the SwitchProBT and the SwitchProUSB library. These allow you to use the Nintendo Switch Pro controller via Bluetooth and USB.

The SwitchProBT.ino and SwitchProUSB.ino examples shows how to easily read the buttons, joysticks and IMU on the controller via Bluetooth and USB respectively. It is also possible to control the rumble and LEDs on the controller.

To pair with the Switch Pro controller via Bluetooth you need create the SwitchProBT instance like so: SwitchProBT SwitchPro(&Btd, PAIR); and then press the Sync button next to the USB connector to put the controller into pairing mode.

It should then automatically pair the dongle with your controller. This only have to be done once.

All the information about the controller are from these sites:

This library implements support for the Playstation Buzz controllers via USB.

It is essentially just a wrapper around the HIDUniversal which takes care of the initializing and reading of the controllers. The PSBuzz class simply inherits this and parses the data, so it is easy for users to read the buttons and turn the big red button on the controllers on and off.

The example PSBuzz.ino shows how one can do this with just a few lines of code.

More information about the controller can be found at the following sites:

HID Libraries

HID devices are also supported by the library. However these require you to write your own driver. A few example are provided in the examples/HID directory. Including an example for the SteelSeries SRW-S1 Steering Wheel.

The library support MIDI devices. You can convert USB MIDI keyboard to legacy serial MIDI.

For more information see : https://github.com/YuuichiAkagawa/USBH_MIDI.

This library support Philips amBX lights. You can set the colors of the lights individually or all at once. The rumble pad and fans are not supported.

Interface modifications

The shield is using SPI for communicating with the MAX3421E USB host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board.

Note this means that it uses pin 13, 12, 11 on an Arduino Uno, so these pins can not be used for anything else than SPI communication!

Furthermore it uses one pin as SS and one INT pin. These are by default located on pin 10 and 9 respectively. They can easily be reconfigured in case you need to use them for something else by cutting the jumper on the shield and then solder a wire from the pad to the new pin.

After that you need modify the following entry in UsbCore.h:

typedef MAX3421e<P10, P9> MAX3421E;

For instance if you have rerouted SS to pin 7 it should read:

typedef MAX3421e<P7, P9> MAX3421E;

See the "Interface modifications" section in the hardware manual for more information.

FAQ

When I plug my device into the USB connector nothing happens?

  • Try to connect a external power supply to the Arduino - this solves the problem in most cases.
  • You can also use a powered hub between the device and the USB Host Shield. You should then include the USB hub library: #include <usbhub.h> and create the instance like so: USBHub Hub1(&Usb);.

When I connecting my PS3 controller I get a output like this:

Dualshock 3 Controller Enabled

LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
  • This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following list for tested working dongles.

When compiling I am getting the following error: "fatal error: SPI.h: No such file or directory".

  • Please make sure to include the SPI library like so: #include <SPI.h> in your .ino file.

usb_host_shield_2.0's People

Contributors

aranvink avatar danielgibson avatar dennisfrett avatar dmadison avatar felis avatar fredej avatar gdsports avatar guruthree avatar hakanl avatar hozen avatar huming2207 avatar itsecholot avatar ivankravets avatar jakobgrootens avatar joebowbeer avatar joseangeljimenez avatar josephduchesne avatar jtenberg avatar kibab avatar kmark avatar lauszus avatar paulstoffregen avatar per1234 avatar rharke avatar riban-bw avatar sieren avatar stumpja avatar v173k avatar xxxajk avatar yuuichiakagawa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usb_host_shield_2.0's Issues

SetReport for a 65 bytes array does not work

Hello, I asked this before to some members who helped in this library but I still can't solve the issue. I am trying to send and receive data from a calculator, this works properly under Windows with my custom application that uses https://github.com/mikeobrien/HidLibrary, in fact, if I send the exact same Report I have received (chat message from the device), the device receives the same answer (loopback) as seen here with 'ABCAAA' as the message: http://cl.ly/TgFp

However, I can't do the same in the library. Here is my parser:

hidprimeparser.cpp:

#include "hidprimeparser.h"

PrimeCalculatorParser::PrimeCalculatorParser(PrimeCalculatorEvents *evt)
{
}

static uint8_t ep=0;
static uint8_t iface=0;

void PrimeCalculatorParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
{
    Serial.println("Responding the very same!");
    Serial.print("Output from hid->SetReport(");
    Serial.print(ep);
    Serial.print(", ");
    Serial.print(iface);
    Serial.print(", 2, 0, ");
    Serial.print(len);
    Serial.println(", buf)");
    delay(250);

    //uint8_t HID::SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) {
    //uint8_t rcode = hid->SetReport(2, 0, 2, 0, len,buf );
    uint8_t rcode = hid->SetReport(ep, iface, 2, 0, len ,&buf );

    ep++;
    if(ep>2)
    {
        ep=0;
        iface++;

        if(iface>3)
        iface=0;
    }

    if (rcode) {
    Serial.print("\r\nError code: ");
    D_PrintHex<uint8_t > (rcode, 0x80);
    }

    Serial.println("... done.");
}

uint8_t PrimeCalculatorEvents::SendMessage(PrimeProgramData *prg)
{
}

uint8_t PrimeCalculatorEvents::SendProgram(char *buf)
{
}

void PrimeCalculatorEvents::OnMessageReceived(PrimeProgramData *prg)
{
}

void PrimeCalculatorEvents::OnProgramReceived(char *buf)
{
}

hidprimeparser.h:

#if !defined(__HIDPRIMEPARSER_H__)
#define __HIDPRIMEPARSER_H__

#include <hid.h>

struct PrimeProgramData {
        char *program;
        char *name;
        uint8_t len;
};

class PrimeCalculatorEvents {
public:        
        uint8_t SendMessage(PrimeProgramData *prg);
        uint8_t SendProgram(char *buf);
        virtual void OnMessageReceived(PrimeProgramData *prg);
        virtual void OnProgramReceived(char *buf);
};

class PrimeCalculatorParser : public HIDReportParser 
{
        PrimeCalculatorEvents *primeEvents;

public:
        PrimeCalculatorParser(PrimeCalculatorEvents *evt);
        virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
};

#endif // __HIDPRIMEPARSER_H__

And the sketch:

#include <hid.h>
#include <usbhub.h>
#include <hiduniversal.h>

#include "hidprimeparser.h"

USB Usb;
USBHub Hub(&Usb);
HIDUniversal Hid(&Usb);
PrimeCalculatorEvents PrimeEvents;
PrimeCalculatorParser Prime(&PrimeEvents);

void setup()
{
  Serial.begin(115200);
  Serial.println("Start");
  if (Usb.Init() == -1)
    Serial.println("OSC did not start.");
  delay(200);

  Hid.SetReportParser(0, (HIDReportParser*)&Prime);
}

void loop()
{
  Usb.Task();
}

In this moment I am using all the valid ep, iface rotating them on each message received just to be sure, what I get as response is:

Output from hid->SetReport(0, 0, 2, 0, 64, buf) No error code, null response.
Output from hid->SetReport(1, 0, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(2, 0, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(0, 1, 2, 0, 64, buf) No error code, null response.
Output from hid->SetReport(1, 1, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(2, 1, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(0, 2, 2, 0, 64, buf) No error code, null response.
Output from hid->SetReport(1, 2, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(2, 2, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(0, 3, 2, 0, 64, buf) No error code, null response.
Output from hid->SetReport(1, 3, 2, 0, 64, buf) Error code: 0D
Output from hid->SetReport(2, 3, 2, 0, 64, buf) Error code: 0D

Here is the output of USBHID_desc:

HU Init
Addr:01
NC:01
Cnf:01
HU configured
0000: 06 00 FF 09 00 A1 01 09 00 75 08 95 40 81 02 09 
0010: 00 75 08 95 40 91 02 C0 
Usage Page Undef(00)
Usage
Collection Application
Usage
Report Size(08)
Report Count(40)
Input(00000010)
Usage
Report Size(08)
Report Count(40)
Output(00000010)
End Collection

And here is the output of USB_desc:

01
--

Device descriptor: 
Descriptor Length:  12
Descriptor type:    01
USB version:        0200
Device class:       00
Device Subclass:    00
Device Protocol:    00
Max.packet size:    40
Vendor  ID:     03F0
Product ID:     0441
Revision ID:        0100
Mfg.string index:   01
Prod.string index:  02
Serial number index:    00
Number of conf.:    01

Configuration descriptor:
Total length:       0029
Num.intf:       01
Conf.value:     01
Conf.string:        00
Attr.:          80
Max.pwr:        32

Interface descriptor:
Intf.number:        00
Alt.:           00
Endpoints:      02
Intf. Class:        03
Intf. Subclass:     00
Intf. Protocol:     00
Intf.string:        00
Unknown descriptor:
Length:     09
Type:       21
Contents:   010100012218000705

Endpoint descriptor:
Endpoint address:   81
Attr.:          03
Max.pkt size:       0040
Polling interval:   01

Endpoint descriptor:
Endpoint address:   02
Attr.:          03
Max.pkt size:       0040
Polling interval:   01


Addr:1(0.0.1)

What I am doing wrong? or... does SetReport works with byte arrays? (because the only example I can find is the keyboard led, and this one works with my shield)

Thanks in advance!

PS: I am using a mega2560, and this issue already contains the suggestions from K. Lauszus and A. Glushchenko

Support for GameStop wired controller

Here's a patch with the VID/PID for my wired GameStop controller:

From 8c8e711630301369a0bd0d07244b85bf94512937 Mon Sep 17 00:00:00 2001
From: "Robert T. Adams" <[email protected]>
Date: Sun, 1 Sep 2013 23:21:56 -0700
Subject: [PATCH] Added GAMESTOP_VID and GAMESTOP_PID to support Gamestop Xbox
 360 wired controllers

---
 XBOXUSB.cpp | 7 ++++---
 XBOXUSB.h   | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/XBOXUSB.cpp b/XBOXUSB.cpp
index 7279f63..067af76 100644
--- a/XBOXUSB.cpp
+++ b/XBOXUSB.cpp
@@ -92,7 +92,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
         VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
         PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;

-        if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) // Check VID
+        if (VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID && VID != GAMESTOP_VID) // Check VID
                 goto FailUnknownDevice;
         if (PID == XBOX_WIRELESS_PID) {
 #ifdef DEBUG_USB_HOST
@@ -104,9 +104,10 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
                 Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
 #endif
                 goto FailUnknownDevice;
-        } else if (PID != XBOX_WIRED_PID) // Check PID
+        } else if (PID != XBOX_WIRED_PID && PID != GAMESTOP_PID) { // Check PID
                 goto FailUnknownDevice;
-
+        }
+     
         // Allocate new address according to device class
         bAddress = addrPool.AllocAddress(parent, false, port);

diff --git a/XBOXUSB.h b/XBOXUSB.h
index 11d4bba..f89c7a0 100644
--- a/XBOXUSB.h
+++ b/XBOXUSB.h
@@ -39,11 +39,13 @@
 #define XBOX_OUTPUT_PIPE     2

 // PID and VID of the different devices
+#define GAMESTOP_VID                            0x0E6F  // Gamestop controller 
 #define XBOX_VID                                0x045E  // Microsoft Corporation
 #define MADCATZ_VID                             0x1BAD  // For unofficial Mad Catz controllers
 #define JOYTECH_VID                             0x162E  // For unofficial Joytech controllers

 #define XBOX_WIRED_PID                          0x028E  // Microsoft 360 Wired controller
+#define GAMESTOP_PID                            0x0401  // Gamestop wired controller
 #define XBOX_WIRELESS_PID                       0x028F  // Wireless controller only support charging
 #define XBOX_WIRELESS_RECEIVER_PID              0x0719  // Microsoft Wireless Gaming Receiver
 #define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID  0x0291  // Third party Wireless Gaming Receiver
-- 
1.8.1.2

Update for Keyboard + LCD example?

The previous version of the USB Host Shield has a code example which demonstrates using the Max_LCD with an HID Keyboard.

Would it be possible to provide an updated version of this code which demonstrates the use of version 2.0, Max_LCD and an HID Keyboard?

Thank you!

How to enable DTR, RTS and some other configurations ?

Hi,

I try to receive data from an USB FTDI device (which send data every 10 seconds) then display the data on my Arduino Monitor.
The problem is (I think) I have to enable DTR and RTS from my USB Host Shield 2.0 (because I receive nothing from my device), but I don't know how to do it.

I'm using Arduino UNO R3 + USB Host Shield 2.0

USB Configuration I need:

Baudrate: 115200
Flow Control: XON only
DTR and RTS on
Data Bits: 8
Stop Bits: 1
Capture local echo

If you want to see my code: http://forum.arduino.cc/index.php?topic=244836.0

Thank you in advance.

XBOXUSB::getButtonPress bug

In the XBOXUSB::getButtonPress( ) method (XBOXUSB.cpp),
there is a bug that is caused by casting from uint32_t to uint8_t
which ignores upper ButtonState bits.

uint8_t XBOXUSB::getButtonPress(Button b) {
if (b == L2) // These are analog buttons
return (uint8_t)(ButtonState >> 8);
else if (b == R2)
return (uint8_t)ButtonState;
return (ButtonState & ((uint32_t)pgm_read_word(&XBOXBUTTONS[(uint8_t)b]) << 16));
}

Bug fix returns status of all ButtonState bits:
return (ButtonState & ((uint32_t)pgm_read_word(&XBOXBUTTONS[(uint8_t)b]) << 16)?1:0);

USB keyboard does not work when plugged in during power-on

For testing purposes I have a Cherry RS 6000 USB keyboard that is connected to the Circuits@Home USB host shield on top of an Arduino Uno R3.

However, when my Arduino device is powered on and the keyboard is already connected, the keyboard just does not work. Only when I disconnect the keyboard from the USB host shield and reconnect it again it starts working.

I used the USBHIDBootKbd example as a starting point which also just works when the keyboard is not connected during power-on.

P.S.: Other keyboards do work even when they connected during power-on, e.g. my Fujitsu-Siemens KB SC SI USB.

The lib not working with Arduino 1.0 beta

Downloaded the v2.0 of the lib. Two major issues:

  • WProgram.h renamed to Arduino.h

So after changing the references in the v2.0 USB lib, when compiling the demokit 2, I'm getting:

  • message.cpp: In function 'void Notify(const char*)':
  • message.cpp:26: error: 'BYTE' was not declared in this scope

Support for Playstation Buzz! controller

Hi, I wonder if it would be possible to add support to Playstation Buzz! controller: http://en.wikipedia.org/wiki/Buzz! Those controllers are really cheap and let you have 4 gigantic buttons and 16 relatively big buttons. Great for custom setup in an easy and fast way, and perfect for disabled.

Does anyone know how it could be done? I managed to get them work in my PC but I'm a bit lost to manage it with an Arduino. Thanks a lot

Probelm with Init() function when sending servo signal

We are having problems with sending a servo signal when using the PS4 controller. We have pinpointed the problem to be when we call the Init() function the brushless motor won't work at all. We ttried to initialize the PS4 controller on the simple sweep code for servos and once we initialize it doesn't work. Is there anything wrong with the Init function and the PS4 library that prevents working with servos or brushless motors?

Wii example don't work in Arduino Due

When I use Arduino Due and upload Wii.ino the program locks at message Wiimote Bluetooth Library Started and it not shows any other message. When upload to Arduino Mega Adk works fine.
I use arduino ide 1.5.6 r2.

Any suggests? Could help me? Thanks

Arduino Command Line Compiling with cmake Does not Find USB Host Shield

I'm using Arduino-cmake (https://github.com/queezythegreat/arduino-cmake) to compile and upload sketches to my Arduino from the command line, but it's not able to find the host shield library. I know this issue mostly belongs in the Arduino-cmake project and I have already posted it there a few days ago (queezythegreat/arduino-cmake#81), but I follow USB Host Shield and see that you guys are very active and responsive so I figured I'd see if you have any ideas. I highly suspect that the reason it doesn't find the host shield library is that unlike most arduino libraries, you do not have a .cpp file that's the same name as the folder.

Aside from copying the files into my sketch folder, do you have any suggestions to get it to work or alternative suggestions for command line compiling and uploading?

Android 4.1 ADK Fix

I had a problem after updating my Motorola Xoom to android 4.1.

The ADK test demo failing at "getProto".

I Commented out the highlighted line (206) below bellow line to fix the issue.

    //probe device - get accessory protocol revision
    {
            uint16_t adkproto = -1;
            rcode = getProto((uint8_t*) & adkproto);
            if (rcode) {
               **// goto FailGetProto; //init fails** << 
            }
            USBTRACE2("\r\nADK protocol rev. ", adkproto);
    }

Arduino shield usb + joystick + Turnigy 9x

I'm working on a project to move data from a joystick for Turnigy 9x .
I am using the USB_Host_Shield_2.0 with the code:

/ * Simplified Logitech Extreme 3D Pro Joystick Report Parser * /

# 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 <hid.h>
# include <hiduniversal.h>

# include " le3dp_rptparser.h "

# include <printhex.h>
# include <message.h>
# include <hexdump.h>
# include <parsetools.h>

Usb USB ;
USBHUB Hub ( & Usb ) ;
HIDUniversal Hid ( & Usb ) ;
JoystickEvents JoyEvents ;
JoystickReportParser Joy ( & JoyEvents );


void setup ( )
{
  Serial.begin ( 115200 ) ;
  Serial.println ( " Start" ) ;

  if ( Usb.Init ( ) == -1 )
    Serial.println ( " OSC did not start . " ) ;

  delay ( 200 ) ;

  if ( ! Hid.SetReportParser ( 0 , & Joy) )
    ErrorMessage <uint8_t> ( PSTR ( " SetReportParser " ) , 1);
}

void loop ( )
{
  Usb.Task ();
}

# include " le3dp_rptparser.h "

JoystickReportParser :: JoystickReportParser ( JoystickEvents * evt ) :
joyEvents ( evt )
{
}

void JoystickReportParser :: Parse ( HID hid * , bool is_rpt_id , uint8_t len , uint8_t * buf )
{
  bool match = true;

  / / Checking if there are changes in report since the method was last called
  for ( uint8_t i = 0, i < RPT_GAMEPAD_LEN : i + +) {
    if ( buf [i] ! = oldPad [i] ) {
      match = false;
      break;
    }
  }
  / / Calling Game Pad event handler
  if ( ! joyEvents && match ) {
    joyEvents -> OnGamePadChanged ( (const GamePadEventData *) buf );

    for ( uint8_t i = 0, i < RPT_GAMEPAD_LEN , i + +) oldPad [i ] = buf [i] ;
  }
}

JoystickEvents OnGamePadChanged :: void ( * const GamePadEventData evt )
{

  Serial.print ( " Aeleron ( x ) ");
  Serial.print ( evt->x ) ;

  Serial.print ( "Elevator ( y ) : " ) ;
  Serial.print ( evt->y ) ;

  Serial.print ( " Throttle ( potentiometer ) : " ) ;
  Serial.print ( evt->buttons_b ) ;

  Serial.print ( " Rudder ( leftright ) : " ) ;
  Serial.print ( evt->hat ) ;

  Serial.println ( " " ) ;
  
  

}
# if ! defined ( __HIDJOYSTICKRPTPARSER_H__ )
# define __ HIDJOYSTICKRPTPARSER_H__

# include <inttypes.h>
# include <avr/pgmspace.h>
# include " avrpins.h "
# include " max3421e.h "
# include " usbhost.h "
# include " usb_ch9.h "
# include " Usb.h "

# if defined ( ARDUINO ) && ARDUINO > = 100
# include " Arduino.h "
# else
# include <WProgram.h>
# endif

# include " printhex.h "
# include " hexdump.h "
# include " message.h "
# include " confdescparser.h "
# include " hid.h "

struct GamePadEventData
{
  union { / / switch axes and hut
    uint8_t axes ;
    struct {
      uint8_t x ;
      uint8_t y ;
      uint8_t hat ;
    } ;
  } ;
  uint8_t buttons_a ;
  uint8_t buttons_b ;
} ;

class JoystickEvents
{
public:
OnGamePadChanged virtual void ( * const GamePadEventData evt ) ;
} ;

# define RPT_GAMEPAD_LEN sizeof ( GamePadEventData ) / sizeof ( uint8_t )

JoystickReportParser class : public HIDReportParser
{
* JoystickEvents joyEvents ;

  uint8_t oldPad [ RPT_GAMEPAD_LEN ] ;

public:
JoystickReportParser ( JoystickEvents * evt ) ;

virtual void Parse ( HID hid * , bool is_rpt_id , uint8_t len , uint8_t * buf ) ;
} ;

# endif / / __ HIDJOYSTICKRPTPARSER_H__

And I am using the following code to send the data to the Turnigy 9x :

int aeleronAnalog = 0;
 int aeleron_uS = 0;
int elevatorAnalog = 0;
 int elevator_uS = 0;
int throttleAnalog = 0;
 int throttle_uS = 0;
int rudderAnalog = 0;
 int rudder_uS = 0;

Fixed_uS int = 300 ; / / PPM frame fixed LOW phase
pulseMin int = 650 / / minimum pulse width minus start in uS

outPinPPM int = 10;


ISR ( TIMER1_COMPA_vect ) {
    ppmoutput ( ) / / Jump to subroutine ppmoutput
}

void setup ( )
{
  Serial.begin (9600 );

  pinMode ( outPinPPM , OUTPUT ) ; / / sets the digital pin as output
  
   / / Setup timer
  TCCR1A = B00110001 ; / / Compare register B used in mode '3 '
  TCCR1B = B00010010 ; / / WGM13 and CS11 set to 1
  TCCR1C = B00000000 ; / / All set to 0
  TIMSK1 = B00000010 ; / / Interrupt on compare B
  TIFR1 = B00000010 ; / / Interrupt on compare B
  OCR1A = 22000 / / 22ms PPM output refresh
  OCR1B = 1000;
}

void loop ( )
{
  aeleronAnalog = 900 ;
  elevatorAnalog = 550 ;
  throttleAnalog = 350 ;
  rudderAnalog = 0;
 
   aeleron_uS = ( map ( aeleronAnalog , 90 , 950 , 0, 1023) * 1) + pulseMin ;
   elevator_uS = ( map ( elevatorAnalog , 90 , 950 , 0, 1023) * 1) + pulseMin ;
   throttle_uS = ( map ( throttleAnalog , 90 , 950 , 0, 1023) * 1) + pulseMin ;
   rudder_uS = ( map ( rudderAnalog , 90 , 950 , 0, 1023) * 1) + pulseMin ;

   
  if ( aeleron_uS < = 750 ) aeleron_uS = 750 / / Min
  if ( aeleron_uS > = 1700 ) aeleron_uS = 1700 / / Max

  if ( elevator_uS < = 750 ) elevator_uS = 750 / / Min
  if ( elevator_uS > = 1700 ) elevator_uS = 1700 / / Max

  if ( throttle_uS < = 750 ) throttle_uS = 750 / / Min
  if ( throttle_uS > = 1700 ) throttle_uS = 1700 / / Max
  
  if ( rudder_uS < = 750 ) rudder_uS = 750 / / Min
  if ( rudder_uS > = 1700 ) rudder_uS = 1700 / / Max


}

ppmoutput void ( ) { / / PPM output sub
  / / Channel 1 - Aeleron
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( aeleron_uS ) / / Hold for Aeleron_uS microseconds

 / / Channel 2 - Elevator
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( elevator_uS ) / / Hold for Elevator_uS microseconds

 / / Channel 3 - Throttle
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( throttle_uS ) / / Hold for Throttle_uS microseconds

 / / Channel 4 - Rudder
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( rudder_uS ) / / Hold for Rudder_uS microseconds

 / / Channel 5
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( aeleron_uS );

 / / Channel 6
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( aeleron_uS );

 / / Channel 7
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( aeleron_uS );

 / / Channel 8
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ;
  delayMicroseconds ( aeleron_uS );


 / / Synchro pulse
  digitalWrite ( outPinPPM , LOW) ;
  delayMicroseconds ( Fixed_uS ) / / Hold
  digitalWrite ( outPinPPM , HIGH ) ; / / Start Synchro pulse

}

Anyone know how to integrate these two codes ?

I need to call a function after usb.task ( ) , but errors occur .

WiiMulti confusion

I've been able to get a single WiiMote working, but only when the pair flag ("WII Wii(&Btd,PAIR);" is set. My first issue is, when you say "After [pairing] you can simply create the instance [without the PAIR flag]", what do you mean? Where would the memory of this pairing be stored, and wouldn't it be cleared when I re-flash the Arduino with fresh code?

My second issue: I'm having difficulty with the WiiMulti example. Again, I can start talking to one WiiMote if I use the PAIR flag, but as soon as one is paired, subsequent WiiMotes won't connect. Has this been verified to work?

Thanks!

Asus USB-BT211 Compatibility

Hello, could you offer some guidance as to whether an ASUS USB-RT211 is compatible please?

From running the PS3BT sketch I am getting (with advanced debug turned on):

PS3 Bluetooth Library Started
BTD ConfigureDevice
BTD Init
Addr: 01
Unknown Device Connected - VID: 0CF3 PID: 3000
BTD Init Failed, error code: D1

From the USB_desc sketch I get:

Start

01

Device descriptor:
Descriptor Length: 12
Descriptor type: 01
USB version: 0110
Device class: FF
Device Subclass: 00
Device Protocol: 00
Max.packet size: 40
Vendor ID: 0CF3
Product ID: 3000
Revision ID: 0200
Mfg.string index: 00
Prod.string index: 00
Serial number index: 00
Number of conf.: 01

Configuration descriptor:
Total length: 0019
Num.intf: 01
Conf.value: 01
Conf.string: 00
Attr.: 80
Max.pwr: 32

Interface descriptor:
Intf.number: 00
Alt.: 00
Endpoints: 01
Intf. Class: FF
Intf. Subclass: 00
Intf. Protocol: 00
Intf.string: 00

Endpoint descriptor:
Endpoint address: 02
Attr.: 02
Max.pkt size: 0040
Polling interval: 00

Addr:1(0.0.1)

I've been looking through other examples with different VID/PID but have got stuck when it came to 'Endpoints', I found that this dongle has allegedly worked with the motionjoy interface for controlling PS3 controllers, but is it no good here?

Arduino Yun

Hi,

I have an arduino UNO + official USB HOST SHIELD 2.0
I managed to connect my SIXAXIS controller both via USB and a BLUETOOTH DONGLE
It was pretty straightforward

My goal is to send the SIXAXIS data to my robot using wifi
I therefore bought an official wifi shield
But I realized that both USB and WIFI shields can't work together :-(
Both are using the ICSP pins.
Only the first connected card is working

Then I bought an Arduino YUN card because it has WIFI + USB HOST integrated
Now I realize that the YUN card is not a 100% arduino board
It's ARDUINO / LINUX
In fact the USB port and the WIFI controller is controlled by the LINUX side of the card, not the arduino side.
Is there any chance to make the YUN work with my SIXAXIS controller with this library ?

Getting around usb.Task() blocking

Is there a way to prevent usb.Task() from blocking for 5 seconds when no input is detected without adding another hacked device that just polls some data?

I'm trying to use the host shield with the hidmouse example for a controller for my quad copter. But unless I constantly move the mouse about it will lock for 5 seconds.

Xbox original wire controller

Dear friend How must I modify Xbox Library for use with xbox original wire controller, not xbox 360, original (black) xbox. Thanks

Joystick Initialization problems

I am using the HID Joystick code in a project of mine, and I find that the joystick does not get initialized correctly most of the time. If I reset the board / power cycle it , it works one out of eight times or so.

I tried using an external power supply, but to no avail.

I am reading the UsbTaskState, which becomes "144" on correct initialization and "160" when the joystick doesn't initialize properly. The USB_desc sketch sometimes returns " Error Code 0D "

I tried un-commenting the lines :

      USBTRACE2("\r\nAddress: ", addr);
      USBTRACE2(" EP: ", ep);
      USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower);
      USBTRACE2(" NAK Limit: ", nak_limit);
      USBTRACE("\r\n");

But still it doesn't work correctly. Could you please check.

I am using the Logitech Attack 3 joystick.

Arduino Due not supported?

I am trying to compile the ADK samples for the Arduino Due and get the following error messages:

Arduino: 1.5.5-r2 (Windows 7), Board: "Arduino Due (Programming Port)"

In file included from Usb.h:36,
                 from adk.h:23,
                 from term_test.ino:1:
usbhost.h:73: error: #error "No SPI entry in usbhost.h"
usbhost.h: In static member function 'static void SPi<SPI_CLK, SPI_MOSI, SPI_MISO, SPI_SS>::init()':
usbhost.h:54: error: 'SPCR' was not declared in this scope
usbhost.h:55: error: 'SPSR' was not declared in this scope
In file included from Usb.h:36,
                 from adk.h:23,
                 from term_test.ino:1:
usbhost.h: In member function 'void MAX3421e<SPI_SS, INTR>::regWr(uint8_t, uint8_t)':
usbhost.h:134: error: 'SPDR' was not declared in this scope
usbhost.h:135: error: 'SPSR' was not declared in this scope
usbhost.h:135: error: 'SPIF' was not declared in this scope
usbhost.h:137: error: 'SPSR' was not declared in this scope
usbhost.h:137: error: 'SPIF' was not declared in this scope
usbhost.h: In member function 'uint8_t* MAX3421e<SPI_SS, INTR>::bytesWr(uint8_t, uint8_t, uint8_t*)':
usbhost.h:155: error: 'SPDR' was not declared in this scope
usbhost.h:157: error: 'SPSR' was not declared in this scope
usbhost.h:157: error: 'SPIF' was not declared in this scope
usbhost.h:162: error: 'SPSR' was not declared in this scope
usbhost.h:162: error: 'SPIF' was not declared in this scope
usbhost.h: In member function 'uint8_t MAX3421e<SPI_SS, INTR>::regRd(uint8_t)':
usbhost.h:190: error: 'SPDR' was not declared in this scope
usbhost.h:191: error: 'SPSR' was not declared in this scope
usbhost.h:191: error: 'SPIF' was not declared in this scope
usbhost.h:193: error: 'SPSR' was not declared in this scope
usbhost.h:193: error: 'SPIF' was not declared in this scope
usbhost.h: In member function 'uint8_t* MAX3421e<SPI_SS, INTR>::bytesRd(uint8_t, uint8_t, uint8_t*)':
usbhost.h:212: error: 'SPDR' was not declared in this scope
usbhost.h:213: error: 'SPSR' was not declared in this scope
usbhost.h:213: error: 'SPIF' was not declared in this scope
usbhost.h:217: error: 'SPSR' was not declared in this scope
usbhost.h:217: error: 'SPIF' was not declared in this scope
usbhost.h: In member function 'int8_t MAX3421e<SPI_SS, INTR>::Init()':
usbhost.h:272: error: 'spi' has not been declared
usbhost.h: In member function 'int8_t MAX3421e<SPI_SS, INTR>::Init(int)':
usbhost.h:309: error: 'spi' has not been declared
In file included from Usb.h:37,
                 from adk.h:23,
                 from term_test.ino:1:
UsbCore.h: At global scope:
UsbCore.h:27: error: 'P10' was not declared in this scope
UsbCore.h:27: error: 'P9' was not declared in this scope
UsbCore.h:27: error: template argument 1 is invalid
UsbCore.h:27: error: template argument 2 is invalid
UsbCore.h:27: error: invalid type in declaration before ';' token
In file included from Usb.h:37,
                 from adk.h:23,
                 from term_test.ino:1:
UsbCore.h:176: error: expected class-name before '{' token
term_test.ino: In function 'void setup()':
term_test:20: error: 'class USB' has no member named 'Init'

avr/io.h not found on compiling testusbhostFAT.ino for Due

Hi,
I'm using the USB Host Shield 2.0, and i installed the library follow indication at this project page.
if i compile testusbhostFAT.ino for Atmega 2560 there is no problem, but when i try to compile for Arduino due I've this error:

In file included from C:\Program Files (x86)\Arduino\libraries\generic_storage/FAT/FatFS/src/diskio.h:13,
from C:\Program Files (x86)\Arduino\libraries\generic_storage/Storage.h:10,
from testusbhostFAT.ino:63:
C:\Program Files (x86)\Arduino\libraries\generic_storage/FAT/FatFS/src/ffconf.h:192: fatal error: avr/io.h: No such file or directory
compilation terminated.

I'v tried to change avr/io.h in the ffconf.h line 192 with sam/pio.h, but the error change in "fatal error: sam/pio.h: No such file or directory"

can you help me to find the error and compile the code?
thank you for help

IOGEAR GBU521 not working

I have tried an GBU521 dongle and it fails to work.

Debugging Enabled shows:

SPP Bluetooth Library Started
Unknown Device Connected - VID: 0A5C PID: 4500
BTD Init Failed, error code: D1

Has IOGEAR switched internal chips ??

The gamepad code is stopping after sometime

The code given as example for using HID joystick is working properly for sometime.But stops after that. I noticed it happens after a certain amount of data polling. after that the output is simply "POLL:0xFF".
Is it because the memory is getting completely filled buy pointers allocated. I didnt change the code.
I made sure the parsing is proper and suitable for my gamepad and the output i got was proper also.
So how can i correct this problem.
Pls help me

Aravind
Robotics Interest Group
National Institute of Technology

Hardware pin re-assignment

Hi Oleg and the others from the team working on the USB host shield. Thank you very much for your great work. I noticed that you've changed the structure of the library a bit. I am re-wiring my SS signal to pin 7 on my Arduino Mega but I couldn't find where to change that in the code. The USB.h doesn't include the pin assignment anymore. I suspect it has been moved to avrpins.h but I am not quite sure how to change that.

Android Terminal APK Crashes

Here's the stacktrace:
01-24 12:19:22.771 26986-26986/com.victorint.android.usb D/dalvikvm﹕ DexOpt: couldn't find field Landroid/app/ActivityThread;.mActiveResources
01-24 12:19:22.771 26986-26986/com.victorint.android.usb W/dalvikvm﹕ VFY: unable to resolve instance field 1
01-24 12:19:22.771 26986-26986/com.victorint.android.usb D/dalvikvm﹕ VFY: replacing opcode 0x54 at 0x0006
01-24 12:19:22.771 26986-26986/com.victorint.android.usb D/dalvikvm﹕ DexOpt: couldn't find field Landroid/app/ActivityThread;.mPackages
01-24 12:19:22.771 26986-26986/com.victorint.android.usb W/dalvikvm﹕ VFY: unable to resolve instance field 4
01-24 12:19:22.771 26986-26986/com.victorint.android.usb D/dalvikvm﹕ VFY: replacing opcode 0x54 at 0x0000
01-24 12:19:22.801 26986-26986/com.victorint.android.usb D/AndroidRuntime﹕ Shutting down VM
01-24 12:19:22.801 26986-26986/com.victorint.android.usb W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41529d40)
01-24 12:19:22.811 26986-26986/com.victorint.android.usb E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.victorint.android.usb, PID: 26986
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.victorint.android.usb/com.victorint.android.usb.ArduinoTerminalActivity}: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:261)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2830)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3085)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:286)
at android.app.Activity.setContentView(Activity.java:1929)
at com.victorint.android.usb.TerminalViewable.setActivity(TerminalViewable.java:92)
at com.victorint.android.usb.ArduinoTerminalActivity.createAndSetViews(ArduinoTerminalActivity.java:23)
at com.victorint.android.usb.UsbActivity.onCreate(UsbActivity.java:223)
at com.victorint.android.usb.ArduinoTerminalActivity.onCreate(ArduinoTerminalActivity.java:17)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
            at dalvik.system.NativeStart.main(Native Method)

I'm running android 4.2.2 on a nexus 5, probably the reason why BT won't work either.

HID Keyboard: No event for control keys?

At the moment the HID keyboard class does not seem to provide an event for the case when just a control key has been pressed/released. When passing key presses through to the PC this can be a problem because on Mac OS the right mouse click is performed by pressing the command key (Windows key on Windows keyboards) plus pressing the mouse button. As you cannot react on a control key press alone (say the Windows key) you also cannot forward this to the PC.

Arduino Due support?

How deeply tied is the library to the ATMega chipset? I tried building it onto the Due, but a lot of the old avr includes won't work (obviously). It would be great to have the extra 480KB of memory.

Just curious -- this library, and its predecessor, are amazing!

L2 Button of PS3 Navigation controller is not working

Hi,

I've just managed to get the PS3 navigation controller running on USB and via BT.
When i connect it via USB i see all buttons working with the default example sketch.
But when i use the BT connection all but the L2 Button are working.

Any idea why this happens?

How to communicate with FTDI instrument

Dears,
I would like to communicate with FTDI instrument(an illuminance meter TOPCON IM-600) by usb host shiled. When it directly connect with PC, it will create a FTDI virtual com, and I can use command "STR0\r\n" to get the meter value return.
Now I would like to communicate with usb host shiled. I used USBFTDILoopback.ino and change char strbuf[] = "DEADBEEF" to char strbuf[] = "STR0\r\n" . But I can't get the meter value return.

How could I solve this problem, thank you very much.

Ian

How to support both keyboard and mouse simultaneously?

How do you support both at once? I tried declaring HIDBoot twice for one instance of USB, and also something like this:

USB Usb;
USB Usb2;

HIDBoot<HID_PROTOCOL_MOUSE> HidMouse(&Usb);
HIDBoot<HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb2);

Neither method works, just the first declaration of HIDBoot works. Thanks for your help.

3DConnexion with USB Host Shield 2.0

Hi, would it be possible to tweak the Logitech Extreme 3D to support 3DConnexion SpaceNavigator?
( http://www.3dconnexion.com/products/spacenavigator.html )

I'm planning on using it as a Vertical Take Off and Landing.
So the controls would be something like this:

JoystickPullUp = More power
JoystickPressDown = Less power
JoystickTwistRight = Rotate Right
JoystickTwistLeft = Rotate Left
JoystickPushForward = Rotate Servo1+
JoystickPushBackwards = Rotate Servo1-
JoystickPushRight = Rotate Servo2+
JoystickPushLeft = Rotate Servo2-
Button1 = Change LCD UI
Button2 = Hover (reset all Servos to 0)

There is a SDK file for 3DConnexion SpaceNavigator. But the file is on 124MB :p
Seems a bit overkill for usability towards Arduino.

If you could compile a code, I could run some tests.
As Im currently new to Arduino and Sparkfuns products, my programming skills are "under development" :D

PS4BT paired but unable to reconnect after paired.

Hello, I've purchased the USB-Host-Shield 2.0, PS4 controller, and GMYLE bluetooth 4.0 dongle. I've downloaded the library and quick run the PS4BT example.

It paired without any problem at all. I replaced "PS4BT PS4(&Btd, PAIR);" with the new line "PS4BT PS4(&Btd);" because it only needed pair once.

I've uploaded it and it seems somewhere connected but no responding in the Arduino Serial Monitor. The bluetooth's blue led was blinking shortly after I pressed the PS button on my ps4 controller, the ps4 controller's white light came on but no responding at all.

Any advice?

Thanks!
-Steven

Problem when using dynamic declaration of PS4BT on Arduino

Hi,

I'm using your PS4BT library for robotics, and it's very great !

Now I'm trying to make a program that allows to switch from hard pairing to soft pairing without uploading a new software. To do this, I need to read a value (digital pin set to 1 or 0) before the creation of PS4BT to know if the "pair" parameter is to set to 1 or 0, thus creating the PS4BT object in the setup() function.

To keep the global knowledge of PS4, I declare a global pointer,

PS4BT* pPS4;

and then do a

pPS4 = new PS4BT(&Btd,pair);

in the setup() function, and then use pPS4->getButtonClick(...).

But when I do this, the remote controller pairs with the Arduino (hard or soft depending on the switch) and immediatly lose the connexion. If I stay with plain object declared as global for PS4BT, I need to change the pairing mode in the source code, but then the connexion works perfectly.

Do you have an idea of why this does not work ?

Thanks in advance

examples/Xbox/XBOXRECV/XBOXRECV.ino Bug

Dear @Lauszus when I tested this example with two wireless controllers when I pressed L2 o R2 of second controller rumble controller one.

We need to modify #L30 of examples/Xbox/XBOXRECV/XBOXRECV.ino

Xbox.setRumbleOn(Xbox.getButtonPress(L2,i),Xbox.getButtonPress(R2,i)); must be changed

Xbox.setRumbleOn(Xbox.getButtonPress(L2,i),Xbox.getButtonPress(R2,i),i);

Compilation error with Arduino Mega ADK

@Lauszus Dear friend when I activate #define EXTRADEBUG in WII.cpp and try to compile WII.ino example compile show this error:

d:/datos/electronica/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function __vector_default (.vectors+0x1c): relocation truncated to fit: R_AVR_13_PCREL against symbol__vector_7' defined in .text section in d:/datos/electronica/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o

I use #define DEBUG_USB_HOST in message.h too

Any suggest? Thanks

FYI Arduino MEGA ADK *IS* supported - see details

I was having a hard time finding info about the MEGA ADK board and how or if this library would work as all my googling and net surfing led me back to this site and project.

Yes this library (USB_Host_Shield_2.0) will work with the Arduino MEGA ADK. You have to uncomment one line of code and that's it:

define BOARD_MEGA_ADK

which can be found in avrpins.h

If you try it without the modification, you'll get an error "OSC did not start".

I didn't come up with this idea, Lauszus mentioned it at the URL below. My intent in regurgitating it is to answer the question for the next googler so they don't spend 8 hours searching for this tidbit of info like I did.

http://www.circuitsathome.com/mcu/hid-support-for-usb-host-shield-library-2-0-released

Native USB port on DUE?

Is it possible to use this library with the Native USB port on Arduino DUE? If yes, is there anything to be changed?

PS4BT Pairing but not connected?

I am using the example code for PS4BT and have a PS4 controller. I put it in pair mode, and then run the example code. And after a few restarts of the Arduino, I can get it to print "PS4 library started" or whatever it says in the serial monitor. After this, though, nothing happens. I have changed the code to

if(PS4.connected()) {Serial.print("It worked");}

and that doesn't even work. So something is screwy. I just got the board in the mail so not sure what is happening.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.