To complete Danny_ds answer :
The "standard" Atmel compiler for Arduino (and 8-bit AVR) is nowaday avr-gcc
, GCC standing for GNU Compiler Collection (so, a free software tool).
It is the toolchain used by Arduino IDE, as well as Atmel Studio. Note that Atmel Studio is configurable, it can use another toolchains/compilers (someone told me that it exist at least 8 AVR compilers).
To understand how importing an Arduino sketche in Atmel Studio is possible, better to understand what an arduino is :
- A "breadboard" powered by an Atmega328 chip
- A library (API imported when
#include <Arduino.h>
formerly Program.h IIRC)
- An IDE, that do all the editor and "makefile" job
Let's pop the stack :
First, you can wipe out the Arduino IDE by using your own editor and makefiles. See Arduino Makefile on github for easy switching to this.
Doing this, you may have to add the Arduino.h inclusion in your sketche. But you have full control of the source tree processing. That was my motivation, when quit Arduino IDE early, because by that time it was impossible to use 2 libraries in the same sketche, what Arduino-Makefile allowed.
Secondly, if you don't plan to use the Serial
class (driving the UART/USB interface for console text communication with the Duino), it comes a temptation to remove the dependencies... I made the try, and i come to the conclusion that rewriting functions like setMode()
, digitalRead()
and write, etc... is just THE obvious : just open the PDF datasheet side by side with your code and set the bits accordingly.
ADC convertion, timer/counter management, eeprom read/write and even UART connexion driving, are all more tricky, as they imply to drive AVR I/O registers directly, and understanding the subsystem you're interacting with... But not impossible !!
Further, it is more than likely that (free) libraries are available, other than Arduino, to drive those jobs.
After this step, your source tree can be imported AS IT IS in Studio, and (assuming your compiler is still set on GCC, and Atmel Studio knows about your dependencies), it will compile seamlessly.
So Atmel Studio has just to import the Arduino Library in the project (and maybe adding some header inclusion as we have to do by hand) to compile it as a native project.
NOTE that inserting some existing files and particularily whole existing directories is a pain-in-the-ass with Studio.