I maintain a library of Arduino code for sending/receiving/decoding IR signals. At times I need to detect which hardware platform I'm using so that I know things like the availability of hardware timers, interrupts etc. Typically I use conditional compiles such as
#if defined(AVR_ATmega32U4)
for example I presume this is a Leonardo or compatible platform. Which values if any should I check when detecting Arduino Due or Arduino Yun. Note I've never used either of those platforms so I realize it's a bit tricky to support them without any hardware to actually test but there are certain things I can implement just based on documentation. Therefore I'd like to support them in my library if I knew how to detect them.
When compiling for the Due, ARDUINO_SAM_DUE is defined.
The avr part of the you is just a leonardo.
Mark
There are two ways to find an identifier (define) that is always defined to specify the board being used.
- In the IDE, turn on verbose output during compilation (File | Preference}, select the board your interested in, and using a basic sketch hit the compile button (not the upload). You can do this even if you don't have the board. You can then look at the avr-g++ command line for text that starts like this -DARDUINO_???? This is the define you can use in you code to conditionally execute code for that particular board.
or option
- Open up the boards.txt file for your arduino installation (../arduino-1.5.6-r2/hardware/avr/boards.txt or ../arduino-1.5.6-r2/hardware/sam/boards.txt) and search for the definition of the board you are interested in. For the YUN it looks like this:
##############################################################
yun.name=Arduino Yún
yun.upload.via_ssh=true
yun.vid.0=0x2341
yun.pid.0=0x0041
yun.vid.1=0x2341
yun.pid.1=0x8041
yun.upload.tool=avrdude
yun.upload.protocol=avr109
yun.upload.maximum_size=28672
yun.upload.maximum_data_size=2560
yun.upload.speed=57600
yun.upload.disable_flushing=true
yun.upload.use_1200bps_touch=true
yun.upload.wait_for_upload_port=true
yun.bootloader.tool=avrdude
yun.bootloader.low_fuses=0xff
yun.bootloader.high_fuses=0xd8
yun.bootloader.extended_fuses=0xfb
yun.bootloader.file=caterina/Caterina-Yun.hex
yun.bootloader.unlock_bits=0x3F
yun.bootloader.lock_bits=0x2F
yun.build.mcu=atmega32u4
yun.build.f_cpu=16000000L
yun.build.vid=0x2341
yun.build.pid=0x8041
yun.build.usb_product="Arduino Yun"
yun.build.board=AVR_YUN
yun.build.core=arduino
yun.build.variant=yun
yun.build.extra_flags={build.usb_flags}
In this file you look for the ???.build.board= line and append the value to ARDUINO_
So for the YUN, you would use #if defined(ARDUINO_AVR_YUN) and for the DUE you would use #if defined(ARDUINO_SAM_DUE)
How can i flash a .hex file on Arduino Due board?
I have downloaded AVRdudes GUI but ATSAM3x is not there.? Is there any similar tool for flashing ATSAM processors?
Please help