David Rimer / RadioHead-148
Embed: (wiki syntax)

« Back to documentation index

RH_NRF905 Class Reference

Send and receive addressed, reliable, acknowledged datagrams by nRF905 and compatible transceivers. More...

#include <RH_NRF905.h>

Inherits RHNRFSPIDriver.

Public Types

enum  TransmitPower { TransmitPowerm10dBm = 0, TransmitPowerm2dBm, TransmitPower6dBm, TransmitPower10dBm }
 

Convenient values for setting transmitter power in setRF() These are designed to agree with the values for PA_PWR To be passed to setRF();.

More...
enum  RHMode {
  RHModeInitialising = 0, RHModeSleep, RHModeIdle, RHModeTx,
  RHModeRx
}
 

Defines different operating modes for the transport hardware.

More...

Public Member Functions

 RH_NRF905 (PINS chipEnablePin, PINS txEnablePin, PINS slaveSelectPin, RHGenericSPI &spi=hardware_spi)
 Constructor.
bool init ()
 Initialises this instance and the radio module connected to it.
uint8_t spiReadRegister (uint8_t reg)
 Reads a single register from the NRF905.
uint8_t spiWriteRegister (uint8_t reg, uint8_t val)
 Writes a single byte to the NRF905, and at the ame time reads the current STATUS register.
uint8_t spiBurstReadRegister (uint8_t reg, uint8_t *dest, uint8_t len)
 Reads a number of consecutive registers from the NRF905 using burst read mode.
uint8_t spiBurstWriteRegister (uint8_t reg, uint8_t *src, uint8_t len)
 Write a number of consecutive registers using burst write mode.
uint8_t statusRead ()
 Reads and returns the device status register NRF905_REG_02_DEVICE_STATUS.
bool setChannel (uint16_t channel, bool hiFrequency=false)
 Sets the transmit and receive channel number.
bool setNetworkAddress (uint8_t *address, uint8_t len)
 Sets the Network address.
bool setRF (TransmitPower power)
 Sets the transmitter power to use.
void setModeIdle ()
 Sets the radio in power down mode.
void setModeRx ()
 Sets the radio in RX mode.
void setModeTx ()
 Sets the radio in TX mode.
bool send (const uint8_t *data, uint8_t len)
 Sends data to the address set by setTransmitAddress() Sets the radio to TX mode.
virtual bool waitPacketSent ()
 Blocks until the current message (if any) has been transmitted.
bool isSending ()
 Indicates if the chip is in transmit mode and there is a packet currently being transmitted.
bool printRegister (uint8_t reg)
 Prints the value of a single chip register to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging purposes only.
bool printRegisters ()
 Prints the value of all chip registers to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging purposes only.
bool available ()
 Checks whether a received message is available.
bool recv (uint8_t *buf, uint8_t *len)
 Turns the receiver on if it not already on.
uint8_t maxMessageLength ()
 The maximum message length supported by this driver.
uint8_t spiCommand (uint8_t command)
 Sends a single command to the device.
uint8_t spiRead (uint8_t reg)
 Reads a single register from the SPI device.
uint8_t spiWrite (uint8_t reg, uint8_t val)
 Writes a single byte to the SPI device.
uint8_t spiBurstRead (uint8_t reg, uint8_t *dest, uint8_t len)
 Reads a number of consecutive registers from the SPI device using burst read mode.
uint8_t spiBurstWrite (uint8_t reg, const uint8_t *src, uint8_t len)
 Write a number of consecutive registers using burst write mode.
virtual void waitAvailable ()
 Starts the receiver and blocks until a valid received message is available.
virtual bool waitPacketSent (uint16_t timeout)
 Blocks until the transmitter is no longer transmitting.
virtual bool waitAvailableTimeout (uint16_t timeout)
 Starts the receiver and blocks until a received message is available or a timeout.
virtual void setThisAddress (uint8_t thisAddress)
 Sets the address of this node.
virtual void setHeaderTo (uint8_t to)
 Sets the TO header to be sent in all subsequent messages.
virtual void setHeaderFrom (uint8_t from)
 Sets the FROM header to be sent in all subsequent messages.
virtual void setHeaderId (uint8_t id)
 Sets the ID header to be sent in all subsequent messages.
virtual void setHeaderFlags (uint8_t set, uint8_t clear=RH_FLAGS_APPLICATION_SPECIFIC)
 Sets and clears bits in the FLAGS header to be sent in all subsequent messages First it clears he FLAGS according to the clear argument, then sets the flags according to the set argument.
virtual void setPromiscuous (bool promiscuous)
 Tells the receiver to accept messages with any TO address, not just messages addressed to thisAddress or the broadcast address.
virtual uint8_t headerTo ()
 Returns the TO header of the last received message.
virtual uint8_t headerFrom ()
 Returns the FROM header of the last received message.
virtual uint8_t headerId ()
 Returns the ID header of the last received message.
virtual uint8_t headerFlags ()
 Returns the FLAGS header of the last received message.
int8_t lastRssi ()
 Returns the most recent RSSI (Receiver Signal Strength Indicator).
RHMode mode ()
 Returns the operating mode of the library.
void setMode (RHMode mode)
 Sets the operating mode of the transport.
virtual bool sleep ()
 Sets the transport hardware into low-power sleep mode (if supported).
uint16_t rxBad ()
 Returns the count of the number of bad received packets (ie packets with bad lengths, checksum etc) which were rejected and not delivered to the application.
uint16_t rxGood ()
 Returns the count of the number of good received packets.
uint16_t txGood ()
 Returns the count of the number of packets successfully transmitted (though not necessarily received by the destination)

Static Public Member Functions

static void printBuffer (const char *prompt, const uint8_t *buf, uint8_t len)
 Prints a data buffer in HEX.

Protected Member Functions

void validateRxBuf ()
 Examine the revceive buffer to determine whether the message is for this node.
void clearRxBuf ()
 Clear our local receive buffer.

Protected Attributes

RHGenericSPI_spi
 Reference to the RHGenericSPI instance to use to trasnfer data with teh SPI device.
DigitalOut _slaveSelectPin
 The pin number of the Slave Selct pin that is used to select the desired device.
volatile RHMode _mode
 The current transport operating mode.
uint8_t _thisAddress
 This node id.
bool _promiscuous
 Whether the transport is in promiscuous mode.
volatile uint8_t _rxHeaderTo
 TO header in the last received mesasge.
volatile uint8_t _rxHeaderFrom
 FROM header in the last received mesasge.
volatile uint8_t _rxHeaderId
 ID header in the last received mesasge.
volatile uint8_t _rxHeaderFlags
 FLAGS header in the last received mesasge.
uint8_t _txHeaderTo
 TO header to send in all messages.
uint8_t _txHeaderFrom
 FROM header to send in all messages.
uint8_t _txHeaderId
 ID header to send in all messages.
uint8_t _txHeaderFlags
 FLAGS header to send in all messages.
volatile int8_t _lastRssi
 The value of the last received RSSI value, in some transport specific units.
volatile uint16_t _rxBad
 Count of the number of bad messages (eg bad checksum etc) received.
volatile uint16_t _rxGood
 Count of the number of successfully transmitted messaged.
volatile uint16_t _txGood
 Count of the number of bad messages (correct checksum etc) received.

Detailed Description

Send and receive addressed, reliable, acknowledged datagrams by nRF905 and compatible transceivers.

This base class provides basic functions for sending and receiving unaddressed, unreliable datagrams of arbitrary length to 28 octets per packet. Use one of the Manager classes to get addressing and acknowledgement reliability, routing, meshes etc.

The nRF905 transceiver is configured to use Enhanced Shockburst with 16 Bit CRC, and 32 octet packets.

Naturally, for any 2 radios to communicate that must be configured to use the same frequency and with identical network addresses.

The nRF905 from Nordic Semiconductor http://www.nordicsemi.com/eng/Products/Sub-1-GHz-RF/nRF905 (http://www.nordicsemi.com/jpn/nordic/content_download/2452/29528/file/Product_Specification_nRF905_v1.5.pdf) is a low-cost 433/868/915 MHz ISM transceiver module. It supports a number of channel frequencies at 100kHz deviation and 50kHz bandwidth with Manchester encoding.

We tested with inexpensive nRF905 modules from eBay, similar to: http://www.aliexpress.com/store/product/Free-ship-NRF905-433MHz-Wireless-Transmission-Module-Transceiver-Module-with-Antenna-for-the-433MHz-ISM-band/513046_607163305.html

This library provides functions for sending and receiving messages of up to 27 octets on any frequency supported by the nRF905.

Several nRF905 modules can be connected to an Arduino, permitting the construction of translators and frequency changers, etc.

Example Arduino programs are included to show the main modes of use.

Packet Format

All messages sent and received by this class conform to this fixed length packet format

  • 4 octets NETWORK ADDRESS
  • 32 octets PAYLOAD, consisting of:
    • 1 octet TO header
    • 1 octet FROM header
    • 1 octet ID header
    • 1 octet FLAGS header
    • 1 octet user message length header
    • 0 to 27 octets of user message, trailing octets after the user message length are ignored
  • 2 octets CRC

All messages sent and received by this driver are 32 octets. The user message length is embedded in the message.

Connecting nRF905

The nRF905 is a 3.3V part is is *NOT* 5V tolerant. So you MUST use a 3.3V CPU such as Teensy, Arduino Due etc or else provide for level shifters between the CPU and the nRF905. Failure to consider this will probbaly break your nRF905.

The electrical connection between the nRF905 and the CPU require 3.3V, the 3 x SPI pins (SCK, SDI, SDO), a Chip Enable pin, a Transmit Enable pin and a Slave Select pin.

The examples below assume the commonly found cheap Chinese nRF905 modules. The RH_RF905 driver assumes the the nRF905 has a 16MHz crystal.

Connect the nRF905 to Teensy like this

                 CPU          nRF905 module
                 3V3----------VCC   (3.3V)
             pin D8-----------CE    (chip enable in)
             pin D9-----------TX_EN (transmit enable in)
          SS pin D10----------CSN   (chip select in)
         SCK pin D13----------SCK   (SPI clock in)
        MOSI pin D11----------MOSI  (SPI Data in)
        MISO pin D12----------MISO  (SPI data out)
                 GND----------GND   (ground in)

Caution: Arduino Due is a 3.3V part and is not 5V tolerant (so too is the nRF905 module so they can be connected directly together. Unlike other Arduinos the Due has it default SPI connections on a dedicated 6 pin SPI header in the center of the board, which is physically compatible with Uno, Leonardo and Mega2560. A little dot marks pin 1 on the header. You must connect to these and *not* to the usual Arduino SPI pins 11, 12 and 13. See http://21stdigitalhome.blogspot.com.au/2013/02/arduino-due-hardware-spi.html

Connect the nRF905 to Arduino Due like this

                      CPU          nRF905 module
                      3V3----------VCC   (3.3V)
                  pin D8-----------CE    (chip enable in)
                  pin D9-----------TX_EN (transmit enable in)
               SS pin D10----------CSN   (chip select in)
  SCK on SPI header pin 3----------SCK   (SPI clock in)
 MOSI on SPI header pin 4----------MOSI  (SPI Data in)
 MISO on SPI header pin 1----------MISO  (SPI data out)
                      GND----------GND   (ground in)

and you can then use the default constructor RH_NRF905(). You can override the default settings for the CE, TX_EN and CSN pins in the NRF905() constructor if you wish to connect the slave select CSN to other than the normal one for your CPU.

It is possible to have 2 radios conected to one CPU, provided each radio has its own CSN, TX_EN and CE line (SCK, MOSI and MISO are common to both radios)

Example programs

Several example programs are provided. They work out of the box with Teensy 3.1 and Arduino Due connected as show above.

Radio Performance

Frequency accuracy may be debatable.

Memory

Memory usage of this class is minimal. The compiled client and server sketches are about 16000 bytes on Teensy.

Definition at line 208 of file RH_NRF905.h.


Member Enumeration Documentation

enum RHMode [inherited]

Defines different operating modes for the transport hardware.

These are the different values that can be adopted by the _mode variable and returned by the mode() member function,

Enumerator:
RHModeInitialising 

Transport is initialising. Initial default value until init() is called..

RHModeSleep 

Transport hardware is in low power sleep mode (if supported)

RHModeIdle 

Transport is idle.

RHModeTx 

Transport is in the process of transmitting a message.

RHModeRx 

Transport is in the process of receiving a message.

Definition at line 45 of file RHGenericDriver.h.

Convenient values for setting transmitter power in setRF() These are designed to agree with the values for PA_PWR To be passed to setRF();.

Enumerator:
TransmitPowerm10dBm 

-10 dBm

TransmitPowerm2dBm 

-2 dBm

TransmitPower6dBm 

6 dBm

TransmitPower10dBm 

10 dBm

Definition at line 214 of file RH_NRF905.h.


Constructor & Destructor Documentation

RH_NRF905 ( PINS  chipEnablePin,
PINS  txEnablePin,
PINS  slaveSelectPin,
RHGenericSPI spi = hardware_spi 
)

Constructor.

You can have multiple instances, but each instance must have its own chip enable and slave select pin. After constructing, you must call init() to initialise the interface and the radio module

Parameters:
[in]chipEnablePinthe Arduino pin to use to enable the chip for transmit/receive
[in]txEnablePinthe Arduino pin cponnected to the txEn pin on the radio that enable transmit mode
[in]slaveSelectPinthe Arduino pin number of the output to use to select the NRF905 before accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega, D10 for Maple, Teensy)
[in]spiPointer to the SPI interface object to use. Defaults to the standard Arduino hardware SPI interface

Definition at line 8 of file RH_NRF905.cpp.


Member Function Documentation

bool available (  ) [virtual]

Checks whether a received message is available.

This can be called multiple times in a timeout loop

Returns:
true if a complete, valid message has been received and is able to be retrieved by recv()

Implements RHGenericDriver.

Definition at line 221 of file RH_NRF905.cpp.

void clearRxBuf (  ) [protected]

Clear our local receive buffer.

Definition at line 240 of file RH_NRF905.cpp.

uint8_t headerFlags (  ) [virtual, inherited]

Returns the FLAGS header of the last received message.

Returns:
The FLAGS header

Definition at line 119 of file RHGenericDriver.cpp.

uint8_t headerFrom (  ) [virtual, inherited]

Returns the FROM header of the last received message.

Returns:
The FROM header

Definition at line 109 of file RHGenericDriver.cpp.

uint8_t headerId (  ) [virtual, inherited]

Returns the ID header of the last received message.

Returns:
The ID header

Definition at line 114 of file RHGenericDriver.cpp.

uint8_t headerTo (  ) [virtual, inherited]

Returns the TO header of the last received message.

Returns:
The TO header

Definition at line 104 of file RHGenericDriver.cpp.

bool init (  ) [virtual]

Initialises this instance and the radio module connected to it.

The following steps are taken:g

  • Set the chip enable and chip select pins to output LOW, HIGH respectively.
  • Initialise the SPI output pins
  • Initialise the SPI interface library to 8MHz (Hint, if you want to lower the SPI frequency (perhaps where you have other SPI shields, low voltages etc), call SPI.setClockDivider() after init()). -Flush the receiver and transmitter buffers
  • Set the radio to receive with powerUpRx();
    Returns:
    true if everything was successful

Reimplemented from RHNRFSPIDriver.

Definition at line 16 of file RH_NRF905.cpp.

bool isSending (  )

Indicates if the chip is in transmit mode and there is a packet currently being transmitted.

Returns:
true if the chip is in transmit mode and there is a transmission in progress

Definition at line 169 of file RH_NRF905.cpp.

int8_t lastRssi (  ) [inherited]

Returns the most recent RSSI (Receiver Signal Strength Indicator).

Usually it is the RSSI of the last received message, which is measured when the preamble is received. If you called readRssi() more recently, it will return that more recent value.

Returns:
The most recent RSSI measurement in dBm.

Definition at line 124 of file RHGenericDriver.cpp.

uint8_t maxMessageLength (  ) [virtual]

The maximum message length supported by this driver.

Returns:
The maximum message length supported by this driver

Implements RHGenericDriver.

Definition at line 261 of file RH_NRF905.cpp.

RHGenericDriver::RHMode mode (  ) [inherited]

Returns the operating mode of the library.

Returns:
the current mode, one of RF69_MODE_*

Definition at line 129 of file RHGenericDriver.cpp.

void printBuffer ( const char *  prompt,
const uint8_t *  buf,
uint8_t  len 
) [static, inherited]

Prints a data buffer in HEX.

For diagnostic use

Parameters:
[in]promptstring to preface the print
[in]bufLocation of the buffer to print
[in]lenLength of the buffer in octets.

Definition at line 145 of file RHGenericDriver.cpp.

bool printRegister ( uint8_t  reg )

Prints the value of a single chip register to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging purposes only.

Returns:
true on success

Definition at line 177 of file RH_NRF905.cpp.

bool printRegisters (  )

Prints the value of all chip registers to the Serial device if RH_HAVE_SERIAL is defined for the current platform For debugging purposes only.

Returns:
true on success

Definition at line 188 of file RH_NRF905.cpp.

bool recv ( uint8_t *  buf,
uint8_t *  len 
) [virtual]

Turns the receiver on if it not already on.

If there is a valid message available, copy it to buf and return true else return false. If a message is copied, *len is set to the length (Caution, 0 length messages are permitted). You should be sure to call this function frequently enough to not miss any messages It is recommended that you call it in your main loop.

Parameters:
[in]bufLocation to copy the received message
[in,out]lenPointer to available space in buf. Set to the actual number of octets copied.
Returns:
true if a valid message was copied to buf

Implements RHGenericDriver.

Definition at line 246 of file RH_NRF905.cpp.

uint16_t rxBad (  ) [inherited]

Returns the count of the number of bad received packets (ie packets with bad lengths, checksum etc) which were rejected and not delivered to the application.

Caution: not all drivers can correctly report this count. Some underlying hardware only report good packets.

Returns:
The number of bad packets received.

Definition at line 165 of file RHGenericDriver.cpp.

uint16_t rxGood (  ) [inherited]

Returns the count of the number of good received packets.

Returns:
The number of good packets received.

Definition at line 170 of file RHGenericDriver.cpp.

bool send ( const uint8_t *  data,
uint8_t  len 
) [virtual]

Sends data to the address set by setTransmitAddress() Sets the radio to TX mode.

Parameters:
[in]dataData bytes to send.
[in]lenNumber of data bytes to set in teh TX buffer. The actual size of the transmitted data payload is set by setPayloadSize
Returns:
true on success (which does not necessarily mean the receiver got the message, only that the message was successfully transmitted).

Implements RHGenericDriver.

Definition at line 140 of file RH_NRF905.cpp.

bool setChannel ( uint16_t  channel,
bool  hiFrequency = false 
)

Sets the transmit and receive channel number.

The RF frequency used is (422.4 + channel/10) * (1+hiFrequency) MHz

Parameters:
[in]channelThe channel number.
[in]hiFrequencyfalse for low frequency band (422.4MHz and up), true for high frequency band (845MHz and up)
Returns:
true on success

Definition at line 76 of file RH_NRF905.cpp.

void setHeaderFlags ( uint8_t  set,
uint8_t  clear = RH_FLAGS_APPLICATION_SPECIFIC 
) [virtual, inherited]

Sets and clears bits in the FLAGS header to be sent in all subsequent messages First it clears he FLAGS according to the clear argument, then sets the flags according to the set argument.

The default for clear always clears the application specific flags.

Parameters:
[in]setbitmask of bits to be set. Flags are cleared with the clear mask before being set.
[in]clearbitmask of flags to clear. Defaults to RH_FLAGS_APPLICATION_SPECIFIC which clears the application specific flags, resultiung in new application specific flags identical to the set.

Definition at line 98 of file RHGenericDriver.cpp.

void setHeaderFrom ( uint8_t  from ) [virtual, inherited]

Sets the FROM header to be sent in all subsequent messages.

Parameters:
[in]fromThe new FROM header value

Definition at line 88 of file RHGenericDriver.cpp.

void setHeaderId ( uint8_t  id ) [virtual, inherited]

Sets the ID header to be sent in all subsequent messages.

Parameters:
[in]idThe new ID header value

Definition at line 93 of file RHGenericDriver.cpp.

void setHeaderTo ( uint8_t  to ) [virtual, inherited]

Sets the TO header to be sent in all subsequent messages.

Parameters:
[in]toThe new TO header value

Definition at line 83 of file RHGenericDriver.cpp.

void setMode ( RHMode  mode ) [inherited]

Sets the operating mode of the transport.

Definition at line 134 of file RHGenericDriver.cpp.

void setModeIdle (  )

Sets the radio in power down mode.

Sets chip enable to LOW.

Returns:
true on success

Definition at line 109 of file RH_NRF905.cpp.

void setModeRx (  )

Sets the radio in RX mode.

Sets chip enable to HIGH to enable the chip in RX mode.

Returns:
true on success

Definition at line 119 of file RH_NRF905.cpp.

void setModeTx (  )

Sets the radio in TX mode.

Pulses the chip enable LOW then HIGH to enable the chip in TX mode.

Returns:
true on success

Definition at line 129 of file RH_NRF905.cpp.

bool setNetworkAddress ( uint8_t *  address,
uint8_t  len 
)

Sets the Network address.

Only nodes with the same network address can communicate with each other. You can set different network addresses in different sets of nodes to isolate them from each other. The default network address is 0xE7E7E7E7

Parameters:
[in]addressThe new network address. Must match the network address of any receiving node(s).
[in]lenNumber of bytes of address to set (1 to 4).
Returns:
true on success, false if len is not in the range 1-4 inclusive.

Definition at line 91 of file RH_NRF905.cpp.

void setPromiscuous ( bool  promiscuous ) [virtual, inherited]

Tells the receiver to accept messages with any TO address, not just messages addressed to thisAddress or the broadcast address.

Parameters:
[in]promiscuoustrue if you wish to receive messages with any TO address

Reimplemented in RH_RF22.

Definition at line 73 of file RHGenericDriver.cpp.

bool setRF ( TransmitPower  power )

Sets the transmitter power to use.

Parameters:
[in]powerTransmitter power. One of NRF905::TransmitPower.
Returns:
true on success

Definition at line 102 of file RH_NRF905.cpp.

void setThisAddress ( uint8_t  thisAddress ) [virtual, inherited]

Sets the address of this node.

Defaults to 0xFF. Subclasses or the user may want to change this. This will be used to test the adddress in incoming messages. In non-promiscuous mode, only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted. In promiscuous mode, all messages will be accepted regardless of the TO header. In a conventional multinode system, all nodes will have a unique address (which you could store in EEPROM). You would normally set the header FROM address to be the same as thisAddress (though you dont have to, allowing the possibilty of address spoofing).

Parameters:
[in]thisAddressThe address of this node.

Reimplemented in RH_RF22, and RH_TCP.

Definition at line 78 of file RHGenericDriver.cpp.

bool sleep (  ) [virtual, inherited]

Sets the transport hardware into low-power sleep mode (if supported).

May be overridden by specific drivers to initialte sleep mode. If successful, the transport will stay in sleep mode until woken by changing mode it idle, transmit or receive (eg by calling send(), recv(), available() etc)

Returns:
true if sleep mode is supported by transport hardware and the RadioHead driver, and if sleep mode was successfully entered. If sleep mode is not suported, return false.

Reimplemented in RH_NRF24, RH_RF22, RH_RF24, RH_RF69, and RH_RF95.

Definition at line 139 of file RHGenericDriver.cpp.

uint8_t spiBurstRead ( uint8_t  reg,
uint8_t *  dest,
uint8_t  len 
) [inherited]

Reads a number of consecutive registers from the SPI device using burst read mode.

Parameters:
[in]regRegister number of the first register
[in]destArray to write the register values to. Must be at least len bytes
[in]lenNumber of bytes to read
Returns:
Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.

Definition at line 68 of file RHNRFSPIDriver.cpp.

uint8_t spiBurstReadRegister ( uint8_t  reg,
uint8_t *  dest,
uint8_t  len 
)

Reads a number of consecutive registers from the NRF905 using burst read mode.

Parameters:
[in]regRegister number of the first register, one of NRF905_REG_*
[in]destArray to write the register values to. Must be at least len bytes
[in]lenNumber of bytes to read
Returns:
the current STATUS (read while the command is sent)

Definition at line 60 of file RH_NRF905.cpp.

uint8_t spiBurstWrite ( uint8_t  reg,
const uint8_t *  src,
uint8_t  len 
) [inherited]

Write a number of consecutive registers using burst write mode.

Parameters:
[in]regRegister number of the first register
[in]srcArray of new register values to write. Must be at least len bytes
[in]lenNumber of bytes to write
Returns:
Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.

Definition at line 81 of file RHNRFSPIDriver.cpp.

uint8_t spiBurstWriteRegister ( uint8_t  reg,
uint8_t *  src,
uint8_t  len 
)

Write a number of consecutive registers using burst write mode.

Parameters:
[in]regRegister number of the first register, one of NRF905_REG_*
[in]srcArray of new register values to write. Must be at least len bytes
[in]lenNumber of bytes to write
Returns:
the current STATUS (read while the command is sent)

Definition at line 65 of file RH_NRF905.cpp.

uint8_t spiCommand ( uint8_t  command ) [inherited]

Sends a single command to the device.

Parameters:
[in]commandThe command code to send to the device.
Returns:
Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.

Definition at line 33 of file RHNRFSPIDriver.cpp.

uint8_t spiRead ( uint8_t  reg ) [inherited]

Reads a single register from the SPI device.

Parameters:
[in]regRegister number
Returns:
The value of the register

Definition at line 44 of file RHNRFSPIDriver.cpp.

uint8_t spiReadRegister ( uint8_t  reg )

Reads a single register from the NRF905.

Parameters:
[in]regRegister number, one of NR905_REG_*
Returns:
The value of the register

Definition at line 50 of file RH_NRF905.cpp.

uint8_t spiWrite ( uint8_t  reg,
uint8_t  val 
) [inherited]

Writes a single byte to the SPI device.

Parameters:
[in]regRegister number
[in]valThe value to write
Returns:
Some devices return a status byte during the first data transfer. This byte is returned. it may or may not be meaningfule depending on the the type of device being accessed.

Definition at line 56 of file RHNRFSPIDriver.cpp.

uint8_t spiWriteRegister ( uint8_t  reg,
uint8_t  val 
)

Writes a single byte to the NRF905, and at the ame time reads the current STATUS register.

Parameters:
[in]regRegister number, one of NRF905_REG_*
[in]valThe value to write
Returns:
the current STATUS (read while the command is sent)

Definition at line 55 of file RH_NRF905.cpp.

uint8_t statusRead (  )

Reads and returns the device status register NRF905_REG_02_DEVICE_STATUS.

Returns:
The value of the device status register

Definition at line 70 of file RH_NRF905.cpp.

uint16_t txGood (  ) [inherited]

Returns the count of the number of packets successfully transmitted (though not necessarily received by the destination)

Returns:
The number of packets successfully transmitted

Definition at line 175 of file RHGenericDriver.cpp.

void validateRxBuf (  ) [protected]

Examine the revceive buffer to determine whether the message is for this node.

Definition at line 199 of file RH_NRF905.cpp.

void waitAvailable (  ) [virtual, inherited]

Starts the receiver and blocks until a valid received message is available.

Reimplemented in RH_TCP.

Definition at line 33 of file RHGenericDriver.cpp.

bool waitAvailableTimeout ( uint16_t  timeout ) [virtual, inherited]

Starts the receiver and blocks until a received message is available or a timeout.

Parameters:
[in]timeoutMaximum time to wait in milliseconds.
Returns:
true if a message is available

Reimplemented in RH_TCP.

Definition at line 42 of file RHGenericDriver.cpp.

bool waitPacketSent (  ) [virtual]

Blocks until the current message (if any) has been transmitted.

Returns:
true on success, false if the chip is not in transmit mode

Reimplemented from RHGenericDriver.

Definition at line 158 of file RH_NRF905.cpp.

bool waitPacketSent ( uint16_t  timeout ) [virtual, inherited]

Blocks until the transmitter is no longer transmitting.

or until the timeout occuers, whichever happens first

Parameters:
[in]timeoutMaximum time to wait in milliseconds.
Returns:
true if the RF22 completed transmission within the timeout period. False if it timed out.

Definition at line 61 of file RHGenericDriver.cpp.


Field Documentation

volatile int8_t _lastRssi [protected, inherited]

The value of the last received RSSI value, in some transport specific units.

Definition at line 249 of file RHGenericDriver.h.

volatile RHMode _mode [protected, inherited]

The current transport operating mode.

Definition at line 216 of file RHGenericDriver.h.

bool _promiscuous [protected, inherited]

Whether the transport is in promiscuous mode.

Definition at line 222 of file RHGenericDriver.h.

volatile uint16_t _rxBad [protected, inherited]

Count of the number of bad messages (eg bad checksum etc) received.

Definition at line 252 of file RHGenericDriver.h.

volatile uint16_t _rxGood [protected, inherited]

Count of the number of successfully transmitted messaged.

Definition at line 255 of file RHGenericDriver.h.

volatile uint8_t _rxHeaderFlags [protected, inherited]

FLAGS header in the last received mesasge.

Definition at line 234 of file RHGenericDriver.h.

volatile uint8_t _rxHeaderFrom [protected, inherited]

FROM header in the last received mesasge.

Definition at line 228 of file RHGenericDriver.h.

volatile uint8_t _rxHeaderId [protected, inherited]

ID header in the last received mesasge.

Definition at line 231 of file RHGenericDriver.h.

volatile uint8_t _rxHeaderTo [protected, inherited]

TO header in the last received mesasge.

Definition at line 225 of file RHGenericDriver.h.

DigitalOut _slaveSelectPin [protected, inherited]

The pin number of the Slave Selct pin that is used to select the desired device.

Definition at line 87 of file RHNRFSPIDriver.h.

RHGenericSPI& _spi [protected, inherited]

Reference to the RHGenericSPI instance to use to trasnfer data with teh SPI device.

Definition at line 83 of file RHNRFSPIDriver.h.

uint8_t _thisAddress [protected, inherited]

This node id.

Definition at line 219 of file RHGenericDriver.h.

volatile uint16_t _txGood [protected, inherited]

Count of the number of bad messages (correct checksum etc) received.

Definition at line 258 of file RHGenericDriver.h.

uint8_t _txHeaderFlags [protected, inherited]

FLAGS header to send in all messages.

Definition at line 246 of file RHGenericDriver.h.

uint8_t _txHeaderFrom [protected, inherited]

FROM header to send in all messages.

Definition at line 240 of file RHGenericDriver.h.

uint8_t _txHeaderId [protected, inherited]

ID header to send in all messages.

Definition at line 243 of file RHGenericDriver.h.

uint8_t _txHeaderTo [protected, inherited]

TO header to send in all messages.

Definition at line 237 of file RHGenericDriver.h.