sprintf enable

Fork of RF24 by Akash Vibhute

Committer:
fmanzano_dtk
Date:
Tue Jul 18 05:58:10 2017 +0000
Revision:
11:992552951877
Parent:
6:5cc7136648d1
Se descomenta la linea;

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