,

Dependencies:   mbed

Committer:
jjeong
Date:
Sat Dec 03 08:21:37 2022 +0000
Revision:
0:9d06cdd73bc7
controller for quadrotor with RF24 driver;

Who changed what in which revision?

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