Arduino Due and ADK 2012

nwscfox1:
Did you make changes to the code on the Due that you can share?

Yes, I did. ADK 2012 will not run as is on DUE board.

First, you have to comment out BT and some init parts in ADK.cpp file as below.

void ADK::adkInit(void){

    //board init
    ::fwkInit();
    ::coopInit();
    ::ledsInit();
    ::i2cInit(1, 400000);
    ::rtcInit();
    ::rtcSet(2012, 3, 28, 19, 8, 50);
    ::audioInit();
    ::usbh_init();

    //bt init
    static const BtFuncs myBtFuncs = {this, btVerboseScanCbkF, btConnReqF, btConnStartF, btConnEndF, btPinRequestF, btLinkKeyRequest, btLinkKeyCreated, btAclDataRxF, btSspShowF};

//	btInit(&myBtFuncs);              //BT UART & HCI driver
//    btSdpRegisterL2capService();     //SDP daemon
//    btRfcommRegisterL2capService();  //RFCOMM framework
    eliza();                         //easter egg
//    btA2dpRegister();                //A2DP profile
   

    uint8_t mac[BT_MAC_SIZE];

//    if(::btLocalMac(mac)) dbgPrintf("BT MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
	
    //i2c devices init
//    if(!hygroInit()) dbgPrintf("ADK i2c init failure: hygrometer\n");	
//    if(!baroInit()) dbgPrintf("ADK i2c init failure: barometer\n");
//    if(!capSenseInit()) dbgPrintf("ADK i2c init failure: capsense\n");
//    if(!alsInit()) dbgPrintf("ADK i2c init failure: ALS\n");
//    if(!accelInit()) dbgPrintf("ADK i2c init failure: accelerometer\n");
//    if(!magInit())  dbgPrintf("ADK i2c init failure: magnetometer\n");

	dbgPrintf("BT iniit end\n");

}

And, also you have to change code in usbh.c code as below, (It's in usbhwork(void) function's switch command)

	switch (usbh.state) {

		case USBH_DISABLED:
			break;

		case USBH_INIT:
	
			Usb_unfreeze_clock();

			Usb_force_host_mode();
			//Wr_bitfield(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SPDCONF_Msk, 1, UOTGHS_HSTCTRL_SPDCONF_Pos); // force full/low speed
			Usb_disable_id_pin();

			Disable_global_interrupt();
			
			(void)Is_usb_enabled();
			Enable_global_interrupt();
			
			Usb_enable_otg_pad();
			Usb_enable();
							
			TRACE_OTG("USB_INIT\n");

			Usb_set_vbof_active_low();
			Usb_disable_vbus_hw_control();
						
			Host_enable_device_disconnection_interrupt();
						
			
#if !USE_HIGH_SPEED
			Wr_bitfield(UOTGHS->UOTGHS_HSTCTRL, UOTGHS_HSTCTRL_SPDCONF_Msk, 3, UOTGHS_HSTCTRL_SPDCONF_Pos); // force full speed mode
#endif
			usbh.state = USBH_DEVICE_UNATTACHED;

			// clear all ints
			UOTGHS->UOTGHS_SCR = 0xf;
			UOTGHS->UOTGHS_HSTICR = 0xf;
			break;

Simple Arduino Terminal App Sample for ADK 2012,

#include "Arduino.h"
#include "variant.h"
#include <ADK.h>


ADK L;

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

void adkPutchar(char c){Serial.write(c);}
extern "C" void dbgPrintf(const char *, ... );

 

void setup(void)
{
 

   
  Serial.begin(115200);

  L.adkSetPutchar(adkPutchar);
  L.adkInit();
  
  // set the old accessory strings
  L.usbSetAccessoryStringVendor(ACCESSORY_STRING_VENDOR);
  L.usbSetAccessoryStringName(ACCESSORY_STRING_NAME);
  L.usbSetAccessoryStringLongname(ACCESSORY_STRING_LONGNAME);
  L.usbSetAccessoryStringVersion(ACCESSORY_STRING_VERSION);
  L.usbSetAccessoryStringUrl(ACCESSORY_STRING_URL);
  L.usbSetAccessoryStringSerial(ACCESSORY_STRING_SERIAL);
  
  L.usbStart();
}


void loop()
{
 
 
  char helloWorld[] = "Hello World! \r\n";
    
  uint8_t buf[128];

  
  
  if (L.accessoryConnected()) {
      
    int res = L.accessoryReceive(buf, sizeof(buf));
    
   if (res > 0) {
     
     L.accessorySend((uint8_t *)helloWorld, strlen(helloWorld));
         
      for (uint32_t i = 0; i < res; ++i)
			{
				printf("%c", (char)buf[i]);
			}
                                            
			printf("\r\n");
      
    }
  }
  L.adkEventProcess(); //let the adk framework do its thing
}

Your android device will recognized as accessory device like this,
Imgur

-Kevin