Go Down

Topic: Arduino Due code porting (Read 231 times) previous topic - next topic

haxan

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 ( http://playground.arduino.cc/Code/Keypad ) with the tutorial mentioned here ( http://playground.arduino.cc/Main/KeypadTutorial )


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

Code: [Select]

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
Code: [Select]

#include "utility/Key.h"


And so when i check Key.h file at line 37 its written
Code: [Select]

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.

haxan

#1
Oct 18, 2014, 12:07 pm Last Edit: Oct 18, 2014, 12:33 pm by haxan Reason: 1
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:

Code: [Select]

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    
 ^

AnalysIR

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.
Visit our Blog about Infrared Remote Control >>>> http://www.AnalysIR.com/blog/  Twitter: @AnalysIR
First Read this PDF=> 10 common pitfalls with Infrared Remote Control >>> http://bit.ly/1cvd0at

Go Up