no modif

Dependents:   ISEN_RF24Network_Node_01 ISEN_RF24Network_Node_02

Committer:
akashvibhute
Date:
Thu Nov 05 05:40:23 2015 +0000
Revision:
2:3bdf0d9bb71f
Parent:
0:bb74812ac6bb
Child:
3:e94be00fd19e
Updated with TMRh20's RF24 library on Nov/04/2015 from https://github.com/TMRh20; Porting completed on Nov/05/2015

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:bb74812ac6bb 1 /*
akashvibhute 0:bb74812ac6bb 2 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
akashvibhute 0:bb74812ac6bb 3
akashvibhute 0:bb74812ac6bb 4 This program is free software; you can redistribute it and/or
akashvibhute 0:bb74812ac6bb 5 modify it under the terms of the GNU General Public License
akashvibhute 0:bb74812ac6bb 6 version 2 as published by the Free Software Foundation.
akashvibhute 0:bb74812ac6bb 7 */
akashvibhute 0:bb74812ac6bb 8
akashvibhute 0:bb74812ac6bb 9 /**
akashvibhute 0:bb74812ac6bb 10 * @file RF24.h
akashvibhute 0:bb74812ac6bb 11 *
akashvibhute 0:bb74812ac6bb 12 * Class declaration for RF24 and helper enums
akashvibhute 0:bb74812ac6bb 13 */
akashvibhute 0:bb74812ac6bb 14
akashvibhute 0:bb74812ac6bb 15 #ifndef __RF24_H__
akashvibhute 0:bb74812ac6bb 16 #define __RF24_H__
akashvibhute 0:bb74812ac6bb 17
akashvibhute 2:3bdf0d9bb71f 18 #include "RF24_config.h"
akashvibhute 2:3bdf0d9bb71f 19
akashvibhute 2:3bdf0d9bb71f 20 #define HIGH 1
akashvibhute 2:3bdf0d9bb71f 21 #define LOW 0
akashvibhute 2:3bdf0d9bb71f 22
akashvibhute 0:bb74812ac6bb 23 #include <mbed.h>
akashvibhute 0:bb74812ac6bb 24
akashvibhute 2:3bdf0d9bb71f 25
akashvibhute 2:3bdf0d9bb71f 26
akashvibhute 2:3bdf0d9bb71f 27
akashvibhute 0:bb74812ac6bb 28 /**
akashvibhute 0:bb74812ac6bb 29 * Power Amplifier level.
akashvibhute 0:bb74812ac6bb 30 *
akashvibhute 0:bb74812ac6bb 31 * For use with setPALevel()
akashvibhute 0:bb74812ac6bb 32 */
akashvibhute 0:bb74812ac6bb 33 typedef enum { RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR } rf24_pa_dbm_e ;
akashvibhute 0:bb74812ac6bb 34
akashvibhute 0:bb74812ac6bb 35 /**
akashvibhute 0:bb74812ac6bb 36 * Data rate. How fast data moves through the air.
akashvibhute 0:bb74812ac6bb 37 *
akashvibhute 0:bb74812ac6bb 38 * For use with setDataRate()
akashvibhute 0:bb74812ac6bb 39 */
akashvibhute 0:bb74812ac6bb 40 typedef enum { RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS } rf24_datarate_e;
akashvibhute 0:bb74812ac6bb 41
akashvibhute 0:bb74812ac6bb 42 /**
akashvibhute 0:bb74812ac6bb 43 * CRC Length. How big (if any) of a CRC is included.
akashvibhute 0:bb74812ac6bb 44 *
akashvibhute 0:bb74812ac6bb 45 * For use with setCRCLength()
akashvibhute 0:bb74812ac6bb 46 */
akashvibhute 0:bb74812ac6bb 47 typedef enum { RF24_CRC_DISABLED = 0, RF24_CRC_8, RF24_CRC_16 } rf24_crclength_e;
akashvibhute 0:bb74812ac6bb 48
akashvibhute 0:bb74812ac6bb 49 /**
akashvibhute 0:bb74812ac6bb 50 * Driver for nRF24L01(+) 2.4GHz Wireless Transceiver
akashvibhute 0:bb74812ac6bb 51 */
akashvibhute 0:bb74812ac6bb 52
akashvibhute 0:bb74812ac6bb 53 class RF24
akashvibhute 0:bb74812ac6bb 54 {
akashvibhute 0:bb74812ac6bb 55 private:
akashvibhute 2:3bdf0d9bb71f 56
akashvibhute 2:3bdf0d9bb71f 57 SPI spi;
akashvibhute 2:3bdf0d9bb71f 58 Timer mainTimer;
akashvibhute 2:3bdf0d9bb71f 59 DigitalOut ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */
akashvibhute 2:3bdf0d9bb71f 60 DigitalOut csn_pin; /**< SPI Chip select */
akashvibhute 2:3bdf0d9bb71f 61
akashvibhute 2:3bdf0d9bb71f 62
akashvibhute 2:3bdf0d9bb71f 63
akashvibhute 2:3bdf0d9bb71f 64
akashvibhute 2:3bdf0d9bb71f 65
akashvibhute 2:3bdf0d9bb71f 66
akashvibhute 2:3bdf0d9bb71f 67
akashvibhute 2:3bdf0d9bb71f 68
akashvibhute 2:3bdf0d9bb71f 69
akashvibhute 2:3bdf0d9bb71f 70
akashvibhute 2:3bdf0d9bb71f 71
akashvibhute 2:3bdf0d9bb71f 72
akashvibhute 2:3bdf0d9bb71f 73
akashvibhute 2:3bdf0d9bb71f 74
akashvibhute 0:bb74812ac6bb 75 bool p_variant; /* False for RF24L01 and true for RF24L01P */
akashvibhute 0:bb74812ac6bb 76 uint8_t payload_size; /**< Fixed size of payloads */
akashvibhute 2:3bdf0d9bb71f 77 bool dynamic_payloads_enabled; /**< Whether dynamic payloads are enabled. */
akashvibhute 2:3bdf0d9bb71f 78 uint8_t pipe0_reading_address[5]; /**< Last address set on pipe 0 for reading. */
akashvibhute 2:3bdf0d9bb71f 79 uint8_t addr_width; /**< The address width to use - 3,4 or 5 bytes. */
akashvibhute 2:3bdf0d9bb71f 80 uint32_t txRxDelay; /**< Var for adjusting delays depending on datarate */
akashvibhute 2:3bdf0d9bb71f 81
akashvibhute 0:bb74812ac6bb 82
akashvibhute 0:bb74812ac6bb 83 protected:
akashvibhute 0:bb74812ac6bb 84 /**
akashvibhute 2:3bdf0d9bb71f 85 * SPI transactions
akashvibhute 2:3bdf0d9bb71f 86 *
akashvibhute 2:3bdf0d9bb71f 87 * Common code for SPI transactions including CSN toggle
akashvibhute 2:3bdf0d9bb71f 88 *
akashvibhute 2:3bdf0d9bb71f 89 */
akashvibhute 2:3bdf0d9bb71f 90 inline void beginTransaction();
akashvibhute 2:3bdf0d9bb71f 91
akashvibhute 2:3bdf0d9bb71f 92 inline void endTransaction();
akashvibhute 2:3bdf0d9bb71f 93
akashvibhute 2:3bdf0d9bb71f 94 public:
akashvibhute 2:3bdf0d9bb71f 95
akashvibhute 2:3bdf0d9bb71f 96 /**
akashvibhute 2:3bdf0d9bb71f 97 * @name Primary public interface
akashvibhute 2:3bdf0d9bb71f 98 *
akashvibhute 2:3bdf0d9bb71f 99 * These are the main methods you need to operate the chip
akashvibhute 2:3bdf0d9bb71f 100 */
akashvibhute 2:3bdf0d9bb71f 101 /**@{*/
akashvibhute 2:3bdf0d9bb71f 102
akashvibhute 2:3bdf0d9bb71f 103
akashvibhute 2:3bdf0d9bb71f 104
akashvibhute 2:3bdf0d9bb71f 105
akashvibhute 2:3bdf0d9bb71f 106
akashvibhute 2:3bdf0d9bb71f 107
akashvibhute 2:3bdf0d9bb71f 108
akashvibhute 2:3bdf0d9bb71f 109
akashvibhute 2:3bdf0d9bb71f 110
akashvibhute 2:3bdf0d9bb71f 111
akashvibhute 2:3bdf0d9bb71f 112
akashvibhute 2:3bdf0d9bb71f 113
akashvibhute 2:3bdf0d9bb71f 114
akashvibhute 2:3bdf0d9bb71f 115
akashvibhute 2:3bdf0d9bb71f 116
akashvibhute 2:3bdf0d9bb71f 117
akashvibhute 2:3bdf0d9bb71f 118
akashvibhute 2:3bdf0d9bb71f 119
akashvibhute 2:3bdf0d9bb71f 120
akashvibhute 2:3bdf0d9bb71f 121
akashvibhute 2:3bdf0d9bb71f 122
akashvibhute 2:3bdf0d9bb71f 123
akashvibhute 2:3bdf0d9bb71f 124
akashvibhute 2:3bdf0d9bb71f 125
akashvibhute 2:3bdf0d9bb71f 126 RF24(PinName miso, PinName mosi, PinName sck, PinName _cepin, PinName _csnpin);
akashvibhute 2:3bdf0d9bb71f 127
akashvibhute 2:3bdf0d9bb71f 128
akashvibhute 2:3bdf0d9bb71f 129
akashvibhute 2:3bdf0d9bb71f 130
akashvibhute 2:3bdf0d9bb71f 131
akashvibhute 2:3bdf0d9bb71f 132
akashvibhute 2:3bdf0d9bb71f 133 /**
akashvibhute 2:3bdf0d9bb71f 134 * Begin operation of the chip
akashvibhute 2:3bdf0d9bb71f 135 *
akashvibhute 2:3bdf0d9bb71f 136 * Call this in setup(), before calling any other methods.
akashvibhute 2:3bdf0d9bb71f 137 * @code radio.begin() @endcode
akashvibhute 2:3bdf0d9bb71f 138 */
akashvibhute 2:3bdf0d9bb71f 139 bool begin(void);
akashvibhute 2:3bdf0d9bb71f 140
akashvibhute 2:3bdf0d9bb71f 141 /**
akashvibhute 2:3bdf0d9bb71f 142 * Start listening on the pipes opened for reading.
akashvibhute 2:3bdf0d9bb71f 143 *
akashvibhute 2:3bdf0d9bb71f 144 * 1. Be sure to call openReadingPipe() first.
akashvibhute 2:3bdf0d9bb71f 145 * 2. Do not call write() while in this mode, without first calling stopListening().
akashvibhute 2:3bdf0d9bb71f 146 * 3. Call available() to check for incoming traffic, and read() to get it.
akashvibhute 2:3bdf0d9bb71f 147 *
akashvibhute 2:3bdf0d9bb71f 148 * @code
akashvibhute 2:3bdf0d9bb71f 149 * Open reading pipe 1 using address CCCECCCECC
akashvibhute 2:3bdf0d9bb71f 150 *
akashvibhute 2:3bdf0d9bb71f 151 * byte address[] = { 0xCC,0xCE,0xCC,0xCE,0xCC };
akashvibhute 2:3bdf0d9bb71f 152 * radio.openReadingPipe(1,address);
akashvibhute 2:3bdf0d9bb71f 153 * radio.startListening();
akashvibhute 2:3bdf0d9bb71f 154 * @endcode
akashvibhute 2:3bdf0d9bb71f 155 */
akashvibhute 2:3bdf0d9bb71f 156 void startListening(void);
akashvibhute 2:3bdf0d9bb71f 157
akashvibhute 2:3bdf0d9bb71f 158 /**
akashvibhute 2:3bdf0d9bb71f 159 * Stop listening for incoming messages, and switch to transmit mode.
akashvibhute 2:3bdf0d9bb71f 160 *
akashvibhute 2:3bdf0d9bb71f 161 * Do this before calling write().
akashvibhute 2:3bdf0d9bb71f 162 * @code
akashvibhute 2:3bdf0d9bb71f 163 * radio.stopListening();
akashvibhute 2:3bdf0d9bb71f 164 * radio.write(&data,sizeof(data));
akashvibhute 2:3bdf0d9bb71f 165 * @endcode
akashvibhute 2:3bdf0d9bb71f 166 */
akashvibhute 2:3bdf0d9bb71f 167 void stopListening(void);
akashvibhute 2:3bdf0d9bb71f 168
akashvibhute 2:3bdf0d9bb71f 169 /**
akashvibhute 2:3bdf0d9bb71f 170 * Check whether there are bytes available to be read
akashvibhute 2:3bdf0d9bb71f 171 * @code
akashvibhute 2:3bdf0d9bb71f 172 * if(radio.available()){
akashvibhute 2:3bdf0d9bb71f 173 * radio.read(&data,sizeof(data));
akashvibhute 2:3bdf0d9bb71f 174 * }
akashvibhute 2:3bdf0d9bb71f 175 * @endcode
akashvibhute 2:3bdf0d9bb71f 176 * @return True if there is a payload available, false if none is
akashvibhute 2:3bdf0d9bb71f 177 */
akashvibhute 2:3bdf0d9bb71f 178 bool available(void);
akashvibhute 2:3bdf0d9bb71f 179
akashvibhute 2:3bdf0d9bb71f 180 /**
akashvibhute 2:3bdf0d9bb71f 181 * Read the available payload
akashvibhute 2:3bdf0d9bb71f 182 *
akashvibhute 2:3bdf0d9bb71f 183 * The size of data read is the fixed payload size, see getPayloadSize()
akashvibhute 2:3bdf0d9bb71f 184 *
akashvibhute 2:3bdf0d9bb71f 185 * @note I specifically chose 'void*' as a data type to make it easier
akashvibhute 2:3bdf0d9bb71f 186 * for beginners to use. No casting needed.
akashvibhute 2:3bdf0d9bb71f 187 *
akashvibhute 2:3bdf0d9bb71f 188 * @note No longer boolean. Use available to determine if packets are
akashvibhute 2:3bdf0d9bb71f 189 * available. Interrupt flags are now cleared during reads instead of
akashvibhute 2:3bdf0d9bb71f 190 * when calling available().
akashvibhute 2:3bdf0d9bb71f 191 *
akashvibhute 2:3bdf0d9bb71f 192 * @param buf Pointer to a buffer where the data should be written
akashvibhute 2:3bdf0d9bb71f 193 * @param len Maximum number of bytes to read into the buffer
akashvibhute 2:3bdf0d9bb71f 194 *
akashvibhute 2:3bdf0d9bb71f 195 * @code
akashvibhute 2:3bdf0d9bb71f 196 * if(radio.available()){
akashvibhute 2:3bdf0d9bb71f 197 * radio.read(&data,sizeof(data));
akashvibhute 2:3bdf0d9bb71f 198 * }
akashvibhute 2:3bdf0d9bb71f 199 * @endcode
akashvibhute 2:3bdf0d9bb71f 200 * @return No return value. Use available().
akashvibhute 2:3bdf0d9bb71f 201 */
akashvibhute 2:3bdf0d9bb71f 202 void read( void* buf, uint8_t len );
akashvibhute 2:3bdf0d9bb71f 203
akashvibhute 2:3bdf0d9bb71f 204 /**
akashvibhute 2:3bdf0d9bb71f 205 * Be sure to call openWritingPipe() first to set the destination
akashvibhute 2:3bdf0d9bb71f 206 * of where to write to.
akashvibhute 2:3bdf0d9bb71f 207 *
akashvibhute 2:3bdf0d9bb71f 208 * This blocks until the message is successfully acknowledged by
akashvibhute 2:3bdf0d9bb71f 209 * the receiver or the timeout/retransmit maxima are reached. In
akashvibhute 2:3bdf0d9bb71f 210 * the current configuration, the max delay here is 60-70ms.
akashvibhute 2:3bdf0d9bb71f 211 *
akashvibhute 2:3bdf0d9bb71f 212 * The maximum size of data written is the fixed payload size, see
akashvibhute 2:3bdf0d9bb71f 213 * getPayloadSize(). However, you can write less, and the remainder
akashvibhute 2:3bdf0d9bb71f 214 * will just be filled with zeroes.
akashvibhute 2:3bdf0d9bb71f 215 *
akashvibhute 2:3bdf0d9bb71f 216 * TX/RX/RT interrupt flags will be cleared every time write is called
akashvibhute 2:3bdf0d9bb71f 217 *
akashvibhute 2:3bdf0d9bb71f 218 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 219 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 220 *
akashvibhute 2:3bdf0d9bb71f 221 * @code
akashvibhute 2:3bdf0d9bb71f 222 * radio.stopListening();
akashvibhute 2:3bdf0d9bb71f 223 * radio.write(&data,sizeof(data));
akashvibhute 2:3bdf0d9bb71f 224 * @endcode
akashvibhute 2:3bdf0d9bb71f 225 * @return True if the payload was delivered successfully false if not
akashvibhute 2:3bdf0d9bb71f 226 */
akashvibhute 2:3bdf0d9bb71f 227 bool write( const void* buf, uint8_t len );
akashvibhute 2:3bdf0d9bb71f 228
akashvibhute 2:3bdf0d9bb71f 229 /**
akashvibhute 2:3bdf0d9bb71f 230 * New: Open a pipe for writing via byte array. Old addressing format retained
akashvibhute 2:3bdf0d9bb71f 231 * for compatibility.
akashvibhute 2:3bdf0d9bb71f 232 *
akashvibhute 2:3bdf0d9bb71f 233 * Only one writing pipe can be open at once, but you can change the address
akashvibhute 2:3bdf0d9bb71f 234 * you'll write to. Call stopListening() first.
akashvibhute 2:3bdf0d9bb71f 235 *
akashvibhute 2:3bdf0d9bb71f 236 * Addresses are assigned via a byte array, default is 5 byte address length
akashvibhute 2:3bdf0d9bb71f 237 s *
akashvibhute 2:3bdf0d9bb71f 238 * @code
akashvibhute 2:3bdf0d9bb71f 239 * uint8_t addresses[][6] = {"1Node","2Node"};
akashvibhute 2:3bdf0d9bb71f 240 * radio.openWritingPipe(addresses[0]);
akashvibhute 2:3bdf0d9bb71f 241 * @endcode
akashvibhute 2:3bdf0d9bb71f 242 * @code
akashvibhute 2:3bdf0d9bb71f 243 * uint8_t address[] = { 0xCC,0xCE,0xCC,0xCE,0xCC };
akashvibhute 2:3bdf0d9bb71f 244 * radio.openWritingPipe(address);
akashvibhute 2:3bdf0d9bb71f 245 * address[0] = 0x33;
akashvibhute 2:3bdf0d9bb71f 246 * radio.openReadingPipe(1,address);
akashvibhute 2:3bdf0d9bb71f 247 * @endcode
akashvibhute 2:3bdf0d9bb71f 248 * @see setAddressWidth
akashvibhute 2:3bdf0d9bb71f 249 *
akashvibhute 2:3bdf0d9bb71f 250 * @param address The address of the pipe to open. Coordinate these pipe
akashvibhute 2:3bdf0d9bb71f 251 * addresses amongst nodes on the network.
akashvibhute 2:3bdf0d9bb71f 252 */
akashvibhute 2:3bdf0d9bb71f 253
akashvibhute 2:3bdf0d9bb71f 254 void openWritingPipe(const uint8_t *address);
akashvibhute 2:3bdf0d9bb71f 255
akashvibhute 2:3bdf0d9bb71f 256 /**
akashvibhute 2:3bdf0d9bb71f 257 * Open a pipe for reading
akashvibhute 2:3bdf0d9bb71f 258 *
akashvibhute 2:3bdf0d9bb71f 259 * Up to 6 pipes can be open for reading at once. Open all the required
akashvibhute 2:3bdf0d9bb71f 260 * reading pipes, and then call startListening().
akashvibhute 2:3bdf0d9bb71f 261 *
akashvibhute 2:3bdf0d9bb71f 262 * @see openWritingPipe
akashvibhute 2:3bdf0d9bb71f 263 * @see setAddressWidth
akashvibhute 2:3bdf0d9bb71f 264 *
akashvibhute 2:3bdf0d9bb71f 265 * @note Pipes 0 and 1 will store a full 5-byte address. Pipes 2-5 will technically
akashvibhute 2:3bdf0d9bb71f 266 * only store a single byte, borrowing up to 4 additional bytes from pipe #1 per the
akashvibhute 2:3bdf0d9bb71f 267 * assigned address width.
akashvibhute 2:3bdf0d9bb71f 268 * @warning Pipes 1-5 should share the same address, except the first byte.
akashvibhute 2:3bdf0d9bb71f 269 * Only the first byte in the array should be unique, e.g.
akashvibhute 2:3bdf0d9bb71f 270 * @code
akashvibhute 2:3bdf0d9bb71f 271 * uint8_t addresses[][6] = {"1Node","2Node"};
akashvibhute 2:3bdf0d9bb71f 272 * openReadingPipe(1,addresses[0]);
akashvibhute 2:3bdf0d9bb71f 273 * openReadingPipe(2,addresses[1]);
akashvibhute 2:3bdf0d9bb71f 274 * @endcode
akashvibhute 2:3bdf0d9bb71f 275 *
akashvibhute 2:3bdf0d9bb71f 276 * @warning Pipe 0 is also used by the writing pipe. So if you open
akashvibhute 2:3bdf0d9bb71f 277 * pipe 0 for reading, and then startListening(), it will overwrite the
akashvibhute 2:3bdf0d9bb71f 278 * writing pipe. Ergo, do an openWritingPipe() again before write().
akashvibhute 2:3bdf0d9bb71f 279 *
akashvibhute 2:3bdf0d9bb71f 280 * @param number Which pipe# to open, 0-5.
akashvibhute 2:3bdf0d9bb71f 281 * @param address The 24, 32 or 40 bit address of the pipe to open.
akashvibhute 2:3bdf0d9bb71f 282 */
akashvibhute 2:3bdf0d9bb71f 283
akashvibhute 2:3bdf0d9bb71f 284 void openReadingPipe(uint8_t number, const uint8_t *address);
akashvibhute 2:3bdf0d9bb71f 285
akashvibhute 2:3bdf0d9bb71f 286 /**@}*/
akashvibhute 2:3bdf0d9bb71f 287 /**
akashvibhute 2:3bdf0d9bb71f 288 * @name Advanced Operation
akashvibhute 2:3bdf0d9bb71f 289 *
akashvibhute 2:3bdf0d9bb71f 290 * Methods you can use to drive the chip in more advanced ways
akashvibhute 2:3bdf0d9bb71f 291 */
akashvibhute 2:3bdf0d9bb71f 292 /**@{*/
akashvibhute 2:3bdf0d9bb71f 293
akashvibhute 2:3bdf0d9bb71f 294 /**
akashvibhute 2:3bdf0d9bb71f 295 * Print a giant block of debugging information to stdout
akashvibhute 2:3bdf0d9bb71f 296 *
akashvibhute 2:3bdf0d9bb71f 297 * @warning Does nothing if stdout is not defined. See fdevopen in stdio.h
akashvibhute 2:3bdf0d9bb71f 298 * The printf.h file is included with the library for Arduino.
akashvibhute 2:3bdf0d9bb71f 299 * @code
akashvibhute 2:3bdf0d9bb71f 300 * #include <printf.h>
akashvibhute 2:3bdf0d9bb71f 301 * setup(){
akashvibhute 2:3bdf0d9bb71f 302 * Serial.begin(115200);
akashvibhute 2:3bdf0d9bb71f 303 * printf_begin();
akashvibhute 2:3bdf0d9bb71f 304 * ...
akashvibhute 2:3bdf0d9bb71f 305 * }
akashvibhute 2:3bdf0d9bb71f 306 * @endcode
akashvibhute 2:3bdf0d9bb71f 307 */
akashvibhute 2:3bdf0d9bb71f 308 void printDetails(void);
akashvibhute 2:3bdf0d9bb71f 309
akashvibhute 2:3bdf0d9bb71f 310 /**
akashvibhute 2:3bdf0d9bb71f 311 * Test whether there are bytes available to be read in the
akashvibhute 2:3bdf0d9bb71f 312 * FIFO buffers.
akashvibhute 2:3bdf0d9bb71f 313 *
akashvibhute 2:3bdf0d9bb71f 314 * @param[out] pipe_num Which pipe has the payload available
akashvibhute 2:3bdf0d9bb71f 315 *
akashvibhute 2:3bdf0d9bb71f 316 * @code
akashvibhute 2:3bdf0d9bb71f 317 * uint8_t pipeNum;
akashvibhute 2:3bdf0d9bb71f 318 * if(radio.available(&pipeNum)){
akashvibhute 2:3bdf0d9bb71f 319 * radio.read(&data,sizeof(data));
akashvibhute 2:3bdf0d9bb71f 320 * Serial.print("Got data on pipe");
akashvibhute 2:3bdf0d9bb71f 321 * Serial.println(pipeNum);
akashvibhute 2:3bdf0d9bb71f 322 * }
akashvibhute 2:3bdf0d9bb71f 323 * @endcode
akashvibhute 2:3bdf0d9bb71f 324 * @return True if there is a payload available, false if none is
akashvibhute 2:3bdf0d9bb71f 325 */
akashvibhute 2:3bdf0d9bb71f 326 bool available(uint8_t* pipe_num);
akashvibhute 2:3bdf0d9bb71f 327
akashvibhute 2:3bdf0d9bb71f 328 /**
akashvibhute 2:3bdf0d9bb71f 329 * Check if the radio needs to be read. Can be used to prevent data loss
akashvibhute 2:3bdf0d9bb71f 330 * @return True if all three 32-byte radio buffers are full
akashvibhute 2:3bdf0d9bb71f 331 */
akashvibhute 2:3bdf0d9bb71f 332 bool rxFifoFull();
akashvibhute 2:3bdf0d9bb71f 333
akashvibhute 2:3bdf0d9bb71f 334 /**
akashvibhute 2:3bdf0d9bb71f 335 * Enter low-power mode
akashvibhute 2:3bdf0d9bb71f 336 *
akashvibhute 2:3bdf0d9bb71f 337 * To return to normal power mode, call powerUp().
akashvibhute 2:3bdf0d9bb71f 338 *
akashvibhute 2:3bdf0d9bb71f 339 * @note After calling startListening(), a basic radio will consume about 13.5mA
akashvibhute 2:3bdf0d9bb71f 340 * at max PA level.
akashvibhute 2:3bdf0d9bb71f 341 * During active transmission, the radio will consume about 11.5mA, but this will
akashvibhute 2:3bdf0d9bb71f 342 * be reduced to 26uA (.026mA) between sending.
akashvibhute 2:3bdf0d9bb71f 343 * In full powerDown mode, the radio will consume approximately 900nA (.0009mA)
akashvibhute 2:3bdf0d9bb71f 344 *
akashvibhute 2:3bdf0d9bb71f 345 * @code
akashvibhute 2:3bdf0d9bb71f 346 * radio.powerDown();
akashvibhute 2:3bdf0d9bb71f 347 * avr_enter_sleep_mode(); // Custom function to sleep the device
akashvibhute 2:3bdf0d9bb71f 348 * radio.powerUp();
akashvibhute 2:3bdf0d9bb71f 349 * @endcode
akashvibhute 2:3bdf0d9bb71f 350 */
akashvibhute 2:3bdf0d9bb71f 351 void powerDown(void);
akashvibhute 2:3bdf0d9bb71f 352
akashvibhute 2:3bdf0d9bb71f 353 /**
akashvibhute 2:3bdf0d9bb71f 354 * Leave low-power mode - required for normal radio operation after calling powerDown()
akashvibhute 2:3bdf0d9bb71f 355 *
akashvibhute 2:3bdf0d9bb71f 356 * To return to low power mode, call powerDown().
akashvibhute 2:3bdf0d9bb71f 357 * @note This will take up to 5ms for maximum compatibility
akashvibhute 2:3bdf0d9bb71f 358 */
akashvibhute 2:3bdf0d9bb71f 359 void powerUp(void) ;
akashvibhute 2:3bdf0d9bb71f 360
akashvibhute 2:3bdf0d9bb71f 361 /**
akashvibhute 2:3bdf0d9bb71f 362 * Write for single NOACK writes. Optionally disables acknowledgements/autoretries for a single write.
akashvibhute 2:3bdf0d9bb71f 363 *
akashvibhute 2:3bdf0d9bb71f 364 * @note enableDynamicAck() must be called to enable this feature
akashvibhute 2:3bdf0d9bb71f 365 *
akashvibhute 2:3bdf0d9bb71f 366 * Can be used with enableAckPayload() to request a response
akashvibhute 2:3bdf0d9bb71f 367 * @see enableDynamicAck()
akashvibhute 2:3bdf0d9bb71f 368 * @see setAutoAck()
akashvibhute 2:3bdf0d9bb71f 369 * @see write()
akashvibhute 2:3bdf0d9bb71f 370 *
akashvibhute 2:3bdf0d9bb71f 371 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 372 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 373 * @param multicast Request ACK (0), NOACK (1)
akashvibhute 2:3bdf0d9bb71f 374 */
akashvibhute 2:3bdf0d9bb71f 375 bool write( const void* buf, uint8_t len, const bool multicast );
akashvibhute 2:3bdf0d9bb71f 376
akashvibhute 2:3bdf0d9bb71f 377 /**
akashvibhute 2:3bdf0d9bb71f 378 * This will not block until the 3 FIFO buffers are filled with data.
akashvibhute 2:3bdf0d9bb71f 379 * Once the FIFOs are full, writeFast will simply wait for success or
akashvibhute 2:3bdf0d9bb71f 380 * timeout, and return 1 or 0 respectively. From a user perspective, just
akashvibhute 2:3bdf0d9bb71f 381 * keep trying to send the same data. The library will keep auto retrying
akashvibhute 2:3bdf0d9bb71f 382 * the current payload using the built in functionality.
akashvibhute 2:3bdf0d9bb71f 383 * @warning It is important to never keep the nRF24L01 in TX mode and FIFO full for more than 4ms at a time. If the auto
akashvibhute 2:3bdf0d9bb71f 384 * retransmit is enabled, the nRF24L01 is never in TX mode long enough to disobey this rule. Allow the FIFO
akashvibhute 2:3bdf0d9bb71f 385 * to clear by issuing txStandBy() or ensure appropriate time between transmissions.
akashvibhute 2:3bdf0d9bb71f 386 *
akashvibhute 2:3bdf0d9bb71f 387 * @code
akashvibhute 2:3bdf0d9bb71f 388 * Example (Partial blocking):
akashvibhute 2:3bdf0d9bb71f 389 *
akashvibhute 2:3bdf0d9bb71f 390 * radio.writeFast(&buf,32); // Writes 1 payload to the buffers
akashvibhute 2:3bdf0d9bb71f 391 * txStandBy(); // Returns 0 if failed. 1 if success. Blocks only until MAX_RT timeout or success. Data flushed on fail.
akashvibhute 2:3bdf0d9bb71f 392 *
akashvibhute 2:3bdf0d9bb71f 393 * radio.writeFast(&buf,32); // Writes 1 payload to the buffers
akashvibhute 2:3bdf0d9bb71f 394 * txStandBy(1000); // Using extended timeouts, returns 1 if success. Retries failed payloads for 1 seconds before returning 0.
akashvibhute 2:3bdf0d9bb71f 395 * @endcode
akashvibhute 2:3bdf0d9bb71f 396 *
akashvibhute 2:3bdf0d9bb71f 397 * @see txStandBy()
akashvibhute 2:3bdf0d9bb71f 398 * @see write()
akashvibhute 2:3bdf0d9bb71f 399 * @see writeBlocking()
akashvibhute 2:3bdf0d9bb71f 400 *
akashvibhute 2:3bdf0d9bb71f 401 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 402 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 403 * @return True if the payload was delivered successfully false if not
akashvibhute 2:3bdf0d9bb71f 404 */
akashvibhute 2:3bdf0d9bb71f 405 bool writeFast( const void* buf, uint8_t len );
akashvibhute 2:3bdf0d9bb71f 406
akashvibhute 2:3bdf0d9bb71f 407 /**
akashvibhute 2:3bdf0d9bb71f 408 * WriteFast for single NOACK writes. Disables acknowledgements/autoretries for a single write.
akashvibhute 2:3bdf0d9bb71f 409 *
akashvibhute 2:3bdf0d9bb71f 410 * @note enableDynamicAck() must be called to enable this feature
akashvibhute 2:3bdf0d9bb71f 411 * @see enableDynamicAck()
akashvibhute 2:3bdf0d9bb71f 412 * @see setAutoAck()
akashvibhute 2:3bdf0d9bb71f 413 *
akashvibhute 2:3bdf0d9bb71f 414 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 415 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 416 * @param multicast Request ACK (0) or NOACK (1)
akashvibhute 2:3bdf0d9bb71f 417 */
akashvibhute 2:3bdf0d9bb71f 418 bool writeFast( const void* buf, uint8_t len, const bool multicast );
akashvibhute 2:3bdf0d9bb71f 419
akashvibhute 2:3bdf0d9bb71f 420 /**
akashvibhute 2:3bdf0d9bb71f 421 * This function extends the auto-retry mechanism to any specified duration.
akashvibhute 2:3bdf0d9bb71f 422 * It will not block until the 3 FIFO buffers are filled with data.
akashvibhute 2:3bdf0d9bb71f 423 * If so the library will auto retry until a new payload is written
akashvibhute 2:3bdf0d9bb71f 424 * or the user specified timeout period is reached.
akashvibhute 2:3bdf0d9bb71f 425 * @warning It is important to never keep the nRF24L01 in TX mode and FIFO full for more than 4ms at a time. If the auto
akashvibhute 2:3bdf0d9bb71f 426 * retransmit is enabled, the nRF24L01 is never in TX mode long enough to disobey this rule. Allow the FIFO
akashvibhute 2:3bdf0d9bb71f 427 * to clear by issuing txStandBy() or ensure appropriate time between transmissions.
akashvibhute 2:3bdf0d9bb71f 428 *
akashvibhute 2:3bdf0d9bb71f 429 * @code
akashvibhute 2:3bdf0d9bb71f 430 * Example (Full blocking):
akashvibhute 2:3bdf0d9bb71f 431 *
akashvibhute 2:3bdf0d9bb71f 432 * radio.writeBlocking(&buf,32,1000); //Wait up to 1 second to write 1 payload to the buffers
akashvibhute 2:3bdf0d9bb71f 433 * txStandBy(1000); //Wait up to 1 second for the payload to send. Return 1 if ok, 0 if failed.
akashvibhute 2:3bdf0d9bb71f 434 * //Blocks only until user timeout or success. Data flushed on fail.
akashvibhute 2:3bdf0d9bb71f 435 * @endcode
akashvibhute 2:3bdf0d9bb71f 436 * @note If used from within an interrupt, the interrupt should be disabled until completion, and sei(); called to enable millis().
akashvibhute 2:3bdf0d9bb71f 437 * @see txStandBy()
akashvibhute 2:3bdf0d9bb71f 438 * @see write()
akashvibhute 2:3bdf0d9bb71f 439 * @see writeFast()
akashvibhute 2:3bdf0d9bb71f 440 *
akashvibhute 2:3bdf0d9bb71f 441 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 442 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 443 * @param timeout User defined timeout in milliseconds.
akashvibhute 2:3bdf0d9bb71f 444 * @return True if the payload was loaded into the buffer successfully false if not
akashvibhute 2:3bdf0d9bb71f 445 */
akashvibhute 2:3bdf0d9bb71f 446 bool writeBlocking( const void* buf, uint8_t len, uint32_t timeout );
akashvibhute 2:3bdf0d9bb71f 447
akashvibhute 2:3bdf0d9bb71f 448 /**
akashvibhute 2:3bdf0d9bb71f 449 * This function should be called as soon as transmission is finished to
akashvibhute 2:3bdf0d9bb71f 450 * drop the radio back to STANDBY-I mode. If not issued, the radio will
akashvibhute 2:3bdf0d9bb71f 451 * remain in STANDBY-II mode which, per the data sheet, is not a recommended
akashvibhute 2:3bdf0d9bb71f 452 * operating mode.
akashvibhute 2:3bdf0d9bb71f 453 *
akashvibhute 2:3bdf0d9bb71f 454 * @note When transmitting data in rapid succession, it is still recommended by
akashvibhute 2:3bdf0d9bb71f 455 * the manufacturer to drop the radio out of TX or STANDBY-II mode if there is
akashvibhute 2:3bdf0d9bb71f 456 * time enough between sends for the FIFOs to empty. This is not required if auto-ack
akashvibhute 2:3bdf0d9bb71f 457 * is enabled.
akashvibhute 2:3bdf0d9bb71f 458 *
akashvibhute 2:3bdf0d9bb71f 459 * Relies on built-in auto retry functionality.
akashvibhute 2:3bdf0d9bb71f 460 *
akashvibhute 2:3bdf0d9bb71f 461 * @code
akashvibhute 2:3bdf0d9bb71f 462 * Example (Partial blocking):
akashvibhute 2:3bdf0d9bb71f 463 *
akashvibhute 2:3bdf0d9bb71f 464 * radio.writeFast(&buf,32);
akashvibhute 2:3bdf0d9bb71f 465 * radio.writeFast(&buf,32);
akashvibhute 2:3bdf0d9bb71f 466 * radio.writeFast(&buf,32); //Fills the FIFO buffers up
akashvibhute 2:3bdf0d9bb71f 467 * bool ok = txStandBy(); //Returns 0 if failed. 1 if success.
akashvibhute 2:3bdf0d9bb71f 468 * //Blocks only until MAX_RT timeout or success. Data flushed on fail.
akashvibhute 2:3bdf0d9bb71f 469 * @endcode
akashvibhute 2:3bdf0d9bb71f 470 * @see txStandBy(unsigned long timeout)
akashvibhute 2:3bdf0d9bb71f 471 * @return True if transmission is successful
akashvibhute 2:3bdf0d9bb71f 472 *
akashvibhute 2:3bdf0d9bb71f 473 */
akashvibhute 2:3bdf0d9bb71f 474 bool txStandBy();
akashvibhute 2:3bdf0d9bb71f 475
akashvibhute 2:3bdf0d9bb71f 476 /**
akashvibhute 2:3bdf0d9bb71f 477 * This function allows extended blocking and auto-retries per a user defined timeout
akashvibhute 2:3bdf0d9bb71f 478 * @code
akashvibhute 2:3bdf0d9bb71f 479 * Fully Blocking Example:
akashvibhute 2:3bdf0d9bb71f 480 *
akashvibhute 2:3bdf0d9bb71f 481 * radio.writeFast(&buf,32);
akashvibhute 2:3bdf0d9bb71f 482 * radio.writeFast(&buf,32);
akashvibhute 2:3bdf0d9bb71f 483 * radio.writeFast(&buf,32); //Fills the FIFO buffers up
akashvibhute 2:3bdf0d9bb71f 484 * bool ok = txStandBy(1000); //Returns 0 if failed after 1 second of retries. 1 if success.
akashvibhute 2:3bdf0d9bb71f 485 * //Blocks only until user defined timeout or success. Data flushed on fail.
akashvibhute 2:3bdf0d9bb71f 486 * @endcode
akashvibhute 2:3bdf0d9bb71f 487 * @note If used from within an interrupt, the interrupt should be disabled until completion, and sei(); called to enable millis().
akashvibhute 2:3bdf0d9bb71f 488 * @param timeout Number of milliseconds to retry failed payloads
akashvibhute 2:3bdf0d9bb71f 489 * @return True if transmission is successful
akashvibhute 2:3bdf0d9bb71f 490 *
akashvibhute 2:3bdf0d9bb71f 491 */
akashvibhute 2:3bdf0d9bb71f 492 bool txStandBy(uint32_t timeout, bool startTx = 0);
akashvibhute 2:3bdf0d9bb71f 493
akashvibhute 2:3bdf0d9bb71f 494 /**
akashvibhute 2:3bdf0d9bb71f 495 * Write an ack payload for the specified pipe
akashvibhute 2:3bdf0d9bb71f 496 *
akashvibhute 2:3bdf0d9bb71f 497 * The next time a message is received on @p pipe, the data in @p buf will
akashvibhute 2:3bdf0d9bb71f 498 * be sent back in the acknowledgement.
akashvibhute 2:3bdf0d9bb71f 499 * @see enableAckPayload()
akashvibhute 2:3bdf0d9bb71f 500 * @see enableDynamicPayloads()
akashvibhute 2:3bdf0d9bb71f 501 * @warning Only three of these can be pending at any time as there are only 3 FIFO buffers.<br> Dynamic payloads must be enabled.
akashvibhute 2:3bdf0d9bb71f 502 * @note Ack payloads are handled automatically by the radio chip when a payload is received. Users should generally
akashvibhute 2:3bdf0d9bb71f 503 * write an ack payload as soon as startListening() is called, so one is available when a regular payload is received.
akashvibhute 2:3bdf0d9bb71f 504 * @note Ack payloads are dynamic payloads. This only works on pipes 0&1 by default. Call
akashvibhute 2:3bdf0d9bb71f 505 * enableDynamicPayloads() to enable on all pipes.
akashvibhute 2:3bdf0d9bb71f 506 *
akashvibhute 2:3bdf0d9bb71f 507 * @param pipe Which pipe# (typically 1-5) will get this response.
akashvibhute 2:3bdf0d9bb71f 508 * @param buf Pointer to data that is sent
akashvibhute 2:3bdf0d9bb71f 509 * @param len Length of the data to send, up to 32 bytes max. Not affected
akashvibhute 2:3bdf0d9bb71f 510 * by the static payload set by setPayloadSize().
akashvibhute 2:3bdf0d9bb71f 511 */
akashvibhute 2:3bdf0d9bb71f 512 void writeAckPayload(uint8_t pipe, const void* buf, uint8_t len);
akashvibhute 2:3bdf0d9bb71f 513
akashvibhute 2:3bdf0d9bb71f 514 /**
akashvibhute 2:3bdf0d9bb71f 515 * Determine if an ack payload was received in the most recent call to
akashvibhute 2:3bdf0d9bb71f 516 * write(). The regular available() can also be used.
akashvibhute 2:3bdf0d9bb71f 517 *
akashvibhute 2:3bdf0d9bb71f 518 * Call read() to retrieve the ack payload.
akashvibhute 2:3bdf0d9bb71f 519 *
akashvibhute 2:3bdf0d9bb71f 520 * @return True if an ack payload is available.
akashvibhute 2:3bdf0d9bb71f 521 */
akashvibhute 2:3bdf0d9bb71f 522 bool isAckPayloadAvailable(void);
akashvibhute 2:3bdf0d9bb71f 523
akashvibhute 2:3bdf0d9bb71f 524 /**
akashvibhute 2:3bdf0d9bb71f 525 * Call this when you get an interrupt to find out why
akashvibhute 2:3bdf0d9bb71f 526 *
akashvibhute 2:3bdf0d9bb71f 527 * Tells you what caused the interrupt, and clears the state of
akashvibhute 2:3bdf0d9bb71f 528 * interrupts.
akashvibhute 2:3bdf0d9bb71f 529 *
akashvibhute 2:3bdf0d9bb71f 530 * @param[out] tx_ok The send was successful (TX_DS)
akashvibhute 2:3bdf0d9bb71f 531 * @param[out] tx_fail The send failed, too many retries (MAX_RT)
akashvibhute 2:3bdf0d9bb71f 532 * @param[out] rx_ready There is a message waiting to be read (RX_DS)
akashvibhute 2:3bdf0d9bb71f 533 */
akashvibhute 2:3bdf0d9bb71f 534 void whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready);
akashvibhute 2:3bdf0d9bb71f 535
akashvibhute 2:3bdf0d9bb71f 536 /**
akashvibhute 2:3bdf0d9bb71f 537 * Non-blocking write to the open writing pipe used for buffered writes
akashvibhute 2:3bdf0d9bb71f 538 *
akashvibhute 2:3bdf0d9bb71f 539 * @note Optimization: This function now leaves the CE pin high, so the radio
akashvibhute 2:3bdf0d9bb71f 540 * will remain in TX or STANDBY-II Mode until a txStandBy() command is issued. Can be used as an alternative to startWrite()
akashvibhute 2:3bdf0d9bb71f 541 * if writing multiple payloads at once.
akashvibhute 2:3bdf0d9bb71f 542 * @warning It is important to never keep the nRF24L01 in TX mode with FIFO full for more than 4ms at a time. If the auto
akashvibhute 2:3bdf0d9bb71f 543 * retransmit/autoAck is enabled, the nRF24L01 is never in TX mode long enough to disobey this rule. Allow the FIFO
akashvibhute 2:3bdf0d9bb71f 544 * to clear by issuing txStandBy() or ensure appropriate time between transmissions.
akashvibhute 2:3bdf0d9bb71f 545 *
akashvibhute 2:3bdf0d9bb71f 546 * @see write()
akashvibhute 2:3bdf0d9bb71f 547 * @see writeFast()
akashvibhute 2:3bdf0d9bb71f 548 * @see startWrite()
akashvibhute 2:3bdf0d9bb71f 549 * @see writeBlocking()
akashvibhute 2:3bdf0d9bb71f 550 *
akashvibhute 2:3bdf0d9bb71f 551 * For single noAck writes see:
akashvibhute 2:3bdf0d9bb71f 552 * @see enableDynamicAck()
akashvibhute 2:3bdf0d9bb71f 553 * @see setAutoAck()
akashvibhute 2:3bdf0d9bb71f 554 *
akashvibhute 2:3bdf0d9bb71f 555 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 556 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 557 * @param multicast Request ACK (0) or NOACK (1)
akashvibhute 2:3bdf0d9bb71f 558 * @return True if the payload was delivered successfully false if not
akashvibhute 2:3bdf0d9bb71f 559 */
akashvibhute 2:3bdf0d9bb71f 560 void startFastWrite( const void* buf, uint8_t len, const bool multicast, bool startTx = 1 );
akashvibhute 2:3bdf0d9bb71f 561
akashvibhute 2:3bdf0d9bb71f 562 /**
akashvibhute 2:3bdf0d9bb71f 563 * Non-blocking write to the open writing pipe
akashvibhute 2:3bdf0d9bb71f 564 *
akashvibhute 2:3bdf0d9bb71f 565 * Just like write(), but it returns immediately. To find out what happened
akashvibhute 2:3bdf0d9bb71f 566 * to the send, catch the IRQ and then call whatHappened().
akashvibhute 2:3bdf0d9bb71f 567 *
akashvibhute 2:3bdf0d9bb71f 568 * @see write()
akashvibhute 2:3bdf0d9bb71f 569 * @see writeFast()
akashvibhute 2:3bdf0d9bb71f 570 * @see startFastWrite()
akashvibhute 2:3bdf0d9bb71f 571 * @see whatHappened()
akashvibhute 2:3bdf0d9bb71f 572 *
akashvibhute 2:3bdf0d9bb71f 573 * For single noAck writes see:
akashvibhute 2:3bdf0d9bb71f 574 * @see enableDynamicAck()
akashvibhute 2:3bdf0d9bb71f 575 * @see setAutoAck()
akashvibhute 2:3bdf0d9bb71f 576 *
akashvibhute 2:3bdf0d9bb71f 577 * @param buf Pointer to the data to be sent
akashvibhute 2:3bdf0d9bb71f 578 * @param len Number of bytes to be sent
akashvibhute 2:3bdf0d9bb71f 579 * @param multicast Request ACK (0) or NOACK (1)
akashvibhute 2:3bdf0d9bb71f 580 *
akashvibhute 2:3bdf0d9bb71f 581 */
akashvibhute 2:3bdf0d9bb71f 582 void startWrite( const void* buf, uint8_t len, const bool multicast );
akashvibhute 2:3bdf0d9bb71f 583
akashvibhute 2:3bdf0d9bb71f 584 /**
akashvibhute 2:3bdf0d9bb71f 585 * This function is mainly used internally to take advantage of the auto payload
akashvibhute 2:3bdf0d9bb71f 586 * re-use functionality of the chip, but can be beneficial to users as well.
akashvibhute 2:3bdf0d9bb71f 587 *
akashvibhute 2:3bdf0d9bb71f 588 * The function will instruct the radio to re-use the data in the FIFO buffers,
akashvibhute 2:3bdf0d9bb71f 589 * and instructs the radio to re-send once the timeout limit has been reached.
akashvibhute 2:3bdf0d9bb71f 590 * Used by writeFast and writeBlocking to initiate retries when a TX failure
akashvibhute 2:3bdf0d9bb71f 591 * occurs. Retries are automatically initiated except with the standard write().
akashvibhute 2:3bdf0d9bb71f 592 * This way, data is not flushed from the buffer until switching between modes.
akashvibhute 2:3bdf0d9bb71f 593 *
akashvibhute 2:3bdf0d9bb71f 594 * @note This is to be used AFTER auto-retry fails if wanting to resend
akashvibhute 2:3bdf0d9bb71f 595 * using the built-in payload reuse features.
akashvibhute 2:3bdf0d9bb71f 596 * After issuing reUseTX(), it will keep reending the same payload forever or until
akashvibhute 2:3bdf0d9bb71f 597 * a payload is written to the FIFO, or a flush_tx command is given.
akashvibhute 2:3bdf0d9bb71f 598 */
akashvibhute 2:3bdf0d9bb71f 599 void reUseTX();
akashvibhute 2:3bdf0d9bb71f 600
akashvibhute 2:3bdf0d9bb71f 601 /**
akashvibhute 2:3bdf0d9bb71f 602 * Empty the transmit buffer. This is generally not required in standard operation.
akashvibhute 2:3bdf0d9bb71f 603 * May be required in specific cases after stopListening() , if operating at 250KBPS data rate.
akashvibhute 2:3bdf0d9bb71f 604 *
akashvibhute 2:3bdf0d9bb71f 605 * @return Current value of status register
akashvibhute 2:3bdf0d9bb71f 606 */
akashvibhute 2:3bdf0d9bb71f 607 uint8_t flush_tx(void);
akashvibhute 2:3bdf0d9bb71f 608
akashvibhute 2:3bdf0d9bb71f 609 /**
akashvibhute 2:3bdf0d9bb71f 610 * Test whether there was a carrier on the line for the
akashvibhute 2:3bdf0d9bb71f 611 * previous listening period.
akashvibhute 2:3bdf0d9bb71f 612 *
akashvibhute 2:3bdf0d9bb71f 613 * Useful to check for interference on the current channel.
akashvibhute 2:3bdf0d9bb71f 614 *
akashvibhute 2:3bdf0d9bb71f 615 * @return true if was carrier, false if not
akashvibhute 2:3bdf0d9bb71f 616 */
akashvibhute 2:3bdf0d9bb71f 617 bool testCarrier(void);
akashvibhute 2:3bdf0d9bb71f 618
akashvibhute 2:3bdf0d9bb71f 619 /**
akashvibhute 2:3bdf0d9bb71f 620 * Test whether a signal (carrier or otherwise) greater than
akashvibhute 2:3bdf0d9bb71f 621 * or equal to -64dBm is present on the channel. Valid only
akashvibhute 2:3bdf0d9bb71f 622 * on nRF24L01P (+) hardware. On nRF24L01, use testCarrier().
akashvibhute 2:3bdf0d9bb71f 623 *
akashvibhute 2:3bdf0d9bb71f 624 * Useful to check for interference on the current channel and
akashvibhute 2:3bdf0d9bb71f 625 * channel hopping strategies.
akashvibhute 2:3bdf0d9bb71f 626 *
akashvibhute 2:3bdf0d9bb71f 627 * @code
akashvibhute 2:3bdf0d9bb71f 628 * bool goodSignal = radio.testRPD();
akashvibhute 2:3bdf0d9bb71f 629 * if(radio.available()){
akashvibhute 2:3bdf0d9bb71f 630 * Serial.println(goodSignal ? "Strong signal > 64dBm" : "Weak signal < 64dBm" );
akashvibhute 2:3bdf0d9bb71f 631 * radio.read(0,0);
akashvibhute 2:3bdf0d9bb71f 632 * }
akashvibhute 2:3bdf0d9bb71f 633 * @endcode
akashvibhute 2:3bdf0d9bb71f 634 * @return true if signal => -64dBm, false if not
akashvibhute 2:3bdf0d9bb71f 635 */
akashvibhute 2:3bdf0d9bb71f 636 bool testRPD(void) ;
akashvibhute 2:3bdf0d9bb71f 637
akashvibhute 2:3bdf0d9bb71f 638 /**
akashvibhute 2:3bdf0d9bb71f 639 * Test whether this is a real radio, or a mock shim for
akashvibhute 2:3bdf0d9bb71f 640 * debugging. Setting either pin to 0xff is the way to
akashvibhute 2:3bdf0d9bb71f 641 * indicate that this is not a real radio.
akashvibhute 2:3bdf0d9bb71f 642 *
akashvibhute 2:3bdf0d9bb71f 643 * @return true if this is a legitimate radio
akashvibhute 2:3bdf0d9bb71f 644 */
akashvibhute 2:3bdf0d9bb71f 645 bool isValid() { return ce_pin != 0xff && csn_pin != 0xff; }
akashvibhute 2:3bdf0d9bb71f 646
akashvibhute 2:3bdf0d9bb71f 647 /**
akashvibhute 2:3bdf0d9bb71f 648 * Close a pipe after it has been previously opened.
akashvibhute 2:3bdf0d9bb71f 649 * Can be safely called without having previously opened a pipe.
akashvibhute 2:3bdf0d9bb71f 650 * @param pipe Which pipe # to close, 0-5.
akashvibhute 2:3bdf0d9bb71f 651 */
akashvibhute 2:3bdf0d9bb71f 652 void closeReadingPipe( uint8_t pipe ) ;
akashvibhute 2:3bdf0d9bb71f 653
akashvibhute 2:3bdf0d9bb71f 654 /**
akashvibhute 2:3bdf0d9bb71f 655 * Enable error detection by un-commenting #define FAILURE_HANDLING in RF24_config.h
akashvibhute 2:3bdf0d9bb71f 656 * If a failure has been detected, it usually indicates a hardware issue. By default the library
akashvibhute 2:3bdf0d9bb71f 657 * will cease operation when a failure is detected.
akashvibhute 2:3bdf0d9bb71f 658 * This should allow advanced users to detect and resolve intermittent hardware issues.
akashvibhute 2:3bdf0d9bb71f 659 *
akashvibhute 2:3bdf0d9bb71f 660 * In most cases, the radio must be re-enabled via radio.begin(); and the appropriate settings
akashvibhute 2:3bdf0d9bb71f 661 * applied after a failure occurs, if wanting to re-enable the device immediately.
akashvibhute 2:3bdf0d9bb71f 662 *
akashvibhute 2:3bdf0d9bb71f 663 * Usage: (Failure handling must be enabled per above)
akashvibhute 2:3bdf0d9bb71f 664 * @code
akashvibhute 2:3bdf0d9bb71f 665 * if(radio.failureDetected){
akashvibhute 2:3bdf0d9bb71f 666 * radio.begin(); // Attempt to re-configure the radio with defaults
akashvibhute 2:3bdf0d9bb71f 667 * radio.failureDetected = 0; // Reset the detection value
akashvibhute 2:3bdf0d9bb71f 668 * radio.openWritingPipe(addresses[1]); // Re-configure pipe addresses
akashvibhute 2:3bdf0d9bb71f 669 * radio.openReadingPipe(1,addresses[0]);
akashvibhute 2:3bdf0d9bb71f 670 * report_failure(); // Blink leds, send a message, etc. to indicate failure
akashvibhute 2:3bdf0d9bb71f 671 * }
akashvibhute 2:3bdf0d9bb71f 672 * @endcode
akashvibhute 2:3bdf0d9bb71f 673 */
akashvibhute 2:3bdf0d9bb71f 674 //#if defined (FAILURE_HANDLING)
akashvibhute 2:3bdf0d9bb71f 675 bool failureDetected;
akashvibhute 2:3bdf0d9bb71f 676 //#endif
akashvibhute 2:3bdf0d9bb71f 677
akashvibhute 2:3bdf0d9bb71f 678 /**@}*/
akashvibhute 2:3bdf0d9bb71f 679
akashvibhute 2:3bdf0d9bb71f 680 /**@}*/
akashvibhute 2:3bdf0d9bb71f 681 /**
akashvibhute 2:3bdf0d9bb71f 682 * @name Optional Configurators
akashvibhute 2:3bdf0d9bb71f 683 *
akashvibhute 2:3bdf0d9bb71f 684 * Methods you can use to get or set the configuration of the chip.
akashvibhute 2:3bdf0d9bb71f 685 * None are required. Calling begin() sets up a reasonable set of
akashvibhute 2:3bdf0d9bb71f 686 * defaults.
akashvibhute 2:3bdf0d9bb71f 687 */
akashvibhute 2:3bdf0d9bb71f 688 /**@{*/
akashvibhute 2:3bdf0d9bb71f 689
akashvibhute 2:3bdf0d9bb71f 690 /**
akashvibhute 2:3bdf0d9bb71f 691 * Set the address width from 3 to 5 bytes (24, 32 or 40 bit)
akashvibhute 2:3bdf0d9bb71f 692 *
akashvibhute 2:3bdf0d9bb71f 693 * @param a_width The address width to use: 3,4 or 5
akashvibhute 2:3bdf0d9bb71f 694 */
akashvibhute 2:3bdf0d9bb71f 695
akashvibhute 2:3bdf0d9bb71f 696 void setAddressWidth(uint8_t a_width);
akashvibhute 2:3bdf0d9bb71f 697
akashvibhute 2:3bdf0d9bb71f 698 /**
akashvibhute 2:3bdf0d9bb71f 699 * Set the number and delay of retries upon failed submit
akashvibhute 2:3bdf0d9bb71f 700 *
akashvibhute 2:3bdf0d9bb71f 701 * @param delay How long to wait between each retry, in multiples of 250us,
akashvibhute 2:3bdf0d9bb71f 702 * max is 15. 0 means 250us, 15 means 4000us.
akashvibhute 2:3bdf0d9bb71f 703 * @param count How many retries before giving up, max 15
akashvibhute 2:3bdf0d9bb71f 704 */
akashvibhute 2:3bdf0d9bb71f 705 void setRetries(uint8_t delay, uint8_t count);
akashvibhute 2:3bdf0d9bb71f 706
akashvibhute 2:3bdf0d9bb71f 707 /**
akashvibhute 2:3bdf0d9bb71f 708 * Set RF communication channel
akashvibhute 2:3bdf0d9bb71f 709 *
akashvibhute 2:3bdf0d9bb71f 710 * @param channel Which RF channel to communicate on, 0-127
akashvibhute 2:3bdf0d9bb71f 711 */
akashvibhute 2:3bdf0d9bb71f 712 void setChannel(uint8_t channel);
akashvibhute 2:3bdf0d9bb71f 713
akashvibhute 2:3bdf0d9bb71f 714 /**
akashvibhute 2:3bdf0d9bb71f 715 * Get RF communication channel
akashvibhute 2:3bdf0d9bb71f 716 *
akashvibhute 2:3bdf0d9bb71f 717 * @return The currently configured RF Channel
akashvibhute 2:3bdf0d9bb71f 718 */
akashvibhute 2:3bdf0d9bb71f 719 uint8_t getChannel(void);
akashvibhute 2:3bdf0d9bb71f 720
akashvibhute 2:3bdf0d9bb71f 721 /**
akashvibhute 2:3bdf0d9bb71f 722 * Set Static Payload Size
akashvibhute 2:3bdf0d9bb71f 723 *
akashvibhute 2:3bdf0d9bb71f 724 * This implementation uses a pre-stablished fixed payload size for all
akashvibhute 2:3bdf0d9bb71f 725 * transmissions. If this method is never called, the driver will always
akashvibhute 2:3bdf0d9bb71f 726 * transmit the maximum payload size (32 bytes), no matter how much
akashvibhute 2:3bdf0d9bb71f 727 * was sent to write().
akashvibhute 2:3bdf0d9bb71f 728 *
akashvibhute 2:3bdf0d9bb71f 729 * @todo Implement variable-sized payloads feature
akashvibhute 2:3bdf0d9bb71f 730 *
akashvibhute 2:3bdf0d9bb71f 731 * @param size The number of bytes in the payload
akashvibhute 2:3bdf0d9bb71f 732 */
akashvibhute 2:3bdf0d9bb71f 733 void setPayloadSize(uint8_t size);
akashvibhute 2:3bdf0d9bb71f 734
akashvibhute 2:3bdf0d9bb71f 735 /**
akashvibhute 2:3bdf0d9bb71f 736 * Get Static Payload Size
akashvibhute 2:3bdf0d9bb71f 737 *
akashvibhute 2:3bdf0d9bb71f 738 * @see setPayloadSize()
akashvibhute 2:3bdf0d9bb71f 739 *
akashvibhute 2:3bdf0d9bb71f 740 * @return The number of bytes in the payload
akashvibhute 2:3bdf0d9bb71f 741 */
akashvibhute 2:3bdf0d9bb71f 742 uint8_t getPayloadSize(void);
akashvibhute 2:3bdf0d9bb71f 743
akashvibhute 2:3bdf0d9bb71f 744 /**
akashvibhute 2:3bdf0d9bb71f 745 * Get Dynamic Payload Size
akashvibhute 2:3bdf0d9bb71f 746 *
akashvibhute 2:3bdf0d9bb71f 747 * For dynamic payloads, this pulls the size of the payload off
akashvibhute 2:3bdf0d9bb71f 748 * the chip
akashvibhute 2:3bdf0d9bb71f 749 *
akashvibhute 2:3bdf0d9bb71f 750 * @note Corrupt packets are now detected and flushed per the
akashvibhute 2:3bdf0d9bb71f 751 * manufacturer.
akashvibhute 2:3bdf0d9bb71f 752 * @code
akashvibhute 2:3bdf0d9bb71f 753 * if(radio.available()){
akashvibhute 2:3bdf0d9bb71f 754 * if(radio.getDynamicPayloadSize() < 1){
akashvibhute 2:3bdf0d9bb71f 755 * // Corrupt payload has been flushed
akashvibhute 2:3bdf0d9bb71f 756 * return;
akashvibhute 2:3bdf0d9bb71f 757 * }
akashvibhute 2:3bdf0d9bb71f 758 * radio.read(&data,sizeof(data));
akashvibhute 2:3bdf0d9bb71f 759 * }
akashvibhute 2:3bdf0d9bb71f 760 * @endcode
akashvibhute 2:3bdf0d9bb71f 761 *
akashvibhute 2:3bdf0d9bb71f 762 * @return Payload length of last-received dynamic payload
akashvibhute 2:3bdf0d9bb71f 763 */
akashvibhute 2:3bdf0d9bb71f 764 uint8_t getDynamicPayloadSize(void);
akashvibhute 2:3bdf0d9bb71f 765
akashvibhute 2:3bdf0d9bb71f 766 /**
akashvibhute 2:3bdf0d9bb71f 767 * Enable custom payloads on the acknowledge packets
akashvibhute 2:3bdf0d9bb71f 768 *
akashvibhute 2:3bdf0d9bb71f 769 * Ack payloads are a handy way to return data back to senders without
akashvibhute 2:3bdf0d9bb71f 770 * manually changing the radio modes on both units.
akashvibhute 2:3bdf0d9bb71f 771 *
akashvibhute 2:3bdf0d9bb71f 772 * @note Ack payloads are dynamic payloads. This only works on pipes 0&1 by default. Call
akashvibhute 2:3bdf0d9bb71f 773 * enableDynamicPayloads() to enable on all pipes.
akashvibhute 2:3bdf0d9bb71f 774 */
akashvibhute 2:3bdf0d9bb71f 775 void enableAckPayload(void);
akashvibhute 2:3bdf0d9bb71f 776
akashvibhute 2:3bdf0d9bb71f 777 /**
akashvibhute 2:3bdf0d9bb71f 778 * Enable dynamically-sized payloads
akashvibhute 2:3bdf0d9bb71f 779 *
akashvibhute 2:3bdf0d9bb71f 780 * This way you don't always have to send large packets just to send them
akashvibhute 2:3bdf0d9bb71f 781 * once in a while. This enables dynamic payloads on ALL pipes.
akashvibhute 2:3bdf0d9bb71f 782 *
akashvibhute 2:3bdf0d9bb71f 783 */
akashvibhute 2:3bdf0d9bb71f 784 void enableDynamicPayloads(void);
akashvibhute 2:3bdf0d9bb71f 785
akashvibhute 2:3bdf0d9bb71f 786 /**
akashvibhute 2:3bdf0d9bb71f 787 * Enable dynamic ACKs (single write multicast or unicast) for chosen messages
akashvibhute 2:3bdf0d9bb71f 788 *
akashvibhute 2:3bdf0d9bb71f 789 * @note To enable full multicast or per-pipe multicast, use setAutoAck()
akashvibhute 2:3bdf0d9bb71f 790 *
akashvibhute 2:3bdf0d9bb71f 791 * @warning This MUST be called prior to attempting single write NOACK calls
akashvibhute 2:3bdf0d9bb71f 792 * @code
akashvibhute 2:3bdf0d9bb71f 793 * radio.enableDynamicAck();
akashvibhute 2:3bdf0d9bb71f 794 * radio.write(&data,32,1); // Sends a payload with no acknowledgement requested
akashvibhute 2:3bdf0d9bb71f 795 * radio.write(&data,32,0); // Sends a payload using auto-retry/autoACK
akashvibhute 2:3bdf0d9bb71f 796 * @endcode
akashvibhute 2:3bdf0d9bb71f 797 */
akashvibhute 2:3bdf0d9bb71f 798 void enableDynamicAck();
akashvibhute 2:3bdf0d9bb71f 799
akashvibhute 2:3bdf0d9bb71f 800 /**
akashvibhute 2:3bdf0d9bb71f 801 * Determine whether the hardware is an nRF24L01+ or not.
akashvibhute 2:3bdf0d9bb71f 802 *
akashvibhute 2:3bdf0d9bb71f 803 * @return true if the hardware is nRF24L01+ (or compatible) and false
akashvibhute 2:3bdf0d9bb71f 804 * if its not.
akashvibhute 2:3bdf0d9bb71f 805 */
akashvibhute 2:3bdf0d9bb71f 806 bool isPVariant(void) ;
akashvibhute 2:3bdf0d9bb71f 807
akashvibhute 2:3bdf0d9bb71f 808 /**
akashvibhute 2:3bdf0d9bb71f 809 * Enable or disable auto-acknowlede packets
akashvibhute 2:3bdf0d9bb71f 810 *
akashvibhute 2:3bdf0d9bb71f 811 * This is enabled by default, so it's only needed if you want to turn
akashvibhute 2:3bdf0d9bb71f 812 * it off for some reason.
akashvibhute 2:3bdf0d9bb71f 813 *
akashvibhute 2:3bdf0d9bb71f 814 * @param enable Whether to enable (true) or disable (false) auto-acks
akashvibhute 2:3bdf0d9bb71f 815 */
akashvibhute 2:3bdf0d9bb71f 816 void setAutoAck(bool enable);
akashvibhute 2:3bdf0d9bb71f 817
akashvibhute 2:3bdf0d9bb71f 818 /**
akashvibhute 2:3bdf0d9bb71f 819 * Enable or disable auto-acknowlede packets on a per pipeline basis.
akashvibhute 2:3bdf0d9bb71f 820 *
akashvibhute 2:3bdf0d9bb71f 821 * AA is enabled by default, so it's only needed if you want to turn
akashvibhute 2:3bdf0d9bb71f 822 * it off/on for some reason on a per pipeline basis.
akashvibhute 2:3bdf0d9bb71f 823 *
akashvibhute 2:3bdf0d9bb71f 824 * @param pipe Which pipeline to modify
akashvibhute 2:3bdf0d9bb71f 825 * @param enable Whether to enable (true) or disable (false) auto-acks
akashvibhute 2:3bdf0d9bb71f 826 */
akashvibhute 2:3bdf0d9bb71f 827 void setAutoAck( uint8_t pipe, bool enable ) ;
akashvibhute 2:3bdf0d9bb71f 828
akashvibhute 2:3bdf0d9bb71f 829 /**
akashvibhute 2:3bdf0d9bb71f 830 * Set Power Amplifier (PA) level to one of four levels:
akashvibhute 2:3bdf0d9bb71f 831 * RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
akashvibhute 2:3bdf0d9bb71f 832 *
akashvibhute 2:3bdf0d9bb71f 833 * The power levels correspond to the following output levels respectively:
akashvibhute 2:3bdf0d9bb71f 834 * NRF24L01: -18dBm, -12dBm,-6dBM, and 0dBm
akashvibhute 2:3bdf0d9bb71f 835 *
akashvibhute 2:3bdf0d9bb71f 836 * SI24R1: -6dBm, 0dBm, 3dBM, and 7dBm.
akashvibhute 2:3bdf0d9bb71f 837 *
akashvibhute 2:3bdf0d9bb71f 838 * @param level Desired PA level.
akashvibhute 2:3bdf0d9bb71f 839 */
akashvibhute 2:3bdf0d9bb71f 840 void setPALevel ( uint8_t level );
akashvibhute 2:3bdf0d9bb71f 841
akashvibhute 2:3bdf0d9bb71f 842 /**
akashvibhute 2:3bdf0d9bb71f 843 * Fetches the current PA level.
akashvibhute 2:3bdf0d9bb71f 844 *
akashvibhute 2:3bdf0d9bb71f 845 * NRF24L01: -18dBm, -12dBm, -6dBm and 0dBm
akashvibhute 2:3bdf0d9bb71f 846 * SI24R1: -6dBm, 0dBm, 3dBm, 7dBm
akashvibhute 2:3bdf0d9bb71f 847 *
akashvibhute 2:3bdf0d9bb71f 848 * @return Returns values 0 to 3 representing the PA Level.
akashvibhute 2:3bdf0d9bb71f 849 */
akashvibhute 2:3bdf0d9bb71f 850 uint8_t getPALevel( void );
akashvibhute 2:3bdf0d9bb71f 851
akashvibhute 2:3bdf0d9bb71f 852 /**
akashvibhute 2:3bdf0d9bb71f 853 * Set the transmission data rate
akashvibhute 2:3bdf0d9bb71f 854 *
akashvibhute 2:3bdf0d9bb71f 855 * @warning setting RF24_250KBPS will fail for non-plus units
akashvibhute 2:3bdf0d9bb71f 856 *
akashvibhute 2:3bdf0d9bb71f 857 * @param speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
akashvibhute 2:3bdf0d9bb71f 858 * @return true if the change was successful
akashvibhute 2:3bdf0d9bb71f 859 */
akashvibhute 2:3bdf0d9bb71f 860 bool setDataRate(rf24_datarate_e speed);
akashvibhute 2:3bdf0d9bb71f 861
akashvibhute 2:3bdf0d9bb71f 862 /**
akashvibhute 2:3bdf0d9bb71f 863 * Fetches the transmission data rate
akashvibhute 2:3bdf0d9bb71f 864 *
akashvibhute 2:3bdf0d9bb71f 865 * @return Returns the hardware's currently configured datarate. The value
akashvibhute 2:3bdf0d9bb71f 866 * is one of 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS, as defined in the
akashvibhute 2:3bdf0d9bb71f 867 * rf24_datarate_e enum.
akashvibhute 2:3bdf0d9bb71f 868 */
akashvibhute 2:3bdf0d9bb71f 869 rf24_datarate_e getDataRate( void ) ;
akashvibhute 2:3bdf0d9bb71f 870
akashvibhute 2:3bdf0d9bb71f 871 /**
akashvibhute 2:3bdf0d9bb71f 872 * Set the CRC length
akashvibhute 2:3bdf0d9bb71f 873 *
akashvibhute 2:3bdf0d9bb71f 874 * @param length RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit
akashvibhute 2:3bdf0d9bb71f 875 */
akashvibhute 2:3bdf0d9bb71f 876 void setCRCLength(rf24_crclength_e length);
akashvibhute 2:3bdf0d9bb71f 877
akashvibhute 2:3bdf0d9bb71f 878 /**
akashvibhute 2:3bdf0d9bb71f 879 * Get the CRC length
akashvibhute 2:3bdf0d9bb71f 880 *
akashvibhute 2:3bdf0d9bb71f 881 * @return RF24_DISABLED if disabled or RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit
akashvibhute 2:3bdf0d9bb71f 882 */
akashvibhute 2:3bdf0d9bb71f 883 rf24_crclength_e getCRCLength(void);
akashvibhute 2:3bdf0d9bb71f 884
akashvibhute 2:3bdf0d9bb71f 885 /**
akashvibhute 2:3bdf0d9bb71f 886 * Disable CRC validation
akashvibhute 2:3bdf0d9bb71f 887 *
akashvibhute 2:3bdf0d9bb71f 888 * @warning CRC cannot be disabled if auto-ack/ESB is enabled.
akashvibhute 2:3bdf0d9bb71f 889 */
akashvibhute 2:3bdf0d9bb71f 890 void disableCRC( void ) ;
akashvibhute 2:3bdf0d9bb71f 891
akashvibhute 2:3bdf0d9bb71f 892 /**
akashvibhute 2:3bdf0d9bb71f 893 * The radio will generate interrupt signals when a transmission is complete,
akashvibhute 2:3bdf0d9bb71f 894 * a transmission fails, or a payload is received. This allows users to mask
akashvibhute 2:3bdf0d9bb71f 895 * those interrupts to prevent them from generating a signal on the interrupt
akashvibhute 2:3bdf0d9bb71f 896 * pin. Interrupts are enabled on the radio chip by default.
akashvibhute 2:3bdf0d9bb71f 897 *
akashvibhute 2:3bdf0d9bb71f 898 * @code
akashvibhute 2:3bdf0d9bb71f 899 * Mask all interrupts except the receive interrupt:
akashvibhute 2:3bdf0d9bb71f 900 *
akashvibhute 2:3bdf0d9bb71f 901 * radio.maskIRQ(1,1,0);
akashvibhute 2:3bdf0d9bb71f 902 * @endcode
akashvibhute 2:3bdf0d9bb71f 903 *
akashvibhute 2:3bdf0d9bb71f 904 * @param tx_ok Mask transmission complete interrupts
akashvibhute 2:3bdf0d9bb71f 905 * @param tx_fail Mask transmit failure interrupts
akashvibhute 2:3bdf0d9bb71f 906 * @param rx_ready Mask payload received interrupts
akashvibhute 2:3bdf0d9bb71f 907 */
akashvibhute 2:3bdf0d9bb71f 908 void maskIRQ(bool tx_ok,bool tx_fail,bool rx_ready);
akashvibhute 2:3bdf0d9bb71f 909
akashvibhute 2:3bdf0d9bb71f 910 /**@}*/
akashvibhute 2:3bdf0d9bb71f 911 /**
akashvibhute 2:3bdf0d9bb71f 912 * @name Deprecated
akashvibhute 2:3bdf0d9bb71f 913 *
akashvibhute 2:3bdf0d9bb71f 914 * Methods provided for backwards compabibility.
akashvibhute 2:3bdf0d9bb71f 915 */
akashvibhute 2:3bdf0d9bb71f 916 /**@{*/
akashvibhute 2:3bdf0d9bb71f 917
akashvibhute 2:3bdf0d9bb71f 918
akashvibhute 2:3bdf0d9bb71f 919 /**
akashvibhute 2:3bdf0d9bb71f 920 * Open a pipe for reading
akashvibhute 2:3bdf0d9bb71f 921 * @note For compatibility with old code only, see new function
akashvibhute 2:3bdf0d9bb71f 922 *
akashvibhute 2:3bdf0d9bb71f 923 * @warning Pipes 1-5 should share the first 32 bits.
akashvibhute 2:3bdf0d9bb71f 924 * Only the least significant byte should be unique, e.g.
akashvibhute 2:3bdf0d9bb71f 925 * @code
akashvibhute 2:3bdf0d9bb71f 926 * openReadingPipe(1,0xF0F0F0F0AA);
akashvibhute 2:3bdf0d9bb71f 927 * openReadingPipe(2,0xF0F0F0F066);
akashvibhute 2:3bdf0d9bb71f 928 * @endcode
akashvibhute 2:3bdf0d9bb71f 929 *
akashvibhute 2:3bdf0d9bb71f 930 * @warning Pipe 0 is also used by the writing pipe. So if you open
akashvibhute 2:3bdf0d9bb71f 931 * pipe 0 for reading, and then startListening(), it will overwrite the
akashvibhute 2:3bdf0d9bb71f 932 * writing pipe. Ergo, do an openWritingPipe() again before write().
akashvibhute 2:3bdf0d9bb71f 933 *
akashvibhute 2:3bdf0d9bb71f 934 * @param number Which pipe# to open, 0-5.
akashvibhute 2:3bdf0d9bb71f 935 * @param address The 40-bit address of the pipe to open.
akashvibhute 2:3bdf0d9bb71f 936 */
akashvibhute 2:3bdf0d9bb71f 937 void openReadingPipe(uint8_t number, uint64_t address);
akashvibhute 2:3bdf0d9bb71f 938
akashvibhute 2:3bdf0d9bb71f 939 /**
akashvibhute 2:3bdf0d9bb71f 940 * Open a pipe for writing
akashvibhute 2:3bdf0d9bb71f 941 * @note For compatibility with old code only, see new function
akashvibhute 2:3bdf0d9bb71f 942 *
akashvibhute 2:3bdf0d9bb71f 943 * Addresses are 40-bit hex values, e.g.:
akashvibhute 2:3bdf0d9bb71f 944 *
akashvibhute 2:3bdf0d9bb71f 945 * @code
akashvibhute 2:3bdf0d9bb71f 946 * openWritingPipe(0xF0F0F0F0F0);
akashvibhute 2:3bdf0d9bb71f 947 * @endcode
akashvibhute 2:3bdf0d9bb71f 948 *
akashvibhute 2:3bdf0d9bb71f 949 * @param address The 40-bit address of the pipe to open.
akashvibhute 2:3bdf0d9bb71f 950 */
akashvibhute 2:3bdf0d9bb71f 951 void openWritingPipe(uint64_t address);
akashvibhute 2:3bdf0d9bb71f 952
akashvibhute 2:3bdf0d9bb71f 953 private:
akashvibhute 2:3bdf0d9bb71f 954
akashvibhute 2:3bdf0d9bb71f 955 /**
akashvibhute 0:bb74812ac6bb 956 * @name Low-level internal interface.
akashvibhute 0:bb74812ac6bb 957 *
akashvibhute 0:bb74812ac6bb 958 * Protected methods that address the chip directly. Regular users cannot
akashvibhute 0:bb74812ac6bb 959 * ever call these. They are documented for completeness and for developers who
akashvibhute 0:bb74812ac6bb 960 * may want to extend this class.
akashvibhute 0:bb74812ac6bb 961 */
akashvibhute 0:bb74812ac6bb 962 /**@{*/
akashvibhute 0:bb74812ac6bb 963
akashvibhute 0:bb74812ac6bb 964 /**
akashvibhute 0:bb74812ac6bb 965 * Set chip select pin
akashvibhute 0:bb74812ac6bb 966 *
akashvibhute 0:bb74812ac6bb 967 * Running SPI bus at PI_CLOCK_DIV2 so we don't waste time transferring data
akashvibhute 0:bb74812ac6bb 968 * and best of all, we make use of the radio's FIFO buffers. A lower speed
akashvibhute 0:bb74812ac6bb 969 * means we're less likely to effectively leverage our FIFOs and pay a higher
akashvibhute 0:bb74812ac6bb 970 * AVR runtime cost as toll.
akashvibhute 0:bb74812ac6bb 971 *
akashvibhute 0:bb74812ac6bb 972 * @param mode HIGH to take this unit off the SPI bus, LOW to put it on
akashvibhute 0:bb74812ac6bb 973 */
akashvibhute 2:3bdf0d9bb71f 974 void csn(bool mode);
akashvibhute 0:bb74812ac6bb 975
akashvibhute 0:bb74812ac6bb 976 /**
akashvibhute 0:bb74812ac6bb 977 * Set chip enable
akashvibhute 0:bb74812ac6bb 978 *
akashvibhute 0:bb74812ac6bb 979 * @param level HIGH to actively begin transmission or LOW to put in standby. Please see data sheet
akashvibhute 0:bb74812ac6bb 980 * for a much more detailed description of this pin.
akashvibhute 0:bb74812ac6bb 981 */
akashvibhute 2:3bdf0d9bb71f 982 void ce(bool level);
akashvibhute 0:bb74812ac6bb 983
akashvibhute 0:bb74812ac6bb 984 /**
akashvibhute 0:bb74812ac6bb 985 * Read a chunk of data in from a register
akashvibhute 0:bb74812ac6bb 986 *
akashvibhute 0:bb74812ac6bb 987 * @param reg Which register. Use constants from nRF24L01.h
akashvibhute 0:bb74812ac6bb 988 * @param buf Where to put the data
akashvibhute 0:bb74812ac6bb 989 * @param len How many bytes of data to transfer
akashvibhute 0:bb74812ac6bb 990 * @return Current value of status register
akashvibhute 0:bb74812ac6bb 991 */
akashvibhute 0:bb74812ac6bb 992 uint8_t read_register(uint8_t reg, uint8_t* buf, uint8_t len);
akashvibhute 0:bb74812ac6bb 993
akashvibhute 0:bb74812ac6bb 994 /**
akashvibhute 0:bb74812ac6bb 995 * Read single byte from a register
akashvibhute 0:bb74812ac6bb 996 *
akashvibhute 0:bb74812ac6bb 997 * @param reg Which register. Use constants from nRF24L01.h
akashvibhute 0:bb74812ac6bb 998 * @return Current value of register @p reg
akashvibhute 0:bb74812ac6bb 999 */
akashvibhute 0:bb74812ac6bb 1000 uint8_t read_register(uint8_t reg);
akashvibhute 0:bb74812ac6bb 1001
akashvibhute 0:bb74812ac6bb 1002 /**
akashvibhute 0:bb74812ac6bb 1003 * Write a chunk of data to a register
akashvibhute 0:bb74812ac6bb 1004 *
akashvibhute 0:bb74812ac6bb 1005 * @param reg Which register. Use constants from nRF24L01.h
akashvibhute 0:bb74812ac6bb 1006 * @param buf Where to get the data
akashvibhute 0:bb74812ac6bb 1007 * @param len How many bytes of data to transfer
akashvibhute 0:bb74812ac6bb 1008 * @return Current value of status register
akashvibhute 0:bb74812ac6bb 1009 */
akashvibhute 0:bb74812ac6bb 1010 uint8_t write_register(uint8_t reg, const uint8_t* buf, uint8_t len);
akashvibhute 0:bb74812ac6bb 1011
akashvibhute 0:bb74812ac6bb 1012 /**
akashvibhute 0:bb74812ac6bb 1013 * Write a single byte to a register
akashvibhute 0:bb74812ac6bb 1014 *
akashvibhute 0:bb74812ac6bb 1015 * @param reg Which register. Use constants from nRF24L01.h
akashvibhute 0:bb74812ac6bb 1016 * @param value The new value to write
akashvibhute 0:bb74812ac6bb 1017 * @return Current value of status register
akashvibhute 0:bb74812ac6bb 1018 */
akashvibhute 0:bb74812ac6bb 1019 uint8_t write_register(uint8_t reg, uint8_t value);
akashvibhute 0:bb74812ac6bb 1020
akashvibhute 0:bb74812ac6bb 1021 /**
akashvibhute 0:bb74812ac6bb 1022 * Write the transmit payload
akashvibhute 0:bb74812ac6bb 1023 *
akashvibhute 0:bb74812ac6bb 1024 * The size of data written is the fixed payload size, see getPayloadSize()
akashvibhute 0:bb74812ac6bb 1025 *
akashvibhute 0:bb74812ac6bb 1026 * @param buf Where to get the data
akashvibhute 0:bb74812ac6bb 1027 * @param len Number of bytes to be sent
akashvibhute 0:bb74812ac6bb 1028 * @return Current value of status register
akashvibhute 0:bb74812ac6bb 1029 */
akashvibhute 2:3bdf0d9bb71f 1030 uint8_t write_payload(const void* buf, uint8_t len, const uint8_t writeType);
akashvibhute 0:bb74812ac6bb 1031
akashvibhute 0:bb74812ac6bb 1032 /**
akashvibhute 0:bb74812ac6bb 1033 * Read the receive payload
akashvibhute 0:bb74812ac6bb 1034 *
akashvibhute 0:bb74812ac6bb 1035 * The size of data read is the fixed payload size, see getPayloadSize()
akashvibhute 0:bb74812ac6bb 1036 *
akashvibhute 0:bb74812ac6bb 1037 * @param buf Where to put the data
akashvibhute 0:bb74812ac6bb 1038 * @param len Maximum number of bytes to read
akashvibhute 0:bb74812ac6bb 1039 * @return Current value of status register
akashvibhute 0:bb74812ac6bb 1040 */
akashvibhute 0:bb74812ac6bb 1041 uint8_t read_payload(void* buf, uint8_t len);
akashvibhute 0:bb74812ac6bb 1042
akashvibhute 2:3bdf0d9bb71f 1043 /**
akashvibhute 2:3bdf0d9bb71f 1044 * Empty the receive buffer
akashvibhute 2:3bdf0d9bb71f 1045 *
akashvibhute 2:3bdf0d9bb71f 1046 * @return Current value of status register
akashvibhute 2:3bdf0d9bb71f 1047 */
akashvibhute 2:3bdf0d9bb71f 1048 uint8_t flush_rx(void);
akashvibhute 0:bb74812ac6bb 1049
akashvibhute 0:bb74812ac6bb 1050 /**
akashvibhute 2:3bdf0d9bb71f 1051 * Retrieve the current status of the chip
akashvibhute 2:3bdf0d9bb71f 1052 *
akashvibhute 2:3bdf0d9bb71f 1053 * @return Current value of status register
akashvibhute 2:3bdf0d9bb71f 1054 */
akashvibhute 2:3bdf0d9bb71f 1055 uint8_t get_status(void);
akashvibhute 2:3bdf0d9bb71f 1056
akashvibhute 2:3bdf0d9bb71f 1057 #if !defined (MINIMAL)
akashvibhute 2:3bdf0d9bb71f 1058 /**
akashvibhute 0:bb74812ac6bb 1059 * Decode and print the given status to stdout
akashvibhute 0:bb74812ac6bb 1060 *
akashvibhute 0:bb74812ac6bb 1061 * @param status Status value to print
akashvibhute 0:bb74812ac6bb 1062 *
akashvibhute 0:bb74812ac6bb 1063 * @warning Does nothing if stdout is not defined. See fdevopen in stdio.h
akashvibhute 0:bb74812ac6bb 1064 */
akashvibhute 0:bb74812ac6bb 1065 void print_status(uint8_t status);
akashvibhute 0:bb74812ac6bb 1066
akashvibhute 0:bb74812ac6bb 1067 /**
akashvibhute 0:bb74812ac6bb 1068 * Decode and print the given 'observe_tx' value to stdout
akashvibhute 0:bb74812ac6bb 1069 *
akashvibhute 0:bb74812ac6bb 1070 * @param value The observe_tx value to print
akashvibhute 0:bb74812ac6bb 1071 *
akashvibhute 0:bb74812ac6bb 1072 * @warning Does nothing if stdout is not defined. See fdevopen in stdio.h
akashvibhute 0:bb74812ac6bb 1073 */
akashvibhute 0:bb74812ac6bb 1074 void print_observe_tx(uint8_t value);
akashvibhute 0:bb74812ac6bb 1075
akashvibhute 0:bb74812ac6bb 1076 /**
akashvibhute 0:bb74812ac6bb 1077 * Print the name and value of an 8-bit register to stdout
akashvibhute 0:bb74812ac6bb 1078 *
akashvibhute 0:bb74812ac6bb 1079 * Optionally it can print some quantity of successive
akashvibhute 0:bb74812ac6bb 1080 * registers on the same line. This is useful for printing a group
akashvibhute 0:bb74812ac6bb 1081 * of related registers on one line.
akashvibhute 0:bb74812ac6bb 1082 *
akashvibhute 0:bb74812ac6bb 1083 * @param name Name of the register
akashvibhute 0:bb74812ac6bb 1084 * @param reg Which register. Use constants from nRF24L01.h
akashvibhute 0:bb74812ac6bb 1085 * @param qty How many successive registers to print
akashvibhute 0:bb74812ac6bb 1086 */
akashvibhute 0:bb74812ac6bb 1087 void print_byte_register(const char* name, uint8_t reg, uint8_t qty = 1);
akashvibhute 0:bb74812ac6bb 1088
akashvibhute 0:bb74812ac6bb 1089 /**
akashvibhute 0:bb74812ac6bb 1090 * Print the name and value of a 40-bit address register to stdout
akashvibhute 0:bb74812ac6bb 1091 *
akashvibhute 0:bb74812ac6bb 1092 * Optionally it can print some quantity of successive
akashvibhute 0:bb74812ac6bb 1093 * registers on the same line. This is useful for printing a group
akashvibhute 0:bb74812ac6bb 1094 * of related registers on one line.
akashvibhute 0:bb74812ac6bb 1095 *
akashvibhute 0:bb74812ac6bb 1096 * @param name Name of the register
akashvibhute 0:bb74812ac6bb 1097 * @param reg Which register. Use constants from nRF24L01.h
akashvibhute 0:bb74812ac6bb 1098 * @param qty How many successive registers to print
akashvibhute 0:bb74812ac6bb 1099 */
akashvibhute 0:bb74812ac6bb 1100 void print_address_register(const char* name, uint8_t reg, uint8_t qty = 1);
akashvibhute 2:3bdf0d9bb71f 1101 #endif
akashvibhute 0:bb74812ac6bb 1102 /**
akashvibhute 0:bb74812ac6bb 1103 * Turn on or off the special features of the chip
akashvibhute 0:bb74812ac6bb 1104 *
akashvibhute 0:bb74812ac6bb 1105 * The chip has certain 'features' which are only available when the 'features'
akashvibhute 0:bb74812ac6bb 1106 * are enabled. See the datasheet for details.
akashvibhute 0:bb74812ac6bb 1107 */
akashvibhute 0:bb74812ac6bb 1108 void toggle_features(void);
akashvibhute 0:bb74812ac6bb 1109
akashvibhute 0:bb74812ac6bb 1110 /**
akashvibhute 2:3bdf0d9bb71f 1111 * Built in spi transfer function to simplify repeating code repeating code
akashvibhute 0:bb74812ac6bb 1112 */
akashvibhute 0:bb74812ac6bb 1113
akashvibhute 2:3bdf0d9bb71f 1114 uint8_t spiTrans(uint8_t cmd);
akashvibhute 0:bb74812ac6bb 1115
akashvibhute 2:3bdf0d9bb71f 1116 #if defined (FAILURE_HANDLING) || defined (RF24_LINUX)
akashvibhute 2:3bdf0d9bb71f 1117 void errNotify(void);
akashvibhute 2:3bdf0d9bb71f 1118 #endif
akashvibhute 2:3bdf0d9bb71f 1119
akashvibhute 0:bb74812ac6bb 1120 /**@}*/
akashvibhute 0:bb74812ac6bb 1121
akashvibhute 0:bb74812ac6bb 1122 };
akashvibhute 0:bb74812ac6bb 1123
akashvibhute 0:bb74812ac6bb 1124
akashvibhute 2:3bdf0d9bb71f 1125 /**
akashvibhute 2:3bdf0d9bb71f 1126 * @example GettingStarted.ino
akashvibhute 2:3bdf0d9bb71f 1127 * <b>For Arduino</b><br>
akashvibhute 2:3bdf0d9bb71f 1128 * <b>Updated: TMRh20 2014 </b><br>
akashvibhute 2:3bdf0d9bb71f 1129 *
akashvibhute 2:3bdf0d9bb71f 1130 * This is an example of how to use the RF24 class to communicate on a basic level. Configure and write this sketch to two
akashvibhute 2:3bdf0d9bb71f 1131 * different nodes. Put one of the nodes into 'transmit' mode by connecting with the serial monitor and <br>
akashvibhute 2:3bdf0d9bb71f 1132 * sending a 'T'. The ping node sends the current time to the pong node, which responds by sending the value
akashvibhute 2:3bdf0d9bb71f 1133 * back. The ping node can then see how long the whole cycle took. <br>
akashvibhute 2:3bdf0d9bb71f 1134 * @note For a more efficient call-response scenario see the GettingStarted_CallResponse.ino example.
akashvibhute 2:3bdf0d9bb71f 1135 * @note When switching between sketches, the radio may need to be powered down to clear settings that are not "un-set" otherwise
akashvibhute 2:3bdf0d9bb71f 1136 */
akashvibhute 2:3bdf0d9bb71f 1137
akashvibhute 2:3bdf0d9bb71f 1138 /**
akashvibhute 2:3bdf0d9bb71f 1139 * @example GettingStarted.cpp
akashvibhute 2:3bdf0d9bb71f 1140 * <b>For Raspberry Pi</b><br>
akashvibhute 2:3bdf0d9bb71f 1141 * <b>Updated: TMRh20 2014 </b><br>
akashvibhute 2:3bdf0d9bb71f 1142 *
akashvibhute 2:3bdf0d9bb71f 1143 * This is an example of how to use the RF24 class to communicate on a basic level. Configure and write this sketch to two
akashvibhute 2:3bdf0d9bb71f 1144 * different nodes. Put one of the nodes into 'transmit' mode by connecting with the serial monitor and <br>
akashvibhute 2:3bdf0d9bb71f 1145 * sending a 'T'. The ping node sends the current time to the pong node, which responds by sending the value
akashvibhute 2:3bdf0d9bb71f 1146 * back. The ping node can then see how long the whole cycle took. <br>
akashvibhute 2:3bdf0d9bb71f 1147 * @note For a more efficient call-response scenario see the GettingStarted_CallResponse.ino example.
akashvibhute 2:3bdf0d9bb71f 1148 */
akashvibhute 2:3bdf0d9bb71f 1149
akashvibhute 2:3bdf0d9bb71f 1150 /**
akashvibhute 2:3bdf0d9bb71f 1151 * @example GettingStarted_CallResponse.ino
akashvibhute 2:3bdf0d9bb71f 1152 * <b>For Arduino</b><br>
akashvibhute 2:3bdf0d9bb71f 1153 * <b>New: TMRh20 2014</b><br>
akashvibhute 2:3bdf0d9bb71f 1154 *
akashvibhute 2:3bdf0d9bb71f 1155 * This example continues to make use of all the normal functionality of the radios including
akashvibhute 2:3bdf0d9bb71f 1156 * the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well. <br>
akashvibhute 2:3bdf0d9bb71f 1157 * This allows very fast call-response communication, with the responding radio never having to
akashvibhute 2:3bdf0d9bb71f 1158 * switch out of Primary Receiver mode to send back a payload, but having the option to switch to <br>
akashvibhute 2:3bdf0d9bb71f 1159 * primary transmitter if wanting to initiate communication instead of respond to a commmunication.
akashvibhute 2:3bdf0d9bb71f 1160 */
akashvibhute 2:3bdf0d9bb71f 1161
akashvibhute 2:3bdf0d9bb71f 1162 /**
akashvibhute 2:3bdf0d9bb71f 1163 * @example GettingStarted_Call_Response.cpp
akashvibhute 2:3bdf0d9bb71f 1164 * <b>For Raspberry Pi</b><br>
akashvibhute 2:3bdf0d9bb71f 1165 * <b>New: TMRh20 2014</b><br>
akashvibhute 2:3bdf0d9bb71f 1166 *
akashvibhute 2:3bdf0d9bb71f 1167 * This example continues to make use of all the normal functionality of the radios including
akashvibhute 2:3bdf0d9bb71f 1168 * the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well. <br>
akashvibhute 2:3bdf0d9bb71f 1169 * This allows very fast call-response communication, with the responding radio never having to
akashvibhute 2:3bdf0d9bb71f 1170 * switch out of Primary Receiver mode to send back a payload, but having the option to switch to <br>
akashvibhute 2:3bdf0d9bb71f 1171 * primary transmitter if wanting to initiate communication instead of respond to a commmunication.
akashvibhute 2:3bdf0d9bb71f 1172 */
akashvibhute 2:3bdf0d9bb71f 1173
akashvibhute 2:3bdf0d9bb71f 1174 /**
akashvibhute 2:3bdf0d9bb71f 1175 * @example GettingStarted_HandlingData.ino
akashvibhute 2:3bdf0d9bb71f 1176 * <b>Dec 2014 - TMRh20</b><br>
akashvibhute 2:3bdf0d9bb71f 1177 *
akashvibhute 2:3bdf0d9bb71f 1178 * This example demonstrates how to send multiple variables in a single payload and work with data. As usual, it is
akashvibhute 2:3bdf0d9bb71f 1179 * generally important to include an incrementing value like millis() in the payloads to prevent errors.
akashvibhute 2:3bdf0d9bb71f 1180 */
akashvibhute 2:3bdf0d9bb71f 1181
akashvibhute 2:3bdf0d9bb71f 1182 /**
akashvibhute 2:3bdf0d9bb71f 1183 * @example Transfer.ino
akashvibhute 2:3bdf0d9bb71f 1184 * <b>For Arduino</b><br>
akashvibhute 2:3bdf0d9bb71f 1185 * This example demonstrates half-rate transfer using the FIFO buffers<br>
akashvibhute 2:3bdf0d9bb71f 1186 *
akashvibhute 2:3bdf0d9bb71f 1187 * It is an example of how to use the RF24 class. Write this sketch to two
akashvibhute 2:3bdf0d9bb71f 1188 * different nodes. Put one of the nodes into 'transmit' mode by connecting <br>
akashvibhute 2:3bdf0d9bb71f 1189 * with the serial monitor and sending a 'T'. The data transfer will begin,
akashvibhute 2:3bdf0d9bb71f 1190 * with the receiver displaying the payload count. (32Byte Payloads) <br>
akashvibhute 2:3bdf0d9bb71f 1191 */
akashvibhute 2:3bdf0d9bb71f 1192
akashvibhute 2:3bdf0d9bb71f 1193 /**
akashvibhute 2:3bdf0d9bb71f 1194 * @example Transfer.cpp
akashvibhute 2:3bdf0d9bb71f 1195 * <b>For Raspberry Pi</b><br>
akashvibhute 2:3bdf0d9bb71f 1196 * This example demonstrates half-rate transfer using the FIFO buffers<br>
akashvibhute 2:3bdf0d9bb71f 1197 *
akashvibhute 2:3bdf0d9bb71f 1198 * It is an example of how to use the RF24 class. Write this sketch to two
akashvibhute 2:3bdf0d9bb71f 1199 * different nodes. Put one of the nodes into 'transmit' mode by connecting <br>
akashvibhute 2:3bdf0d9bb71f 1200 * with the serial monitor and sending a 'T'. The data transfer will begin,
akashvibhute 2:3bdf0d9bb71f 1201 * with the receiver displaying the payload count. (32Byte Payloads) <br>
akashvibhute 2:3bdf0d9bb71f 1202 */
akashvibhute 2:3bdf0d9bb71f 1203
akashvibhute 2:3bdf0d9bb71f 1204 /**
akashvibhute 2:3bdf0d9bb71f 1205 * @example TransferTimeouts.ino
akashvibhute 2:3bdf0d9bb71f 1206 * <b>New: TMRh20 </b><br>
akashvibhute 2:3bdf0d9bb71f 1207 * This example demonstrates the use of and extended timeout period and
akashvibhute 2:3bdf0d9bb71f 1208 * auto-retries/auto-reUse to increase reliability in noisy or low signal scenarios. <br>
akashvibhute 2:3bdf0d9bb71f 1209 *
akashvibhute 2:3bdf0d9bb71f 1210 * Write this sketch to two different nodes. Put one of the nodes into 'transmit'
akashvibhute 2:3bdf0d9bb71f 1211 * mode by connecting with the serial monitor and sending a 'T'. The data <br>
akashvibhute 2:3bdf0d9bb71f 1212 * transfer will begin, with the receiver displaying the payload count and the
akashvibhute 2:3bdf0d9bb71f 1213 * data transfer rate.
akashvibhute 2:3bdf0d9bb71f 1214 */
akashvibhute 2:3bdf0d9bb71f 1215
akashvibhute 2:3bdf0d9bb71f 1216 /**
akashvibhute 2:3bdf0d9bb71f 1217 * @example starping.pde
akashvibhute 2:3bdf0d9bb71f 1218 *
akashvibhute 2:3bdf0d9bb71f 1219 * This sketch is a more complex example of using the RF24 library for Arduino.
akashvibhute 2:3bdf0d9bb71f 1220 * Deploy this on up to six nodes. Set one as the 'pong receiver' by tying the
akashvibhute 2:3bdf0d9bb71f 1221 * role_pin low, and the others will be 'ping transmit' units. The ping units
akashvibhute 2:3bdf0d9bb71f 1222 * unit will send out the value of millis() once a second. The pong unit will
akashvibhute 2:3bdf0d9bb71f 1223 * respond back with a copy of the value. Each ping unit can get that response
akashvibhute 2:3bdf0d9bb71f 1224 * back, and determine how long the whole cycle took.
akashvibhute 2:3bdf0d9bb71f 1225 *
akashvibhute 2:3bdf0d9bb71f 1226 * This example requires a bit more complexity to determine which unit is which.
akashvibhute 2:3bdf0d9bb71f 1227 * The pong receiver is identified by having its role_pin tied to ground.
akashvibhute 2:3bdf0d9bb71f 1228 * The ping senders are further differentiated by a byte in eeprom.
akashvibhute 2:3bdf0d9bb71f 1229 */
akashvibhute 2:3bdf0d9bb71f 1230
akashvibhute 2:3bdf0d9bb71f 1231 /**
akashvibhute 2:3bdf0d9bb71f 1232 * @example pingpair_ack.ino
akashvibhute 2:3bdf0d9bb71f 1233 * <b>Update: TMRh20</b><br>
akashvibhute 2:3bdf0d9bb71f 1234 * This example continues to make use of all the normal functionality of the radios including
akashvibhute 2:3bdf0d9bb71f 1235 * the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well.<br>
akashvibhute 2:3bdf0d9bb71f 1236 * This allows very fast call-response communication, with the responding radio never having to
akashvibhute 2:3bdf0d9bb71f 1237 * switch out of Primary Receiver mode to send back a payload, but having the option to if wanting<br>
akashvibhute 2:3bdf0d9bb71f 1238 * to initiate communication instead of respond to a commmunication.
akashvibhute 2:3bdf0d9bb71f 1239 */
akashvibhute 2:3bdf0d9bb71f 1240
akashvibhute 2:3bdf0d9bb71f 1241 /**
akashvibhute 2:3bdf0d9bb71f 1242 * @example pingpair_irq.ino
akashvibhute 2:3bdf0d9bb71f 1243 * <b>Update: TMRh20</b><br>
akashvibhute 2:3bdf0d9bb71f 1244 * This is an example of how to user interrupts to interact with the radio, and a demonstration
akashvibhute 2:3bdf0d9bb71f 1245 * of how to use them to sleep when receiving, and not miss any payloads.<br>
akashvibhute 2:3bdf0d9bb71f 1246 * The pingpair_sleepy example expands on sleep functionality with a timed sleep option for the transmitter.
akashvibhute 2:3bdf0d9bb71f 1247 * Sleep functionality is built directly into my fork of the RF24Network library<br>
akashvibhute 2:3bdf0d9bb71f 1248 */
akashvibhute 2:3bdf0d9bb71f 1249
akashvibhute 2:3bdf0d9bb71f 1250 /**
akashvibhute 2:3bdf0d9bb71f 1251 * @example pingpair_irq_simple.ino
akashvibhute 2:3bdf0d9bb71f 1252 * <b>Dec 2014 - TMRh20</b><br>
akashvibhute 2:3bdf0d9bb71f 1253 * This is an example of how to user interrupts to interact with the radio, with bidirectional communication.
akashvibhute 2:3bdf0d9bb71f 1254 */
akashvibhute 2:3bdf0d9bb71f 1255
akashvibhute 2:3bdf0d9bb71f 1256 /**
akashvibhute 2:3bdf0d9bb71f 1257 * @example pingpair_sleepy.ino
akashvibhute 2:3bdf0d9bb71f 1258 * <b>Update: TMRh20</b><br>
akashvibhute 2:3bdf0d9bb71f 1259 * This is an example of how to use the RF24 class to create a battery-
akashvibhute 2:3bdf0d9bb71f 1260 * efficient system. It is just like the GettingStarted_CallResponse example, but the<br>
akashvibhute 2:3bdf0d9bb71f 1261 * ping node powers down the radio and sleeps the MCU after every
akashvibhute 2:3bdf0d9bb71f 1262 * ping/pong cycle, and the receiver sleeps between payloads. <br>
akashvibhute 2:3bdf0d9bb71f 1263 */
akashvibhute 2:3bdf0d9bb71f 1264
akashvibhute 2:3bdf0d9bb71f 1265 /**
akashvibhute 2:3bdf0d9bb71f 1266 * @example rf24ping85.ino
akashvibhute 2:3bdf0d9bb71f 1267 * <b>New: Contributed by https://github.com/tong67</b><br>
akashvibhute 2:3bdf0d9bb71f 1268 * This is an example of how to use the RF24 class to communicate with ATtiny85 and other node. <br>
akashvibhute 2:3bdf0d9bb71f 1269 */
akashvibhute 2:3bdf0d9bb71f 1270
akashvibhute 2:3bdf0d9bb71f 1271 /**
akashvibhute 2:3bdf0d9bb71f 1272 * @example timingSearch3pin.ino
akashvibhute 2:3bdf0d9bb71f 1273 * <b>New: Contributed by https://github.com/tong67</b><br>
akashvibhute 2:3bdf0d9bb71f 1274 * This is an example of how to determine the correct timing for ATtiny when using only 3-pins
akashvibhute 2:3bdf0d9bb71f 1275 */
akashvibhute 2:3bdf0d9bb71f 1276
akashvibhute 2:3bdf0d9bb71f 1277 /**
akashvibhute 2:3bdf0d9bb71f 1278 * @example pingpair_dyn.ino
akashvibhute 2:3bdf0d9bb71f 1279 *
akashvibhute 2:3bdf0d9bb71f 1280 * This is an example of how to use payloads of a varying (dynamic) size on Arduino.
akashvibhute 2:3bdf0d9bb71f 1281 */
akashvibhute 2:3bdf0d9bb71f 1282
akashvibhute 2:3bdf0d9bb71f 1283 /**
akashvibhute 2:3bdf0d9bb71f 1284 * @example pingpair_dyn.cpp
akashvibhute 2:3bdf0d9bb71f 1285 *
akashvibhute 2:3bdf0d9bb71f 1286 * This is an example of how to use payloads of a varying (dynamic) size on Raspberry Pi.
akashvibhute 2:3bdf0d9bb71f 1287 */
akashvibhute 2:3bdf0d9bb71f 1288
akashvibhute 2:3bdf0d9bb71f 1289 /**
akashvibhute 2:3bdf0d9bb71f 1290 * @example pingpair_dyn.py
akashvibhute 2:3bdf0d9bb71f 1291 *
akashvibhute 2:3bdf0d9bb71f 1292 * This is a python example for RPi of how to use payloads of a varying (dynamic) size.
akashvibhute 2:3bdf0d9bb71f 1293 */
akashvibhute 2:3bdf0d9bb71f 1294
akashvibhute 2:3bdf0d9bb71f 1295 /**
akashvibhute 2:3bdf0d9bb71f 1296 * @example pingpair_dyn.ino
akashvibhute 2:3bdf0d9bb71f 1297 *
akashvibhute 2:3bdf0d9bb71f 1298 * This is an example of how to use payloads of a varying (dynamic) size.
akashvibhute 2:3bdf0d9bb71f 1299 */
akashvibhute 2:3bdf0d9bb71f 1300
akashvibhute 2:3bdf0d9bb71f 1301 /**
akashvibhute 2:3bdf0d9bb71f 1302 * @example pingpair_dyn.ino
akashvibhute 2:3bdf0d9bb71f 1303 *
akashvibhute 2:3bdf0d9bb71f 1304 * This is an example of how to use payloads of a varying (dynamic) size.
akashvibhute 2:3bdf0d9bb71f 1305 */
akashvibhute 2:3bdf0d9bb71f 1306
akashvibhute 2:3bdf0d9bb71f 1307 /**
akashvibhute 2:3bdf0d9bb71f 1308 * @example scanner.ino
akashvibhute 2:3bdf0d9bb71f 1309 *
akashvibhute 2:3bdf0d9bb71f 1310 * Example to detect interference on the various channels available.
akashvibhute 2:3bdf0d9bb71f 1311 * This is a good diagnostic tool to check whether you're picking a
akashvibhute 2:3bdf0d9bb71f 1312 * good channel for your application.
akashvibhute 2:3bdf0d9bb71f 1313 *
akashvibhute 2:3bdf0d9bb71f 1314 * Inspired by cpixip.
akashvibhute 2:3bdf0d9bb71f 1315 * See http://arduino.cc/forum/index.php/topic,54795.0.html
akashvibhute 2:3bdf0d9bb71f 1316 */
akashvibhute 2:3bdf0d9bb71f 1317
akashvibhute 2:3bdf0d9bb71f 1318 /**
akashvibhute 2:3bdf0d9bb71f 1319 * @mainpage Optimized High Speed Driver for nRF24L01(+) 2.4GHz Wireless Transceiver
akashvibhute 2:3bdf0d9bb71f 1320 *
akashvibhute 2:3bdf0d9bb71f 1321 * @section Goals Design Goals
akashvibhute 2:3bdf0d9bb71f 1322 *
akashvibhute 2:3bdf0d9bb71f 1323 * This library fork is designed to be...
akashvibhute 2:3bdf0d9bb71f 1324 * @li More compliant with the manufacturer specified operation of the chip, while allowing advanced users
akashvibhute 2:3bdf0d9bb71f 1325 * to work outside the recommended operation.
akashvibhute 2:3bdf0d9bb71f 1326 * @li Utilize the capabilities of the radio to their full potential via Arduino
akashvibhute 2:3bdf0d9bb71f 1327 * @li More reliable, responsive, bug-free and feature rich
akashvibhute 2:3bdf0d9bb71f 1328 * @li Easy for beginners to use, with well documented examples and features
akashvibhute 2:3bdf0d9bb71f 1329 * @li Consumed with a public interface that's similar to other Arduino standard libraries
akashvibhute 2:3bdf0d9bb71f 1330 *
akashvibhute 2:3bdf0d9bb71f 1331 * @section News News
akashvibhute 2:3bdf0d9bb71f 1332 *
akashvibhute 2:3bdf0d9bb71f 1333 * **March 2015**<br>
akashvibhute 2:3bdf0d9bb71f 1334 * - Uses SPI transactions on Arduino
akashvibhute 2:3bdf0d9bb71f 1335 * - New layout for <a href="Portability.html">easier portability:</a> Break out defines & includes for individual platforms to RF24/utility
akashvibhute 2:3bdf0d9bb71f 1336 * - <a href="MRAA.html">MRAA</a> support added ( Galileo, Edison, etc)
akashvibhute 2:3bdf0d9bb71f 1337 * - <a href="BBB.html">BBB/Generic Linux </a> support via spidev & MRAA
akashvibhute 2:3bdf0d9bb71f 1338 * - Support for RPi 2 added
akashvibhute 2:3bdf0d9bb71f 1339 * - Major Documentation cleanup & update (Move all docs to github.io)
akashvibhute 2:3bdf0d9bb71f 1340 *
akashvibhute 2:3bdf0d9bb71f 1341 * <b>Dec 2014 </b><br>
akashvibhute 2:3bdf0d9bb71f 1342 * - New: Intel Galileo now supported
akashvibhute 2:3bdf0d9bb71f 1343 * - New: Python wrapper for RPi included
akashvibhute 2:3bdf0d9bb71f 1344 * - Documentation updated
akashvibhute 2:3bdf0d9bb71f 1345 * - Example files have been updated
akashvibhute 2:3bdf0d9bb71f 1346 * - See the links below and class documentation for more info.
akashvibhute 2:3bdf0d9bb71f 1347 *
akashvibhute 2:3bdf0d9bb71f 1348 * If issues are discovered with the documentation, please report them <a href="https://github.com/TMRh20/tmrh20.github.io/issues"> here</a>
akashvibhute 2:3bdf0d9bb71f 1349 *
akashvibhute 2:3bdf0d9bb71f 1350 * <br>
akashvibhute 2:3bdf0d9bb71f 1351 * @section Useful Useful References
akashvibhute 2:3bdf0d9bb71f 1352 *
akashvibhute 2:3bdf0d9bb71f 1353 *
akashvibhute 2:3bdf0d9bb71f 1354 * @li <a href="http://tmrh20.github.io/RF24/classRF24.html"><b>RF24</b> Class Documentation</a>
akashvibhute 2:3bdf0d9bb71f 1355 * @li <a href="https://github.com/TMRh20/RF24/archive/master.zip"><b>Download</b></a>
akashvibhute 2:3bdf0d9bb71f 1356 * @li <a href="https://github.com/tmrh20/RF24/"><b>Source Code</b></a>
akashvibhute 2:3bdf0d9bb71f 1357 * @li <a href="http://tmrh20.blogspot.com/2014/03/high-speed-data-transfers-and-wireless.html"><b>My Blog:</b> RF24 Optimization Overview</a>
akashvibhute 2:3bdf0d9bb71f 1358 * @li <a href="http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf">Chip Datasheet</a>
akashvibhute 2:3bdf0d9bb71f 1359 *
akashvibhute 2:3bdf0d9bb71f 1360 * **Additional Information and Add-ons**
akashvibhute 2:3bdf0d9bb71f 1361 *
akashvibhute 2:3bdf0d9bb71f 1362 * @li <a href="http://tmrh20.github.io/RF24Network"> <b>RF24Network:</b> OSI Network Layer for multi-device communication. Create a home sensor network.</a>
akashvibhute 2:3bdf0d9bb71f 1363 * @li <a href="http://tmrh20.github.io/RF24Mesh"> <b>RF24Mesh:</b> Dynamic Mesh Layer for RF24Network</a>
akashvibhute 2:3bdf0d9bb71f 1364 * @li <a href="http://tmrh20.github.io/RF24Ethernet"> <b>RF24Ethernet:</b> TCP/IP Radio Mesh Networking (shares Arduino Ethernet API)</a>
akashvibhute 2:3bdf0d9bb71f 1365 * @li <a href="http://tmrh20.github.io/RF24Audio"> <b>RF24Audio:</b> Realtime Wireless Audio streaming</a>
akashvibhute 2:3bdf0d9bb71f 1366 * @li <a href="http://tmrh20.github.io/">All TMRh20 Documentation Main Page</a>
akashvibhute 2:3bdf0d9bb71f 1367 *
akashvibhute 2:3bdf0d9bb71f 1368 * **More Information and RF24 Based Projects**
akashvibhute 2:3bdf0d9bb71f 1369 *
akashvibhute 2:3bdf0d9bb71f 1370 * @li <a href="http://TMRh20.blogspot.com"> Project Blog: TMRh20.blogspot.com </a>
akashvibhute 2:3bdf0d9bb71f 1371 * @li <a href="http://maniacalbits.blogspot.ca/"> Maniacal Bits Blog</a>
akashvibhute 2:3bdf0d9bb71f 1372 * @li <a href="http://www.mysensors.org/">MySensors.org (User friendly sensor networks/IoT)</a>
akashvibhute 2:3bdf0d9bb71f 1373 * @li <a href="https://github.com/mannkind/RF24Node_MsgProto"> RF24Node_MsgProto (MQTT)</a>
akashvibhute 2:3bdf0d9bb71f 1374 * @li <a href="https://bitbucket.org/pjhardy/rf24sensornet/"> RF24SensorNet </a>
akashvibhute 2:3bdf0d9bb71f 1375 * @li <a href="http://www.homeautomationforgeeks.com/rf24software.shtml">Home Automation for Geeks</a>
akashvibhute 2:3bdf0d9bb71f 1376 * @li <a href="https://maniacbug.wordpress.com/2012/03/30/rf24network/"> Original Maniacbug RF24Network Blog Post</a>
akashvibhute 2:3bdf0d9bb71f 1377 * @li <a href="https://github.com/maniacbug/RF24"> ManiacBug on GitHub (Original Library Author)</a>
akashvibhute 2:3bdf0d9bb71f 1378 *
akashvibhute 2:3bdf0d9bb71f 1379 *
akashvibhute 2:3bdf0d9bb71f 1380 * <br>
akashvibhute 2:3bdf0d9bb71f 1381 *
akashvibhute 2:3bdf0d9bb71f 1382 * @section Platform_Support Platform Support Pages
akashvibhute 2:3bdf0d9bb71f 1383 *
akashvibhute 2:3bdf0d9bb71f 1384 * @li <a href="Arduino.html"><b>Arduino</b></a> (Uno, Nano, Mega, Due, Galileo, etc)
akashvibhute 2:3bdf0d9bb71f 1385 * @li <a href="ATTiny.html"><b>ATTiny</b></a>
akashvibhute 2:3bdf0d9bb71f 1386 * @li Linux ( <a href="RPi.html"><b>RPi</b></a> , <a href="BBB.html"><b>BBB</b></a>, <a href="MRAA.html"><b>MRAA</b></a> supported boards ( Galileo, Edison, etc))
akashvibhute 2:3bdf0d9bb71f 1387 * @li <a href="Python.html"><b>Python</b></a> wrapper available for RPi
akashvibhute 2:3bdf0d9bb71f 1388 *
akashvibhute 2:3bdf0d9bb71f 1389 * <br>
akashvibhute 2:3bdf0d9bb71f 1390 * **General µC Pin layout** (See the individual board support pages for more info)
akashvibhute 2:3bdf0d9bb71f 1391 *
akashvibhute 2:3bdf0d9bb71f 1392 * The table below shows how to connect the the pins of the NRF24L01(+) to different boards.
akashvibhute 2:3bdf0d9bb71f 1393 * CE and CSN are configurable.
akashvibhute 2:3bdf0d9bb71f 1394 *
akashvibhute 2:3bdf0d9bb71f 1395 * | PIN | NRF24L01 | Arduino UNO | ATtiny25/45/85 [0] | ATtiny44/84 [1] | LittleWire [2] | RPI | RPi -P1 Connector |
akashvibhute 2:3bdf0d9bb71f 1396 * |-----|----------|-------------|--------------------|-----------------|-------------------------|------------|-------------------|
akashvibhute 2:3bdf0d9bb71f 1397 * | 1 | GND | GND | pin 4 | pin 14 | GND | rpi-gnd | (25) |
akashvibhute 2:3bdf0d9bb71f 1398 * | 2 | VCC | 3.3V | pin 8 | pin 1 | regulator 3.3V required | rpi-3v3 | (17) |
akashvibhute 2:3bdf0d9bb71f 1399 * | 3 | CE | digIO 7 | pin 2 | pin 12 | pin to 3.3V | rpi-gpio22 | (15) |
akashvibhute 2:3bdf0d9bb71f 1400 * | 4 | CSN | digIO 8 | pin 3 | pin 11 | RESET | rpi-gpio8 | (24) |
akashvibhute 2:3bdf0d9bb71f 1401 * | 5 | SCK | digIO 13 | pin 7 | pin 9 | SCK | rpi-sckl | (23) |
akashvibhute 2:3bdf0d9bb71f 1402 * | 6 | MOSI | digIO 11 | pin 6 | pin 7 | MOSI | rpi-mosi | (19) |
akashvibhute 2:3bdf0d9bb71f 1403 * | 7 | MISO | digIO 12 | pin 5 | pin 8 | MISO | rpi-miso | (21) |
akashvibhute 2:3bdf0d9bb71f 1404 * | 8 | IRQ | - | - | - | - | - | - |
akashvibhute 2:3bdf0d9bb71f 1405 *
akashvibhute 2:3bdf0d9bb71f 1406 * @li [0] https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints
akashvibhute 2:3bdf0d9bb71f 1407 * @li [1] http://highlowtech.org/?p=1695
akashvibhute 2:3bdf0d9bb71f 1408 * @li [2] http://littlewire.cc/
akashvibhute 2:3bdf0d9bb71f 1409 * <br><br><br>
akashvibhute 2:3bdf0d9bb71f 1410 *
akashvibhute 2:3bdf0d9bb71f 1411 *
akashvibhute 2:3bdf0d9bb71f 1412 *
akashvibhute 2:3bdf0d9bb71f 1413 *
akashvibhute 2:3bdf0d9bb71f 1414 * @page Arduino Arduino
akashvibhute 2:3bdf0d9bb71f 1415 *
akashvibhute 2:3bdf0d9bb71f 1416 * RF24 is fully compatible with Arduino boards <br>
akashvibhute 2:3bdf0d9bb71f 1417 * See <b> http://www.arduino.cc/en/Reference/Board </b> and <b> http://arduino.cc/en/Reference/SPI </b> for more information
akashvibhute 2:3bdf0d9bb71f 1418 *
akashvibhute 2:3bdf0d9bb71f 1419 * RF24 makes use of the standard hardware SPI pins (MISO,MOSI,SCK) and requires two additional pins, to control
akashvibhute 2:3bdf0d9bb71f 1420 * the chip-select and chip-enable functions.<br>
akashvibhute 2:3bdf0d9bb71f 1421 * These pins must be chosen and designated by the user, in RF24 radio(ce_pin,cs_pin); and can use any
akashvibhute 2:3bdf0d9bb71f 1422 * available pins.
akashvibhute 2:3bdf0d9bb71f 1423 *
akashvibhute 2:3bdf0d9bb71f 1424 * <br>
akashvibhute 2:3bdf0d9bb71f 1425 * @section ARD_DUE Arduino Due
akashvibhute 2:3bdf0d9bb71f 1426 *
akashvibhute 2:3bdf0d9bb71f 1427 * RF24 makes use of the extended SPI functionality available on the Arduino Due, and requires one of the
akashvibhute 2:3bdf0d9bb71f 1428 * defined hardware SS/CS pins to be designated in RF24 radio(ce_pin,cs_pin);<br>
akashvibhute 2:3bdf0d9bb71f 1429 * See http://arduino.cc/en/Reference/DueExtendedSPI for more information
akashvibhute 2:3bdf0d9bb71f 1430 *
akashvibhute 2:3bdf0d9bb71f 1431 * Initial Due support taken from https://github.com/mcrosson/RF24/tree/due
akashvibhute 2:3bdf0d9bb71f 1432 *
akashvibhute 2:3bdf0d9bb71f 1433 * <br>
akashvibhute 2:3bdf0d9bb71f 1434 * @section Alternate_SPI Alternate SPI Support
akashvibhute 2:3bdf0d9bb71f 1435 *
akashvibhute 2:3bdf0d9bb71f 1436 * RF24 supports alternate SPI methods, in case the standard hardware SPI pins are otherwise unavailable.
akashvibhute 2:3bdf0d9bb71f 1437 *
akashvibhute 2:3bdf0d9bb71f 1438 * <br>
akashvibhute 2:3bdf0d9bb71f 1439 * **Software Driven SPI**
akashvibhute 2:3bdf0d9bb71f 1440 *
akashvibhute 2:3bdf0d9bb71f 1441 * Software driven SPI is provided by the <a href=https://github.com/greiman/DigitalIO>DigitalIO</a> library
akashvibhute 2:3bdf0d9bb71f 1442 *
akashvibhute 2:3bdf0d9bb71f 1443 * Setup:<br>
akashvibhute 2:3bdf0d9bb71f 1444 * 1. Install the digitalIO library<br>
akashvibhute 2:3bdf0d9bb71f 1445 * 2. Open RF24_config.h in a text editor. Uncomment the line #define SOFTSPI<br>
akashvibhute 2:3bdf0d9bb71f 1446 * 3. In your sketch, add #include DigitalIO.h
akashvibhute 2:3bdf0d9bb71f 1447 *
akashvibhute 2:3bdf0d9bb71f 1448 * @note Note: Pins are listed as follows and can be modified by editing the RF24_config.h file<br>
akashvibhute 2:3bdf0d9bb71f 1449 *
akashvibhute 2:3bdf0d9bb71f 1450 * const uint8_t SOFT_SPI_MISO_PIN = 16;
akashvibhute 2:3bdf0d9bb71f 1451 * const uint8_t SOFT_SPI_MOSI_PIN = 15;
akashvibhute 2:3bdf0d9bb71f 1452 * const uint8_t SOFT_SPI_SCK_PIN = 14;
akashvibhute 2:3bdf0d9bb71f 1453 *
akashvibhute 2:3bdf0d9bb71f 1454 * <br>
akashvibhute 2:3bdf0d9bb71f 1455 * **Alternate Hardware (UART) Driven SPI**
akashvibhute 2:3bdf0d9bb71f 1456 *
akashvibhute 2:3bdf0d9bb71f 1457 * The Serial Port (UART) on Arduino can also function in SPI mode, and can double-buffer data, while the
akashvibhute 2:3bdf0d9bb71f 1458 * default SPI hardware cannot.
akashvibhute 2:3bdf0d9bb71f 1459 *
akashvibhute 2:3bdf0d9bb71f 1460 * The SPI_UART library is available at https://github.com/TMRh20/Sketches/tree/master/SPI_UART
akashvibhute 2:3bdf0d9bb71f 1461 *
akashvibhute 2:3bdf0d9bb71f 1462 * Enabling:
akashvibhute 2:3bdf0d9bb71f 1463 * 1. Install the SPI_UART library
akashvibhute 2:3bdf0d9bb71f 1464 * 2. Edit RF24_config.h and uncomment #define SPI_UART
akashvibhute 2:3bdf0d9bb71f 1465 * 3. In your sketch, add @code #include <SPI_UART.h> @endcode
akashvibhute 2:3bdf0d9bb71f 1466 *
akashvibhute 2:3bdf0d9bb71f 1467 * SPI_UART SPI Pin Connections:
akashvibhute 2:3bdf0d9bb71f 1468 * | NRF |Arduino Uno Pin|
akashvibhute 2:3bdf0d9bb71f 1469 * |-----|---------------|
akashvibhute 2:3bdf0d9bb71f 1470 * | MOSI| TX(0) |
akashvibhute 2:3bdf0d9bb71f 1471 * | MISO| RX(1) |
akashvibhute 2:3bdf0d9bb71f 1472 * | SCK | XCK(4) |
akashvibhute 2:3bdf0d9bb71f 1473 * | CE | User Specified|
akashvibhute 2:3bdf0d9bb71f 1474 * | CSN | User Specified|
akashvibhute 2:3bdf0d9bb71f 1475 *
akashvibhute 2:3bdf0d9bb71f 1476 *
akashvibhute 2:3bdf0d9bb71f 1477 * @note SPI_UART on Mega boards requires soldering to an unused pin on the chip. <br>See
akashvibhute 2:3bdf0d9bb71f 1478 * https://github.com/TMRh20/RF24/issues/24 for more information on SPI_UART.
akashvibhute 2:3bdf0d9bb71f 1479 *
akashvibhute 2:3bdf0d9bb71f 1480 * @page ATTiny ATTiny
akashvibhute 2:3bdf0d9bb71f 1481 *
akashvibhute 2:3bdf0d9bb71f 1482 * ATTiny support is built into the library, so users are not required to include SPI.h in their sketches<br>
akashvibhute 2:3bdf0d9bb71f 1483 * See the included rf24ping85 example for pin info and usage
akashvibhute 2:3bdf0d9bb71f 1484 *
akashvibhute 2:3bdf0d9bb71f 1485 * Some versions of Arduino IDE may require a patch to allow use of the full program space on ATTiny<br>
akashvibhute 2:3bdf0d9bb71f 1486 * See https://github.com/TCWORLD/ATTinyCore/tree/master/PCREL%20Patch%20for%20GCC for ATTiny patch
akashvibhute 2:3bdf0d9bb71f 1487 *
akashvibhute 2:3bdf0d9bb71f 1488 * ATTiny board support initially added from https://github.com/jscrane/RF24
akashvibhute 2:3bdf0d9bb71f 1489 *
akashvibhute 2:3bdf0d9bb71f 1490 * @section Hardware Hardware Configuration
akashvibhute 2:3bdf0d9bb71f 1491 * By tong67 ( https://github.com/tong67 )
akashvibhute 2:3bdf0d9bb71f 1492 *
akashvibhute 2:3bdf0d9bb71f 1493 * **ATtiny25/45/85 Pin map with CE_PIN 3 and CSN_PIN 4**
akashvibhute 2:3bdf0d9bb71f 1494 * @code
akashvibhute 2:3bdf0d9bb71f 1495 * +-\/-+
akashvibhute 2:3bdf0d9bb71f 1496 * NC PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 --- LED --- 5V
akashvibhute 2:3bdf0d9bb71f 1497 * nRF24L01 CE, pin3 --- PB3 2| |7 PB2 --- nRF24L01 SCK, pin5
akashvibhute 2:3bdf0d9bb71f 1498 * nRF24L01 CSN, pin4 --- PB4 3| |6 PB1 --- nRF24L01 MOSI, pin7
akashvibhute 2:3bdf0d9bb71f 1499 * nRF24L01 GND, pin1 --- GND 4| |5 PB0 --- nRF24L01 MISO, pin6
akashvibhute 2:3bdf0d9bb71f 1500 * +----+
akashvibhute 2:3bdf0d9bb71f 1501 * @endcode
akashvibhute 2:3bdf0d9bb71f 1502 *
akashvibhute 2:3bdf0d9bb71f 1503 * <br>
akashvibhute 2:3bdf0d9bb71f 1504 * **ATtiny25/45/85 Pin map with CE_PIN 3 and CSN_PIN 3** => PB3 and PB4 are free to use for application <br>
akashvibhute 2:3bdf0d9bb71f 1505 * Circuit idea from http://nerdralph.blogspot.ca/2014/01/nrf24l01-control-with-3-attiny85-pins.html <br>
akashvibhute 2:3bdf0d9bb71f 1506 * Original RC combination was 1K/100nF. 22K/10nF combination worked better. <br>
akashvibhute 2:3bdf0d9bb71f 1507 * For best settletime delay value in RF24::csn() the timingSearch3pin.ino sketch can be used. <br>
akashvibhute 2:3bdf0d9bb71f 1508 * This configuration is enabled when CE_PIN and CSN_PIN are equal, e.g. both 3 <br>
akashvibhute 2:3bdf0d9bb71f 1509 * Because CE is always high the power consumption is higher than for 5 pins solution <br>
akashvibhute 2:3bdf0d9bb71f 1510 * @code
akashvibhute 2:3bdf0d9bb71f 1511 * ^^
akashvibhute 2:3bdf0d9bb71f 1512 * +-\/-+ nRF24L01 CE, pin3 ------| //
akashvibhute 2:3bdf0d9bb71f 1513 * PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 ------x----------x--|<|-- 5V
akashvibhute 2:3bdf0d9bb71f 1514 * NC PB3 2| |7 PB2 --- nRF24L01 SCK, pin5 --|<|---x-[22k]--| LED
akashvibhute 2:3bdf0d9bb71f 1515 * NC PB4 3| |6 PB1 --- nRF24L01 MOSI, pin6 1n4148 |
akashvibhute 2:3bdf0d9bb71f 1516 * nRF24L01 GND, pin1 -x- GND 4| |5 PB0 --- nRF24L01 MISO, pin7 |
akashvibhute 2:3bdf0d9bb71f 1517 * | +----+ |
akashvibhute 2:3bdf0d9bb71f 1518 * |-----------------------------------------------||----x-- nRF24L01 CSN, pin4
akashvibhute 2:3bdf0d9bb71f 1519 * 10nF
akashvibhute 2:3bdf0d9bb71f 1520 * @endcode
akashvibhute 2:3bdf0d9bb71f 1521 *
akashvibhute 2:3bdf0d9bb71f 1522 * <br>
akashvibhute 2:3bdf0d9bb71f 1523 * **ATtiny24/44/84 Pin map with CE_PIN 8 and CSN_PIN 7** <br>
akashvibhute 2:3bdf0d9bb71f 1524 * Schematic provided and successfully tested by Carmine Pastore (https://github.com/Carminepz) <br>
akashvibhute 2:3bdf0d9bb71f 1525 * @code
akashvibhute 2:3bdf0d9bb71f 1526 * +-\/-+
akashvibhute 2:3bdf0d9bb71f 1527 * nRF24L01 VCC, pin2 --- VCC 1|o |14 GND --- nRF24L01 GND, pin1
akashvibhute 2:3bdf0d9bb71f 1528 * PB0 2| |13 AREF
akashvibhute 2:3bdf0d9bb71f 1529 * PB1 3| |12 PA1
akashvibhute 2:3bdf0d9bb71f 1530 * PB3 4| |11 PA2 --- nRF24L01 CE, pin3
akashvibhute 2:3bdf0d9bb71f 1531 * PB2 5| |10 PA3 --- nRF24L01 CSN, pin4
akashvibhute 2:3bdf0d9bb71f 1532 * PA7 6| |9 PA4 --- nRF24L01 SCK, pin5
akashvibhute 2:3bdf0d9bb71f 1533 * nRF24L01 MOSI, pin7 --- PA6 7| |8 PA5 --- nRF24L01 MISO, pin6
akashvibhute 2:3bdf0d9bb71f 1534 * +----+
akashvibhute 2:3bdf0d9bb71f 1535 * @endcode
akashvibhute 2:3bdf0d9bb71f 1536 *
akashvibhute 2:3bdf0d9bb71f 1537 * <br><br><br>
akashvibhute 2:3bdf0d9bb71f 1538 *
akashvibhute 2:3bdf0d9bb71f 1539 *
akashvibhute 2:3bdf0d9bb71f 1540 *
akashvibhute 2:3bdf0d9bb71f 1541 *
akashvibhute 2:3bdf0d9bb71f 1542 *
akashvibhute 2:3bdf0d9bb71f 1543 *
akashvibhute 2:3bdf0d9bb71f 1544 * @page BBB BeagleBone Black
akashvibhute 2:3bdf0d9bb71f 1545 *
akashvibhute 2:3bdf0d9bb71f 1546 * BeagleBone Black is supported via MRAA or SPIDEV.
akashvibhute 2:3bdf0d9bb71f 1547 *
akashvibhute 2:3bdf0d9bb71f 1548 * @note The SPIDEV option should work with most Linux systems supporting SPIDEV. <br>
akashvibhute 2:3bdf0d9bb71f 1549 * Users may need to edit the RF24/utility/BBB/spi.cpp file to configure the spi device. (Defaults: "/dev/spidev1.0"; or "/dev/spidev1.1"; )
akashvibhute 2:3bdf0d9bb71f 1550 *
akashvibhute 2:3bdf0d9bb71f 1551 * <br>
akashvibhute 2:3bdf0d9bb71f 1552 * @section AutoInstall Automated Install
akashvibhute 2:3bdf0d9bb71f 1553 *(**Designed & Tested on RPi** - Defaults to SPIDEV on BBB)
akashvibhute 2:3bdf0d9bb71f 1554 *
akashvibhute 2:3bdf0d9bb71f 1555 *
akashvibhute 2:3bdf0d9bb71f 1556 * 1. Download the install.sh file from http://tmrh20.github.io/RF24Installer/RPi/install.sh
akashvibhute 2:3bdf0d9bb71f 1557 * @code wget http://tmrh20.github.io/RF24Installer/RPi/install.sh @endcode
akashvibhute 2:3bdf0d9bb71f 1558 * 2. Make it executable:
akashvibhute 2:3bdf0d9bb71f 1559 * @code chmod +x install.sh @endcode
akashvibhute 2:3bdf0d9bb71f 1560 * 3. Run it and choose your options
akashvibhute 2:3bdf0d9bb71f 1561 * @code ./install.sh @endcode
akashvibhute 2:3bdf0d9bb71f 1562 * 4. Run an example from one of the libraries
akashvibhute 2:3bdf0d9bb71f 1563 * @code
akashvibhute 2:3bdf0d9bb71f 1564 * cd rf24libs/RF24/examples_RPi
akashvibhute 2:3bdf0d9bb71f 1565 * @endcode
akashvibhute 2:3bdf0d9bb71f 1566 * Edit the gettingstarted example, to set your pin configuration
akashvibhute 2:3bdf0d9bb71f 1567 * @code nano gettingstarted.cpp
akashvibhute 2:3bdf0d9bb71f 1568 * make
akashvibhute 2:3bdf0d9bb71f 1569 * sudo ./gettingstarted
akashvibhute 2:3bdf0d9bb71f 1570 * @endcode
akashvibhute 2:3bdf0d9bb71f 1571 *
akashvibhute 2:3bdf0d9bb71f 1572 * <br>
akashvibhute 2:3bdf0d9bb71f 1573 * @section ManInstall Manual Install
akashvibhute 2:3bdf0d9bb71f 1574 * 1. Make a directory to contain the RF24 and possibly RF24Network lib and enter it:
akashvibhute 2:3bdf0d9bb71f 1575 * @code
akashvibhute 2:3bdf0d9bb71f 1576 * mkdir ~/rf24libs
akashvibhute 2:3bdf0d9bb71f 1577 * cd ~/rf24libs
akashvibhute 2:3bdf0d9bb71f 1578 * @endcode
akashvibhute 2:3bdf0d9bb71f 1579 * 2. Clone the RF24 repo:
akashvibhute 2:3bdf0d9bb71f 1580 * @code git clone https://github.com/tmrh20/RF24.git RF24 @endcode
akashvibhute 2:3bdf0d9bb71f 1581 * 3. Change to the new RF24 directory
akashvibhute 2:3bdf0d9bb71f 1582 * @code cd RF24 @endcode
akashvibhute 2:3bdf0d9bb71f 1583 * 4. Build the library, and run an example file:
akashvibhute 2:3bdf0d9bb71f 1584 * **Note:** See the <a href="http://iotdk.intel.com/docs/master/mraa/index.html">MRAA </a> documentation for more info on installing MRAA
akashvibhute 2:3bdf0d9bb71f 1585 * @code sudo make install OR sudo make install RF24_MRAA=1 @endcode
akashvibhute 2:3bdf0d9bb71f 1586 * @code
akashvibhute 2:3bdf0d9bb71f 1587 * cd examples_RPi
akashvibhute 2:3bdf0d9bb71f 1588 * @endcode
akashvibhute 2:3bdf0d9bb71f 1589 * Edit the gettingstarted example, to set your pin configuration
akashvibhute 2:3bdf0d9bb71f 1590 * @code nano gettingstarted.cpp
akashvibhute 2:3bdf0d9bb71f 1591 * make
akashvibhute 2:3bdf0d9bb71f 1592 * sudo ./gettingstarted
akashvibhute 2:3bdf0d9bb71f 1593 * @endcode
akashvibhute 2:3bdf0d9bb71f 1594 *
akashvibhute 2:3bdf0d9bb71f 1595 * <br><br>
akashvibhute 2:3bdf0d9bb71f 1596 *
akashvibhute 2:3bdf0d9bb71f 1597 * @page MRAA MRAA
akashvibhute 2:3bdf0d9bb71f 1598 *
akashvibhute 2:3bdf0d9bb71f 1599 * MRAA is a Low Level Skeleton Library for Communication on GNU/Linux platforms <br>
akashvibhute 2:3bdf0d9bb71f 1600 * See http://iotdk.intel.com/docs/master/mraa/index.html for more information
akashvibhute 2:3bdf0d9bb71f 1601 *
akashvibhute 2:3bdf0d9bb71f 1602 * RF24 supports all MRAA supported platforms, but might not be tested on each individual platform due to the wide range of hardware support:<br>
akashvibhute 2:3bdf0d9bb71f 1603 * <a href="https://github.com/TMRh20/RF24/issues">Report an RF24 bug or issue </a>
akashvibhute 2:3bdf0d9bb71f 1604 *
akashvibhute 2:3bdf0d9bb71f 1605 * @section Setup Setup
akashvibhute 2:3bdf0d9bb71f 1606 * 1. Install the MRAA lib
akashvibhute 2:3bdf0d9bb71f 1607 * 2. As per your device, SPI may need to be enabled
akashvibhute 2:3bdf0d9bb71f 1608 *
akashvibhute 2:3bdf0d9bb71f 1609 * @section MRAA_Install Install
akashvibhute 2:3bdf0d9bb71f 1610 *
akashvibhute 2:3bdf0d9bb71f 1611 * 1. Make a directory to contain the RF24 and possibly RF24Network lib and enter it:
akashvibhute 2:3bdf0d9bb71f 1612 * @code
akashvibhute 2:3bdf0d9bb71f 1613 * mkdir ~/rf24libs
akashvibhute 2:3bdf0d9bb71f 1614 * cd ~/rf24libs
akashvibhute 2:3bdf0d9bb71f 1615 * @endcode
akashvibhute 2:3bdf0d9bb71f 1616 * 2. Clone the RF24 repo:
akashvibhute 2:3bdf0d9bb71f 1617 * @code git clone https://github.com/tmrh20/RF24.git RF24 @endcode
akashvibhute 2:3bdf0d9bb71f 1618 * 3. Change to the new RF24 directory
akashvibhute 2:3bdf0d9bb71f 1619 * @code cd RF24 @endcode
akashvibhute 2:3bdf0d9bb71f 1620 * 4. Build the library:
akashvibhute 2:3bdf0d9bb71f 1621 * @code sudo make install -B RF24_MRAA=1 @endcode
akashvibhute 2:3bdf0d9bb71f 1622 * 5. Configure the correct pins in gettingstarted.cpp (See http://iotdk.intel.com/docs/master/mraa/index.html )
akashvibhute 2:3bdf0d9bb71f 1623 * @code
akashvibhute 2:3bdf0d9bb71f 1624 * cd examples_RPi
akashvibhute 2:3bdf0d9bb71f 1625 * nano gettingstarted.cpp
akashvibhute 2:3bdf0d9bb71f 1626 * @endcode
akashvibhute 2:3bdf0d9bb71f 1627 * 6. Build an example
akashvibhute 2:3bdf0d9bb71f 1628 * @code
akashvibhute 2:3bdf0d9bb71f 1629 * make
akashvibhute 2:3bdf0d9bb71f 1630 * sudo ./gettingstarted
akashvibhute 2:3bdf0d9bb71f 1631 * @endcode
akashvibhute 2:3bdf0d9bb71f 1632 *
akashvibhute 2:3bdf0d9bb71f 1633 * <br><br><br>
akashvibhute 2:3bdf0d9bb71f 1634 *
akashvibhute 2:3bdf0d9bb71f 1635 *
akashvibhute 2:3bdf0d9bb71f 1636 *
akashvibhute 2:3bdf0d9bb71f 1637 *
akashvibhute 2:3bdf0d9bb71f 1638 * @page RPi Raspberry Pi
akashvibhute 2:3bdf0d9bb71f 1639 *
akashvibhute 2:3bdf0d9bb71f 1640 * RF24 supports a variety of Linux based devices via various drivers. Some boards like RPi can utilize multiple methods
akashvibhute 2:3bdf0d9bb71f 1641 * to drive the GPIO and SPI functionality.
akashvibhute 2:3bdf0d9bb71f 1642 *
akashvibhute 2:3bdf0d9bb71f 1643 * <br>
akashvibhute 2:3bdf0d9bb71f 1644 * @section PreConfig Potential PreConfiguration
akashvibhute 2:3bdf0d9bb71f 1645 *
akashvibhute 2:3bdf0d9bb71f 1646 * If SPI is not already enabled, load it on boot:
akashvibhute 2:3bdf0d9bb71f 1647 * @code sudo raspi-config @endcode
akashvibhute 2:3bdf0d9bb71f 1648 * A. Update the tool via the menu as required<br>
akashvibhute 2:3bdf0d9bb71f 1649 * B. Select **Advanced** and **enable the SPI kernel module** <br>
akashvibhute 2:3bdf0d9bb71f 1650 * C. Update other software and libraries:
akashvibhute 2:3bdf0d9bb71f 1651 * @code sudo apt-get update @endcode
akashvibhute 2:3bdf0d9bb71f 1652 * @code sudo apt-get upgrade @endcode
akashvibhute 2:3bdf0d9bb71f 1653 * <br>
akashvibhute 2:3bdf0d9bb71f 1654 * @section AutoInstall Automated Install
akashvibhute 2:3bdf0d9bb71f 1655 *
akashvibhute 2:3bdf0d9bb71f 1656 * 1. Download the install.sh file from http://tmrh20.github.io/RF24Installer/RPi/install.sh
akashvibhute 2:3bdf0d9bb71f 1657 * @code wget http://tmrh20.github.io/RF24Installer/RPi/install.sh @endcode
akashvibhute 2:3bdf0d9bb71f 1658 * 2. Make it executable:
akashvibhute 2:3bdf0d9bb71f 1659 * @code chmod +x install.sh @endcode
akashvibhute 2:3bdf0d9bb71f 1660 * 3. Run it and choose your options
akashvibhute 2:3bdf0d9bb71f 1661 * @code ./install.sh @endcode
akashvibhute 2:3bdf0d9bb71f 1662 * 4. Run an example from one of the libraries
akashvibhute 2:3bdf0d9bb71f 1663 * @code
akashvibhute 2:3bdf0d9bb71f 1664 * cd rf24libs/RF24/examples_RPi
akashvibhute 2:3bdf0d9bb71f 1665 * make
akashvibhute 2:3bdf0d9bb71f 1666 * sudo ./gettingstarted
akashvibhute 2:3bdf0d9bb71f 1667 * @endcode
akashvibhute 2:3bdf0d9bb71f 1668 * <br><br>
akashvibhute 2:3bdf0d9bb71f 1669 * @section ManInstall Manual Install
akashvibhute 2:3bdf0d9bb71f 1670 * 1. Make a directory to contain the RF24 and possibly RF24Network lib and enter it:
akashvibhute 2:3bdf0d9bb71f 1671 * @code
akashvibhute 2:3bdf0d9bb71f 1672 * mkdir ~/rf24libs
akashvibhute 2:3bdf0d9bb71f 1673 * cd ~/rf24libs
akashvibhute 2:3bdf0d9bb71f 1674 * @endcode
akashvibhute 2:3bdf0d9bb71f 1675 * 2. Clone the RF24 repo:
akashvibhute 2:3bdf0d9bb71f 1676 * @code git clone https://github.com/tmrh20/RF24.git RF24 @endcode
akashvibhute 2:3bdf0d9bb71f 1677 * 3. Change to the new RF24 directory
akashvibhute 2:3bdf0d9bb71f 1678 * @code cd RF24 @endcode
akashvibhute 2:3bdf0d9bb71f 1679 * 4. Build the library, and run an example file:
akashvibhute 2:3bdf0d9bb71f 1680 * @code sudo make install
akashvibhute 2:3bdf0d9bb71f 1681 * cd examples_RPi
akashvibhute 2:3bdf0d9bb71f 1682 * make
akashvibhute 2:3bdf0d9bb71f 1683 * sudo ./gettingstarted
akashvibhute 2:3bdf0d9bb71f 1684 * @endcode
akashvibhute 2:3bdf0d9bb71f 1685 *
akashvibhute 2:3bdf0d9bb71f 1686 * <br><br>
akashvibhute 2:3bdf0d9bb71f 1687 * @section Build Build Options
akashvibhute 2:3bdf0d9bb71f 1688 * The default build on Raspberry Pi utilizes the included **BCM2835** driver from http://www.airspayce.com/mikem/bcm2835
akashvibhute 2:3bdf0d9bb71f 1689 * 1. @code sudo make install -B @endcode
akashvibhute 2:3bdf0d9bb71f 1690 *
akashvibhute 2:3bdf0d9bb71f 1691 * Build using the **MRAA** library from http://iotdk.intel.com/docs/master/mraa/index.html <br>
akashvibhute 2:3bdf0d9bb71f 1692 * MRAA is not included. See the <a href="MRAA.html">MRAA</a> platform page for more information.
akashvibhute 2:3bdf0d9bb71f 1693 *
akashvibhute 2:3bdf0d9bb71f 1694 * 1. Install, and build MRAA:
akashvibhute 2:3bdf0d9bb71f 1695 * @code
akashvibhute 2:3bdf0d9bb71f 1696 * git clone https://github.com/intel-iot-devkit/mraa.git
akashvibhute 2:3bdf0d9bb71f 1697 * cd mraa
akashvibhute 2:3bdf0d9bb71f 1698 * mkdir build
akashvibhute 2:3bdf0d9bb71f 1699 * cd build
akashvibhute 2:3bdf0d9bb71f 1700 * cmake .. -DBUILDSWIGNODE=OFF
akashvibhute 2:3bdf0d9bb71f 1701 * sudo make install
akashvibhute 2:3bdf0d9bb71f 1702 * @endcode
akashvibhute 2:3bdf0d9bb71f 1703 *
akashvibhute 2:3bdf0d9bb71f 1704 * 2. Complete the install <br>
akashvibhute 2:3bdf0d9bb71f 1705 * @code nano /etc/ld.so.conf @endcode
akashvibhute 2:3bdf0d9bb71f 1706 * Add the line @code /usr/local/lib/arm-linux-gnueabihf @endcode
akashvibhute 2:3bdf0d9bb71f 1707 * Run @code sudo ldconfig @endcode
akashvibhute 2:3bdf0d9bb71f 1708 *
akashvibhute 2:3bdf0d9bb71f 1709 * 3. Install RF24, using MRAA
akashvibhute 2:3bdf0d9bb71f 1710 * @code sudo make install -B RF24_MRAA=1 @endcode
akashvibhute 2:3bdf0d9bb71f 1711 * See the gettingstarted example for an example of pin configuration
akashvibhute 2:3bdf0d9bb71f 1712 *
akashvibhute 2:3bdf0d9bb71f 1713 * Build using **spidev**:
akashvibhute 2:3bdf0d9bb71f 1714 *
akashvibhute 2:3bdf0d9bb71f 1715 * 1. Edit the RF24/utility/BBB/spi.cpp file
akashvibhute 2:3bdf0d9bb71f 1716 * 2. Change the default device definition to @code this->device = "/dev/spidev0.0";; @endcode
akashvibhute 2:3bdf0d9bb71f 1717 * 3. Run @code sudo make install -B RF24_SPIDEV=1 @endcode
akashvibhute 2:3bdf0d9bb71f 1718 * 4. See the gettingstarted example for an example of pin configuration
akashvibhute 2:3bdf0d9bb71f 1719 *
akashvibhute 2:3bdf0d9bb71f 1720 * <br>
akashvibhute 2:3bdf0d9bb71f 1721 * @section Pins Connections and Pin Configuration
akashvibhute 2:3bdf0d9bb71f 1722 *
akashvibhute 2:3bdf0d9bb71f 1723 *
akashvibhute 2:3bdf0d9bb71f 1724 * Using pin 15/GPIO 22 for CE, pin 24/GPIO8 (CE0) for CSN
akashvibhute 2:3bdf0d9bb71f 1725 *
akashvibhute 2:3bdf0d9bb71f 1726 * Can use either RPi CE0 or CE1 pins for radio CSN.<br>
akashvibhute 2:3bdf0d9bb71f 1727 * Choose any RPi output pin for radio CE pin.
akashvibhute 2:3bdf0d9bb71f 1728 *
akashvibhute 2:3bdf0d9bb71f 1729 * **BCM2835 Constructor:**
akashvibhute 2:3bdf0d9bb71f 1730 * @code
akashvibhute 2:3bdf0d9bb71f 1731 * RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ);
akashvibhute 2:3bdf0d9bb71f 1732 * or
akashvibhute 2:3bdf0d9bb71f 1733 * RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS1, BCM2835_SPI_SPEED_8MHZ);
akashvibhute 2:3bdf0d9bb71f 1734 *
akashvibhute 2:3bdf0d9bb71f 1735 * RPi B+:
akashvibhute 2:3bdf0d9bb71f 1736 * RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ);
akashvibhute 2:3bdf0d9bb71f 1737 * or
akashvibhute 2:3bdf0d9bb71f 1738 * RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_26, BCM2835_SPI_SPEED_8MHZ);
akashvibhute 2:3bdf0d9bb71f 1739 *
akashvibhute 2:3bdf0d9bb71f 1740 * General:
akashvibhute 2:3bdf0d9bb71f 1741 * RF24 radio(22,0);
akashvibhute 2:3bdf0d9bb71f 1742 * or
akashvibhute 2:3bdf0d9bb71f 1743 * RF24 radio(22,1);
akashvibhute 2:3bdf0d9bb71f 1744 *
akashvibhute 2:3bdf0d9bb71f 1745 * @endcode
akashvibhute 2:3bdf0d9bb71f 1746 * See the gettingstarted example for an example of pin configuration
akashvibhute 2:3bdf0d9bb71f 1747 *
akashvibhute 2:3bdf0d9bb71f 1748 * See http://www.airspayce.com/mikem/bcm2835/index.html for BCM2835 class documentation.
akashvibhute 2:3bdf0d9bb71f 1749 * <br><br>
akashvibhute 2:3bdf0d9bb71f 1750 * **MRAA Constructor:**
akashvibhute 2:3bdf0d9bb71f 1751 *
akashvibhute 2:3bdf0d9bb71f 1752 * @code RF24 radio(15,0); @endcode
akashvibhute 2:3bdf0d9bb71f 1753 *
akashvibhute 2:3bdf0d9bb71f 1754 * See http://iotdk.intel.com/docs/master/mraa/rasppi.html
akashvibhute 2:3bdf0d9bb71f 1755 * <br><br>
akashvibhute 2:3bdf0d9bb71f 1756 * **SPI_DEV Constructor**
akashvibhute 2:3bdf0d9bb71f 1757 *
akashvibhute 2:3bdf0d9bb71f 1758 * @code RF24 radio(22,0); @endcode
akashvibhute 2:3bdf0d9bb71f 1759 *
akashvibhute 2:3bdf0d9bb71f 1760 * See http://pi.gadgetoid.com/pinout
akashvibhute 2:3bdf0d9bb71f 1761 *
akashvibhute 2:3bdf0d9bb71f 1762 * **Pins:**
akashvibhute 2:3bdf0d9bb71f 1763 *
akashvibhute 2:3bdf0d9bb71f 1764 * | PIN | NRF24L01 | RPI | RPi -P1 Connector |
akashvibhute 2:3bdf0d9bb71f 1765 * |-----|----------|------------|-------------------|
akashvibhute 2:3bdf0d9bb71f 1766 * | 1 | GND | rpi-gnd | (25) |
akashvibhute 2:3bdf0d9bb71f 1767 * | 2 | VCC | rpi-3v3 | (17) |
akashvibhute 2:3bdf0d9bb71f 1768 * | 3 | CE | rpi-gpio22 | (15) |
akashvibhute 2:3bdf0d9bb71f 1769 * | 4 | CSN | rpi-gpio8 | (24) |
akashvibhute 2:3bdf0d9bb71f 1770 * | 5 | SCK | rpi-sckl | (23) |
akashvibhute 2:3bdf0d9bb71f 1771 * | 6 | MOSI | rpi-mosi | (19) |
akashvibhute 2:3bdf0d9bb71f 1772 * | 7 | MISO | rpi-miso | (21) |
akashvibhute 2:3bdf0d9bb71f 1773 * | 8 | IRQ | - | - |
akashvibhute 2:3bdf0d9bb71f 1774 *
akashvibhute 2:3bdf0d9bb71f 1775 *
akashvibhute 2:3bdf0d9bb71f 1776 *
akashvibhute 2:3bdf0d9bb71f 1777 *
akashvibhute 2:3bdf0d9bb71f 1778 * <br><br>
akashvibhute 2:3bdf0d9bb71f 1779 ****************
akashvibhute 2:3bdf0d9bb71f 1780 *
akashvibhute 2:3bdf0d9bb71f 1781 * Based on the arduino lib from J. Coliz <maniacbug@ymail.com> <br>
akashvibhute 2:3bdf0d9bb71f 1782 * the library was berryfied by Purinda Gunasekara <purinda@gmail.com> <br>
akashvibhute 2:3bdf0d9bb71f 1783 * then forked from github stanleyseow/RF24 to https://github.com/jscrane/RF24-rpi <br>
akashvibhute 2:3bdf0d9bb71f 1784 * Network lib also based on https://github.com/farconada/RF24Network
akashvibhute 2:3bdf0d9bb71f 1785 *
akashvibhute 2:3bdf0d9bb71f 1786 *
akashvibhute 2:3bdf0d9bb71f 1787 *
akashvibhute 2:3bdf0d9bb71f 1788 *
akashvibhute 2:3bdf0d9bb71f 1789 * <br><br><br>
akashvibhute 2:3bdf0d9bb71f 1790 *
akashvibhute 2:3bdf0d9bb71f 1791 *
akashvibhute 2:3bdf0d9bb71f 1792 *
akashvibhute 2:3bdf0d9bb71f 1793 * @page Python Python Wrapper (by https://github.com/mz-fuzzy)
akashvibhute 2:3bdf0d9bb71f 1794 *
akashvibhute 2:3bdf0d9bb71f 1795 * @section Install Installation:
akashvibhute 2:3bdf0d9bb71f 1796 *
akashvibhute 2:3bdf0d9bb71f 1797 * Install the boost libraries: (Note: Only the python libraries should be needed, this is just for simplicity)
akashvibhute 2:3bdf0d9bb71f 1798 *
akashvibhute 2:3bdf0d9bb71f 1799 * @code sudo apt-get install libboost1.50-all @endcode
akashvibhute 2:3bdf0d9bb71f 1800 *
akashvibhute 2:3bdf0d9bb71f 1801 * Build the library:
akashvibhute 2:3bdf0d9bb71f 1802 *
akashvibhute 2:3bdf0d9bb71f 1803 * @code ./setup.py build @endcode
akashvibhute 2:3bdf0d9bb71f 1804 *
akashvibhute 2:3bdf0d9bb71f 1805 * Install the library
akashvibhute 2:3bdf0d9bb71f 1806 *
akashvibhute 2:3bdf0d9bb71f 1807 * @code sudo ./setup.py install @endcode
akashvibhute 2:3bdf0d9bb71f 1808 *
akashvibhute 2:3bdf0d9bb71f 1809 *
akashvibhute 2:3bdf0d9bb71f 1810 * See the additional <a href="pages.html">Platform Support</a> pages for information on connecting your hardware <br>
akashvibhute 2:3bdf0d9bb71f 1811 * See the included <a href="pingpair_dyn_8py-example.html">example </a> for usage information.
akashvibhute 2:3bdf0d9bb71f 1812 *
akashvibhute 2:3bdf0d9bb71f 1813 * Running the Example:
akashvibhute 2:3bdf0d9bb71f 1814 *
akashvibhute 2:3bdf0d9bb71f 1815 * Edit the pingpair_dyn.py example to configure the appropriate pins per the above documentation:
akashvibhute 2:3bdf0d9bb71f 1816 *
akashvibhute 2:3bdf0d9bb71f 1817 * @code nano pingpair_dyn.py @endcode
akashvibhute 2:3bdf0d9bb71f 1818 *
akashvibhute 2:3bdf0d9bb71f 1819 * Configure another device, Arduino or RPi with the <a href="pingpair_dyn_8py-example.html">pingpair_dyn</a> example
akashvibhute 2:3bdf0d9bb71f 1820 *
akashvibhute 2:3bdf0d9bb71f 1821 * Run the example
akashvibhute 2:3bdf0d9bb71f 1822 *
akashvibhute 2:3bdf0d9bb71f 1823 * @code sudo ./pingpair_dyn.py @endcode
akashvibhute 2:3bdf0d9bb71f 1824 *
akashvibhute 2:3bdf0d9bb71f 1825 * <br><br><br>
akashvibhute 2:3bdf0d9bb71f 1826 *
akashvibhute 2:3bdf0d9bb71f 1827 *
akashvibhute 2:3bdf0d9bb71f 1828 * @page Portability RF24 Portability
akashvibhute 2:3bdf0d9bb71f 1829 *
akashvibhute 2:3bdf0d9bb71f 1830 * The RF24 radio driver mainly utilizes the <a href="http://arduino.cc/en/reference/homePage">Arduino API</a> for GPIO, SPI, and timing functions, which are easily replicated
akashvibhute 2:3bdf0d9bb71f 1831 * on various platforms. <br>Support files for these platforms are stored under RF24/utility, and can be modified to provide
akashvibhute 2:3bdf0d9bb71f 1832 * the required functionality.
akashvibhute 2:3bdf0d9bb71f 1833 *
akashvibhute 2:3bdf0d9bb71f 1834 * <br>
akashvibhute 2:3bdf0d9bb71f 1835 * @section Hardware_Templates Basic Hardware Template
akashvibhute 2:3bdf0d9bb71f 1836 *
akashvibhute 2:3bdf0d9bb71f 1837 * **RF24/utility**
akashvibhute 2:3bdf0d9bb71f 1838 *
akashvibhute 2:3bdf0d9bb71f 1839 * The RF24 library now includes a basic hardware template to assist in porting to various platforms. <br> The following files can be included
akashvibhute 2:3bdf0d9bb71f 1840 * to replicate standard Arduino functions as needed, allowing devices from ATTiny to Raspberry Pi to utilize the same core RF24 driver.
akashvibhute 2:3bdf0d9bb71f 1841 *
akashvibhute 2:3bdf0d9bb71f 1842 * | File | Purpose |
akashvibhute 2:3bdf0d9bb71f 1843 * |--------------------|------------------------------------------------------------------------------|
akashvibhute 2:3bdf0d9bb71f 1844 * | RF24_arch_config.h | Basic Arduino/AVR compatibility, includes for remaining support files, etc |
akashvibhute 2:3bdf0d9bb71f 1845 * | includes.h | Linux only. Defines specific platform, include correct RF24_arch_config file |
akashvibhute 2:3bdf0d9bb71f 1846 * | spi.h | Provides standardized SPI ( transfer() ) methods |
akashvibhute 2:3bdf0d9bb71f 1847 * | gpio.h | Provides standardized GPIO ( digitalWrite() ) methods |
akashvibhute 2:3bdf0d9bb71f 1848 * | compatibility.h | Provides standardized timing (millis(), delay()) methods |
akashvibhute 2:3bdf0d9bb71f 1849 * | your_custom_file.h | Provides access to custom drivers for spi,gpio, etc |
akashvibhute 2:3bdf0d9bb71f 1850 *
akashvibhute 2:3bdf0d9bb71f 1851 * <br>
akashvibhute 2:3bdf0d9bb71f 1852 * Examples are provided via the included hardware support templates in **RF24/utility** <br>
akashvibhute 2:3bdf0d9bb71f 1853 * See the <a href="modules.html">modules</a> page for examples of class declarations
akashvibhute 2:3bdf0d9bb71f 1854 *
akashvibhute 2:3bdf0d9bb71f 1855 *<br>
akashvibhute 2:3bdf0d9bb71f 1856 * @section Device_Detection Device Detection
akashvibhute 2:3bdf0d9bb71f 1857 *
akashvibhute 2:3bdf0d9bb71f 1858 * 1. The main detection for Linux devices is done in the Makefile, with the includes.h from the proper hardware directory copied to RF24/utility/includes.h <br>
akashvibhute 2:3bdf0d9bb71f 1859 * 2. Secondary detection is completed in RF24_config.h, causing the include.h file to be included for all supported Linux devices <br>
akashvibhute 2:3bdf0d9bb71f 1860 * 3. RF24.h contains the declaration for SPI and GPIO objects 'spi' and 'gpio' to be used for porting-in related functions.
akashvibhute 2:3bdf0d9bb71f 1861 *
akashvibhute 2:3bdf0d9bb71f 1862 * <br>
akashvibhute 2:3bdf0d9bb71f 1863 * @section Ported_Code Code
akashvibhute 2:3bdf0d9bb71f 1864 * To have your ported code included in this library, or for assistance in porting, create a pull request or open an issue at https://github.com/TMRh20/RF24
akashvibhute 2:3bdf0d9bb71f 1865 *
akashvibhute 2:3bdf0d9bb71f 1866 *
akashvibhute 2:3bdf0d9bb71f 1867 *<br><br><br>
akashvibhute 2:3bdf0d9bb71f 1868 */
akashvibhute 2:3bdf0d9bb71f 1869
akashvibhute 0:bb74812ac6bb 1870 #endif // __RF24_H__
akashvibhute 2:3bdf0d9bb71f 1871
akashvibhute 2:3bdf0d9bb71f 1872