Just wanted to share my experiences in setting up this wonderful library in Atmel Studio 6.1. It was a bit difficult first, but finally it works – and here’s how to do:
-
Set up a new Project for the library, select “GCC C++ Static Library Project” and your AVR, name it FastSPI or whatever -
Delete the automatically created file and add all FastSPI files to the project, except examples -
Add the following directories to the includes (Rightclick on project -> Properties - > Toolchain -> C++ Compiler -> Directories) <Path to Arduino IDE>\hardware\arduino\cores\arduino AND <Path to Arduino IDE>\hardware\arduino\variants\standard -
Add the following files from the before mentioned folders directly to the project: Arduino.h, binary.h, pins_arduino.h, wiring.c, wiring_private.h -
Add F_CPU to the defined symbols. Rightclick on project -> Properties - > Toolchain -> C++ Compiler -> Symbols -> Add e.g. “F_CPU=16000000U” for 16 MHz. -
Do the same for C Compiler –> Symbols. -
Add the following lines to the beginning of FastSPI_LED2.cpp, just before CFastSPI_LED2::CFastSPI_LED2() { at line 17:
void * operator new(size_t size)
{
return malloc(size);
}
Now the library should compile just fine.
Next step is to set up the main project and including the lib:
-
Set up a new solution for your project, Select “GCC C Executable Project” or “C++ Executable Project” depending on your chosen programming language, choose your MCU and name it however you want to. -
Rightclick on the new solution (Solution Explorer on the right side) -> Add Existing project -> Select <Your Library name from above>.cppproj -
Rightclick on the imported project -> Copy Project as Library Then paste it in the Libraries folder of your main project. You should see a new entry named after you library project. -
Add the following directories to the includes (Rightclick on project -> Properties - > Toolchain -> C++ Compiler -> Directories) <Path to Arduino IDE>\hardware\arduino\cores\arduino AND <Path to Arduino IDE>\hardware\arduino\variants\standard AND <Path to your FastSPI Project where “FastSPI_LED2.h” is> -
Do the same for C Compiler -> Directories -
Add F_CPU to the defined symbols. Rightclick on project -> Properties - > Toolchain -> C++ Compiler -> Symbols -> Add e.g. “F_CPU=16000000U” for 16 MHz. -
Do the same for C Compiler –> Symbols. -
Add “#include "FastSPI_LED2.h" “ to the top of your source files where you want to access the library