USB_Host_Shield_2.0/index.html

385 lines
34 KiB
HTML
Raw Normal View History

2013-01-30 22:00:18 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>USB Host Shield 2.0: USB Host Library Rev.2.0</title>
2013-01-30 22:00:18 +01:00
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
2013-01-30 22:00:18 +01:00
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</script>
2013-01-30 22:00:18 +01:00
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="imageStyle.css" rel="stylesheet" type="text/css"/>
2013-01-30 22:00:18 +01:00
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">USB Host Shield 2.0
2013-01-30 22:00:18 +01:00
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
2013-01-30 22:00:18 +01:00
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
2013-01-30 22:00:18 +01:00
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
2013-01-30 22:00:18 +01:00
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title"><a class="el" href="class_u_s_b.html">USB</a> Host Library Rev.2.0 </div> </div>
2013-01-30 22:00:18 +01:00
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The code is released under the GNU General Public License. </p><hr/>
<p> <a href="https://travis-ci.org/felis/USB_Host_Shield_2.0"></a></p>
2013-01-30 22:00:18 +01:00
<h1>Summary</h1>
<p>This is Revision 2.0 of MAX3421E-based <a class="el" href="class_u_s_b.html">USB</a> Host Shield Library for AVR's.</p>
<p>Project main web site is: <a href="https://chome.nerpa.tech/arduino_usb_host_shield_projects/">https://chome.nerpa.tech/arduino_usb_host_shield_projects/</a>.</p>
2013-01-30 22:00:18 +01:00
<p>Some information can also be found at: <a href="http://blog.tkjelectronics.dk/">http://blog.tkjelectronics.dk/</a>.</p>
<p>The shield can be purchased from <a href="http://tkjelectronics.com/">TKJ Electronics</a>: <a href="http://shop.tkjelectronics.dk/product_info.php?products_id=43">http://shop.tkjelectronics.dk/product_info.php?products_id=43</a>.</p>
<div class="image">
<img src="http://shop.tkjelectronics.dk/images/USB_Host_Shield1.jpg" alt="USB Host Shield"/>
</div>
<p>For more information about the hardware see the <a href="https://chome.nerpa.tech/usb-host-shield-hardware-manual/">Hardware Manual</a>.</p>
2013-01-30 22:00:18 +01:00
<h1>Developed By</h1>
<ul>
<li>__Oleg Mazurov - <a href="#" onclick="location.href='mai'+'lto:'+'maz'+'ur'+'ov@'+'gm'+'ail'+'.c'+'om'; return false;">mazur<span style="display: none;">.nosp@m.</span>ov@g<span style="display: none;">.nosp@m.</span>mail.<span style="display: none;">.nosp@m.</span>com</a></li>
<li><b>Alexei Glushchenko, Circuits@Home</b> - <a href="#" onclick="location.href='mai'+'lto:'+'ale'+'x-'+'gl@'+'ma'+'il.'+'ru'; return false;">alex-<span style="display: none;">.nosp@m.</span>gl@m<span style="display: none;">.nosp@m.</span>ail.r<span style="display: none;">.nosp@m.</span>u</a><ul>
2016-04-19 18:16:46 +02:00
<li>Developers of the <a class="el" href="class_u_s_b.html">USB</a> Core, HID, <a class="el" href="class_f_t_d_i.html">FTDI</a>, <a class="el" href="class_a_d_k.html">ADK</a>, <a class="el" href="class_a_c_m.html">ACM</a>, and <a class="el" href="class_p_l2303.html">PL2303</a> libraries</li>
2013-01-30 22:00:18 +01:00
</ul>
</li>
<li><b>Kristian Lauszus, TKJ Electronics</b> - <a href="#" onclick="location.href='mai'+'lto:'+'kri'+'st'+'ian'+'l@'+'tkj'+'el'+'ect'+'ro'+'nic'+'s.'+'com'; return false;">krist<span style="display: none;">.nosp@m.</span>ianl<span style="display: none;">.nosp@m.</span>@tkje<span style="display: none;">.nosp@m.</span>lect<span style="display: none;">.nosp@m.</span>ronic<span style="display: none;">.nosp@m.</span>s.co<span style="display: none;">.nosp@m.</span>m</a><ul>
<li>Developer of the <a href="#bluetooth-libraries">BTD</a>, <a href="#bthid-library">BTHID</a>, <a href="#spp-library">SPP</a>, <a href="#ps4-library">PS4</a>, <a href="#ps3-library">PS3</a>, <a href="#wii-library">Wii</a>, <a href="#xbox-library">Xbox</a>, and <a href="#ps-buzz-library">PSBuzz</a> libraries</li>
2013-01-30 22:00:18 +01:00
</ul>
</li>
2013-06-17 20:33:24 +02:00
<li><b>Andrew Kroll</b> - <a href="#" onclick="location.href='mai'+'lto:'+'xxx'+'aj'+'k@g'+'ma'+'il.'+'co'+'m'; return false;">xxxaj<span style="display: none;">.nosp@m.</span>k@gm<span style="display: none;">.nosp@m.</span>ail.c<span style="display: none;">.nosp@m.</span>om</a><ul>
<li>Major contributor to mass storage code</li>
</ul>
</li>
2015-04-07 16:07:33 +02:00
<li><b>guruthree</b><ul>
<li><a href="#xbox-one-library">Xbox ONE</a> controller support</li>
</ul>
</li>
<li><b>Yuuichi Akagawa</b> - <a href="https://twitter.com/yuuichiakagawa">@YuuichiAkagawa</a><ul>
2016-04-19 18:16:46 +02:00
<li>Developer of the <a href="#midi-library">MIDI</a> library</li>
</ul>
</li>
2015-04-07 16:07:33 +02:00
</ul>
<h1>Table of Contents</h1>
<ul>
2016-04-19 18:16:46 +02:00
<li><a href="#how-to-include-the-library">How to include the library</a><ul>
<li><a href="#arduino-library-manager">Arduino Library Manager</a></li>
<li><a href="#manual-installation">Manual installation</a></li>
</ul>
</li>
2015-04-07 16:07:33 +02:00
<li><a href="#how-to-use-the-library">How to use the library</a><ul>
<li><a href="#documentation">Documentation</a></li>
<li><a href="#enable-debugging">Enable debugging</a></li>
<li><a href="#boards">Boards</a></li>
<li><a href="#bluetooth-libraries">Bluetooth libraries</a></li>
<li><a href="#bthid-library">BTHID library</a></li>
<li><a href="#spp-library">SPP library</a></li>
<li><a href="#ps4-library">PS4 Library</a></li>
<li><a href="#ps3-library">PS3 Library</a></li>
<li><a href="#xbox-libraries">Xbox Libraries</a><ul>
<li><a href="#xbox-library">Xbox library</a></li>
<li><a href="#xbox-360-library">Xbox 360 Library</a></li>
<li><a href="#xbox-one-library">Xbox ONE Library</a></li>
</ul>
</li>
<li><a href="#wii-library">Wii library</a></li>
<li><a href="#ps-buzz-library">PS Buzz Library</a></li>
2016-04-19 18:16:46 +02:00
<li><a href="#hid-libraries">HID Libraries</a></li>
<li><a href="#midi-library">MIDI Library</a></li>
2015-04-07 16:07:33 +02:00
</ul>
</li>
<li><a href="#interface-modifications">Interface modifications</a></li>
<li><a href="#faq">FAQ</a></li>
2013-01-30 22:00:18 +01:00
</ul>
<h1>How to include the library</h1>
2016-04-19 18:16:46 +02:00
<h3>Arduino Library Manager</h3>
<p>First install Arduino IDE version 1.6.2 or newer, then simply use the Arduino Library Manager to install the library.</p>
<p>Please see the following page for instructions: <a href="http://www.arduino.cc/en/Guide/Libraries#toc3">http://www.arduino.cc/en/Guide/Libraries#toc3</a>.</p>
<h3>Manual installation</h3>
<p>First download the library by clicking on the following link: <a href="https://github.com/felis/USB_Host_Shield_2.0/archive/master.zip">https://github.com/felis/USB_Host_Shield_2.0/archive/master.zip</a>.</p>
2013-06-17 20:33:24 +02:00
<p>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.</p>
<p>Now open up the Arduino IDE and open "File&gt;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.</p>
<p>The final structure should look like this:</p>
<ul>
<li>Arduino/<ul>
<li>libraries/<ul>
<li>USB_Host_Shield_20/</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>Now quit the Arduino IDE and reopen it.</p>
2013-06-17 20:33:24 +02:00
<p>Now you should be able to go open all the examples codes by navigating to "File&gt;Examples&gt;USB\_Host\_Shield\_20" and then select the example you will like to open.</p>
2015-04-07 16:07:33 +02:00
<p>For more information visit the following sites: <a href="http://arduino.cc/en/Guide/Libraries">http://arduino.cc/en/Guide/Libraries</a> and <a href="https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use">https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use</a>.</p>
2013-01-30 22:00:18 +01:00
<h1>How to use the library</h1>
2013-04-01 22:52:24 +02:00
<h3>Documentation</h3>
<p>Documentation for the library can be found at the following link: <a href="https://felis.github.io/USB_Host_Shield_2.0/">https://felis.github.io/USB_Host_Shield_2.0/</a>.</p>
2013-08-14 01:16:29 +02:00
<h3>Enable debugging</h3>
2013-10-21 21:15:43 +02:00
<p>By default serial debugging is disabled. To turn it on simply change <code>ENABLE_UHS_DEBUGGING</code> to 1 in <a href="settings.h">settings.h</a> like so:</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;{C++}</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;#define ENABLE_UHS_DEBUGGING 1</div></div><!-- fragment --><h3>Boards</h3>
2013-10-21 21:15:43 +02:00
<p>Currently the following boards are supported by the library:</p>
<ul>
<li>All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega <a class="el" href="class_a_d_k.html">ADK</a>, Leonardo etc.)</li>
2015-04-07 16:07:33 +02:00
<li>Arduino Due, Intel Galileo, Intel Galileo 2, and Intel Edison<ul>
<li>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 <a href="https://www.circuitsathome.com/usb-host-shield-hardware-manual">hardware manual</a> for more information.</li>
2016-04-19 18:16:46 +02:00
<li>Note native <a class="el" href="class_u_s_b.html">USB</a> host is not supported on any of these platforms. You will have to use the shield for now.</li>
2014-06-09 17:02:31 +02:00
</ul>
</li>
2016-04-19 18:16:46 +02:00
<li>Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, Teensy 3.x, and Teensy LC)<ul>
2014-06-09 17:02:31 +02:00
<li>Note if you are using the Teensy 3.x you should download this SPI library as well: <a href="https://github.com/xxxajk/spi4teensy3">https://github.com/xxxajk/spi4teensy3</a>. You should then add <code>#include &lt;spi4teensy3.h&gt;</code> to your .ino file.</li>
2014-01-10 18:20:37 +01:00
</ul>
</li>
2013-10-21 21:15:43 +02:00
<li>Balanduino</li>
<li>Sanguino</li>
<li>Black Widdow</li>
2016-04-19 18:16:46 +02:00
<li>RedBearLab nRF51822</li>
2015-04-07 16:07:33 +02:00
<li>Digilent chipKIT<ul>
<li>Please see: <a href="http://www.circuitsathome.com/mcu/usb/running-usb-host-code-on-digilent-chipkit-board">http://www.circuitsathome.com/mcu/usb/running-usb-host-code-on-digilent-chipkit-board</a>.</li>
</ul>
</li>
2016-04-19 18:16:46 +02:00
<li>STM32F4<ul>
<li>Currently the <a href="http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF262063">NUCLEO-F446RE</a> is supported featuring the STM32F446. Take a look at the following example code: <a href="https://github.com/Lauszus/Nucleo_F446RE_USBHost">https://github.com/Lauszus/Nucleo_F446RE_USBHost</a>.</li>
</ul>
</li>
2018-10-13 15:47:19 +02:00
<li>ESP8266 is supported using the <a href="https://github.com/esp8266/Arduino">ESP8266 Arduino core</a><ul>
<li>Note it uses pin 15 and 5 for SS and INT respectively</li>
<li>Also please be aware that:<ul>
<li>GPIO16 is <b>NOT</b> usable, as it will be used for some other purposes. For example, reset the SoC itself from sleep mode.</li>
<li>GPIO6 to 11 is also <b>NOT</b> usable, as they are used to connect SPI flash chip and it is used for storing the executable binary content.</li>
</ul>
</li>
</ul>
</li>
<li>ESP32 is supported using the <a href="https://github.com/espressif/arduino-esp32/">arduino-esp32</a><ul>
<li>GPIO5 : SS, GPIO17 : INT, GPIO18 : SCK, GPIO19 : MISO, GPIO23 : MOSI</li>
</ul>
</li>
2013-10-21 21:15:43 +02:00
</ul>
<p>The following boards need to be activated manually in <a href="settings.h">settings.h</a>:</p>
<ul>
<li>Arduino Mega <a class="el" href="class_a_d_k.html">ADK</a><ul>
<li>If you are using Arduino 1.5.5 or newer there is no need to activate the Arduino Mega <a class="el" href="class_a_d_k.html">ADK</a> manually</li>
</ul>
</li>
<li>Black Widdow</li>
</ul>
<p>Simply set the corresponding value to 1 instead of 0.</p>
2013-08-14 01:16:29 +02:00
<h3><a href="BTD.cpp">Bluetooth libraries</a></h3>
<p>The <a href="BTD.cpp">BTD library</a> 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 <a class="el" href="class_s_p_p.html">SPP</a> which is a virtual serial port via Bluetooth. Some different examples can be found in the <a href="examples/Bluetooth">example directory</a>.</p>
2014-01-10 18:20:37 +01:00
<p>The <a class="el" href="class_b_t_d.html">BTD</a> library also makes it possible to use multiple services at once, the following example sketch is an example of this: <a href="examples/Bluetooth/PS3SPP/PS3SPP.ino">PS3SPP.ino</a>.</p>
<h3><a href="BTHID.cpp">BTHID library</a></h3>
2016-04-19 18:16:46 +02:00
<p>The <a href="BTHID.cpp">Bluetooth HID library</a> allows you to connect HID devices via Bluetooth to the <a class="el" href="class_u_s_b.html">USB</a> Host Shield.</p>
<p>Currently HID mice and keyboards are supported.</p>
2014-01-10 18:20:37 +01:00
<p>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 <code>setProtocolMode()</code> and then parse <code>HID_RPT_PROTOCOL</code> as an argument. You will then have to modify the parser for your device. See the example: <a href="examples/Bluetooth/BTHID/BTHID.ino">BTHID.ino</a> for more information.</p>
2014-01-19 17:17:06 +01:00
<p>The <a href="#ps4-library">PS4 library</a> also uses this class to handle all Bluetooth communication.</p>
<p>For information see the following blog post: <a href="http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/">http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/</a>.</p>
2013-08-14 01:16:29 +02:00
<h3><a href="SPP.cpp">SPP library</a></h3>
2013-04-01 22:52:24 +02:00
<p><a class="el" href="class_s_p_p.html">SPP</a> 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.</p>
2014-01-10 18:20:37 +01:00
<p>Take a look at the <a href="examples/Bluetooth/SPP/SPP.ino">SPP.ino</a> example for more information.</p>
2013-01-30 22:00:18 +01:00
<p>More information can be found at these blog posts:</p>
<ul>
<li><a href="http://www.circuitsathome.com/mcu/bluetooth-rfcommspp-service-support-for-usb-host-2-0-library-released">http://www.circuitsathome.com/mcu/bluetooth-rfcommspp-service-support-for-usb-host-2-0-library-released</a></li>
<li><a href="http://blog.tkjelectronics.dk/2012/07/rfcommspp-library-for-arduino/">http://blog.tkjelectronics.dk/2012/07/rfcommspp-library-for-arduino/</a></li>
</ul>
<p>To implement the <a class="el" href="class_s_p_p.html">SPP</a> protocol I used a Bluetooth sniffing tool called <a href="http://www.tkjelectronics.com/uploads/PacketLogger.zip">PacketLogger</a> developed by Apple. It enables me to see the Bluetooth communication between my Mac and any device.</p>
2014-01-19 17:17:06 +01:00
<h3>PS4 Library</h3>
<p>The <a class="el" href="class_p_s4_b_t.html">PS4BT</a> library is split up into the <a href="PS4BT.h">PS4BT</a> and the <a href="PS4USB.h">PS4USB</a> library. These allow you to use the Sony PS4 controller via Bluetooth and <a class="el" href="class_u_s_b.html">USB</a>.</p>
2014-06-09 17:02:31 +02:00
<p>The <a href="examples/Bluetooth/PS4BT/PS4BT.ino">PS4BT.ino</a> and <a href="examples/PS4USB/PS4USB.ino">PS4USB.ino</a> examples shows how to easily read the buttons, joysticks, touchpad and IMU on the controller via Bluetooth and <a class="el" href="class_u_s_b.html">USB</a> respectively. It is also possible to control the rumble and light on the controller and get the battery level.</p>
2014-01-19 17:17:06 +01:00
<p>Before you can use the PS4 controller via Bluetooth you will need to pair with it.</p>
2016-04-19 18:16:46 +02:00
<p>Simply create the <a class="el" href="class_p_s4_b_t.html">PS4BT</a> instance like so: <code><a class="el" href="class_p_s4_b_t.html">PS4BT</a> PS4(&amp;Btd, PAIR);</code> 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.</p>
2014-01-19 17:17:06 +01:00
<p>It should then automatically pair the dongle with your controller. This only have to be done once.</p>
<p>For information see the following blog post: <a href="http://blog.tkjelectronics.dk/2014/01/ps4-controller-now-supported-by-the-usb-host-library/">http://blog.tkjelectronics.dk/2014/01/ps4-controller-now-supported-by-the-usb-host-library/</a>.</p>
2014-06-09 17:02:31 +02:00
<p>Also check out this excellent Wiki by Frank Zhao about the PS4 controller: <a href="http://eleccelerator.com/wiki/index.php?title=DualShock_4">http://eleccelerator.com/wiki/index.php?title=DualShock_4</a> and this Linux driver: <a href="https://github.com/chrippa/ds4drv">https://github.com/chrippa/ds4drv</a>.</p>
<p>Several guides on how to use the PS4 library has been written by Dr. James E. Barger and are available at the following link: <a href="https://sites.google.com/view/vbatc-engineeringtechnology2/control-system-tutorials/ps4-tutorials">https://sites.google.com/view/vbatc-engineeringtechnology2/control-system-tutorials/ps4-tutorials</a>.</p>
2013-01-30 22:00:18 +01:00
<h3>PS3 Library</h3>
2013-08-14 01:16:29 +02:00
<p>These libraries consist of the <a href="PS3BT.cpp">PS3BT</a> and <a href="PS3USB.cpp">PS3USB</a>. These libraries allows you to use a Dualshock 3, Navigation or a Motion controller with the <a class="el" href="class_u_s_b.html">USB</a> Host Shield both via Bluetooth and <a class="el" href="class_u_s_b.html">USB</a>.</p>
2014-06-09 17:02:31 +02:00
<p>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 <a class="el" href="class_u_s_b.html">USB</a> and wait until the LEDs start to flash. The library has now written the Bluetooth address of the dongle to the PS3 controller.</p>
<p>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.</p>
<p><b>Note:</b> 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: <a href="examples/Bluetooth/PS3BT/PS3BT.ino#L20">PS3BT.ino::L20</a>.</p>
2013-01-30 22:00:18 +01:00
<p>For more information about the PS3 protocol see the official wiki: <a href="https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information">https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information</a>.</p>
<p>Also take a look at the blog posts:</p>
<ul>
<li><a href="http://blog.tkjelectronics.dk/2012/01/ps3-controller-bt-library-for-arduino/">http://blog.tkjelectronics.dk/2012/01/ps3-controller-bt-library-for-arduino/</a></li>
<li><a href="http://www.circuitsathome.com/mcu/sony-ps3-controller-support-added-to-usb-host-library">http://www.circuitsathome.com/mcu/sony-ps3-controller-support-added-to-usb-host-library</a></li>
<li><a href="http://www.circuitsathome.com/mcu/arduino/interfacing-ps3-controllers-via-usb">http://www.circuitsathome.com/mcu/arduino/interfacing-ps3-controllers-via-usb</a></li>
</ul>
<p>A special thanks go to the following people:</p>
<ol type="1">
<li><em>Richard Ibbotson</em> who made this excellent guide: <a href="http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part">http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part</a></li>
<li><em>Tomoyuki Tanaka</em> for releasing his code for the Arduino <a class="el" href="class_u_s_b.html">USB</a> Host shield connected to the wiimote: <a href="http://www.circuitsathome.com/mcu/rc-car-controlled-by-wii-remote-on-arduino">http://www.circuitsathome.com/mcu/rc-car-controlled-by-wii-remote-on-arduino</a></li>
</ol>
<p>Also a big thanks all the people behind these sites about the Motion controller:</p>
<ul>
<li><a href="http://thp.io/2010/psmove/">http://thp.io/2010/psmove/</a></li>
<li><a href="http://www.copenhagengamecollective.org/unimove/">http://www.copenhagengamecollective.org/unimove/</a></li>
<li><a href="https://github.com/thp/psmoveapi">https://github.com/thp/psmoveapi</a></li>
<li><a href="http://code.google.com/p/moveonpc/">http://code.google.com/p/moveonpc/</a></li>
</ul>
2013-08-14 01:16:29 +02:00
<h3>Xbox Libraries</h3>
<p>The library supports both the original Xbox controller via <a class="el" href="class_u_s_b.html">USB</a> and the Xbox 360 controller both via <a class="el" href="class_u_s_b.html">USB</a> and wirelessly.</p>
<h4>Xbox library</h4>
<p>The <a href="XBOXOLD.cpp">XBOXOLD</a> class implements support for the original Xbox controller via <a class="el" href="class_u_s_b.html">USB</a>.</p>
<p>All the information are from the following sites:</p>
<ul>
<li><a href="https://github.com/torvalds/linux/blob/master/Documentation/input/xpad.txt">https://github.com/torvalds/linux/blob/master/Documentation/input/xpad.txt</a></li>
<li><a href="https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c">https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c</a></li>
<li><a href="http://euc.jp/periphs/xbox-controller.ja.html">http://euc.jp/periphs/xbox-controller.ja.html</a></li>
<li><a href="https://github.com/Grumbel/xboxdrv/blob/master/PROTOCOL#L15">https://github.com/Grumbel/xboxdrv/blob/master/PROTOCOL#L15</a></li>
</ul>
<h4>Xbox 360 Library</h4>
2013-01-30 22:00:18 +01:00
<p>The library support one Xbox 360 via <a class="el" href="class_u_s_b.html">USB</a> or up to four Xbox 360 controllers wirelessly by using a <a href="http://blog.tkjelectronics.dk/wp-content/uploads/xbox360-wireless-receiver.jpg">Xbox 360 wireless receiver</a>.</p>
2013-08-14 01:16:29 +02:00
<p>To use it via <a class="el" href="class_u_s_b.html">USB</a> use the <a href="XBOXUSB.cpp">XBOXUSB</a> library or to use it wirelessly use the <a href="XBOXRECV.cpp">XBOXRECV</a> library.</p>
2013-01-30 22:00:18 +01:00
<p><b>Note that a Wireless controller can NOT be used via USB!</b></p>
2013-08-14 01:16:29 +02:00
<p>Examples code can be found in the <a href="examples/Xbox">examples directory</a>.</p>
2013-01-30 22:00:18 +01:00
<p>Also see the following blog posts:</p>
<ul>
<li><a href="http://www.circuitsathome.com/mcu/xbox360-controller-support-added-to-usb-host-shield-2-0-library">http://www.circuitsathome.com/mcu/xbox360-controller-support-added-to-usb-host-shield-2-0-library</a></li>
<li><a href="http://blog.tkjelectronics.dk/2012/07/xbox-360-controller-support-added-to-the-usb-host-library/">http://blog.tkjelectronics.dk/2012/07/xbox-360-controller-support-added-to-the-usb-host-library/</a></li>
<li><a href="http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/">http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/</a></li>
</ul>
<p>All the information regarding the Xbox 360 controller protocol are form these sites:</p>
<ul>
<li><a href="http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/UsbInfo">http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/UsbInfo</a></li>
<li><a href="http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/WirelessUsbInfo">http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/WirelessUsbInfo</a></li>
<li><a href="https://github.com/Grumbel/xboxdrv/blob/master/PROTOCOL">https://github.com/Grumbel/xboxdrv/blob/master/PROTOCOL</a></li>
</ul>
2015-04-07 16:07:33 +02:00
<h4>Xbox ONE Library</h4>
<p>An Xbox ONE controller is supported via <a class="el" href="class_u_s_b.html">USB</a> in the <a href="XBOXONE.cpp">XBOXONE</a> class. It is heavily based on the 360 library above. In addition to cross referencing the above, information on the protocol was found at:</p>
<ul>
<li><a href="https://github.com/quantus/xbox-one-controller-protocol">https://github.com/quantus/xbox-one-controller-protocol</a></li>
<li><a href="https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c">https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c</a></li>
<li><a href="https://github.com/kylelemons/xbox/blob/master/xbox.go">https://github.com/kylelemons/xbox/blob/master/xbox.go</a></li>
</ul>
2013-08-14 01:16:29 +02:00
<h3><a href="Wii.cpp">Wii library</a></h3>
2016-04-19 18:16:46 +02:00
<p>The <a href="Wii.cpp">Wii</a> 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.</p>
2013-01-30 22:00:18 +01:00
<p>First you have to pair with the controller, this is done automatically by the library if you create the instance like so:</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;{C++}</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;WII Wii(&amp;Btd, PAIR);</div></div><!-- fragment --><p>And then press 1 &amp; 2 at once on the Wiimote or the SYNC buttons if you are using a Wii U Pro Controller or a Wii Balance Board.</p>
2013-01-30 22:00:18 +01:00
<p>After that you can simply create the instance like so:</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;{C++}</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;WII Wii(&amp;Btd);</div></div><!-- fragment --><p>Then just press any button on the Wiimote and it will then connect to the dongle.</p>
2014-01-10 18:20:37 +01:00
<p>Take a look at the example for more information: <a href="examples/Bluetooth/Wii/Wii.ino">Wii.ino</a>.</p>
2013-01-30 22:00:18 +01:00
<p>Also take a look at the blog post:</p>
<ul>
<li><a href="http://blog.tkjelectronics.dk/2012/08/wiimote-added-to-usb-host-library/">http://blog.tkjelectronics.dk/2012/08/wiimote-added-to-usb-host-library/</a></li>
</ul>
2014-01-10 18:20:37 +01:00
<p>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 <code>ENABLE_WII_IR_CAMERA</code> to 1 in <a href="settings.h">settings.h</a>.</p>
<p>The <a href="examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino">WiiIRCamera.ino</a> example shows how it can be used.</p>
2013-01-30 22:00:18 +01:00
<p>All the information about the Wii controllers are from these sites:</p>
<ul>
<li><a href="http://wiibrew.org/wiki/Wiimote">http://wiibrew.org/wiki/Wiimote</a></li>
<li><a href="http://wiibrew.org/wiki/Wiimote/Extension_Controllers">http://wiibrew.org/wiki/Wiimote/Extension_Controllers</a></li>
<li><a href="http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Nunchuck">http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Nunchuck</a></li>
<li><a href="http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Wii_Motion_Plus">http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Wii_Motion_Plus</a></li>
2016-04-19 18:16:46 +02:00
<li><a href="http://wiibrew.org/wiki/Wii_Balance_Board">http://wiibrew.org/wiki/Wii_Balance_Board</a></li>
2013-01-30 22:00:18 +01:00
<li>The old library created by <em>Tomoyuki Tanaka</em>: <a href="https://github.com/moyuchin/WiiRemote_on_Arduino">https://github.com/moyuchin/WiiRemote_on_Arduino</a> also helped a lot.</li>
</ul>
<h3><a href="PSBuzz.cpp">PS Buzz Library</a></h3>
<p>This library implements support for the Playstation Buzz controllers via <a class="el" href="class_u_s_b.html">USB</a>.</p>
<p>It is essentially just a wrapper around the <a href="hiduniversal.cpp">HIDUniversal</a> which takes care of the initializing and reading of the controllers. The <a href="PSBuzz.cpp">PSBuzz</a> 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.</p>
<p>The example <a href="examples/PSBuzz/PSBuzz.ino">PSBuzz.ino</a> shows how one can do this with just a few lines of code.</p>
<p>More information about the controller can be found at the following sites:</p>
<ul>
<li><a href="http://www.developerfusion.com/article/84338/making-usb-c-friendly/">http://www.developerfusion.com/article/84338/making-usb-c-friendly/</a></li>
<li><a href="https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c">https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c</a></li>
</ul>
2016-04-19 18:16:46 +02:00
<h3>HID Libraries</h3>
<p>HID devices are also supported by the library. However these require you to write your own driver. A few example are provided in the <a href="examples/HID">examples/HID</a> directory. Including an example for the <a href="examples/HID/SRWS1/SRWS1.ino">SteelSeries SRW-S1 Steering Wheel</a>.</p>
<h3><a href="usbh_midi.cpp">MIDI Library</a></h3>
<p>The library support MIDI devices. You can convert <a class="el" href="class_u_s_b.html">USB</a> MIDI keyboard to legacy serial MIDI.</p>
<ul>
2018-10-13 15:47:19 +02:00
<li><a href="examples/USBH_MIDI/USB_MIDI_converter/USB_MIDI_converter.ino">USB_MIDI_converter.ino</a></li>
<li><a href="examples/USBH_MIDI/USB_MIDI_converter_multi/USB_MIDI_converter_multi.ino">USB_MIDI_converter_multi.ino</a></li>
2016-04-19 18:16:46 +02:00
</ul>
<p>For information see the following page: <a href="http://yuuichiakagawa.github.io/USBH_MIDI/">http://yuuichiakagawa.github.io/USBH_MIDI/</a>.</p>
2015-04-07 16:07:33 +02:00
<h1>Interface modifications</h1>
<p>The shield is using SPI for communicating with the MAX3421E <a class="el" href="class_u_s_b.html">USB</a> host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board.</p>
<p>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!</p>
<p>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.</p>
<p>After that you need modify the following entry in <a href="UsbCore.h">UsbCore.h</a>:</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;{C++}</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;typedef MAX3421e&lt;P10, P9&gt; MAX3421E;</div></div><!-- fragment --><p>For instance if you have rerouted SS to pin 7 it should read:</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;{C++}</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;typedef MAX3421e&lt;P7, P9&gt; MAX3421E;</div></div><!-- fragment --><p>See the "Interface modifications" section in the <a href="https://www.circuitsathome.com/usb-host-shield-hardware-manual">hardware manual</a> for more information.</p>
2013-01-30 22:00:18 +01:00
<h1>FAQ</h1>
<blockquote class="doxtable">
<p>When I plug my device into the <a class="el" href="class_u_s_b.html">USB</a> connector nothing happens? </p>
2013-01-30 22:00:18 +01:00
</blockquote>
2014-01-19 17:17:06 +01:00
<ul>
<li>Try to connect a external power supply to the Arduino - this solves the problem in most cases.</li>
2015-04-07 16:07:33 +02:00
<li>You can also use a powered hub between the device and the <a class="el" href="class_u_s_b.html">USB</a> Host Shield. You should then include the <a class="el" href="class_u_s_b.html">USB</a> hub library: <code>#include &lt;<a class="el" href="usbhub_8h.html">usbhub.h</a>&gt;</code> and create the instance like so: <code><a class="el" href="class_u_s_b_hub.html">USBHub</a> Hub1(&amp;Usb);</code>.</li>
</ul>
<blockquote class="doxtable">
<p>When I connecting my PS3 controller I get a output like this: </p>
2015-04-07 16:07:33 +02:00
</blockquote>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;Dualshock 3 Controller Enabled</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0</div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0</div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0</div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0</div></div><!-- fragment --><ul>
2016-04-19 18:16:46 +02:00
<li>This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following <a href="https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles">list</a> for tested working dongles.</li>
</ul>
<blockquote class="doxtable">
<p>When compiling I am getting the following error: "fatal error: SPI.h: No such file or directory". </p>
2016-04-19 18:16:46 +02:00
</blockquote>
2015-04-07 16:07:33 +02:00
<ul>
2016-04-19 18:16:46 +02:00
<li>Please make sure to include the SPI library like so: <code>#include &lt;SPI.h&gt;</code> in your .ino file. </li>
2014-01-19 17:17:06 +01:00
</ul>
2013-01-30 22:00:18 +01:00
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
2013-01-30 22:00:18 +01:00
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
2013-01-30 22:00:18 +01:00
</small></address>
</body>
</html>