Created Sun, 30 Mar 2014 16:04:56 +0000 by benderamp
Sun, 30 Mar 2014 16:04:56 +0000
Hello,
I have made a working example of using ChipKIT (WF32 or Max32 with Network Shield with USB) as Android accessory working in USB-host mode.
Here is the code: https://github.com/1i7/snippets/tree/comments-en/chipkit-android-usb
chipkit_usbhost_android - sketch for ChipKIT AndroidUSBClient - android application
This is a simple demo of Android-board communication over USB cable, Android application has 2 buttons to switch LED on pin 13 on the board on and off.
It works with WF32 or Max32 with Network Shield and Android 4.0 tablet rather fine.
I have also packed this code in ChipKIT-friendly library format (attached archive) - the library should appear like ~\Documents\mpide\libraries\chipKITUSBAndroidHost, then working example would appear in mpide in File/examples/chipKITUSBAndroidHost/USBAndroidHost menu .
I had to solve some problems to make it work with current ChipKIT usb libraries.
For android accessory driver I take the following files from MLA and put them to sketch directory: usb_host_android.c usb_host_android_local.h usb_host_android.h struct_queue.h Compiler.h
To solve it, I have taken a number of files from MLA and replaced their mpide versions in chipKITUSBHost library: usb_common.h (declares EVENT_1MS) usb_host.c (calls event with EVENT_1MS) usb_host.h (EVENT_1MS is not present, but after replacing prev files usb_host.c will not compile without it) usb_host_local.h (same as above)
All above files are moved to chipKITUSBHost without modifications except usb_host.c - in usb_host.c had to replace debug print calls to things like: #ifdef DEBUG_MODE UART2PrintString( "HOST: Cannot allocate for endpoint 0.\r\n" ); #endif
Created chipKITUSBAndroidHost.h and chipKITUSBAndroidHost.cpp ChipKIT-style C++ wrappers (quite optional, C calls also work just fine).
I have also checked at least ChipKITUSBMSDHost examples with updated chipKITUSBHost library and it seems to work. It would be good, if ChipKIT USB Host library provided from digilent would be updated to recent version from MLA, so this manual modifications will not be needed to make android accessory driver work.
Wed, 09 Apr 2014 17:05:12 +0000
This looks really cool. I will be trying it soon.
Update: The example breaks on boards that use USB for Serial. It does not give a compiler warning but the Serial.prints in the sketch cause it to fail. Other than that the code works pretty good so far.
Tue, 06 May 2014 21:54:55 +0000
Here is a video of a demo for Maker Faire that that mikes built for PONTECH based on this Android Accessory example code.
https://www.youtube.com/watch?v=2IdhJw5HJgQ
We are working on posting code here:
http://quick240.com/quicki/demos:pingponglev
Jacob
Wed, 17 Sep 2014 01:43:11 +0000
Here is a new project based on this library that utilizes this library.
http://quick240.com/quicki/demos:androidadkpropertiesviewer
Jacob