I received two wireless transceiver modules in the mail today, and then I borrowed an example code from Arduino Playground ("Arduino Playground - HomePage"). I programmed my Uno first, which completed without any errors, but programming the Due resulted in this:
Arduino: 1.5.6-r2 (Windows 8), Board: "Arduino Due (Native USB Port)"
Build options changed, rebuilding all
C:\Program Files (x86)\Arduino\libraries\Mirf\MirfHardwareSpiDriver.cpp: In member function 'virtual void MirfHardwareSpiDriver::begin()':
C:\Program Files (x86)\Arduino\libraries\Mirf\MirfHardwareSpiDriver.cpp:9: error: 'SPI_2XCLOCK_MASK' was not declared in this scopeThis report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Now, I deployed this example code on both devices:
/**
* An Mirf example which copies back the data it recives.
*
* Pins:
* Hardware SPI:
* MISO -> 12
* MOSI -> 11
* SCK -> 13
*
* Configurable:
* CE -> 8
* CSN -> 7
*
*/
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
void setup(){
Serial.begin(9600);
/*
* Set the SPI Driver.
*/
Mirf.spi = &MirfHardwareSpi;
/*
* Setup pins / SPI.
*/
Mirf.init();
/*
* Configure reciving address.
*/
Mirf.setRADDR((byte *)"serv1");
/*
* Set the payload length to sizeof(unsigned long) the
* return type of millis().
*
* NB: payload on client and server must be the same.
*/
Mirf.payload = sizeof(unsigned long);
/*
* Write channel and payload config then power up reciver.
*/
Mirf.config();
Serial.println("Listening...");
}
void loop(){
/*
* A buffer to store the data.
*/
byte data[Mirf.payload];
/*
* If a packet has been recived.
*
* isSending also restores listening mode when it
* transitions from true to false.
*/
if(!Mirf.isSending() && Mirf.dataReady()){
Serial.println("Got packet");
/*
* Get load the packet into the buffer.
*/
Mirf.getData(data);
/*
* Set the send address.
*/
Mirf.setTADDR((byte *)"clie1");
/*
* Send the data back to the client.
*/
Mirf.send(data);
/*
* Wait untill sending has finished
*
* NB: isSending returns the chip to receving after returning true.
*/
Serial.println("Reply sent.");
}
}
If I understand correctly, the Due may have many additional features that the Uno Rev. 3 has, but not all hardware is compatible. I don't know if it is an incompatibility in the libraries or not, but that's what I can't seem to figure out. I provided the original ZIP file that contains all example codes and libraries for the NRF24L01 in a download below.
Assistance would be much appreciated, so thanks in advance!
Mirf.zip (12.7 KB)