Library for HopeRF RFM22 transceiver module ported to mbed. Original Software from Mike McCauley (mikem@open.com.au) . See http://www.open.com.au/mikem/arduino/RF22/

Fork of RF22 by Karl Zweimüller

Committer:
floha
Date:
Thu Aug 29 21:57:14 2013 +0000
Revision:
9:46fb41f4259d
Parent:
5:0386600f3408
changed the LED default numbers in the RF22 constructor as the former values interfered with pins used on an KL25Z board. The library didn't work with those.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charly 0:79c6d0071c4c 1 // RF22Datagram.h
charly 0:79c6d0071c4c 2 // Author: Mike McCauley (mikem@open.com.au)
charly 0:79c6d0071c4c 3 // Copyright (C) 2011 Mike McCauley
charly 5:0386600f3408 4 // $Id: RF22Datagram.h,v 1.4 2012/05/30 01:50:21 mikem Exp $
charly 0:79c6d0071c4c 5 // ported to mbed by Karl Zweimueller
charly 0:79c6d0071c4c 6
charly 0:79c6d0071c4c 7 #ifndef RF22Datagram_h
charly 0:79c6d0071c4c 8 #define RF22Datagram_h
charly 0:79c6d0071c4c 9
charly 0:79c6d0071c4c 10 #include <RF22.h>
charly 0:79c6d0071c4c 11
charly 0:79c6d0071c4c 12 /////////////////////////////////////////////////////////////////////
charly 0:79c6d0071c4c 13 /// \class RF22Datagram RF22Datagram.h <RF22Datagram.h>
charly 0:79c6d0071c4c 14 /// \brief RF22 subclass for addressed, unreliable messages
charly 0:79c6d0071c4c 15 ///
charly 0:79c6d0071c4c 16 /// Extends RF22 to define addressed, unreliable datagrams.
charly 0:79c6d0071c4c 17 /// Every node has an 8 bit address (defaults to 0).
charly 0:79c6d0071c4c 18 /// Addresses (DEST and SRC) are 8 bit integers with an address of RF22_BROADCAST_ADDRESS (0xff)
charly 0:79c6d0071c4c 19 /// reserved for broadcast.
charly 0:79c6d0071c4c 20 ///
charly 0:79c6d0071c4c 21 /// Part of the Arduino RF22 library for operating with HopeRF RF22 compatible transceivers
charly 0:79c6d0071c4c 22 /// (see http://www.hoperf.com).
charly 0:79c6d0071c4c 23 class RF22Datagram : public RF22
charly 0:79c6d0071c4c 24 {
charly 0:79c6d0071c4c 25 public:
charly 0:79c6d0071c4c 26 /// Constructor.
charly 0:79c6d0071c4c 27 /// \param[in] thisAddress The address to assign to this node. Defaults to 0
charly 0:79c6d0071c4c 28 /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RF22 before
charly 5:0386600f3408 29 /// accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega)
charly 0:79c6d0071c4c 30 /// \param[in] interrupt The interrupt number to use. Default is interrupt 0 (Arduino input pin 2)
charly 5:0386600f3408 31 RF22Datagram(uint8_t thisAddress , PinName slaveSelectPin , PinName mosi, PinName miso, PinName sclk, PinName interrupt );
charly 0:79c6d0071c4c 32
charly 0:79c6d0071c4c 33 /// Initialises this instance and the radio module connected to it.
charly 0:79c6d0071c4c 34 /// Overrides the init() function in RF22
charly 0:79c6d0071c4c 35 boolean init();
charly 0:79c6d0071c4c 36
charly 0:79c6d0071c4c 37 /// Sets the address of this node. Defaults to 0.
charly 0:79c6d0071c4c 38 /// This will be used to set the FROM address of all messages sent by this node.
charly 0:79c6d0071c4c 39 /// If all the nodes leave the address unset (ie 0),
charly 0:79c6d0071c4c 40 /// In a conventional multinode system, all nodes will have a unique address
charly 0:79c6d0071c4c 41 /// (which you could store in EEPROM).
charly 0:79c6d0071c4c 42 /// \param[in] thisAddress The address of this node
charly 0:79c6d0071c4c 43 void setThisAddress(uint8_t thisAddress);
charly 0:79c6d0071c4c 44
charly 0:79c6d0071c4c 45 /// Sends a message to the node(s) with the given address
charly 0:79c6d0071c4c 46 /// RF22_BROADCAST_ADDRESS is a valid address which will cause the message
charly 0:79c6d0071c4c 47 /// to be accepted by all RF22Datagram nodes within range.
charly 0:79c6d0071c4c 48 /// \param[in] buf Pointer to the binary message to send
charly 5:0386600f3408 49 /// \param[in] len Number of octets to send (> 0)
charly 0:79c6d0071c4c 50 /// \param[in] address The address to send the message to.
charly 0:79c6d0071c4c 51 /// \return true if the message was transmitted.
charly 0:79c6d0071c4c 52 boolean sendto(uint8_t* buf, uint8_t len, uint8_t address);
charly 0:79c6d0071c4c 53
charly 0:79c6d0071c4c 54 /// Turns the receiver on if it not already on.
charly 0:79c6d0071c4c 55 /// If there is a valid message available for this node, copy it to buf and return true
charly 0:79c6d0071c4c 56 /// The SRC address is placed in *from if present and not NULL.
charly 0:79c6d0071c4c 57 /// The DEST address is placed in *to if present and not NULL.
charly 0:79c6d0071c4c 58 /// If a message is copied, *len is set to the length.
charly 0:79c6d0071c4c 59 /// You should be sure to call this function frequently enough to not miss any messages
charly 0:79c6d0071c4c 60 /// It is recommended that you call it in your main loop.
charly 0:79c6d0071c4c 61 /// \param[in] buf Location to copy the received message
charly 0:79c6d0071c4c 62 /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
charly 0:79c6d0071c4c 63 /// \param[in] from If present and not NULL, the referenced uint8_t will be set to the FROM address
charly 0:79c6d0071c4c 64 /// \param[in] to If present and not NULL, the referenced uint8_t will be set to the TO address
charly 0:79c6d0071c4c 65 /// \param[in] id If present and not NULL, the referenced uint8_t will be set to the ID
charly 0:79c6d0071c4c 66 /// \param[in] flags If present and not NULL, the referenced uint8_t will be set to the FLAGS
charly 0:79c6d0071c4c 67 /// (not just those addressed to this node).
charly 0:79c6d0071c4c 68 /// \return true if a valid message was copied to buf
charly 0:79c6d0071c4c 69 boolean recvfrom(uint8_t* buf, uint8_t* len, uint8_t* from = NULL, uint8_t* to = NULL, uint8_t* id = NULL, uint8_t* flags = NULL);
charly 0:79c6d0071c4c 70
charly 0:79c6d0071c4c 71 protected:
charly 0:79c6d0071c4c 72 /// The address of this node. Defaults to 0.
charly 0:79c6d0071c4c 73 uint8_t _thisAddress;
charly 0:79c6d0071c4c 74
charly 0:79c6d0071c4c 75 };
charly 0:79c6d0071c4c 76
charly 0:79c6d0071c4c 77 #endif