Reputation: 3831
I'm writing a custom library and it is working correctly on an Arduino Uno. However I've now got my hands on an Arduino Due and I need to define some board specific pin constants.
I know for most boards you can do this through an #ifdef
directive using the IO constants defined in \\arduino-1.5.2\hardware\tools\avr\avr\include\avr\io.h
. For instance:
#if defined (__AVR_ATmega128__)
//do something specific
#endif
Does anybody know which is the correct constant to use for the Due?
Upvotes: 3
Views: 4048
Reputation: 1151
The _SAM3XA_
will work, but includes a lot of other Atmel ARM chips (SAM3X8C, SAM3X8H, etc.).
Something more precise would be
#if defined (__arm__) && defined (__SAM3X8E__) // Arduino Due compatible
// your Arduino Due compatible code here
#endif
(See the file sam3.h for more info.)
If you just want to target the Arduino Due (leaving out compatible boards), you can use
#if defined (_VARIANT_ARDUINO_DUE_X_)
// your Arduino Due code here
#endif
(This is defined in the Arduino Due's variant.h file.)
Upvotes: 5
Reputation: 2827
I typically use ...
#ifndef __AVR__
// something special just for non AVR8's
// ...
#endif
Where as I believe you could also use...
#ifdef _SAM3XA_
// something special just for Due's SAM3XA
// ...
#endif
Upvotes: 3