I am developing AVR microcontollers in Atmle Studio and sometimes I am using Arduino libraries(such as LiquidCrystal).
When I initialize LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
I don't think Arduino Libraries use registers and ports of ATmega2560, although I am building my code with the device selection ATmega2560 option of Atmel Studio. Atmel Studio works in order to program 2560 but how can I tell Arduino libraries that I am using 2560?
-
Take a look here arduino.stackexchange.com/questions/4169/arduino-ide-ifdef I think this will work in Atmel StudioPhillyNJ– PhillyNJ2015年05月21日 13:50:32 +00:00Commented May 21, 2015 at 13:50
1 Answer 1
There are two things that have to be considered here.
One is telling the code what board you are using, so it can compile in the right optional parts, and the other is getting the right pin mappings.
The first can be covered simply with a compilation flag:
-DARDUINO_MEGA2560
That defines the macro ARDUINO_MEGA2560
which is used in some places to know which board you are using.
Second is the pin mappings. These are stored in the file pins_arduino.h
and each board variant has its own copy. You need to ensure that this file (and be sure to get the right one) is included in your code in the right places to ensure that the pins can be mapped right. If you are including the whole Arduino core (which it sounds like you must be in order for things to even have a hope of working) then you just need to ensure that you have the compiler set up to include the right copy of the pins_arduino.h
file.
That means making sure you have an include path in your compile command line which points to where the pins_arduino.h
file is before anything else Arduino core related.
-IC:\Path\to\arduino\mega2560\variant
or
-I/path/to/arduino/mega2560/variant