KRNL - Debugging- boards

need a little cleanup june 2019

A simple way to identify which board and CPU you are compiling for …

  You can test for board by #ifdef ARDUINO_AVR_UNO  etc
  see list below

  Just add ARDUINO_ in front of

  So an uno can be identified by #ifdef ARDUINO_AVR_UNO ...

  AVR_ADK
  AVR_BT
  AVR_DUEMILANOVE
  AVR_ESPLORA
  AVR_ETHERNET
  AVR_FIO
  AVR_GEMMA
  AVR_LEONARDO
  AVR_LILYPAD
  AVR_LILYPAD_USB
  AVR_MEGA
  AVR_MEGA2560
  AVR_MICRO
  AVR_MINI
  AVR_NANO
  AVR_NG
  AVR_PRO
  AVR_ROBOT_CONTROL
  AVR_ROBOT_MOTOR
  AVR_UNO
  AVR_YUN

So

#if defined (ARDUINO_AVR_UNO)
your code
 #endif

#if ( defined (ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) )
your code
#endif

For CPU type


#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
 #endif

#if defined (__AVR_ATmega2560__) || defined (__AVR_ATmega1280__) || defined(__AVR_ATmega2561__)
#endif
etc

A real example

It uses LED13 to indicate when dummy task is running

In compilation it detects if its an uno or mega and insert the relevant code

  • UNO has led om on PORTB bit5

  • MEGA has led om on PORTB bit7

(click for code)