Added some config/init time options
This commit is contained in:
parent
d154274100
commit
fe59becbba
|
@ -10,28 +10,36 @@
|
||||||
#include <mrf24j.h>
|
#include <mrf24j.h>
|
||||||
|
|
||||||
const int pin_reset = 6;
|
const int pin_reset = 6;
|
||||||
const int pin_cs = 10; // default CS pin on ATMEGA8
|
const int pin_cs = 10; // default CS pin on ATmega8/168/328
|
||||||
const int pin_interrupt = 2; // default interrupt pin on ATMEGA8
|
const int pin_interrupt = 2; // default interrupt pin on ATmega8/168/328
|
||||||
|
|
||||||
Mrf24j mrf(pin_reset, pin_cs, pin_interrupt);
|
Mrf24j mrf(pin_reset, pin_cs, pin_interrupt);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
|
mrf.reset();
|
||||||
|
mrf.init();
|
||||||
|
|
||||||
mrf.set_pan(0xcafe);
|
mrf.set_pan(0xcafe);
|
||||||
// This is _our_ address
|
// This is _our_ address
|
||||||
mrf.address16_write(0x6001);
|
mrf.address16_write(0x6001);
|
||||||
mrf.set_channel(12);
|
|
||||||
|
|
||||||
// uncomment if you want to receive any packet on this channel
|
// uncomment if you want to receive any packet on this channel
|
||||||
//mrf.set_promiscuous(true);
|
//mrf.set_promiscuous(true);
|
||||||
|
|
||||||
attachInterrupt(0, interrupt_routine, CHANGE); // interrupt 0 equivalent to pin 2 on ATMEGA8
|
// uncomment if you want to enable PA/LNA external control
|
||||||
|
//mrf.set_palna(true);
|
||||||
|
|
||||||
|
// uncomment if you want to buffer all PHY Payload
|
||||||
|
//mrf.set_bufferPHY(true);
|
||||||
|
|
||||||
|
attachInterrupt(0, interrupt_routine, CHANGE); // interrupt 0 equivalent to pin 2(INT0) on ATmega8/168/328
|
||||||
interrupts();
|
interrupts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void interrupt_routine() {
|
void interrupt_routine() {
|
||||||
mrf.interrupt_handler();
|
mrf.interrupt_handler(); // mrf24 object interrupt routine
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
@ -41,7 +49,14 @@ void loop() {
|
||||||
void handle_rx() {
|
void handle_rx() {
|
||||||
Serial.print("received a packet ");Serial.print(mrf.get_rxinfo()->frame_length, DEC);Serial.println(" bytes long");
|
Serial.print("received a packet ");Serial.print(mrf.get_rxinfo()->frame_length, DEC);Serial.println(" bytes long");
|
||||||
|
|
||||||
Serial.println("Packet data:");
|
if(mrf.get_bufferPHY()){
|
||||||
|
Serial.println("Packet data (PHY Payload):");
|
||||||
|
for (int i = 0; i < mrf.get_rxinfo()->frame_length; i++) {
|
||||||
|
Serial.print(mrf.get_rxbuf()[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("\r\nASCII data (relevant data):");
|
||||||
for (int i = 0; i < mrf.rx_datalength(); i++) {
|
for (int i = 0; i < mrf.rx_datalength(); i++) {
|
||||||
Serial.write(mrf.get_rxinfo()->rx_data[i]);
|
Serial.write(mrf.get_rxinfo()->rx_data[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue