Making Hardware Apps for Smartphones

Demo Projects

Loading...

Saturday, July 14, 2012

ADK 2012 for Android

Despite the popularity of the IOIO board for Android (a tool for adding external hardware to Android devices), which has the largest developer/hacker community, Google does not abandon its Accessory Development Kit (ADK). At Google I/O 2012, the team made another demo of ADK, using another board different from what we saw (or used) last year.

ADK 2011:

This time, you get some serious design:

ADK 2012:

The new Audio dock API and HID API seem to be the main interests of this ADK 2.0, which are very easy to implement.

For example, for those of you who want to make an external audio dock for Android that is able to play audio over a USB connection, simply grab a device running Android 4.1 (API Level 16) or higher (e.g., Galaxy Nexus), prepare your ADK 2012 board, open your favorite Arduino IDE, and start your pleasant development now.

The ADK 2012 provides a reference implementation of this functionality for accessory developers. No software application is required to be installed on the connected Android device, accessory developers only need to support AOA v2. This implementation demonstrates audio output of 16bit, 44.1kHz stereo PCM source data compressed into a single channel due to the audio hardware available on the accessory.

Using the audio output features provided by the ADK library requires only a few function calls. The first few calls are in the accessory setup() routine, which prepare the accessory for USB connections and audio output, as summarized in the code example below:

ADK L;
void setup() {
L.audioInit();
L.usbh_init()
L.usbStart();
}

For more information about the ADK::audioInit() function, see the libraries/ADK/Audio.c library file. For more information about the ADK::usbh_init() function, see the libraries/ADK/Usbh.c library file.

After completing this setup, the loop() function calls ADK::adkEventProcess() to handle audio output and other ADK functions:

This call executes task queuing for the ADK and as part of the execution process, the task queue executes usbh_work() inlibraries/ADK/Usbh.c, which handles audio output requests. Review the implementation of this function for details. For additional implementation details on audio output, see the libraries/ADK/accessory.c library file.