RFM70library
|
Macros | |
#define | RFM70_CMD_R_RX_PAYLOAD 0x61 |
SPI comamnd to read a received payload. | |
#define | RFM70_CMD_W_TX_PAYLOAD 0xA0 |
SPI command to write a payload to be sent. | |
#define | RFM70_CMD_FLUSH_TX 0xE1 |
SPI command to empty the transmit queue. | |
#define | RFM70_CMD_FLUSH_RX 0xE2 |
SPI command to empty the receive queue. | |
#define | RFM70_CMD_REUSE_TX_PL 0xE3 |
SPI command to start continuous retransmission. | |
#define | RFM70_CMD_W_TX_PAYLOAD_NOACK 0xB0 |
SPI command to write a payload to be sent without auto-acknowledgement. | |
#define | RFM70_CMD_W_ACK_PAYLOAD 0xA8 |
SPI command to write the payload to be transmitted with an ack. | |
#define | RFM70_CMD_ACTIVATE 0x50 |
SPI command to toggle register bank or toggle extended functions. | |
#define | RFM70_CMD_R_RX_PL_WID 0x60 |
SPI command to read the payload length for the top payload in the FIFO. | |
#define | RFM70_CMD_NOP 0xFF |
SPI 'no peration', can be used to read the status register. | |
#define | RFM70_REG_CONFIG 0x00 |
CONFIG : rfm70 configuration register. More... | |
#define | RFM70_REG_EN_AA 0x01 |
EN_AA : enable auto ack on pipes. More... | |
#define | RFM70_REG_EN_RXADDR 0x02 |
EN_RXADDR : enable receive pipes. More... | |
#define | RFM70_REG_SETUP_AW 0x03 |
SETUP_AW : set address length. More... | |
#define | RFM70_REG_SETUP_RETR 0x04 |
SETUP_RETR : retransmission settings. More... | |
#define | RFM70_REG_RF_CH 0x05 |
RF_CH : RF channel (frequency) More... | |
#define | RFM70_REG_RF_SETUP 0x06 |
RF_SETUP : RF setup: data rate, transmit power, LNA. More... | |
#define | RFM70_REG_STATUS 0x07 |
STATUS : status register. More... | |
#define | RFM70_REG_OBSERVE_TX 0x08 |
OBSERVE_TX : lost and retransmitted packets. More... | |
#define | RFM70_REG_CD 0x09 |
CD : carrier detect. More... | |
#define | RFM70_REG_RX_ADDR_P0 0x0A |
RX_ADDR_PO : receive address for data pipe 0, 5 bytes. More... | |
#define | RFM70_REG_RX_ADDR_P1 0x0B |
RX_ADDR_P1 : receive address for data pipe 1, 5 bytes. More... | |
#define | RFM70_REG_RX_ADDR_P2 0x0C |
RX_ADDR_P2 : receive address for data pipe 2, 1 byte. More... | |
#define | RFM70_REG_RX_ADDR_P3 0x0D |
RX_ADDR_P3 : receive address for data pipe 3, 1 byte. More... | |
#define | RFM70_REG_RX_ADDR_P4 0x0E |
RX_ADDR_P4 : receive address for data pipe 4, 1 byte. More... | |
#define | RFM70_REG_RX_ADDR_P5 0x0F |
RX_ADDR_P5 : receive address for data pipe 5, 1 byte. More... | |
#define | RFM70_REG_TX_ADDR 0x10 |
TX_ADDR : tranmsit adress, 5 bytes. More... | |
#define | RFM70_REG_RX_PW_P0 0x11 |
RX_PW_P0 : number of bytes in package received into pipe 0. More... | |
#define | RFM70_REG_RX_PW_P1 0x12 |
RX_PW_P1 : number of bytes in package received into pipe 1. More... | |
#define | RFM70_REG_RX_PW_P2 0x13 |
RX_PW_P2 : number of bytes in package received into pipe 2. More... | |
#define | RFM70_REG_RX_PW_P3 0x14 |
RX_PW_P3 : number of bytes in package received into pipe 3. More... | |
#define | RFM70_REG_RX_PW_P4 0x15 |
RX_PW_P4 : number of bytes in package received into pipe 4. More... | |
#define | RFM70_REG_RX_PW_P5 0x16 |
RX_PW_P5 : number of bytes in package received into pipe 5. More... | |
#define | RFM70_REG_FIFO_STATUS 0x17 |
FIFO_STATUS : receive and transmit FIFO status (readonly) More... | |
#define | RFM70_REG_DYNPD 0x1C |
DYNPD: dynamic payload flags. More... | |
#define | RFM70_REG_FEATURE 0x1D |
FEATURE: special fature flags. More... | |
Functions | |
void | rfm70::init (void) |
initialize the library and the rfm70 module More... | |
unsigned char | rfm70::register_read (unsigned char reg) |
read a single-byte command or register More... | |
void | rfm70::buffer_read (unsigned char reg, unsigned char *buf, unsigned char length) |
read a multi-byte command or register More... | |
void | rfm70::register_write (unsigned char reg, unsigned char val) |
write a single-byte command or register More... | |
void | rfm70::buffer_write (char reg, const unsigned char *buf, unsigned char length) |
write a multi-byte command or register More... | |
The low-level interface provides read and write access to the commands and registers of the RFM70.
When a register ( < 0x20 ) is specified for a read or write command the appropriate read or write command bits are added automatically.
To use any of these methods, (except init() itself) the interface and the module must have been initialized by an init() call.
Besides the registers shown here (bank 0) the rfm70 also has a set of registers in bank 1. These bank 1 registers are initialized by the init() call. If you want to do this yourself: the datasheet shows the required values, but in a very confusing way. The HopeRF example code is a better reference. No (or very scarce) explanation is given for these values.
For most users, especially novices, it is recommended to use the high level interaface instead of this low level interface.
#define RFM70_REG_CD 0x09 |
CD : carrier detect.
Bits (0 = LSB):
#define RFM70_REG_CONFIG 0x00 |
CONFIG : rfm70 configuration register.
Bits (0 = LSB):
#define RFM70_REG_DYNPD 0x1C |
DYNPD: dynamic payload flags.
Bits (0 = LSB):
#define RFM70_REG_EN_AA 0x01 |
EN_AA : enable auto ack on pipes.
Bits (0 = LSB):
#define RFM70_REG_EN_RXADDR 0x02 |
EN_RXADDR : enable receive pipes.
Bits (0 = LSB):
#define RFM70_REG_FEATURE 0x1D |
FEATURE: special fature flags.
Bits (0 = LSB):
#define RFM70_REG_FIFO_STATUS 0x17 |
FIFO_STATUS : receive and transmit FIFO status (readonly)
Bits (0 = LSB):
#define RFM70_REG_OBSERVE_TX 0x08 |
OBSERVE_TX : lost and retransmitted packets.
Bits (0 = LSB):
The retransmits counter can not increment beyond 15 because the maximum number of transmissions is 15. This counter is reset when the transmission of a new packet starts.
#define RFM70_REG_RF_CH 0x05 |
RF_CH : RF channel (frequency)
The RF channel frequency is 2.4 MHz + n * 1 MHz.
#define RFM70_REG_RF_SETUP 0x06 |
RF_SETUP : RF setup: data rate, transmit power, LNA.
Bits (0 = LSB):
#define RFM70_REG_RX_ADDR_P0 0x0A |
RX_ADDR_PO : receive address for data pipe 0, 5 bytes.
This is the (up to) 5 byte receive address for data pipe 0. For auto acknowledgement to work this address must be the same as the transmit address.
#define RFM70_REG_RX_ADDR_P1 0x0B |
RX_ADDR_P1 : receive address for data pipe 1, 5 bytes.
This is the (up to) 5 byte receive address for data pipe 1. The higher bytes (all but the LSB) are also used in the receive addresses of data pipes 2 .. 5.
#define RFM70_REG_RX_ADDR_P2 0x0C |
RX_ADDR_P2 : receive address for data pipe 2, 1 byte.
This is the LSB of the receive address for data pipe 2. The higher bytes are copied from the receive address of data pipe 1.
#define RFM70_REG_RX_ADDR_P3 0x0D |
RX_ADDR_P3 : receive address for data pipe 3, 1 byte.
This is the LSB of the receive address for data pipe 3. The higher bytes are copied from the receive address of data pipe 1.
#define RFM70_REG_RX_ADDR_P4 0x0E |
RX_ADDR_P4 : receive address for data pipe 4, 1 byte.
This is the LSB of the receive address for data pipe 4. The higher bytes are copied from the receive address of data pipe 1.
#define RFM70_REG_RX_ADDR_P5 0x0F |
RX_ADDR_P5 : receive address for data pipe 5, 1 byte.
This is the LSB of the receive address for data pipe 2. The higher bytes are copied from the receive address of data pipe 5.
#define RFM70_REG_RX_PW_P0 0x11 |
RX_PW_P0 : number of bytes in package received into pipe 0.
This is the number of data bytes in the message at the head of receive pipe 0.
#define RFM70_REG_RX_PW_P1 0x12 |
RX_PW_P1 : number of bytes in package received into pipe 1.
This is the number of data bytes in the message at the head of receive pipe 1.
#define RFM70_REG_RX_PW_P2 0x13 |
RX_PW_P2 : number of bytes in package received into pipe 2.
This is the number of data bytes in the message at the head of receive pipe 2.
#define RFM70_REG_RX_PW_P3 0x14 |
RX_PW_P3 : number of bytes in package received into pipe 3.
This is the number of data bytes in the message at the head of receive pipe 3.
#define RFM70_REG_RX_PW_P4 0x15 |
RX_PW_P4 : number of bytes in package received into pipe 4.
This is the number of data bytes in the message at the head of receive pipe 4.
#define RFM70_REG_RX_PW_P5 0x16 |
RX_PW_P5 : number of bytes in package received into pipe 5.
This is the number of data bytes in the message at the head of receive pipe 5.
#define RFM70_REG_SETUP_AW 0x03 |
SETUP_AW : set address length.
Bits (0 = LSB):
#define RFM70_REG_SETUP_RETR 0x04 |
SETUP_RETR : retransmission settings.
Bits (0 = LSB):
#define RFM70_REG_STATUS 0x07 |
STATUS : status register.
The value of this register is also clocked out while a SPI command is clocked in.
Bits (0 = LSB):
Bits 6,5,4 are cleared by writing a 1 (!) in that position. When bit 4 is set this will block any communication. When auto retransmission is enabled bit 5 will be set only after the acknowledge has been received.
#define RFM70_REG_TX_ADDR 0x10 |
TX_ADDR : tranmsit adress, 5 bytes.
This is the (up to) 5 byte adress used in transmitted packets. For auto acknowledgement to work this address must be the same as the pipe 0 receive address.
void rfm70::buffer_read | ( | unsigned char | reg, |
unsigned char * | buf, | ||
unsigned char | length | ||
) |
read a multi-byte command or register
This method reads length bytes (8 bit each) from the RFM70 command or register reg into the buffer buf.
void rfm70::buffer_write | ( | char | reg, |
const unsigned char * | buf, | ||
unsigned char | length | ||
) |
write a multi-byte command or register
This method writes length bytes (8 bit each) from the buffer buf into the RFM70 command or register reg.
void rfm70::init | ( | void | ) |
initialize the library and the rfm70 module
This method must be called before any other rfm70 method is called. It can also be called later (maybe even periodically) to re-initialize the interafce and the module.
The rfm70 is initialized to
unsigned char rfm70::register_read | ( | unsigned char | reg | ) |
read a single-byte command or register
This method reads and returns the a single-byte (8 bit) RFM70 command or register reg.
void rfm70::register_write | ( | unsigned char | reg, |
unsigned char | val | ||
) |
write a single-byte command or register
This method writes the single-byte (8 bit) val to the RFM70 command or register reg.