Pages: [1]   Go Down
Author Topic: #Defines - Builtin ?  (Read 389 times)
0 Members and 1 Guest are viewing this topic.
Spain
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
I hope I'm not too old for this stuff...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cool
Logged

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

Leeds, UK
Online Online
Edison Member
*
Karma: 72
Posts: 1642
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
« Last Edit: August 01, 2012, 05:39:09 am by Tom Carpenter » Logged

~Tom~

Spain
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
I hope I'm not too old for this stuff...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, much appreciated.
Kind regards,

jB  smiley-cool
Logged

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

Pages: [1]   Go Up
Jump to: