Implements "much easier to use" as KarlP said in his blog, and some functions to get only the relatively "important data bytes
This commit is contained in:
parent
fac2f3f530
commit
45fe536979
38
mrf24j.h
38
mrf24j.h
|
@ -7,7 +7,11 @@
|
|||
#ifndef LIB_MRF24J_H
|
||||
#define LIB_MRF24J_H
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100 // Arduino IDE version >= 1.0
|
||||
#include "Arduino.h"
|
||||
#else // older Arduino IDE versions
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include "SPI.h"
|
||||
|
||||
|
||||
|
@ -143,10 +147,24 @@
|
|||
#define MRF_I_RXIF 0b00001000
|
||||
#define MRF_I_TXNIF 0b00000001
|
||||
|
||||
typedef struct _rx_info_t{
|
||||
uint8_t frame_length;
|
||||
uint8_t rx_data[116]; //max data length = (127 aMaxPHYPacketSize - 2 Frame control - 1 sequence number - 2 panid - 2 shortAddr Destination - 2 shortAddr Source - 2 FCS)
|
||||
uint8_t lqi;
|
||||
uint8_t rssi;
|
||||
} rx_info_t;
|
||||
|
||||
/**
|
||||
* Based on the TXSTAT register, but "better"
|
||||
*/
|
||||
typedef struct _tx_info_t{
|
||||
uint8_t tx_ok:1;
|
||||
uint8_t retries:2;
|
||||
uint8_t channel_busy:1;
|
||||
} tx_info_t;
|
||||
|
||||
class Mrf24j
|
||||
{
|
||||
|
||||
public:
|
||||
Mrf24j(int pin_reset, int pin_chip_select, int pin_interrupt);
|
||||
void reset(void);
|
||||
|
@ -179,16 +197,24 @@ void rx_disable(void);
|
|||
/** If you want to throw away rx data */
|
||||
void rx_flush(void);
|
||||
|
||||
void send16(word dest16, byte len, char * data);
|
||||
rx_info_t * get_rxinfo(void);
|
||||
|
||||
tx_info_t * get_txinfo(void);
|
||||
|
||||
uint8_t * get_rxbuf(void);
|
||||
|
||||
int rx_datalength(void);
|
||||
|
||||
void send16(word dest16, char * data);
|
||||
|
||||
void interrupt_handler(void);
|
||||
|
||||
void check_flags(void (*rx_handler)(void), void (*tx_handler)(void));
|
||||
|
||||
private:
|
||||
int _pin_reset;
|
||||
int _pin_cs;
|
||||
int _pin_int;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* LIB_MRF24J_H */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue