[SOLVED] Compile error when using SPI library with DUE

Hello,

I have a project that is using the nRF24L01 radio modules, which uses SPI.
and have been using them successfully so far on arduino UNO and PRO mini boards.

The SPI library is the one that came with IDE 1.0.6
The RF24 library I have been using is by gcopeland, and tmrh20

Here are the relevant pages for reference.
http://maniacbug.github.io/RF24

http://tmrh20.github.io/RF24/index.html

Now, I am trying to get the same project to run on DUE, because UNO does not have
enough power to process the amount of data I need to send through it (several simultaneous IMU data streams).
I do not have need for the extended SPI as far as I know, I just need regular SPI, and I have not found any information regarding an SPI library that is specific to the DUE.

But so far, I keep getting a compile error as follows, which point to problems with SPI.h and SPI.cpp
To narrow down the problem, I have tried compiling the example ino that is in the SPI library folder.

I have searched around here and online for solutions, but to no avail.

Arduino Due with SPI declaration problem
http://forum.arduino.cc/index.php?topic=189865.0

Summary of mysteries about SPI and extended SPI library with Due
http://forum.arduino.cc/index.php?topic=167068.0

ILI9341 (new) SPI library for Arduino Due supporting DMA transfer
http://forum.arduino.cc/index.php?topic=265806.0

Has anyone had success compiling the SPI library on DUE?
Any help is appreciated and Happy holidays.

Compile error follows:

Arduino: 1.5.8 (Windows 8), Board: "Arduino Due (Native USB Port)"

In file included from BarometricPressureSensor.ino:26:0:
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h: In static member function 'static byte SPIClass::transfer(byte)':

C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:56:3: error: 'SPDR' was not declared in this scope
   SPDR = _data;
   ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:57:12: error: 'SPSR' was not declared in this scope
   while (!(SPSR & _BV(SPIF)))
            ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:57:23: error: 'SPIF' was not declared in this scope
   while (!(SPSR & _BV(SPIF)))
                       ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:57:27: error: '_BV' was not declared in this scope
   while (!(SPSR & _BV(SPIF)))
                           ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h: In static member function 'static void SPIClass::attachInterrupt()':
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:63:3: error: 'SPCR' was not declared in this scope
   SPCR |= _BV(SPIE);
   ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:63:15: error: 'SPIE' was not declared in this scope
   SPCR |= _BV(SPIE);
               ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:63:19: error: '_BV' was not declared in this scope
   SPCR |= _BV(SPIE);
                   ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h: In static member function 'static void SPIClass::detachInterrupt()':
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:67:3: error: 'SPCR' was not declared in this scope
   SPCR &= ~_BV(SPIE);
   ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:67:16: error: 'SPIE' was not declared in this scope
   SPCR &= ~_BV(SPIE);
                ^
C:\Users\ME\Documents\Arduino\libraries\SPI/SPI.h:67:20: error: '_BV' was not declared in this scope
   SPCR &= ~_BV(SPIE);
                    ^
Error compiling.

Don't do that!

The IDE which works with the Due (1.5.x and above, I believe) has a special copy of SPI.h inside the folder Arduino\hardware\arduino\sam\libraries\SPI

If you don't add any extra copies of SPI.h, then it will use that and it will work.

@MorganS

As indicated in the compile error, I was using Arduino: 1.5.8, so I am not sure what "Don't do that!"
is referring to, but thanks for your response.

But you were right about the libraries hidden in that folder mentioned.
I replaced the default ones with those, and now it has finally compiled !

I searched around a lot, so I am quite certain that there is zero documentation about the location of those DUE specific libraries, so I would recommend that those in charge look into that.

Thanks again!

The point is you shouldn't have to put in your own libraries for SPI. If you didn't add any SPI.h anywhere then the standard installation would work. For the users just starting with Arduino, they don't need to know that there's different libraries in different places. They don't need to copy anything. There's no need to "replace". The IDE already knows how to compile sketches correctly for every different Arduino.

Now if you're doing something special with SPI (and you insist on calling it SPI.h) then you can put in your own version which the IDE will look at before it looks at its own copy. I suggest you don't do that.