Just wanted to share my experiences in setting up this wonderful library in Atmel

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:

  1.   Set up a new Project  for the library, select “GCC C++ Static Library Project” and your AVR, name it FastSPI or whatever
    
  2.   Delete the automatically created file and add all FastSPI files to the project, except examples
    
  3.   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
    
  4.   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
    
  5.   Add F_CPU to the defined symbols. Rightclick on project -> Properties - > Toolchain -> C++ Compiler -> Symbols -> Add e.g.  “F_CPU=16000000U” for 16 MHz.
    
  6.   Do the same for C Compiler –> Symbols.
    
  7.   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:

  1.   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.
    
  2.   Rightclick on the new solution (Solution Explorer on the right side) -> Add Existing project -> Select <Your Library name from above>.cppproj
    
  3.   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.
    
  4.   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>
    
  5.   Do the same for C Compiler -> Directories
    
  6.   Add F_CPU to the defined symbols. Rightclick on project -> Properties - > Toolchain -> C++ Compiler -> Symbols -> Add e.g.  “F_CPU=16000000U” for 16 MHz.
    
  7.   Do the same for C Compiler –> Symbols.
    
  8.   Add “#include "FastSPI_LED2.h" “ to the top of your source files where you want to access the library

You should also add the following compiler symbol:

ARDUINO=105

Which tells the Arduino stuff which version to compile for. This indicates version 1.05. Change to whichever version of Arduino you have installed. Although I don’t think its used by FastSPI, it is used by many other libraries.

Thank you! This is great.

We have a few very small changes to the library for the full “2.0” release that may actually shorten this list a little (eg ‘new’), but I’ll let @Daniel_Garcia chime in if appropriate.

We have two goals that relate to this: we want to be 100% compatible with the Arduino IDE, and we also would like to remove our dependencies on it over time. This kind of hands-on how-to really helps us know where we stand so far.