What is the macro definition to identify a arduino Due board

Just like a title says, what is the macro definition that identify an arduino Due board.

i would like to add one entry to this

#if defined (ARDUINO_ARCH_ARC32)
  #define SPI_DEFAULT_FREQ 16000000 ///< ARC32 SPI default frequency
#elif defined (__AVR__) || defined(TEENSYDUINO)
  #define SPI_DEFAULT_FREQ 8000000 ///< AVR SPI default frequency
#elif defined(__SAMD51__)
  #define SPI_DEFAULT_FREQ 12000000 ///< M4 SPI default frequency
#elif defined(ESP8266) || defined (ARDUINO_MAXIM)
  #define SPI_DEFAULT_FREQ 16000000 ///< ESP8266 SPI default frequency
#elif defined(ESP32)
  #define SPI_DEFAULT_FREQ 24000000 ///< ESP32 SPI default frequency
#elif defined(RASPI)
  #define SPI_DEFAULT_FREQ 24000000 ///< RASPI SPI default frequency
  #define SPI_DEFAULT_FREQ 24000000 ///< SPI default frequency

because i have found out that compiling on a due results in the default frequency which in this library case it just does not work , a value of 20000000 works on the due so i would like to add another entry. what is the identifier of a due board?

There are several you can use.

The macro __SAM3X8E__ should be defined when you compile for any board using the SAM3X8E microcontroller.

The macro ARDUINO_ARCH_SAM is the SAM architecture specific macro defined by the Arduino SAM Boards platform. This would likely also be defined if using a 3rd party board that also used the sam architecture.

The ARDUINO_SAM_DUE macro is the board-specific macro defined by the Arduino SAM Boards platform.

1 Like

There is no macro to identify the specific Arduino board that has been selected by the user.
I have asked for this for many years.
The Arduino IDE knows but does not create any board specific define. The older chipkit mpide did.
You can easily tell which processor or which processor architecture you have.
You can sometimes infer which board you have by looking at a combination of defines, including things like USB_PID, USB_VID, or even reach down into some of the pin definition macros from pins_arduino.h

To see what the IDE passes to the compiler turn on debugging output in the IDE and look at all the -D definitions.
There are other processor specific defines that are set by gcc.
Those are often names that begin with __ (two underbars)

--- bill

There is the macro generated from the build.board property:


If the author doesn't define that property in boards.txt, it is automatically generated.

The boards.txt author may not always use unique build.board property values for each board. For example, the macro will be ARDUINO_SAM_DUE regardless of whether Tools > Board > Arduino Due (Programming Port) or Arduino Due (Native USB Port) is selected. Another example is the Adafruit SAMD Boards platform uses the ARDUINO_SAMD_ZERO macro for several of their boards.

It's also up to the platform author whether they want to follow Arduino's lead and add the -DARDUINO_{build.board} flag in their compilation command patterns. I've never seen a platform that didn't do this though.