Maniacbug's RF24 arduino library ported to mbed. Tested, it works for Nucleo F411

Dependents:   RF24Network_Send RF24Network_Receive WeatherStation maple_chotobot_rf_motores ... more

Committer:
akashvibhute
Date:
Wed Dec 30 01:47:37 2015 +0000
Revision:
4:a35313611c1c
Parent:
3:e94be00fd19e
Child:
6:5cc7136648d1
corrected documentation for swapped miso, mosi pins

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