Skip to main content
deleted 1 character in body
Source Link
KIIV
  • 4.9k
  • 1
  • 14
  • 23

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVRARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

More about predefined macros in avr-gcc.

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

More about predefined macros in avr-gcc.

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use ARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

More about predefined macros in avr-gcc.

added link to avr-gcc predefined macros
Source Link
KIIV
  • 4.9k
  • 1
  • 14
  • 23

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

More about predefined macros in avr-gcc.

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

More about predefined macros in avr-gcc.

extended according to @EdgarBonet's comments
Source Link
KIIV
  • 4.9k
  • 1
  • 14
  • 23

Arduino defines some macros so you can use conditional compilationconditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • ARDUINO_AVR_PROMICRO
  • DARDUINO_ARCH_AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • __AVR_ATmega32U4__

Arduino defines some macros so you can use conditional compilation. For example these are from boards.txt:

  • use ARDUINO_AVR_PROMICRO if it's specific for board variant
  • use DARDUINO_ARCH_AVR if it's specific for Arduino with AVR

Also avr-gcc defines macros according to cpu settings (this should be similar for other platforms too):

  • use __AVR_ATmega32U4__ if it's specific for only one MCU
  • use __AVR__ if it's compatible with all AVR based MCUs

And code examples:

#if defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__)
// something for ATmegaXX8 family...
#else
// ...
#endif

#ifdef __AVR__ 
// Code related to AVR
#else
// Code for other architectures
#endif
Source Link
KIIV
  • 4.9k
  • 1
  • 14
  • 23
Loading