Added some config/init time options

This commit is contained in:
Pkarc 2011-12-17 14:44:18 -05:00
parent fe59becbba
commit 1a92fdfc8e
1 changed files with 10 additions and 11 deletions

View File

@ -10,8 +10,8 @@
#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);
@ -21,12 +21,17 @@ long tx_interval = 1000;
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);
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);
attachInterrupt(0, interrupt_routine, CHANGE); // interrupt 0 equivalent to pin 2(INT0) on ATmega8/168/328
last_time = millis(); last_time = millis();
interrupts(); interrupts();
} }
@ -37,12 +42,6 @@ void interrupt_routine() {
void loop() { void loop() {
mrf.check_flags(&handle_rx, &handle_tx); mrf.check_flags(&handle_rx, &handle_tx);
unsigned long current_time = millis();
if (current_time - last_time > tx_interval) {
last_time = current_time;
Serial.println("txxxing...");
mrf.send16(0x4202, "abcd");
}
} }
void handle_rx() { void handle_rx() {