Arduino Due code porting

Hi,

I had written some code for Arduino mega on which it was working fine. For speed concerns i had to move to Arduino DUE.

I am trying to compile the code and it gives alot of errors (as was expected). However there are some errors i dont know how to resolve.

I am using the keypad library ( Arduino Playground - Keypad Library ) with the tutorial mentioned here ( Arduino Playground - KeypadTutorial )

This is the Error i get when i compile the code :

room_sketch_due.ino:30:35: error: 'S8' redeclared as different kind of symbol
In file included from d:\Arduino\hardware\arduino\sam\system/libsam/chip.h:66:0,
                 from d:\Arduino\hardware\arduino\sam\cores\arduino/Arduino.h:42,
                 from C:\Users\Hassan\Documents\Arduino\libraries\Keypad/utility/Key.h:37,
                 from C:\Users\Hassan\Documents\Arduino\libraries\Keypad/Keypad.h:36,
                 from room_sketch_due.ino:3:
d:\Arduino\hardware\arduino\sam\system/libsam/include/USB_device.h:80:33: error: previous declaration of 'typedef int8_t S8'
 typedef int8_t                  S8;  //!< 8-bit signed integer.
                                 ^

On keypad.h at line 36 its written

#include "utility/Key.h"

And so when i check Key.h file at line 37 its written

36 #if defined(ARDUINO) && ARDUINO >= 100
37 #include "Arduino.h"	// for digitalRead, digitalWrite, etc
38 #else
39 #include "WProgram.h"
40 #endif

So it seems like the error is on line where it includes Arduino.h file. Any suggestions as how to overcome this compiler error

P.S: I am using IDE 1.5.8 on a windows 7 machine.

Oh sorry nevermind. Turns out it was an ENUM of keycodes i had set in my code that was creating conflict.

After that cleared, it gave me dozens of more errors. All these errors are from the famous IRLib library:

Seems other than Port errors, there are couple of errors related to timers and interrupts:

In file included from C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:966:0:
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp: In function 'void do_Blink()':
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:345:25: error: 'PORTB' was not declared in this scope
 #define BLINKLED_ON()  (PORTB |= B00100000)
                         ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:996:7: note: in expansion of macro 'BLINKLED_ON'
       BLINKLED_ON();  // turn pin 13 LED on
       ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:346:25: error: 'PORTB' was not declared in this scope
 #define BLINKLED_OFF() (PORTB &= B11011111)
                         ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:999:7: note: in expansion of macro 'BLINKLED_OFF'
       BLINKLED_OFF();  // turn pin 13 LED off
       ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp: In member function 'void IRrecv::enableIRIn()':
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1016:7: error: 'cli' was not declared in this scope
   cli();
       ^
In file included from C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:966:0:
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:282:4: error: 'TCCR2A' was not declared in this scope
    TCCR2A = _BV(WGM21);   TCCR2B = _BV(CS21); \
    ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:282:17: error: 'WGM21' was not declared in this scope
    TCCR2A = _BV(WGM21);   TCCR2B = _BV(CS21); \
                 ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:282:22: error: '_BV' was not declared in this scope
    TCCR2A = _BV(WGM21);   TCCR2B = _BV(CS21); \
                      ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:282:27: error: 'TCCR2B' was not declared in this scope
    TCCR2A = _BV(WGM21);   TCCR2B = _BV(CS21); \
                           ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:282:40: error: 'CS21' was not declared in this scope
    TCCR2A = _BV(WGM21);   TCCR2B = _BV(CS21); \
                                        ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:283:4: error: 'OCR2A' was not declared in this scope
    OCR2A = IR_RECV_COUNT_TOP / 8;   TCNT2 = 0; })
    ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:283:37: error: 'TCNT2' was not declared in this scope
    OCR2A = IR_RECV_COUNT_TOP / 8;   TCNT2 = 0; })
                                     ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1017:3: note: in expansion of macro 'IR_RECV_CONFIG_TICKS'
   IR_RECV_CONFIG_TICKS();
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:272:34: error: 'TIMSK2' was not declared in this scope
  #define IR_RECV_ENABLE_INTR    (TIMSK2 = _BV(OCIE2A))
                                  ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1018:3: note: in expansion of macro 'IR_RECV_ENABLE_INTR'
   IR_RECV_ENABLE_INTR;
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:272:47: error: 'OCIE2A' was not declared in this scope
  #define IR_RECV_ENABLE_INTR    (TIMSK2 = _BV(OCIE2A))
                                               ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1018:3: note: in expansion of macro 'IR_RECV_ENABLE_INTR'
   IR_RECV_ENABLE_INTR;
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:272:53: error: '_BV' was not declared in this scope
  #define IR_RECV_ENABLE_INTR    (TIMSK2 = _BV(OCIE2A))
                                                     ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1018:3: note: in expansion of macro 'IR_RECV_ENABLE_INTR'
   IR_RECV_ENABLE_INTR;
   ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1019:7: error: 'sei' was not declared in this scope
   sei();
       ^
In file included from C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:966:0:
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp: In member function 'void IRsendBase::enableIROut(unsigned char)':
C:\Users\Hassan\Documents\Arduino\libraries\IRLib/IRLibTimer.h:273:34: error: 'TIMSK2' was not declared in this scope
  #define IR_RECV_DISABLE_INTR   (TIMSK2 = 0)
                                  ^
C:\Users\Hassan\Documents\Arduino\libraries\IRLib\IRLib.cpp:1113:2: note: in expansion of macro 'IR_RECV_DISABLE_INTR'
  IR_RECV_DISABLE_INTR; //Timer2 Overflow Interrupt    
  ^

Yes, it looks like it is complaining about the AVR register definitions, because the Due has ARM architecture.

To complete the port you will need to dig deep intp the IRLib code and add in 'defines' for the various timers/registers etc.

Probably not a quick task.