Arduino Due and ADK 2012

Not nearly impressive but I managed to get the ADK 2012 app and the 2011 DemoKit to recognize Kevin/ardroid's sketch. This might be handy to someone or it might be completely useless. Having a control app already developed might be useful to someone.

It is worth noting, however, that this is working with the default ADK implementation that comes with Arduino 1.5.1r2 and is missing pretty much every feature available in the ADK 2012 libraries (BT, LEDs, etc). Some work would need to be done to get this library working on a vanilla Due rather than the ADK device.

Changing the version number between 1.0 and 2.0 while keeping ACCESSORY_STRING_NAME set to "DemoKit" will allow you to use the 2011 and 2012 ADK test apps, if you so desire.

#include "Arduino.h"
#include "variant.h"
#include <stdio.h>
#include <adk.h>

// ADK1 usb accessory strings
#define ACCESSORY_STRING_VENDOR "Google, Inc."
#define ACCESSORY_STRING_NAME   "DemoKit"
#define ACCESSORY_STRING_LONGNAME "DemoKit Arduino Board"
#define ACCESSORY_STRING_VERSION  "2.0"
#define ACCESSORY_STRING_URL    "http://www.android.com"
#define ACCESSORY_STRING_SERIAL "0000000012345678"

#define RCVSIZE 128

USBHost Usb;
ADK adk(&Usb,ACCESSORY_STRING_VENDOR,ACCESSORY_STRING_NAME,ACCESSORY_STRING_LONGNAME,ACCESSORY_STRING_VERSION,ACCESSORY_STRING_URL,ACCESSORY_STRING_SERIAL);

void setup(void)
{
  Serial.begin(115200);
  cpu_irq_enable();
  printf("\r\nADK demo start\r\n");
  delay(200);
}


void loop()
{
  uint8_t buf[RCVSIZE];
  uint32_t nbread = 0;
  char helloworld[] = "Hello World!\r\n";

  Usb.Task();
  
  if (adk.isReady()) {
    adk.write(strlen(helloworld), (uint8_t *)helloworld);
    
    delay(1000);
    
    adk.read(&nbread, RCVSIZE, buf);
    if (nbread > 0) {
      printf("RCV: ");
      for (uint32_t i = 0; i < nbread; ++i) {
        printf("%c", (char)buf[i]);
      }
      printf("\r\n");
    }
  }
}

If you're trying to duplicate the hardware for some reason, it might be worth checking this out.