15#include <RHNRFSPIDriver.h>
19#define RH_MRF89_NUM_INTERRUPTS 3
22#define RH_MRF89_FIFO_SIZE 64
26#define RH_MRF89_MAX_PAYLOAD_LEN RH_MRF89_FIFO_SIZE
30#define RH_MRF89_HEADER_LEN 4
36#ifndef RH_MRF89_MAX_MESSAGE_LEN
37 #define RH_MRF89_MAX_MESSAGE_LEN (RH_MRF89_MAX_PAYLOAD_LEN - RH_MRF89_HEADER_LEN)
41#define RH_MRF89_SPI_READ_MASK 0x40
44#define RH_MRF89_XTAL_FREQ 12.8
47#define RH_MRF89_REG_00_GCONREG 0x00
48#define RH_MRF89_REG_01_DMODREG 0x01
49#define RH_MRF89_REG_02_FDEVREG 0x02
50#define RH_MRF89_REG_03_BRSREG 0x03
51#define RH_MRF89_REG_04_FLTHREG 0x04
52#define RH_MRF89_REG_05_FIFOCREG 0x05
53#define RH_MRF89_REG_06_R1CREG 0x06
54#define RH_MRF89_REG_07_P1CREG 0x07
55#define RH_MRF89_REG_08_S1CREG 0x08
56#define RH_MRF89_REG_09_R2CREG 0x09
57#define RH_MRF89_REG_0A_P2CREG 0x0a
58#define RH_MRF89_REG_0B_S2CREG 0x0b
59#define RH_MRF89_REG_0C_PACREG 0x0c
60#define RH_MRF89_REG_0D_FTXRXIREG 0x0d
61#define RH_MRF89_REG_0E_FTPRIREG 0x0e
62#define RH_MRF89_REG_0F_RSTHIREG 0x0f
63#define RH_MRF89_REG_10_FILCREG 0x10
64#define RH_MRF89_REG_11_PFCREG 0x11
65#define RH_MRF89_REG_12_SYNCREG 0x12
68#define RH_MRF89_REG_13_RSVREG 0x13
69#define RH_MRF89_REG_14_RSTSREG 0x14
70#define RH_MRF89_REG_15_OOKCREG 0x15
71#define RH_MRF89_REG_16_SYNCV31REG 0x16
72#define RH_MRF89_REG_17_SYNCV23REG 0x17
73#define RH_MRF89_REG_18_SYNCV15REG 0x18
74#define RH_MRF89_REG_19_SYNCV07REG 0x19
75#define RH_MRF89_REG_1A_TXCONREG 0x1a
76#define RH_MRF89_REG_1B_CLKOREG 0x1b
77#define RH_MRF89_REG_1C_PLOADREG 0x1c
78#define RH_MRF89_REG_1D_NADDSREG 0x1d
79#define RH_MRF89_REG_1E_PKTCREG 0x1e
80#define RH_MRF89_REG_1F_FCRCREG 0x1f
84#define RH_MRF89_CMOD 0xe0
85#define RH_MRF89_CMOD_TRANSMIT 0x80
86#define RH_MRF89_CMOD_RECEIVE 0x60
87#define RH_MRF89_CMOD_FS 0x40
88#define RH_MRF89_CMOD_STANDBY 0x20
89#define RH_MRF89_CMOD_SLEEP 0x00
91#define RH_MRF89_FBS 0x18
92#define RH_MRF89_FBS_950_960_or_863_870 0x10
93#define RH_MRF89_FBS_915_928 0x08
94#define RH_MRF89_FBS_902_915 0x00
96#define RH_MRF89_VCOT 0x06
97#define RH_MRF89_VCOT_180MV 0x06
98#define RH_MRF89_VCOT_120MV 0x04
99#define RH_MRF89_VCOT_60MV 0x02
100#define RH_MRF89_VCOT_TANK 0x00
102#define RH_MRF89_RPS 0x01
105#define RH_MRF89_MODSEL 0xc0
106#define RH_MRF89_MODSEL_FSK 0x80
107#define RH_MRF89_MODSEL_OOK 0x40
109#define RH_MRF89_DMODE0 0x20
111#define RH_MRF89_OOKTYP 0x18
112#define RH_MRF89_OOKTYP_AVERAGE 0x10
113#define RH_MRF89_OOKTYP_PEAK 0x08
114#define RH_MRF89_OOKTYP_FIXED 0x00
116#define RH_MRF89_DMODE1 0x04
118#define RH_MRF89_IFGAIN 0x03
119#define RH_MRF89_IFGAIN_M13P5 0x03
120#define RH_MRF89_IFGAIN_M9 0x02
121#define RH_MRF89_IFGAIN_M4P5 0x01
122#define RH_MRF89_IFGAIN_0 0x00
125#define RH_MRF89_OPMODE_CONTINUOUS 0x00
126#define RH_MRF89_OPMODE_BUFFER RH_MRF89_DMODE0
127#define RH_MRF89_OPMODE_PACKET RH_MRF89_DMODE1
130#define RH_MRF89_BRVAL 0x7f
133#define RH_MRF89_FSIZE 0xc0
134#define RH_MRF89_FSIZE_64 0xc0
135#define RH_MRF89_FSIZE_48 0x80
136#define RH_MRF89_FSIZE_32 0x40
137#define RH_MRF89_FSIZE_16 0x00
139#define RH_MRF89_FTINT 0x3f
142#define RH_MRF89_PARC 0x18
143#define RH_MRF89_PARC_23 0x18
144#define RH_MRF89_PARC_15 0x10
145#define RH_MRF89_PARC_8P5 0x08
146#define RH_MRF89_PARC_3 0x00
149#define RH_MRF89_IRQ0RXS 0xc0
150#define RH_MRF89_IRQ0RXS_CONT_RSSI 0x40
151#define RH_MRF89_IRQ0RXS_CONT_SYNC 0x00
152#define RH_MRF89_IRQ0RXS_BUFFER_SYNC 0xc0
153#define RH_MRF89_IRQ0RXS_BUFFER_FIFOEMPTY 0x80
154#define RH_MRF89_IRQ0RXS_BUFFER_WRITEBYTE 0x40
155#define RH_MRF89_IRQ0RXS_BUFFER_NONE 0x00
156#define RH_MRF89_IRQ0RXS_PACKET_SYNC 0xc0
157#define RH_MRF89_IRQ0RXS_PACKET_FIFOEMPTY 0x80
158#define RH_MRF89_IRQ0RXS_PACKET_WRITEBYTE 0x40
159#define RH_MRF89_IRQ0RXS_PACKET_PLREADY 0x00
161#define RH_MRF89_IRQ1RXS 0x30
162#define RH_MRF89_IRQ1RXS_CONT_DCLK 0x00
163#define RH_MRF89_IRQ1RXS_BUFFER_FIFO_THRESH 0x30
164#define RH_MRF89_IRQ1RXS_BUFFER_RSSI 0x20
165#define RH_MRF89_IRQ1RXS_BUFFER_FIFOFULL 0x10
166#define RH_MRF89_IRQ1RXS_BUFFER_NONE 0x00
167#define RH_MRF89_IRQ1RXS_PACKET_FIFO_THRESH 0x30
168#define RH_MRF89_IRQ1RXS_PACKET_RSSI 0x20
169#define RH_MRF89_IRQ1RXS_PACKET_FIFOFULL 0x10
170#define RH_MRF89_IRQ1RXS_PACKET_CRCOK 0x00
172#define RH_MRF89_IRQ1TX 0x08
173#define RH_MRF89_FIFOFULL 0x04
174#define RH_MRF89_FIFOEMPTY 0x02
175#define RH_MRF89_FOVRUN 0x01
178#define RH_MRF89_FIFOFM 0x80
179#define RH_MRF89_FIFOFSC 0x40
180#define RH_MRF89_TXDONE 0x20
181#define RH_MRF89_IRQ0TXST 0x10
182#define RH_MRF89_RIRQS 0x04
183#define RH_MRF89_LSTSPLL 0x02
184#define RH_MRF89_LENPLL 0x01
187#define RH_MRF89_PASFILV 0xf0
188#define RH_MRF89_PASFILV_987KHZ 0xf0
189#define RH_MRF89_PASFILV_676KHZ 0xe0
190#define RH_MRF89_PASFILV_514KHZ 0xd0
191#define RH_MRF89_PASFILV_458KHZ 0xc0
192#define RH_MRF89_PASFILV_414KHZ 0xb0
193#define RH_MRF89_PASFILV_378KHZ 0xa0
194#define RH_MRF89_PASFILV_321KHZ 0x90
195#define RH_MRF89_PASFILV_262KHZ 0x80
196#define RH_MRF89_PASFILV_234KHZ 0x70
197#define RH_MRF89_PASFILV_211KHZ 0x60
198#define RH_MRF89_PASFILV_184KHZ 0x50
199#define RH_MRF89_PASFILV_157KHZ 0x40
200#define RH_MRF89_PASFILV_137KHZ 0x30
201#define RH_MRF89_PASFILV_109KHZ 0x20
202#define RH_MRF89_PASFILV_82KHZ 0x10
203#define RH_MRF89_PASFILV_65KHZ 0x00
205#define RH_MRF89_BUTFILV 0x0f
206#define RH_MRF89_BUTFILV_25KHZ 0x00
207#define RH_MRF89_BUTFILV_50KHZ 0x01
208#define RH_MRF89_BUTFILV_75KHZ 0x02
209#define RH_MRF89_BUTFILV_100KHZ 0x03
210#define RH_MRF89_BUTFILV_125KHZ 0x04
211#define RH_MRF89_BUTFILV_150KHZ 0x05
212#define RH_MRF89_BUTFILV_175KHZ 0x06
213#define RH_MRF89_BUTFILV_200KHZ 0x07
214#define RH_MRF89_BUTFILV_225KHZ 0x08
215#define RH_MRF89_BUTFILV_250KHZ 0x09
216#define RH_MRF89_BUTFILV_275KHZ 0x0a
217#define RH_MRF89_BUTFILV_300KHZ 0x0b
218#define RH_MRF89_BUTFILV_325KHZ 0x0c
219#define RH_MRF89_BUTFILV_350KHZ 0x0d
220#define RH_MRF89_BUTFILV_375KHZ 0x0e
221#define RH_MRF89_BUTFILV_400KHZ 0x0f
224#define RH_MRF89_POLCFV 0xf0
227#define RH_MRF89_POLFILEN 0x80
228#define RH_MRF89_BSYNCEN 0x40
229#define RH_MRF89_SYNCREN 0x20
230#define RH_MRF89_SYNCWSZ 0x18
231#define RH_MRF89_SYNCWSZ_32 0x18
232#define RH_MRF89_SYNCWSZ_24 0x10
233#define RH_MRF89_SYNCWSZ_16 0x08
234#define RH_MRF89_SYNCWSZ_8 0x00
235#define RH_MRF89_SYNCTEN 0x06
236#define RH_MRF89_SYNCTEN_3 0x06
237#define RH_MRF89_SYNCTEN_2 0x04
238#define RH_MRF89_SYNCTEN_1 0x02
239#define RH_MRF89_SYNCTEN_0 0x00
242#define RH_MRF89_OOTHSV 0xe0
243#define RH_MRF89_OOTHSV_6P0DB 0xe0
244#define RH_MRF89_OOTHSV_5P0DB 0xc0
245#define RH_MRF89_OOTHSV_4P0DB 0xa0
246#define RH_MRF89_OOTHSV_3P0DB 0x80
247#define RH_MRF89_OOTHSV_2P0DB 0x60
248#define RH_MRF89_OOTHSV_1P5DB 0x40
249#define RH_MRF89_OOTHSV_1P0DB 0x20
250#define RH_MRF89_OOTHSV_0P5DB 0x00
252#define RH_MRF89_OOKTHPV 0x1c
253#define RH_MRF89_OOKTHPV_16 0x1c
254#define RH_MRF89_OOKTHPV_8 0x18
255#define RH_MRF89_OOKTHPV_4 0x14
256#define RH_MRF89_OOKTHPV_2 0x10
257#define RH_MRF89_OOKTHPV_1_IN_8 0x0c
258#define RH_MRF89_OOKTHPV_1_IN_4 0x08
259#define RH_MRF89_OOKTHPV_1_IN_2 0x04
260#define RH_MRF89_OOKTHPV_1_IN_1 0x00
262#define RH_MRF89_OOKATHC 0x03
263#define RH_MRF89_OOKATHC_32PI 0x03
264#define RH_MRF89_OOKATHC_8PI 0x00
267#define RH_MRF89_TXIPOLFV 0xf0
269#define RH_MRF89_TXOPVAL 0x0e
270#define RH_MRF89_TXOPVAL_M8DBM 0x0e
271#define RH_MRF89_TXOPVAL_M5DBM 0x0c
272#define RH_MRF89_TXOPVAL_M2DBM 0x0a
273#define RH_MRF89_TXOPVAL_1DBM 0x08
274#define RH_MRF89_TXOPVAL_4DBM 0x06
275#define RH_MRF89_TXOPVAL_7DBM 0x04
276#define RH_MRF89_TXOPVAL_10DBM 0x02
277#define RH_MRF89_TXOPVAL_13DBM 0x00
280#define RH_MRF89_CLKOCNTRL 0x80
281#define RH_MRF89_CLKOFREQ 0x7c
284#define RH_MRF89_MCHSTREN 0x80
285#define RH_MRF89_PLDPLEN 0x7f
288#define RH_MRF89_PKTLENF 0x80
290#define RH_MRF89_PRESIZE 0x60
291#define RH_MRF89_PRESIZE_4 0x60
292#define RH_MRF89_PRESIZE_3 0x40
293#define RH_MRF89_PRESIZE_2 0x20
294#define RH_MRF89_PRESIZE_1 0x00
296#define RH_MRF89_WHITEON 0x10
297#define RH_MRF89_CHKCRCEN 0x08
299#define RH_MRF89_ADDFIL 0x06
300#define RH_MRF89_ADDFIL_NODEADDR_00_FF 0x06
301#define RH_MRF89_ADDFIL_NODEADDR_00 0x04
302#define RH_MRF89_ADDFIL_NODEADDR 0x02
303#define RH_MRF89_ADDFIL_OFF 0x00
305#define RH_MRF89_STSCRCEN 0x01
308#define RH_MRF89_ACFCRC 0x80
309#define RH_MRF89_FRWAXS 0x40
447 RH_MRF89(uint8_t csconPin = SS, uint8_t csdatPin = 9, uint8_t interruptPin = 2,
RHGenericSPI& spi = hardware_spi);
465 virtual bool sleep();
514 virtual bool recv(uint8_t* buf, uint8_t* len);
522 virtual bool send(
const uint8_t* data, uint8_t len);
554 void setSyncWords(
const uint8_t* syncWords = NULL, uint8_t len = 0);
615 static RH_MRF89* _deviceForInterrupt[];
618 static uint8_t _interruptCount;
627 uint8_t _interruptPin;
631 uint8_t _myInterruptIndex;
634 volatile uint8_t _bufLen;
637 uint8_t _buf[RH_MRF89_MAX_PAYLOAD_LEN];
640 volatile bool _rxBufValid;
virtual RHMode mode()
Definition RHGenericDriver.cpp:165
Base class for SPI interfaces.
Definition RHGenericSPI.h:31
Base class for RadioHead drivers that use the SPI bus to communicate with its NRF family transport ha...
Definition RHNRFSPIDriver.h:34
Send and receive unaddressed, unreliable datagrams by Microchip MRF89XA and compatible transceivers....
Definition RH_MRF89.h:397
uint8_t spiWriteRegister(uint8_t reg, uint8_t val)
Definition RH_MRF89.cpp:267
void setPreambleLength(uint8_t bytes)
Definition RH_MRF89.cpp:550
uint8_t spiReadRegister(uint8_t reg)
Definition RH_MRF89.cpp:259
bool printRegisters()
Definition RH_MRF89.cpp:176
virtual bool send(const uint8_t *data, uint8_t len)
Definition RH_MRF89.cpp:393
bool verifyPLLLock()
Definition RH_MRF89.cpp:449
void setModeIdle()
Definition RH_MRF89.cpp:321
ModemConfigChoice
Definition RH_MRF89.h:422
@ FSK_Rb200Fd200
FSK, No Manchester, Whitened, Rb = 200kbs, Fd = 200kHz.
Definition RH_MRF89.h:431
@ FSK_Rb2Fd33
FSK, No Manchester, Whitened, Rb = 2kbs, Fd = 33kHz.
Definition RH_MRF89.h:423
@ FSK_Rb5Fd33
FSK, No Manchester, Whitened, Rb = 5kbs, Fd = 33kHz.
Definition RH_MRF89.h:424
@ FSK_Rb100Fd200
FSK, No Manchester, Whitened, Rb = 100kbs, Fd = 200kHz.
Definition RH_MRF89.h:430
@ FSK_Rb10Fd33
FSK, No Manchester, Whitened, Rb = 10kbs, Fd = 33kHz.
Definition RH_MRF89.h:425
@ FSK_Rb40Fd80
FSK, No Manchester, Whitened, Rb = 40kbs, Fd = 80kHz.
Definition RH_MRF89.h:427
@ FSK_Rb50Fd100
FSK, No Manchester, Whitened, Rb = 50kbs, Fd = 100kHz.
Definition RH_MRF89.h:428
@ FSK_Rb66Fd133
FSK, No Manchester, Whitened, Rb = 66kbs, Fd = 133kHz.
Definition RH_MRF89.h:429
@ FSK_Rb20Fd40
FSK, No Manchester, Whitened, Rb = 20kbs, Fd = 40kHz.
Definition RH_MRF89.h:426
void setModeTx()
Definition RH_MRF89.cpp:349
bool setFrequency(float centre)
Definition RH_MRF89.cpp:467
uint8_t spiReadData()
Definition RH_MRF89.cpp:305
virtual bool sleep()
Definition RH_MRF89.cpp:330
void setModeRx()
Definition RH_MRF89.cpp:340
bool setModemConfig(ModemConfigChoice index)
Definition RH_MRF89.cpp:525
virtual bool available()
Definition RH_MRF89.cpp:365
void handleInterrupt()
Definition RH_MRF89.cpp:195
void setOpMode(uint8_t mode)
Definition RH_MRF89.cpp:313
uint8_t spiWriteData(uint8_t data)
Definition RH_MRF89.cpp:278
virtual uint8_t maxMessageLength()
Definition RH_MRF89.cpp:417
void clearRxBuf()
Clear our local receive buffer.
Definition RH_MRF89.cpp:441
virtual bool recv(uint8_t *buf, uint8_t *len)
Definition RH_MRF89.cpp:374
void setTxPower(uint8_t power)
Definition RH_MRF89.cpp:358
virtual bool init()
Definition RH_MRF89.cpp:48
void setSyncWords(const uint8_t *syncWords=NULL, uint8_t len=0)
Definition RH_MRF89.cpp:561
void validateRxBuf()
Examine the revceive buffer to determine whether the message is for this node.
Definition RH_MRF89.cpp:423
Defines register configuration values for a desired modulation.
Definition RH_MRF89.h:405
uint8_t BRVAL
Value for BRVAL RH_MRF89_REG_03_BRSREG.
Definition RH_MRF89.h:408
uint8_t FDVAL
Value for FDVAL in RH_MRF89_REG_02_FDEVREG.
Definition RH_MRF89.h:407
uint8_t MODSEL
Value for MODSEL in RH_MRF89_REG_01_DMODREG.
Definition RH_MRF89.h:406
uint8_t FILCREG
Value for PASFILV | BUTFILV in RH_MRF89_REG_10_FILCREG.
Definition RH_MRF89.h:409
uint8_t TXIPOLFV
Value for TXIPOLFV in RH_MRF89_REG_1A_TXCONREG.
Definition RH_MRF89.h:410