backupbrain / ArduinoBoardManager

Arduino library to determine the Arduino models and features as well as the SDK version.
26 stars 16 forks source link

Library doesn't compile on Mega board #5

Open vossilius opened 7 years ago

vossilius commented 7 years ago

Hi,

thanks for sharing the library. However, I get error trying to compile the example.

Arduino: 1.6.12 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
In file included from /[...]/ArduinoBoardManager.h:140:31: error: '__AVR_ATmega1280__' was not declared in this scope
   static const uint16_t CPU = __AVR_ATmega1280__;
                               ^exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I get the error with my Arduino Mega 2560 as well as Controllino (which is based on Arduino Mega). Any thoughts?

Thanks!

billsewell commented 7 years ago

There is a bug in ArduinoBoardManager.h It will not compile for ATmega2560 because ATmega1280 and ATmega2560 are combined in the same #elif defined section and when ATmega2560 is defined, the code attempts to assign the undefined symbol __AVR_ATmega1280__ to CPU which causes a compile time error.

The solution is to break the #elif defined section into two sections, one for AVR_ATmega1280 and one for AVR_ATmega2560 and change the CPU assignment in the AVR_ATmega2560 define to CPU = AVR_ATmega2560

DeanBilotti commented 7 years ago

I have submitted a pull request with a fix for this and some other issues: https://github.com/backupbrain/ArduinoBoardManager/pull/6