Skip to content

Commit

Permalink
Updating to use the arduino spi library.
Browse files Browse the repository at this point in the history
aaronds committed Apr 11, 2011

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 73442ca commit 1fc7575
Showing 8 changed files with 30 additions and 17 deletions.
3 changes: 3 additions & 0 deletions Mirf/Mirf.cpp
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
* Mirf
*
* Additional bug fixes and improvements
* 11/03/2011:
* Switched spi library.
* 07/13/2010:
* Added example to read a register
* 11/12/2009:
@@ -87,6 +89,7 @@ void Nrf24l::init()
csnHi();

// Initialize spi module
Serial.println("Calling begin");
spi->begin();

}
6 changes: 1 addition & 5 deletions Mirf/MirfHardwareSpiDriver.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#include "MirfHardwareSpiDriver.h"
#include <HardwareSerial.h>

uint8_t MirfHardwareSpiDriver::transfer(uint8_t data){
return SPI.transfer(data);
}

void MirfHardwareSpiDriver::begin(){
Serial.println("Begining SPI");
SPI.begin();
SPI.setBitOrder(SPI_MODE1);
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_2XCLOCK_MASK);
}

6 changes: 3 additions & 3 deletions Mirf/MirfSpiDriver.h
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@ extern "C" {

class MirfSpiDriver {
public:
uint8_t transfer(uint8_t data);
virtual uint8_t transfer(uint8_t data);

void begin();
void end();
virtual void begin();
virtual void end();
};

#endif
4 changes: 3 additions & 1 deletion Mirf/examples/ping_client/ping_client.pde
Original file line number Diff line number Diff line change
@@ -16,9 +16,10 @@
* 'ping_server_interupt' on the server.
*/

#include <Spi.h>
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

void setup(){
Serial.begin(9600);
@@ -35,6 +36,7 @@ void setup(){
Mirf.cePin = 7;
Mirf.csnPin = 8;
*/
Mirf.spi = &MirfHardwareSpi;
Mirf.init();

/*
9 changes: 8 additions & 1 deletion Mirf/examples/ping_server/ping_server.pde
Original file line number Diff line number Diff line change
@@ -13,13 +13,20 @@
*
*/

#include <Spi.h>
#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.
*/
9 changes: 8 additions & 1 deletion Mirf/examples/ping_server_interupt/ping_server_interupt.pde
Original file line number Diff line number Diff line change
@@ -16,9 +16,10 @@
* CSN -> 7
*/

#include <Spi.h>
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
#include <avr/sleep.h>

void wakeupFunction(){
@@ -32,6 +33,12 @@ void toSleep(){

void setup(){
Serial.begin(9600);

/*
* Set the SPI Driver.
*/

Mirf.spi = &MirfHardwareSpi;

/*
* Setup pins / SPI.
6 changes: 4 additions & 2 deletions Mirf/examples/reg_read/reg_read.pde
Original file line number Diff line number Diff line change
@@ -10,15 +10,17 @@
* CSN -> 7
*/

#include <Spi.h>
#include <mirf.h>
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

void setup() {
Serial.begin(9600);
Serial.println( "Starting wireless..." );

// Setup
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"clie1");
Mirf.payload = sizeof(unsigned long);
4 changes: 0 additions & 4 deletions README
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ An Arduino port of the tinkerer.eu library. It works with the Sparkfun nRF24L01+

http://www.arduino.cc/playground/InterfacingWithHardware/Nrf24L01

Currently depends on:

http://www.arduino.cc/playground/Code/Spi

Zip file to be extracted in the Arduino libraries folder:

http://github.com/aaronds/arduino-nrf24l01/downloads

0 comments on commit 1fc7575

Please sign in to comment.