libukhasnet-rfm69
An RFM69 library maintained for UKHASnet
Typedefs | Enumerations | Functions | Variables
Ukhasnet-rfm69

Typedefs

typedef uint8_t rfm_reg_t
 
typedef enum rfm_status_t rfm_status_t
 

Enumerations

enum  rfm_status_t { RFM_OK, RFM_FAIL, RFM_TIMEOUT }
 

Functions

rfm_status_t rf69_init (void)
 
rfm_status_t _rf69_read (const rfm_reg_t reg, rfm_reg_t *result)
 
rfm_status_t _rf69_write (const rfm_reg_t reg, const rfm_reg_t val)
 
rfm_status_t _rf69_burst_read (const rfm_reg_t reg, rfm_reg_t *dest, uint8_t len)
 
rfm_status_t _rf69_burst_write (rfm_reg_t reg, const rfm_reg_t *src, uint8_t len)
 
rfm_status_t _rf69_fifo_write (const rfm_reg_t *src, uint8_t len)
 
rfm_status_t rf69_set_mode (const rfm_reg_t newMode)
 
rfm_status_t rf69_receive (rfm_reg_t *buf, rfm_reg_t *len, int16_t *lastrssi, bool *rfm_packet_waiting)
 
rfm_status_t rf69_send (const rfm_reg_t *data, uint8_t len, const uint8_t power)
 
rfm_status_t _rf69_clear_fifo (void)
 
rfm_status_t rf69_read_temp (int8_t *temperature)
 
rfm_status_t _rf69_sample_rssi (int16_t *rssi)
 
rfm_status_t spi_init (void)
 
rfm_status_t spi_exchange_single (const rfm_reg_t out, rfm_reg_t *in)
 
rfm_status_t spi_ss_assert (void)
 
rfm_status_t spi_ss_deassert (void)
 

Variables

static const rfm_reg_t CONFIG [][2]
 
static rfm_reg_t _mode
 

Detailed Description

Function Documentation

rfm_status_t _rf69_burst_read ( const rfm_reg_t  reg,
rfm_reg_t *  dest,
uint8_t  len 
)

Read a given number of bytes from the given register address into a provided buffer

Parameters
regThe address of the register to start from
destA pointer into the destination buffer
lenThe number of bytes to read
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t _rf69_burst_write ( rfm_reg_t  reg,
const rfm_reg_t *  src,
uint8_t  len 
)

Write a given number of bytes into the registers in the RFM69.

Parameters
regThe first byte address into which to write
srcA pointer into the source data buffer
lenThe number of bytes to write
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t _rf69_clear_fifo ( void  )

Clear the FIFO in the RFM69. We do this by entering STBY mode and then returing to RX mode.

Warning
Must only be called in RX Mode
Note
Apparently this works... found in HopeRF demo code
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t _rf69_fifo_write ( const rfm_reg_t *  src,
uint8_t  len 
)

Write data into the FIFO on the RFM69

Parameters
srcThe source data comes from this buffer
lenWrite this number of bytes from the buffer into the FIFO
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t _rf69_read ( const rfm_reg_t  reg,
rfm_reg_t *  result 
)

Read a single byte from a register in the RFM69. Transmit the (one byte) address of the register to be read, then read the (one byte) response.

Parameters
regThe register address to be read
resultA pointer to where to put the result
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t _rf69_sample_rssi ( int16_t *  rssi)

Get the last RSSI value from the RFM69

Warning
Must only be called when the RFM69 is in rx mode
Parameters
rssiA pointer to an int16_t where we will place the RSSI value
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t _rf69_write ( const rfm_reg_t  reg,
const rfm_reg_t  val 
)

Write a single byte to a register in the RFM69. Transmit the register address (one byte) with the write mask RFM_SPI_WRITE_MASK on, and then the value of the register to be written.

Parameters
regThe address of the register to write
valThe value for the address
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t rf69_init ( void  )

Initialise the RFM69 device.

Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t rf69_read_temp ( int8_t *  temperature)

The RFM69 has an onboard temperature sensor, read its value

Warning
RFM69 must be in one of the active modes for temp sensor to work.
Parameters
temperatureA pointer to the variable into which the temperature will be read by this method.
Returns
RFM_OK for success, RFM_FAIL for failure, RFM_TIMEOUT if there is a timeout due to the sensor on the RFM not starting and/or finishing a conversion.
rfm_status_t rf69_receive ( rfm_reg_t *  buf,
rfm_reg_t *  len,
int16_t *  lastrssi,
bool *  rfm_packet_waiting 
)

Get data from the RFM69 receive buffer.

Parameters
bufA pointer into the local buffer in which we would like the data.
lenThe length of the data
lastrssiThe RSSI of the packet we're getting
rfm_packet_waitingA boolean pointer which is true if a packet was received and has been put into the buffer buf, false if there was no packet to get from the RFM69.
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t rf69_send ( const rfm_reg_t *  data,
uint8_t  len,
const uint8_t  power 
)

Send a packet using the RFM69 radio.

Parameters
dataThe data buffer that contains the string to transmit
lenThe number of bytes in the data packet (excluding preamble, sync and checksum)
powerThe transmit power to be used in dBm
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t rf69_set_mode ( const rfm_reg_t  newMode)

Change the RFM69 operating mode to a new one.

Parameters
newModeThe value representing the new mode (see datasheet for further information). The MODE bits are masked in the register, i.e. only bits 2-4 of newMode are ovewritten in the register.
Returns
RFM_OK for success, RFM_FAIL for failure.
rfm_status_t spi_init ( void  )

SPI device driver functions. These are to be provided by the user. Prototypes are provided here such that the library can be built. Documentation can be found in spi_conf.c.

Variable Documentation

rfm_reg_t _mode
static

Track the current mode of the radio