Could you tell me if there is a #define that identifies whether the board is a ARM/Due or an AVR/Uno/Mega/Leonard/etc? The best I could come up with it to just pick a random #define that is in the Arduino.h file for the Due, but not in the Arduino.h file for the atmega core.
I stuck this at the top of my cpp file, which appears to work, but surely there is a more future proof method
I see that gcc has the following built-in defines that I used into the SD library to distinguish between architectures:
#if defined(__arm__)
// Arduino Due Board follows
#elif defined(__AVR__)
// Other AVR based Boards follows
#else
#error Architecture or board not supported.
#endif
For what I want it to mean that is not an issue, in fact it is a good thing. Basically it is a check to say, if it is an ARM processor, don't use the PROGMEM command, and default to using digitalWrite() rather than direct port writes.
Hi all, I'm updating my AtomicBlock library for the Due, the update contains versions for 'ARM' and the 'Cortex M3' variant. However I can't find any defines to conditionally decide which to use.
pYro_65:
Hi all, I'm updating my AtomicBlock library for the Due, the update contains versions for 'ARM' and the 'Cortex M3' variant. However I can't find any defines to conditionally decide which to use.
Is there a macro like _TARGET_ARCH_xx or similar?
Looking at the current GCC sources, there doesn't appear to any single macro that completely identifies each chip, rather there are a bunch of feature macros defined (i.e. thumb/thumb2 instruction sets, whether it has DSP multiply, etc.). I believe the Arduino IDE defines things like MK20DX128 and SAM3X8E.
avr_atmega328p is set by the compiler as a consequence of the -mmcu=atmega328p command-line option.
The arm-gcc compiler isn't quite so customized, so it looks like SAM3X8E is set explicitly with a -D command-line option.
The other symbols used in newer versions of the IDE (1.5+?), like ARDUINO_SAM_DUE or ARDUINO_AVR_UNO are also set from the command line using -D, based on the contents of the xxx.build.board variable defined in boards.txt and the recipes in platform.txt
The build command can be see by turning on verbose compilation in the preferences dialog. It looks like this: