I am developing libraries for compatibility across a number of Arduino/compatible boards. I know that Arduino boards can be identified by the test "#if defined (AVR_ATmega328P)" and compatibles as well: #if defined(TM4C123GH6PM). There are a few lists of these IDs on the web but are all outdated. I have searched various cores and library code and do not see where these defines are actually defined.
Nick Gammon's Sketch to detect Atmega chip types identifies the chip type. What I'm looking for the board type to define pin configurations, etc.
Where and in what format are board signatures stored? Is there c++ code that can find the board signature? Does anyone know of a site where these signatures are stored and updated by the Arduino community?
1 Answer 1
In the boards.txt
file each board has a board type definition, such as:
uno.build.board=AVR_UNO
When you compile your sketch that is adapted into a "board" define by prepending -DARDUINO_
to it and adding it to the compilation command line - so that one becomes the same as #define ARDUINO_AVR_UNO
. You can, of course, test for it with:
#ifdef ARDUINO_AVR_UNO
....
#endif
The location of the boards.txt
file varies with different versions of the IDE, but every installed core will have one. Look around in your Arduino program folder in the hardware
subdirectory.
-
Thanks, Majenko. That one has been bugging me for months.user3511552– user35115522015年11月21日 17:37:59 +00:00Commented Nov 21, 2015 at 17:37