USB accessory ADK MEGA example errors

Hi,

I'm having problems with compiling Mega ADK USB accessory example. I'm doing everyting mentioned here: Urządzenia peryferyjne i akcesoria Android  |  Android Open Source Project

But im getting compile errors:

In file included from C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/usb_drv.h:56:0,
                 from C:\Users\Marduk\Documents\Arduino\libraries\ADK2\accessory.c:19:
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:238:1: error: unknown type name 'Bool'
 typedef Bool                Status_bool_t;  //!< Boolean status.
 ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:239:1: error: unknown type name 'U8'
 typedef U8                  Status_t;       //!< 8-bit-coded status.
 ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:248:3: error: unknown type name 'S16'
   S16 s16   ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:249:3: error: unknown type name 'U16'
   U16 u16   ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:250:3: error: unknown type name 'S8'
   S8  s8 [2];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:251:3: error: unknown type name 'U8'
   U8  u8 [2];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:257:3: error: unknown type name 'S32'
   S32 s32   ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:258:3: error: unknown type name 'U32'
   U32 u32   ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:259:3: error: unknown type name 'S16'
   S16 s16[2];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:260:3: error: unknown type name 'U16'
   U16 u16[2];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:261:3: error: unknown type name 'S8'
   S8  s8 [4];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:262:3: error: unknown type name 'U8'
   U8  u8 [4];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:268:3: error: unknown type name 'S64'
   S64 s64   ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:269:3: error: unknown type name 'U64'
   U64 u64   ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:270:3: error: unknown type name 'S32'
   S32 s32[2];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:271:3: error: unknown type name 'U32'
   U32 u32[2];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:272:3: error: unknown type name 'S16'
   S16 s16[4];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:273:3: error: unknown type name 'U16'
   U16 u16[4];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:274:3: error: unknown type name 'S8'
   S8  s8 [8];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:275:3: error: unknown type name 'U8'
   U8  u8 [8];
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:281:3: error: unknown type name 'S64'
   S64 *s64ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:282:3: error: unknown type name 'U64'
   U64 *u64ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:283:3: error: unknown type name 'S32'
   S32 *s32ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:284:3: error: unknown type name 'U32'
   U32 *u32ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:285:3: error: unknown type name 'S16'
   S16 *s16ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:286:3: error: unknown type name 'U16'
   U16 *u16ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:287:3: error: unknown type name 'S8'
   S8  *s8ptr ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:288:3: error: unknown type name 'U8'
   U8  *u8ptr ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:294:3: error: unknown type name 'S64'
   volatile S64 *s64ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:295:3: error: unknown type name 'U64'
   volatile U64 *u64ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:296:3: error: unknown type name 'S32'
   volatile S32 *s32ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:297:3: error: unknown type name 'U32'
   volatile U32 *u32ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:298:3: error: unknown type name 'S16'
   volatile S16 *s16ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:299:3: error: unknown type name 'U16'
   volatile U16 *u16ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:300:3: error: unknown type name 'S8'
   volatile S8  *s8ptr ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:301:3: error: unknown type name 'U8'
   volatile U8  *u8ptr ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:307:3: error: unknown type name 'S64'
   const S64 *s64ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:308:3: error: unknown type name 'U64'
   const U64 *u64ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:377:3: error: unknown type name 'U16'
   const volatile U16 *u16ptr;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:378:3: error: unknown type name 'S8'
   const volatile S8  *s8ptr ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:379:3: error: unknown type name 'U8'
   const volatile U8  *u8ptr ;
   ^
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/compiler.h:1221:1: error: unknown type name 'U8'
 typedef U8                  Byte;       //!< 8-bit unsigned integer.
 ^
In file included from C:\Users\Marduk\Documents\Arduino\libraries\ADK2\accessory.c:19:0:
C:\Users\Marduk\Documents\Arduino\libraries\ADK2\utility/usb_drv.h:60:18: fatal error: chip.h: No such file or directory
 #include "chip.h"
                  ^
compilation terminated.
Error compiling.

Changing line
#include <ADK.h>
to
#include <C:\Users\Marduk\Documents\Arduino\libraries\ADK2\ADK.h>

fixes some problems but other errors are shown:

usbaccessory.cpp.o: In function `setup':
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:36: undefined reference to `ADK::adkSetPutchar(void (*)(char))'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:37: undefined reference to `ADK::adkInit()'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:40: undefined reference to `ADK::usbSetAccessoryStringVendor(char const*)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:41: undefined reference to `ADK::usbSetAccessoryStringName(char const*)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:42: undefined reference to `ADK::usbSetAccessoryStringLongname(char const*)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:43: undefined reference to `ADK::usbSetAccessoryStringVersion(char const*)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:44: undefined reference to `ADK::usbSetAccessoryStringUrl(char const*)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:45: undefined reference to `ADK::usbSetAccessoryStringSerial(char const*)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:47: undefined reference to `ADK::usbStart()'
usbaccessory.cpp.o: In function `loop':
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:100: undefined reference to `ADK::capSenseSlider()'
usbaccessory.cpp.o: In function `SendBuf::Send()':
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:57: undefined reference to `ADK::accessorySend(void const*, unsigned int)'
usbaccessory.cpp.o: In function `loop':
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:112: undefined reference to `ADK::accessoryReceive(void*, unsigned int)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:150: undefined reference to `ADK::ledDrawLetter(char, unsigned char, unsigned char, unsigned char, unsigned char)'
C:\Users\Marduk\Desktop\adk\arduino-1.6.5-r5/usbaccessory.ino:153: undefined reference to `ADK::adkEventProcess()'
collect2.exe: error: ld returned 1 exit status
Error compiling.

I have no idea what im doing wrong and how to fix this, any ideas?

Forgot about example code:

/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "Arduino.h"
#include <C:\Users\Marduk\Documents\Arduino\libraries\ADK2\ADK.h>

ADK L;

// 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  "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();
}

struct SendBuf {
  void Reset() { pos = 0; memset(buf, 0, sizeof(buf)); }
  void Append(int val) { buf[pos++] = val; }
  void Append(uint8_t val) { buf[pos++] = val; }
  void Append(uint16_t val) { buf[pos++] = val >> 8; buf[pos++] = val; }
  void Append(uint32_t val) { buf[pos++] = val >> 24; buf[pos++] = val >> 16; buf[pos++] = val >> 8; buf[pos++] = val; }

  int Send() { return L.accessorySend(buf, pos); }

  uint8_t buf[128];
  int pos;
};

void loop()
{
  static int last_report = 0;
  static uint16_t temp = 0;
  static uint16_t light = 0;
  static uint8_t buttons = 0;
  static uint8_t joyx = 0;
  static uint8_t joyy = 0;
  static uint8_t ledrgb[6][3];

  int now = millis() / 100;
  
  // see if we need to report our current status
  if (now != last_report) {
    SendBuf buf;
    buf.Reset();

    // temperature
    buf.Append(0x04);
    buf.Append(temp);
    temp++;

    // light<
    buf.Append(0x05);
    buf.Append(light);
    light++;

    // buttons
    for (int i = 0; i < 5; i++) {
      buf.Append(0x01);
      buf.Append(i);
      buf.Append((uint8_t)(buttons & (1 << i)));
    }
    buttons++;

    // joystick
    buf.Append(0x06);
    buf.Append((uint8_t)(L.capSenseSlider() - 128));
    buf.Append(0);
    joyx += 2;
    joyy += 3;

    buf.Send();
  }

  // read from phone
  {
    uint8_t buf[64];

    int res = L.accessoryReceive(buf, sizeof(buf));
 
    int pos = 0;
    while (pos < res) {
      uint8_t op = buf[pos++];
  
      switch (op) {
        case 0x2: {
          // color sliders
          unsigned int led = buf[pos];
          
          if (led < 12) {
            ledrgb[led/3][led%3] = buf[pos+1]; 
          } else if (led >= 0x10 || led <= 0x12) {
            ledrgb[3][led%3] = buf[pos+1];            
          }

          pos += 2;
          break;
        }
        case 0x3: {
          // relay
          int val = buf[pos+1] ? 255 : 0;
          int led = (buf[pos] == 0) ? 4 : 5;
          ledrgb[led][0] = val;              
          ledrgb[led][1] = val;              
          ledrgb[led][2] = val;              
          pos += 2;
          break;
        }
        default: // assume 3 byte packet
          pos += 2;
          break;
      }    
    }
  }
  
  for (int i = 0; i < 6; i++) {
    L.ledDrawLetter(i, '8', ledrgb[i][0], ledrgb[i][1], ledrgb[i][2]);
  }

  last_report = now;
  
  L.adkEventProcess(); //let the adk framework do its thing
}

MardukGD:
Forgot about example code:

/*
  • Copyright (C) 2012 The Android Open Source Project
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at

*      Apache License, Version 2.0
*

  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */
    #include "Arduino.h"
    #include <C:\Users\Marduk\Documents\Arduino\libraries\ADK2\ADK.h>

ADK L;

// 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  "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();
}

struct SendBuf {
  void Reset() { pos = 0; memset(buf, 0, sizeof(buf)); }
  void Append(int val) { buf[pos++] = val; }
  void Append(uint8_t val) { buf[pos++] = val; }
  void Append(uint16_t val) { buf[pos++] = val >> 8; buf[pos++] = val; }
  void Append(uint32_t val) { buf[pos++] = val >> 24; buf[pos++] = val >> 16; buf[pos++] = val >> 8; buf[pos++] = val; }

int Send() { return L.accessorySend(buf, pos); }

uint8_t buf[128];
  int pos;
};

void loop()
{
  static int last_report = 0;
  static uint16_t temp = 0;
  static uint16_t light = 0;
  static uint8_t buttons = 0;
  static uint8_t joyx = 0;
  static uint8_t joyy = 0;
  static uint8_t ledrgb[6][3];

int now = millis() / 100;
 
  // see if we need to report our current status
  if (now != last_report) {
    SendBuf buf;
    buf.Reset();

// temperature
    buf.Append(0x04);
    buf.Append(temp);
    temp++;

// light<
    buf.Append(0x05);
    buf.Append(light);
    light++;

// buttons
    for (int i = 0; i < 5; i++) {
      buf.Append(0x01);
      buf.Append(i);
      buf.Append((uint8_t)(buttons & (1 << i)));
    }
    buttons++;

// joystick
    buf.Append(0x06);
    buf.Append((uint8_t)(L.capSenseSlider() - 128));
    buf.Append(0);
    joyx += 2;
    joyy += 3;

buf.Send();
  }

// read from phone
  {
    uint8_t buf[64];

int res = L.accessoryReceive(buf, sizeof(buf));

int pos = 0;
    while (pos < res) {
      uint8_t op = buf[pos++];
 
      switch (op) {
        case 0x2: {
          // color sliders
          unsigned int led = buf[pos];
         
          if (led < 12) {
            ledrgb[led/3][led%3] = buf[pos+1];
          } else if (led >= 0x10 || led <= 0x12) {
            ledrgb[3][led%3] = buf[pos+1];           
          }

pos += 2;
          break;
        }
        case 0x3: {
          // relay
          int val = buf[pos+1] ? 255 : 0;
          int led = (buf[pos] == 0) ? 4 : 5;
          ledrgb[led][0] = val;             
          ledrgb[led][1] = val;             
          ledrgb[led][2] = val;             
          pos += 2;
          break;
        }
        default: // assume 3 byte packet
          pos += 2;
          break;
      }   
    }
  }
 
  for (int i = 0; i < 6; i++) {
    L.ledDrawLetter(i, '8', ledrgb[i][0], ledrgb[i][1], ledrgb[i][2]);
  }

last_report = now;
 
  L.adkEventProcess(); //let the adk framework do its thing
}

I have the same problem. Have you got it work?