pardon me for my lack of knowledge in programming, well ths thing is there is a code i had obtained from the sparkfunforum, but its for pic18XXX kind of microcontroller.
It looks like simple SPI code. The Arduino has a library for that:
In terms of porting the code its not so easy. Embedded code even in the same language is a pain to port because it usually contains a lot of hardware specific identifiers and hardware registers.
It would be much much easier to learn the arduino SPI library than what you need to know to port code. (for reference sake, I spent 3 months at a company (which i won't name) porting a c-code base that worked in the IAR compiler to work in gcc and it was a P.I.T.A. and that was for the same hardware)
Its a simple demo for a spi radio. Have you searched for everything "nRF24L01 or nRF24L01+" related?
If nothing is found using AVR for this radio, then simply port the code.
These radios I don't think are too popular in the arduino crowd, they are an Olimex design, mostly aimed at PICs and ARMs.
As was said earlier, all SPI stuff is now a library in Arduino (hint: look at those examples first). Then he has a home made "dly" timer delay (convert all those to arduino delay()s).
The rest is just poking bytes to the radio to configure, send and receive data.
thanx for ur replies... much appreciated... i have a code for arduino, but the thing is.. its not working as was expected... and i m not sure wad the problem is...
this is the sending end:
#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>
// constants won't change. They're used here to
// set pin numbers:
const int switchPin = 2; // the number of the pushbutton pin
const int ledPin = 7; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup(){
Serial.begin(9600);
Mirf.init();
Mirf.setRADDR((byte *)"clie1");
Mirf.config();
Mirf.payload = sizeof(int);
// initialize the LED pin as an INPUT:
pinMode(ledPin, INPUT);
// initialize the switch pin as an output:
pinMode(switchPin, OUTPUT);
}
void loop(){
digitalWrite(switchPin, HIGH);
// read the state of the pushbutton value:
buttonState = digitalRead(ledPin);
if (buttonState == LOW) {
//byte data[Mirf.payload];
Mirf.setTADDR((byte *)"serv1");
Mirf.send((byte *)"hello");
while(Mirf.isSending()){
}
Serial.println("Finished sending");
delay(10);
}
// else {
// turn LED off:
//digitalWrite(ledPin, LOW);
// }
}
the receiving end:
#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>
const int ledPin = 13; // the number of the LED pin
void setup(){
Serial.begin(9600);
Mirf.init();
Mirf.setRADDR((byte *)"serv1");
Mirf.config();
Mirf.payload = sizeof(int);
pinMode(ledPin, OUTPUT);
}
void loop(){
byte data[Mirf.payload];
if(Mirf.dataReady()){
do{
Mirf.getData(data);
Serial.println(data[0]);
Serial.println("Got packet");
digitalWrite(ledPin, HIGH);
}while(!Mirf.rxFifoEmpty());
}
}
the sending part is working well... but there is no reaction on the receiving end... is there anything i m doing wrong here? this is something i modified.. so ya..