COSA
An Object-Oriented Platform for Arduino Programming
RFM69 Class Reference

#include <RFM69.hh>

Inheritance diagram for RFM69:
Inheritance graph
Collaboration diagram for RFM69:
Collaboration graph

Public Member Functions

 RFM69 (uint16_t net, uint8_t dev, Board::DigitalPin csn=Board::D10, Board::ExternalInterruptPin irq=Board::EXT0)
 
virtual bool begin (const void *config=NULL)
 
virtual bool end ()
 
virtual int send (uint8_t dest, uint8_t port, const iovec_t *vec)
 
virtual int send (uint8_t dest, uint8_t port, const void *buf, size_t len)
 
virtual int recv (uint8_t &src, uint8_t &port, void *buf, size_t len, uint32_t ms=0L)
 
virtual void powerdown ()
 
virtual void wakeup_on_radio ()
 
virtual void output_power_level (int8_t dBm)
 
virtual int input_power_level ()
 
int temperature ()
 
void recalibrate ()
 
uint8_t channel () const
 
void channel (uint8_t channel)
 
int16_t network_address () const
 
uint8_t device_address () const
 
void address (int16_t net, uint8_t dev)
 
virtual void powerup ()
 
virtual bool available ()
 
virtual bool room ()
 
virtual int broadcast (uint8_t port, const iovec_t *vec)
 
virtual int broadcast (uint8_t port, const void *buf, size_t len)
 
virtual bool is_broadcast ()
 
virtual int link_quality_indicator ()
 

Static Public Attributes

static const size_t HEADER_MAX = 3
 
static const size_t PAYLOAD_MAX = 66 - HEADER_MAX
 
static const uint8_t BROADCAST = 0x00
 

Protected Attributes

uint8_t m_channel
 Current channel (device dependent. More...
 
addr_t m_addr
 Current network and device address. More...
 
volatile bool m_avail
 Message available. May be set by ISR. More...
 
uint8_t m_dest
 Latest message destination device address. More...
 

Private Member Functions

void set_clock (Clock rate)
 
void set_clock (uint32_t freq)
 

Static Private Member Functions

static Clock clock (uint32_t freq)
 
static Clock cycle (uint16_t ns)
 

Private Attributes

Driverm_next
 List of drivers. More...
 
OutputPin m_cs
 Device chip select pin. More...
 
Pulse m_pulse
 Chip select pulse width. More...
 
uint8_t m_spcr
 SPI/SPCR hardware control register setting. More...
 
uint8_t m_spsr
 SPI/SPSR hardware status register. More...
 

Detailed Description

Cosa Device Driver for RFM69W/HW, Low-Power Sub-1 GHz RF Transceiver. Note that this device requires data in big endian order.

Circuit

This is the pin-out for the RFM69W/HW module.

RFM69W/HW
+------------+
(RST)---------------1-|RESET NC|-16
(D2/EXT0)-----------2-|DIO0 NSS|-15---------------(D10)
3-|DIO1 MOSI|-14---------------(D11/MOSI)
4-|DIO2 MISO|-13---------------(D12/MISO)
5-|DIO3 SCK|-12---------------(D13/SCK) V
6-|DIO4 GND|-11---------------(GND) |
7-|DIO4 ANT|-10-----------------------------+
(3V3)---------------8-|VCC GND|-9----------------(GND)
+------------+

References

  1. Product datasheet, RFM69W ISM Transceiver Module V1.3, http://www.hoperf.com/rf/fsk_module/RFM69W.htm
  2. Product datasheet, RFM69HW ISM Transceiver Module V1.3, http://www.hoperf.com/rf/fsk_module/RFM69HW.htm

Definition at line 56 of file RFM69.hh.

Constructor & Destructor Documentation

RFM69::RFM69 ( uint16_t  net,
uint8_t  dev,
Board::DigitalPin  csn = Board::D10,
Board::ExternalInterruptPin  irq = Board::EXT0 
)

Construct RFM69 device driver with given network and device address. Connected to SPI bus and given chip select pin. Default pins are Arduino Nano IO Shield for RFM69 module are D10 chip select (RFM69:NSS) and D2/EXT0 external interrupt pin (RFM69:DIO0).

Parameters
[in]netnetwork address.
[in]devdevice address.
[in]csnchip select pin (Default D2/D10/D53).
[in]irqinterrupt pin (Default EXT0).

Definition at line 110 of file RFM69.cpp.

Member Function Documentation

void Wireless::Driver::address ( int16_t  net,
uint8_t  dev 
)
inlineinherited

Set network and device address. Do not use the broadcast address(0). Should be used before calling begin().

Parameters
[in]netnetwork address.
[in]devdevice address.

Definition at line 106 of file Wireless.hh.

virtual bool Wireless::Driver::available ( )
inlinevirtualinherited

Return true(1) if a message is available otherwise false(0).

Returns
bool.

Reimplemented in VWI, and NRF24L01P.

Definition at line 165 of file Wireless.hh.

bool RFM69::begin ( const void *  config = NULL)
virtual

Start and configure RFM69 device driver. The configuration must set DIO0 to assert on received message. This device pin is assumed to be connected the device driver interrupt pin (EXTn). Return true(1) if successful othewise false(0).

Parameters
[in]configconfiguration vector (default NULL)

Implements Wireless::Driver.

Definition at line 142 of file RFM69.cpp.

virtual int Wireless::Driver::broadcast ( uint8_t  port,
const iovec_t vec 
)
inlinevirtualinherited

Broadcast message in given null terminated io vector. Returns number of bytes sent if successful otherwise a negative error code.

Parameters
[in]portdevice port (or message type).
[in]vecnull termianted io vector.
Returns
number of bytes send or negative error code.

Definition at line 220 of file Wireless.hh.

virtual int Wireless::Driver::broadcast ( uint8_t  port,
const void *  buf,
size_t  len 
)
inlinevirtualinherited

Boardcast message in given buffer, with given number of bytes. Returns number of bytes sent if successful otherwise a negative error code.

Parameters
[in]portdevice port (or message type).
[in]bufbuffer to transmit.
[in]lennumber of bytes in buffer.
Returns
number of bytes send or negative error code.

Definition at line 235 of file Wireless.hh.

uint8_t Wireless::Driver::channel ( ) const
inlineinherited

Get driver channel.

Returns
channel.

Definition at line 77 of file Wireless.hh.

void Wireless::Driver::channel ( uint8_t  channel)
inlineinherited

Set device transmission channel. Should be used before calling begin().

Parameters
[in]channel.

Definition at line 117 of file Wireless.hh.

uint8_t Wireless::Driver::device_address ( ) const
inlineinherited

Get driver device address.

Returns
device address.

Definition at line 95 of file Wireless.hh.

bool RFM69::end ( )
virtual

Shut down the device driver. Return true(1) if successful otherwise false(0).

Returns
bool

Reimplemented from Wireless::Driver.

Definition at line 172 of file RFM69.cpp.

int RFM69::input_power_level ( )
virtual

Return estimated input power level (dBm) from latest successful message received.

Reimplemented from Wireless::Driver.

Definition at line 281 of file RFM69.cpp.

virtual bool Wireless::Driver::is_broadcast ( )
inlinevirtualinherited

Return true(1) if the latest received message was a broadcast otherwise false(0).

Definition at line 262 of file Wireless.hh.

virtual int Wireless::Driver::link_quality_indicator ( )
inlinevirtualinherited

Return link quality indicator. Default zero(0).

Returns
quality indicator.

Reimplemented in VWI, and CC1101.

Definition at line 292 of file Wireless.hh.

int16_t Wireless::Driver::network_address ( ) const
inlineinherited

Get driver network address.

Returns
network address.

Definition at line 86 of file Wireless.hh.

void RFM69::output_power_level ( int8_t  dBm)
virtual

Set output power level [-18..13] dBm.

Parameters
[in]dBm.

Reimplemented from Wireless::Driver.

Definition at line 271 of file RFM69.cpp.

void RFM69::powerdown ( )
virtual

Set device in power down mode.

Reimplemented from Wireless::Driver.

Definition at line 258 of file RFM69.cpp.

virtual void Wireless::Driver::powerup ( )
inlinevirtualinherited

Set device in power up mode.

Reimplemented in VWI, and NRF24L01P.

Definition at line 146 of file Wireless.hh.

void RFM69::recalibrate ( )

Recalibrate internal RC oscillator when device is used in an environment with high temperature variation.

Definition at line 295 of file RFM69.cpp.

int RFM69::recv ( uint8_t &  src,
uint8_t &  port,
void *  buf,
size_t  len,
uint32_t  ms = 0L 
)
virtual

Receive message and store into given buffer with given maximum length. The source network address is returned in the parameter src. Returns error code(-2) if no message is available and/or a timeout occured. Returns error code(-1) if the buffer size if to small for incoming message or if the receiver fifo has overflowed. Otherwise the actual number of received bytes is returned

Parameters
[out]srcsource network address.
[out]portdevice port (or message type).
[in]bufbuffer to store incoming message.
[in]lenmaximum number of bytes to receive.
[in]msmaximum time out period.
Returns
number of bytes received or negative error code.

Implements Wireless::Driver.

Definition at line 223 of file RFM69.cpp.

virtual bool Wireless::Driver::room ( )
inlinevirtualinherited

Return true(1) if there is room to send on the device otherwise false(0).

Returns
bool.

Definition at line 176 of file Wireless.hh.

int RFM69::send ( uint8_t  dest,
uint8_t  port,
const iovec_t vec 
)
virtual

Send message in given null terminated io vector. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode and/or packet is available to receive.

Parameters
[in]destdestination network address.
[in]portdevice port (or message type).
[in]vecnull termianted io vector.
Returns
number of bytes send or negative error code.

Implements Wireless::Driver.

Definition at line 180 of file RFM69.cpp.

int RFM69::send ( uint8_t  dest,
uint8_t  port,
const void *  buf,
size_t  len 
)
virtual

Send message in given buffer, with given number of bytes. Returns number of bytes sent. Returns error code(-1) if number of bytes is greater than PAYLOAD_MAX. Return error code(-2) if fails to set transmit mode.

Parameters
[in]destdestination network address.
[in]portdevice port (or message type).
[in]bufbuffer to transmit.
[in]lennumber of bytes in buffer.
Returns
number of bytes send or negative error code.

Reimplemented from Wireless::Driver.

Definition at line 213 of file RFM69.cpp.

int RFM69::temperature ( )

Sample internal digital thermometer and return in centigrade Celsius.

Returns
temperature.

Definition at line 287 of file RFM69.cpp.

void RFM69::wakeup_on_radio ( )
virtual

Set device in wakeup on radio mode.

Reimplemented from Wireless::Driver.

Definition at line 264 of file RFM69.cpp.

Member Data Documentation

const uint8_t Wireless::Driver::BROADCAST = 0x00
staticinherited

Broadcast device address.

Definition at line 58 of file Wireless.hh.

const size_t RFM69::HEADER_MAX = 3
static

Maximum size of frame header is dest(1), src(1), and port(1).

Definition at line 61 of file RFM69.hh.

addr_t Wireless::Driver::m_addr
protectedinherited

Current network and device address.

Definition at line 299 of file Wireless.hh.

volatile bool Wireless::Driver::m_avail
protectedinherited

Message available. May be set by ISR.

Definition at line 300 of file Wireless.hh.

uint8_t Wireless::Driver::m_channel
protectedinherited

Current channel (device dependent.

Definition at line 298 of file Wireless.hh.

uint8_t Wireless::Driver::m_dest
protectedinherited

Latest message destination device address.

Definition at line 301 of file Wireless.hh.

const size_t RFM69::PAYLOAD_MAX = 66 - HEADER_MAX
static

Maximum size of payload. The device allows 66 bytes payload. Adjust for frame header.

Definition at line 67 of file RFM69.hh.


The documentation for this class was generated from the following files: