Pages: [1] 2 3 4   Go Down
Author Topic: Arduino Due and ADK 2012  (Read 17263 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've successfully loaded Google's ADK 2012 demo onto DUE board. Changed code to disabling BT interface and also updated USB VSB pin control portion.

http://youtu.be/XJgN1gAwGQY   
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
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)
Code:
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,

Code:
#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,
http://www.flickr.com/photos/picolink/8345855859/

-Kevin

 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great. That works for me. Thanks!

Logged

refined-apps.com

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great! I have the following questions:

1. Which Arduino IDE do you use? arduino-1.5.1r2? or adk2012_ide-win32-20120629?
2. What app do you use on Nexus 7 to transfer data to Due?
3. Is DC to supply power a must? Arduino Due can't work when I use a DC--3.3V & 2.0A. What DC do you use?
« Last Edit: January 06, 2013, 11:28:34 am by jangofei » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


1. adk2012 ide / mac. Please note that the libraries/core contained in the adk2012 ide differs significantly from the arduino ide. Thus the adk2012 sources are probably not compatible with the arduino ide.

2. None. I just tested audio output. The adk2012 audio feature automatically reroutes all audio output to the adk hardware if activated. I.e. you can use every app that makes some noise (youtube, one of my virtual instrument apps ("Opus #1" / "Grand Piano" / "Keyboard Sounds"), ...). BTW: if audio stutters, you may want to adjust the size of audrecvbuf in accessory.c to the buffer size of the audio endpoint.

3. I powered the Due via the usb cable from my mac -> due programming port. A usb power supply on the programming port seems to work too. However, a power supply on the power connector does not work for me.
Logged

refined-apps.com

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi aleu,
Great work!

I try to do same things in my environment with MacBook pro.
After finish compule, ADK2012 says
adk2tool /dev/tty.usbmodemfa131 erase
bossac --port=tty.usbmodemfa131 -w -b
****usbaccessory.cpp.bin
"No device found on tty.usbmodemfa131"
adk2tool /dev/tty.usbmodemfa131 reset

Do you have any suggestion?
Sho
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's an erase button on the Due. Press it for a few seconds before you upload a new sketch.
Logged

refined-apps.com

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi aleu,
Thanks a lot! It works.
Now I can enjoy the sound.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It still can't work. PC-->Programming port, Nexus 7-->OTG-->Native port. Due can't be reconginzed by Nexus 7 or i9300.
OS: Android 4.2.1 on Nexus 7 or i9300.


I got error when I was uploading sketch into Due board. What is wrong I did?

C:\ADK2012_IDE_0/hardware/tools/adk2tool.exe COM3 erase
erasing...done.
C:\ADK2012_IDE_0/hardware/tools/bossac.exe --port=COM3 -w -b C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build5785210613214747736.tmp/Arduino_Terminal_App_Sample.cpp.bin
No device found on COM3
C:\ADK2012_IDE_0/hardware/tools/adk2tool.exe COM3 reset
resetting...done.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ensure you selected the right com port and read above about the erase button.
Logged

refined-apps.com

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Aleu!

It should be correct com port(Arduino Due programming port on PC). And I pressed the erase button before uploading.

It seems that Due was not recognized by ADK2012 IDE after erasing (erasing done).

IDE should prompt like below if it uploads successfully?
.....
Verify successful
Set boot flash true
CPU reset.
« Last Edit: January 08, 2013, 04:28:28 am by jangofei » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, All
I did it!!!
I changed port to Native USB for uploading sketch into Due.  Now I am enjoying the music from Nexus 7.

Thanks Aleu, Ardroid and all!!
« Last Edit: January 08, 2013, 04:42:48 pm by jangofei » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Another question:
I just use left channel or right channel to DAC0. Is it possible to use both of left and right channel? Thanks.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Google's ADK2012 sample actually merge left/right channel into one and output to DAC0. Yes it is possible separate L/R to DAC0/1. I am thinking about actually doing so. However, I am currently woking on attaching bluetooth HCI module. I will let you know once it done.

-Kevin   
Logged

Pages: [1] 2 3 4   Go Up
Jump to: