Go Down

Topic: #Defines - Builtin ? (Read 629 times) previous topic - next topic

britesc

Hi,
As I hate re-inventing the wheel, is there a list of builtin defines / macros for the Arduino MCU?
I know from reading that there is __DATE__ & __TIME__ but do defines for ARDUINO_UNO_R3 and ARDUINO_MEGA_2560_R3 (for example), exist, as this would make life much easier for making headers etc.
Has anyone compiled a list somewhere?

Appreciate the help as always, kind regards,

jB  8)
=====================================================
My Grandkids think I'm cool but, actually I'm partially sighted so sorry for any typos

Tom Carpenter

#1
Aug 01, 2012, 12:35 pm Last Edit: Aug 01, 2012, 12:39 pm by Tom Carpenter Reason: 1
They are sort of there, but in their processor form rather than arduino name, which allows compatibily between different variants with the same chip.
Uno:
__AVR_ATmega328P__

Mega1280 and Mega2560:
__AVR_ATmega1280__
__AVR_ATmega2560__

Leonardo:
__AVR_ATmega32U4__


Code: [Select]
#if defined(__AVR_ATmega328P__)

//This is only defined for the atmega328P, e.g. Uno, and many other variants. You could add:
// || defined(__AVR_ATmega168__) to support the older versions as well.

#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

//This is only defined for the atmega1280 and atmega2560, e.g. any of the Arduino Mega boards

#elif defined(__AVR_ATmega32U4__)

//This code if only compiled for an Atmega32U4 chip, e.g. a Leonardo

#endif
~Tom~

britesc

Thanks, much appreciated.
Kind regards,

jB  8)
=====================================================
My Grandkids think I'm cool but, actually I'm partially sighted so sorry for any typos

Go Up