10 #include <RHGenericSPI.h>
11 #include <RHNRFSPIDriver.h>
15 #define RH_NRF905_MAX_PAYLOAD_LEN 32
22 #define RH_NRF905_HEADER_LEN 5
26 #define RH_NRF905_MAX_MESSAGE_LEN (RH_NRF905_MAX_PAYLOAD_LEN-RH_NRF905_HEADER_LEN)
29 #define RH_NRF905_REG_MASK 0x0f
30 #define RH_NRF905_REG_W_CONFIG 0x00
31 #define RH_NRF905_REG_R_CONFIG 0x10
32 #define RH_NRF905_REG_W_TX_PAYLOAD 0x20
33 #define RH_NRF905_REG_R_TX_PAYLOAD 0x21
34 #define RH_NRF905_REG_W_TX_ADDRESS 0x22
35 #define RH_NRF905_REG_R_TX_ADDRESS 0x23
36 #define RH_NRF905_REG_R_RX_PAYLOAD 0x24
37 #define RH_NRF905_REG_CHANNEL_CONFIG 0x80
40 #define RH_NRF905_CONFIG_0 0x00
41 #define RH_NRF905_CONFIG_0_CH_NO 0xff
43 #define RH_NRF905_CONFIG_1 0x01
44 #define RH_NRF905_CONFIG_1_AUTO_RETRAN 0x20
45 #define RH_NRF905_CONFIG_1_RX_RED_PWR 0x10
46 #define RH_NRF905_CONFIG_1_PA_PWR 0x0c
47 #define RH_NRF905_CONFIG_1_PA_PWR_N10DBM 0x00
48 #define RH_NRF905_CONFIG_1_PA_PWR_N2DBM 0x04
49 #define RH_NRF905_CONFIG_1_PA_PWR_6DBM 0x08
50 #define RH_NRF905_CONFIG_1_PA_PWR_10DBM 0x0c
51 #define RH_NRF905_CONFIG_1_HFREQ_PLL 0x02
52 #define RH_NRF905_CONFIG_1_CH_NO 0x01
54 #define RH_NRF905_CONFIG_2 0x02
55 #define RH_NRF905_CONFIG_2_TX_AFW 0x70
56 #define RH_NRF905_CONFIG_2_RX_AFW 0x07
58 #define RH_NRF905_CONFIG_3 0x03
59 #define RH_NRF905_CONFIG_3_RX_PW 0x3f
61 #define RH_NRF905_CONFIG_4 0x04
62 #define RH_NRF905_CONFIG_4_TX_PW 0x3f
64 #define RH_NRF905_CONFIG_5 0x05
65 #define RH_NRF905_CONFIG_5_RX_ADDRESS 0xff
67 #define RH_NRF905_CONFIG_6 0x06
68 #define RH_NRF905_CONFIG_6_RX_ADDRESS 0xff
70 #define RH_NRF905_CONFIG_7 0x07
71 #define RH_NRF905_CONFIG_7_RX_ADDRESS 0xff
73 #define RH_NRF905_CONFIG_8 0x08
74 #define RH_NRF905_CONFIG_8_RX_ADDRESS 0xff
76 #define RH_NRF905_CONFIG_9 0x09
77 #define RH_NRF905_CONFIG_9_CRC_MODE_16BIT 0x80
78 #define RH_NRF905_CONFIG_9_CRC_EN 0x40
79 #define RH_NRF905_CONFIG_9_XOF 0x38
80 #define RH_NRF905_CONFIG_9_XOF_4MHZ 0x00
81 #define RH_NRF905_CONFIG_9_XOF_8MHZ 0x08
82 #define RH_NRF905_CONFIG_9_XOF_12MHZ 0x10
83 #define RH_NRF905_CONFIG_9_XOF_16MHZ 0x18
84 #define RH_NRF905_CONFIG_9_XOF_20MHZ 0x20
85 #define RH_NRF905_CONFIG_9_UP_CLK_EN 0x04
86 #define RH_NRF905_CONFIG_9_UP_CLK_FREQ 0x03
87 #define RH_NRF905_CONFIG_9_UP_CLK_FREQ_4MHZ 0x00
88 #define RH_NRF905_CONFIG_9_UP_CLK_FREQ_2MHZ 0x01
89 #define RH_NRF905_CONFIG_9_UP_CLK_FREQ_1MHZ 0x02
90 #define RH_NRF905_CONFIG_9_UP_CLK_FREQ_500KHZ 0x03
93 #define RH_NRF905_STATUS_AM 0x80
94 #define RH_NRF905_STATUS_DR 0x20
260 RH_NRF905(uint8_t chipEnablePin = 8, uint8_t txEnablePin = 9, uint8_t slaveSelectPin = SS,
RHGenericSPI& spi = hardware_spi);
308 bool setChannel(uint16_t channel,
bool hiFrequency =
false);
347 bool send(
const uint8_t* data, uint8_t len);
386 bool recv(uint8_t* buf, uint8_t* len);
401 uint8_t _configuration;
404 uint8_t _chipEnablePin;
407 uint8_t _txEnablePin;
413 uint8_t _buf[RH_NRF905_MAX_PAYLOAD_LEN];
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition: RHGenericDriver.h:292
void validateRxBuf()
Examine the revceive buffer to determine whether the message is for this node.
Definition: RH_NRF905.cpp:204
@ Frequency8MHz
SPI bus frequency close to 8MHz.
Definition: RHGenericSPI.h:60
uint8_t spiCommand(uint8_t command)
Definition: RHNRFSPIDriver.cpp:31
Base class for SPI interfaces.
Definition: RHGenericSPI.h:30
uint8_t spiRead(uint8_t reg)
Definition: RHNRFSPIDriver.cpp:48
@ TransmitPower6dBm
6 dBm
Definition: RH_NRF905.h:245
bool setRF(TransmitPower power)
Definition: RH_NRF905.cpp:100
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition: RHGenericDriver.h:265
virtual void setFrequency(Frequency frequency)
Definition: RHGenericSPI.cpp:27
Send and receive unaddressed, unreliable datagrams by nRF905 and compatible transceivers.
Definition: RH_NRF905.h:234
volatile uint8_t _rxHeaderTo
TO header in the last received mesasge.
Definition: RHGenericDriver.h:262
RH_NRF905(uint8_t chipEnablePin=8, uint8_t txEnablePin=9, uint8_t slaveSelectPin=SS, RHGenericSPI &spi=hardware_spi)
Definition: RH_NRF905.cpp:8
uint8_t _txHeaderFrom
FROM header to send in all messages.
Definition: RHGenericDriver.h:277
void clearRxBuf()
Clear our local receive buffer.
Definition: RH_NRF905.cpp:246
uint8_t _thisAddress
This node id.
Definition: RHGenericDriver.h:256
TransmitPower
Convenient values for setting transmitter power in setRF() These are designed to agree with the value...
Definition: RH_NRF905.h:241
volatile uint16_t _txGood
Count of the number of bad messages (correct checksum etc) received.
Definition: RHGenericDriver.h:295
bool available()
Definition: RH_NRF905.cpp:226
bool init()
Definition: RHNRFSPIDriver.cpp:15
bool _promiscuous
Whether the transport is in promiscuous mode.
Definition: RHGenericDriver.h:259
uint8_t spiBurstWriteRegister(uint8_t reg, uint8_t *src, uint8_t len)
Definition: RH_NRF905.cpp:63
uint8_t spiBurstWrite(uint8_t reg, const uint8_t *src, uint8_t len)
Definition: RHNRFSPIDriver.cpp:109
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition: RHGenericDriver.h:271
uint8_t spiReadRegister(uint8_t reg)
Definition: RH_NRF905.cpp:48
void setModeTx()
Definition: RH_NRF905.cpp:130
bool setChannel(uint16_t channel, bool hiFrequency=false)
Definition: RH_NRF905.cpp:74
uint8_t spiBurstReadRegister(uint8_t reg, uint8_t *dest, uint8_t len)
Definition: RH_NRF905.cpp:58
@ TransmitPower10dBm
10 dBm
Definition: RH_NRF905.h:246
bool printRegister(uint8_t reg)
Definition: RH_NRF905.cpp:182
bool init()
Definition: RH_NRF905.cpp:16
uint8_t _txHeaderId
ID header to send in all messages.
Definition: RHGenericDriver.h:280
uint8_t maxMessageLength()
Definition: RH_NRF905.cpp:267
bool printRegisters()
Definition: RH_NRF905.cpp:193
uint8_t _txHeaderTo
TO header to send in all messages.
Definition: RHGenericDriver.h:274
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition: RHGenericDriver.h:283
uint8_t statusRead()
Definition: RH_NRF905.cpp:68
bool setNetworkAddress(uint8_t *address, uint8_t len)
Definition: RH_NRF905.cpp:89
Base class for RadioHead drivers that use the SPI bus to communicate with its NRF family transport ha...
Definition: RHNRFSPIDriver.h:33
uint8_t spiWrite(uint8_t reg, uint8_t val)
Definition: RHNRFSPIDriver.cpp:66
bool recv(uint8_t *buf, uint8_t *len)
Definition: RH_NRF905.cpp:252
void setModeRx()
Definition: RH_NRF905.cpp:120
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition: RHGenericDriver.h:268
uint8_t spiWriteRegister(uint8_t reg, uint8_t val)
Definition: RH_NRF905.cpp:53
uint8_t spiBurstRead(uint8_t reg, uint8_t *dest, uint8_t len)
Definition: RHNRFSPIDriver.cpp:90
@ RHModeIdle
Transport is idle.
Definition: RHGenericDriver.h:52
bool isSending()
Definition: RH_NRF905.cpp:174
volatile RHMode _mode
The current transport operating mode.
Definition: RHGenericDriver.h:253
bool send(const uint8_t *data, uint8_t len)
Definition: RH_NRF905.cpp:141
RHGenericSPI & _spi
Reference to the RHGenericSPI instance to use to trasnfer data with teh SPI device.
Definition: RHNRFSPIDriver.h:95
@ TransmitPowerm10dBm
-10 dBm
Definition: RH_NRF905.h:243
@ RHModeTx
Transport is in the process of transmitting a message.
Definition: RHGenericDriver.h:53
void setModeIdle()
Definition: RH_NRF905.cpp:110
@ RHModeRx
Transport is in the process of receiving a message.
Definition: RHGenericDriver.h:54
@ Frequency1MHz
SPI bus frequency close to 1MHz.
Definition: RHGenericSPI.h:57
virtual bool waitCAD()
Definition: RHGenericDriver.cpp:72
virtual bool waitPacketSent()
Definition: RH_NRF905.cpp:163
@ TransmitPowerm2dBm
-2 dBm
Definition: RH_NRF905.h:244