Some improvement on mrcrsch's RF24 library

Dependents:   BabaTalp-NRF

Fork of RF24_fork by Marcell Rausch

Committer:
gume
Date:
Wed Sep 19 22:50:11 2018 +0000
Revision:
13:d295c8b3f742
Parent:
12:9a4127130006
adapted radio presence test

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