Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RF24 by
RF24.h
00001 /* 00002 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License 00006 version 2 as published by the Free Software Foundation. 00007 */ 00008 00009 /** 00010 * @file RF24.h 00011 * 00012 * Class declaration for RF24 and helper enums 00013 */ 00014 00015 /* 00016 * Mbed support added by Akash Vibhute <akash.roboticist@gmail.com> 00017 * Porting completed on Nov/05/2015 00018 * 00019 * Updated 1: Synced with TMRh20's RF24 library on Nov/04/2015 from https://github.com/TMRh20 00020 * Updated 2: Synced with TMRh20's RF24 library on Apr/18/2015 from https://github.com/TMRh20 00021 * 00022 */ 00023 00024 #ifndef __RF24_H__ 00025 #define __RF24_H__ 00026 00027 #include "RF24_config.h" 00028 #include <mbed.h> 00029 00030 00031 00032 00033 00034 00035 /** 00036 * Power Amplifier level. 00037 * 00038 * For use with setPALevel() 00039 */ 00040 typedef enum { RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR } rf24_pa_dbm_e ; 00041 00042 /** 00043 * Data rate. How fast data moves through the air. 00044 * 00045 * For use with setDataRate() 00046 */ 00047 typedef enum { RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS } rf24_datarate_e; 00048 00049 /** 00050 * CRC Length. How big (if any) of a CRC is included. 00051 * 00052 * For use with setCRCLength() 00053 */ 00054 typedef enum { RF24_CRC_DISABLED = 0, RF24_CRC_8, RF24_CRC_16 } rf24_crclength_e; 00055 00056 /** 00057 * Driver for nRF24L01(+) 2.4GHz Wireless Transceiver 00058 */ 00059 00060 class RF24 00061 { 00062 private: 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 DigitalOut ce_pin; /**< "Chip Enable" pin, activates the RX or TX role */ 00077 DigitalOut csn_pin; /**< SPI Chip select */ 00078 uint16_t spi_speed; /**< SPI Bus Speed */ 00079 00080 SPI spi; 00081 Timer mainTimer; 00082 00083 bool p_variant; /* False for RF24L01 and true for RF24L01P */ 00084 uint8_t payload_size; /**< Fixed size of payloads */ 00085 bool dynamic_payloads_enabled; /**< Whether dynamic payloads are enabled. */ 00086 uint8_t pipe0_reading_address[5]; /**< Last address set on pipe 0 for reading. */ 00087 uint8_t addr_width; /**< The address width to use - 3,4 or 5 bytes. */ 00088 uint32_t txRxDelay; /**< Var for adjusting delays depending on datarate */ 00089 00090 00091 protected: 00092 /** 00093 * SPI transactions 00094 * 00095 * Common code for SPI transactions including CSN toggle 00096 * 00097 */ 00098 inline void beginTransaction(); 00099 00100 inline void endTransaction(); 00101 00102 public: 00103 00104 /** 00105 * @name Primary public interface 00106 * 00107 * These are the main methods you need to operate the chip 00108 */ 00109 /**@{*/ 00110 00111 /** 00112 * Arduino Constructor 00113 * 00114 * Creates a new instance of this driver. Before using, you create an instance 00115 * and send in the unique pins that this chip is connected to. 00116 * 00117 * @param _cepin The pin attached to Chip Enable on the RF module 00118 * @param _cspin The pin attached to Chip Select 00119 */ 00120 RF24(PinName mosi, PinName miso, PinName sck, PinName _cepin, PinName _csnpin); 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 /** 00142 * Begin operation of the chip 00143 * 00144 * Call this in setup(), before calling any other methods. 00145 * @code radio.begin() @endcode 00146 */ 00147 bool begin(void); 00148 00149 /** 00150 * Start listening on the pipes opened for reading. 00151 * 00152 * 1. Be sure to call openReadingPipe() first. 00153 * 2. Do not call write() while in this mode, without first calling stopListening(). 00154 * 3. Call available() to check for incoming traffic, and read() to get it. 00155 * 00156 * @code 00157 * Open reading pipe 1 using address CCCECCCECC 00158 * 00159 * byte address[] = { 0xCC,0xCE,0xCC,0xCE,0xCC }; 00160 * radio.openReadingPipe(1,address); 00161 * radio.startListening(); 00162 * @endcode 00163 */ 00164 void startListening(void); 00165 00166 /** 00167 * Stop listening for incoming messages, and switch to transmit mode. 00168 * 00169 * Do this before calling write(). 00170 * @code 00171 * radio.stopListening(); 00172 * radio.write(&data,sizeof(data)); 00173 * @endcode 00174 */ 00175 void stopListening(void); 00176 00177 /** 00178 * Check whether there are bytes available to be read 00179 * @code 00180 * if(radio.available()){ 00181 * radio.read(&data,sizeof(data)); 00182 * } 00183 * @endcode 00184 * @return True if there is a payload available, false if none is 00185 */ 00186 bool available(void); 00187 00188 /** 00189 * Read the available payload 00190 * 00191 * The size of data read is the fixed payload size, see getPayloadSize() 00192 * 00193 * @note I specifically chose 'void*' as a data type to make it easier 00194 * for beginners to use. No casting needed. 00195 * 00196 * @note No longer boolean. Use available to determine if packets are 00197 * available. Interrupt flags are now cleared during reads instead of 00198 * when calling available(). 00199 * 00200 * @param buf Pointer to a buffer where the data should be written 00201 * @param len Maximum number of bytes to read into the buffer 00202 * 00203 * @code 00204 * if(radio.available()){ 00205 * radio.read(&data,sizeof(data)); 00206 * } 00207 * @endcode 00208 * @return No return value. Use available(). 00209 */ 00210 void read( void* buf, uint8_t len ); 00211 00212 /** 00213 * Be sure to call openWritingPipe() first to set the destination 00214 * of where to write to. 00215 * 00216 * This blocks until the message is successfully acknowledged by 00217 * the receiver or the timeout/retransmit maxima are reached. In 00218 * the current configuration, the max delay here is 60-70ms. 00219 * 00220 * The maximum size of data written is the fixed payload size, see 00221 * getPayloadSize(). However, you can write less, and the remainder 00222 * will just be filled with zeroes. 00223 * 00224 * TX/RX/RT interrupt flags will be cleared every time write is called 00225 * 00226 * @param buf Pointer to the data to be sent 00227 * @param len Number of bytes to be sent 00228 * 00229 * @code 00230 * radio.stopListening(); 00231 * radio.write(&data,sizeof(data)); 00232 * @endcode 00233 * @return True if the payload was delivered successfully false if not 00234 */ 00235 bool write( const void* buf, uint8_t len ); 00236 00237 /** 00238 * New: Open a pipe for writing via byte array. Old addressing format retained 00239 * for compatibility. 00240 * 00241 * Only one writing pipe can be open at once, but you can change the address 00242 * you'll write to. Call stopListening() first. 00243 * 00244 * Addresses are assigned via a byte array, default is 5 byte address length 00245 s * 00246 * @code 00247 * uint8_t addresses[][6] = {"1Node","2Node"}; 00248 * radio.openWritingPipe(addresses[0]); 00249 * @endcode 00250 * @code 00251 * uint8_t address[] = { 0xCC,0xCE,0xCC,0xCE,0xCC }; 00252 * radio.openWritingPipe(address); 00253 * address[0] = 0x33; 00254 * radio.openReadingPipe(1,address); 00255 * @endcode 00256 * @see setAddressWidth 00257 * 00258 * @param address The address of the pipe to open. Coordinate these pipe 00259 * addresses amongst nodes on the network. 00260 */ 00261 00262 void openWritingPipe(const uint8_t *address); 00263 00264 /** 00265 * Open a pipe for reading 00266 * 00267 * Up to 6 pipes can be open for reading at once. Open all the required 00268 * reading pipes, and then call startListening(). 00269 * 00270 * @see openWritingPipe 00271 * @see setAddressWidth 00272 * 00273 * @note Pipes 0 and 1 will store a full 5-byte address. Pipes 2-5 will technically 00274 * only store a single byte, borrowing up to 4 additional bytes from pipe #1 per the 00275 * assigned address width. 00276 * @warning Pipes 1-5 should share the same address, except the first byte. 00277 * Only the first byte in the array should be unique, e.g. 00278 * @code 00279 * uint8_t addresses[][6] = {"1Node","2Node"}; 00280 * openReadingPipe(1,addresses[0]); 00281 * openReadingPipe(2,addresses[1]); 00282 * @endcode 00283 * 00284 * @warning Pipe 0 is also used by the writing pipe. So if you open 00285 * pipe 0 for reading, and then startListening(), it will overwrite the 00286 * writing pipe. Ergo, do an openWritingPipe() again before write(). 00287 * 00288 * @param number Which pipe# to open, 0-5. 00289 * @param address The 24, 32 or 40 bit address of the pipe to open. 00290 */ 00291 00292 void openReadingPipe(uint8_t number, const uint8_t *address); 00293 00294 /**@}*/ 00295 /** 00296 * @name Advanced Operation 00297 * 00298 * Methods you can use to drive the chip in more advanced ways 00299 */ 00300 /**@{*/ 00301 00302 /** 00303 * Print a giant block of debugging information to stdout 00304 * 00305 * @warning Does nothing if stdout is not defined. See fdevopen in stdio.h 00306 * The printf.h file is included with the library for Arduino. 00307 * @code 00308 * #include <printf.h> 00309 * setup(){ 00310 * Serial.begin(115200); 00311 * printf_begin(); 00312 * ... 00313 * } 00314 * @endcode 00315 */ 00316 void printDetails(void); 00317 00318 /** 00319 * Test whether there are bytes available to be read in the 00320 * FIFO buffers. 00321 * 00322 * @param[out] pipe_num Which pipe has the payload available 00323 * 00324 * @code 00325 * uint8_t pipeNum; 00326 * if(radio.available(&pipeNum)){ 00327 * radio.read(&data,sizeof(data)); 00328 * Serial.print("Got data on pipe"); 00329 * Serial.println(pipeNum); 00330 * } 00331 * @endcode 00332 * @return True if there is a payload available, false if none is 00333 */ 00334 bool available(uint8_t* pipe_num); 00335 00336 /** 00337 * Check if the radio needs to be read. Can be used to prevent data loss 00338 * @return True if all three 32-byte radio buffers are full 00339 */ 00340 bool rxFifoFull(); 00341 00342 /** 00343 * Enter low-power mode 00344 * 00345 * To return to normal power mode, call powerUp(). 00346 * 00347 * @note After calling startListening(), a basic radio will consume about 13.5mA 00348 * at max PA level. 00349 * During active transmission, the radio will consume about 11.5mA, but this will 00350 * be reduced to 26uA (.026mA) between sending. 00351 * In full powerDown mode, the radio will consume approximately 900nA (.0009mA) 00352 * 00353 * @code 00354 * radio.powerDown(); 00355 * avr_enter_sleep_mode(); // Custom function to sleep the device 00356 * radio.powerUp(); 00357 * @endcode 00358 */ 00359 void powerDown(void); 00360 00361 /** 00362 * Leave low-power mode - required for normal radio operation after calling powerDown() 00363 * 00364 * To return to low power mode, call powerDown(). 00365 * @note This will take up to 5ms for maximum compatibility 00366 */ 00367 void powerUp(void) ; 00368 00369 /** 00370 * Write for single NOACK writes. Optionally disables acknowledgements/autoretries for a single write. 00371 * 00372 * @note enableDynamicAck() must be called to enable this feature 00373 * 00374 * Can be used with enableAckPayload() to request a response 00375 * @see enableDynamicAck() 00376 * @see setAutoAck() 00377 * @see write() 00378 * 00379 * @param buf Pointer to the data to be sent 00380 * @param len Number of bytes to be sent 00381 * @param multicast Request ACK (0), NOACK (1) 00382 */ 00383 bool write( const void* buf, uint8_t len, const bool multicast ); 00384 00385 /** 00386 * This will not block until the 3 FIFO buffers are filled with data. 00387 * Once the FIFOs are full, writeFast will simply wait for success or 00388 * timeout, and return 1 or 0 respectively. From a user perspective, just 00389 * keep trying to send the same data. The library will keep auto retrying 00390 * the current payload using the built in functionality. 00391 * @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 00392 * retransmit is enabled, the nRF24L01 is never in TX mode long enough to disobey this rule. Allow the FIFO 00393 * to clear by issuing txStandBy() or ensure appropriate time between transmissions. 00394 * 00395 * @code 00396 * Example (Partial blocking): 00397 * 00398 * radio.writeFast(&buf,32); // Writes 1 payload to the buffers 00399 * txStandBy(); // Returns 0 if failed. 1 if success. Blocks only until MAX_RT timeout or success. Data flushed on fail. 00400 * 00401 * radio.writeFast(&buf,32); // Writes 1 payload to the buffers 00402 * txStandBy(1000); // Using extended timeouts, returns 1 if success. Retries failed payloads for 1 seconds before returning 0. 00403 * @endcode 00404 * 00405 * @see txStandBy() 00406 * @see write() 00407 * @see writeBlocking() 00408 * 00409 * @param buf Pointer to the data to be sent 00410 * @param len Number of bytes to be sent 00411 * @return True if the payload was delivered successfully false if not 00412 */ 00413 bool writeFast( const void* buf, uint8_t len ); 00414 00415 /** 00416 * WriteFast for single NOACK writes. Disables acknowledgements/autoretries for a single write. 00417 * 00418 * @note enableDynamicAck() must be called to enable this feature 00419 * @see enableDynamicAck() 00420 * @see setAutoAck() 00421 * 00422 * @param buf Pointer to the data to be sent 00423 * @param len Number of bytes to be sent 00424 * @param multicast Request ACK (0) or NOACK (1) 00425 */ 00426 bool writeFast( const void* buf, uint8_t len, const bool multicast ); 00427 00428 /** 00429 * This function extends the auto-retry mechanism to any specified duration. 00430 * It will not block until the 3 FIFO buffers are filled with data. 00431 * If so the library will auto retry until a new payload is written 00432 * or the user specified timeout period is reached. 00433 * @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 00434 * retransmit is enabled, the nRF24L01 is never in TX mode long enough to disobey this rule. Allow the FIFO 00435 * to clear by issuing txStandBy() or ensure appropriate time between transmissions. 00436 * 00437 * @code 00438 * Example (Full blocking): 00439 * 00440 * radio.writeBlocking(&buf,32,1000); //Wait up to 1 second to write 1 payload to the buffers 00441 * txStandBy(1000); //Wait up to 1 second for the payload to send. Return 1 if ok, 0 if failed. 00442 * //Blocks only until user timeout or success. Data flushed on fail. 00443 * @endcode 00444 * @note If used from within an interrupt, the interrupt should be disabled until completion, and sei(); called to enable millis(). 00445 * @see txStandBy() 00446 * @see write() 00447 * @see writeFast() 00448 * 00449 * @param buf Pointer to the data to be sent 00450 * @param len Number of bytes to be sent 00451 * @param timeout User defined timeout in milliseconds. 00452 * @return True if the payload was loaded into the buffer successfully false if not 00453 */ 00454 bool writeBlocking( const void* buf, uint8_t len, uint32_t timeout ); 00455 00456 /** 00457 * This function should be called as soon as transmission is finished to 00458 * drop the radio back to STANDBY-I mode. If not issued, the radio will 00459 * remain in STANDBY-II mode which, per the data sheet, is not a recommended 00460 * operating mode. 00461 * 00462 * @note When transmitting data in rapid succession, it is still recommended by 00463 * the manufacturer to drop the radio out of TX or STANDBY-II mode if there is 00464 * time enough between sends for the FIFOs to empty. This is not required if auto-ack 00465 * is enabled. 00466 * 00467 * Relies on built-in auto retry functionality. 00468 * 00469 * @code 00470 * Example (Partial blocking): 00471 * 00472 * radio.writeFast(&buf,32); 00473 * radio.writeFast(&buf,32); 00474 * radio.writeFast(&buf,32); //Fills the FIFO buffers up 00475 * bool ok = txStandBy(); //Returns 0 if failed. 1 if success. 00476 * //Blocks only until MAX_RT timeout or success. Data flushed on fail. 00477 * @endcode 00478 * @see txStandBy(unsigned long timeout) 00479 * @return True if transmission is successful 00480 * 00481 */ 00482 bool txStandBy(); 00483 00484 /** 00485 * This function allows extended blocking and auto-retries per a user defined timeout 00486 * @code 00487 * Fully Blocking Example: 00488 * 00489 * radio.writeFast(&buf,32); 00490 * radio.writeFast(&buf,32); 00491 * radio.writeFast(&buf,32); //Fills the FIFO buffers up 00492 * bool ok = txStandBy(1000); //Returns 0 if failed after 1 second of retries. 1 if success. 00493 * //Blocks only until user defined timeout or success. Data flushed on fail. 00494 * @endcode 00495 * @note If used from within an interrupt, the interrupt should be disabled until completion, and sei(); called to enable millis(). 00496 * @param timeout Number of milliseconds to retry failed payloads 00497 * @return True if transmission is successful 00498 * 00499 */ 00500 bool txStandBy(uint32_t timeout, bool startTx = 0); 00501 00502 /** 00503 * Write an ack payload for the specified pipe 00504 * 00505 * The next time a message is received on @p pipe, the data in @p buf will 00506 * be sent back in the acknowledgement. 00507 * @see enableAckPayload() 00508 * @see enableDynamicPayloads() 00509 * @warning Only three of these can be pending at any time as there are only 3 FIFO buffers.<br> Dynamic payloads must be enabled. 00510 * @note Ack payloads are handled automatically by the radio chip when a payload is received. Users should generally 00511 * write an ack payload as soon as startListening() is called, so one is available when a regular payload is received. 00512 * @note Ack payloads are dynamic payloads. This only works on pipes 0&1 by default. Call 00513 * enableDynamicPayloads() to enable on all pipes. 00514 * 00515 * @param pipe Which pipe# (typically 1-5) will get this response. 00516 * @param buf Pointer to data that is sent 00517 * @param len Length of the data to send, up to 32 bytes max. Not affected 00518 * by the static payload set by setPayloadSize(). 00519 */ 00520 void writeAckPayload(uint8_t pipe, const void* buf, uint8_t len); 00521 00522 /** 00523 * Determine if an ack payload was received in the most recent call to 00524 * write(). The regular available() can also be used. 00525 * 00526 * Call read() to retrieve the ack payload. 00527 * 00528 * @return True if an ack payload is available. 00529 */ 00530 bool isAckPayloadAvailable(void); 00531 00532 /** 00533 * Call this when you get an interrupt to find out why 00534 * 00535 * Tells you what caused the interrupt, and clears the state of 00536 * interrupts. 00537 * 00538 * @param[out] tx_ok The send was successful (TX_DS) 00539 * @param[out] tx_fail The send failed, too many retries (MAX_RT) 00540 * @param[out] rx_ready There is a message waiting to be read (RX_DS) 00541 */ 00542 void whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready); 00543 00544 /** 00545 * Non-blocking write to the open writing pipe used for buffered writes 00546 * 00547 * @note Optimization: This function now leaves the CE pin high, so the radio 00548 * will remain in TX or STANDBY-II Mode until a txStandBy() command is issued. Can be used as an alternative to startWrite() 00549 * if writing multiple payloads at once. 00550 * @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 00551 * retransmit/autoAck is enabled, the nRF24L01 is never in TX mode long enough to disobey this rule. Allow the FIFO 00552 * to clear by issuing txStandBy() or ensure appropriate time between transmissions. 00553 * 00554 * @see write() 00555 * @see writeFast() 00556 * @see startWrite() 00557 * @see writeBlocking() 00558 * 00559 * For single noAck writes see: 00560 * @see enableDynamicAck() 00561 * @see setAutoAck() 00562 * 00563 * @param buf Pointer to the data to be sent 00564 * @param len Number of bytes to be sent 00565 * @param multicast Request ACK (0) or NOACK (1) 00566 * @return True if the payload was delivered successfully false if not 00567 */ 00568 void startFastWrite( const void* buf, uint8_t len, const bool multicast, bool startTx = 1 ); 00569 00570 /** 00571 * Non-blocking write to the open writing pipe 00572 * 00573 * Just like write(), but it returns immediately. To find out what happened 00574 * to the send, catch the IRQ and then call whatHappened(). 00575 * 00576 * @see write() 00577 * @see writeFast() 00578 * @see startFastWrite() 00579 * @see whatHappened() 00580 * 00581 * For single noAck writes see: 00582 * @see enableDynamicAck() 00583 * @see setAutoAck() 00584 * 00585 * @param buf Pointer to the data to be sent 00586 * @param len Number of bytes to be sent 00587 * @param multicast Request ACK (0) or NOACK (1) 00588 * 00589 */ 00590 void startWrite( const void* buf, uint8_t len, const bool multicast ); 00591 00592 /** 00593 * This function is mainly used internally to take advantage of the auto payload 00594 * re-use functionality of the chip, but can be beneficial to users as well. 00595 * 00596 * The function will instruct the radio to re-use the data in the FIFO buffers, 00597 * and instructs the radio to re-send once the timeout limit has been reached. 00598 * Used by writeFast and writeBlocking to initiate retries when a TX failure 00599 * occurs. Retries are automatically initiated except with the standard write(). 00600 * This way, data is not flushed from the buffer until switching between modes. 00601 * 00602 * @note This is to be used AFTER auto-retry fails if wanting to resend 00603 * using the built-in payload reuse features. 00604 * After issuing reUseTX(), it will keep reending the same payload forever or until 00605 * a payload is written to the FIFO, or a flush_tx command is given. 00606 */ 00607 void reUseTX(); 00608 00609 /** 00610 * Empty the transmit buffer. This is generally not required in standard operation. 00611 * May be required in specific cases after stopListening() , if operating at 250KBPS data rate. 00612 * 00613 * @return Current value of status register 00614 */ 00615 uint8_t flush_tx(void); 00616 00617 /** 00618 * Test whether there was a carrier on the line for the 00619 * previous listening period. 00620 * 00621 * Useful to check for interference on the current channel. 00622 * 00623 * @return true if was carrier, false if not 00624 */ 00625 bool testCarrier(void); 00626 00627 /** 00628 * Test whether a signal (carrier or otherwise) greater than 00629 * or equal to -64dBm is present on the channel. Valid only 00630 * on nRF24L01P (+) hardware. On nRF24L01, use testCarrier(). 00631 * 00632 * Useful to check for interference on the current channel and 00633 * channel hopping strategies. 00634 * 00635 * @code 00636 * bool goodSignal = radio.testRPD(); 00637 * if(radio.available()){ 00638 * Serial.println(goodSignal ? "Strong signal > 64dBm" : "Weak signal < 64dBm" ); 00639 * radio.read(0,0); 00640 * } 00641 * @endcode 00642 * @return true if signal => -64dBm, false if not 00643 */ 00644 bool testRPD(void) ; 00645 00646 /** 00647 * Test whether this is a real radio, or a mock shim for 00648 * debugging. Setting either pin to 0xff is the way to 00649 * indicate that this is not a real radio. 00650 * 00651 * @return true if this is a legitimate radio 00652 */ 00653 bool isValid() { return ce_pin != 0xff && csn_pin != 0xff; } 00654 00655 /** 00656 * Close a pipe after it has been previously opened. 00657 * Can be safely called without having previously opened a pipe. 00658 * @param pipe Which pipe # to close, 0-5. 00659 */ 00660 void closeReadingPipe( uint8_t pipe ) ; 00661 00662 /** 00663 * Enable error detection by un-commenting #define FAILURE_HANDLING in RF24_config.h 00664 * If a failure has been detected, it usually indicates a hardware issue. By default the library 00665 * will cease operation when a failure is detected. 00666 * This should allow advanced users to detect and resolve intermittent hardware issues. 00667 * 00668 * In most cases, the radio must be re-enabled via radio.begin(); and the appropriate settings 00669 * applied after a failure occurs, if wanting to re-enable the device immediately. 00670 * 00671 * Usage: (Failure handling must be enabled per above) 00672 * @code 00673 * if(radio.failureDetected){ 00674 * radio.begin(); // Attempt to re-configure the radio with defaults 00675 * radio.failureDetected = 0; // Reset the detection value 00676 * radio.openWritingPipe(addresses[1]); // Re-configure pipe addresses 00677 * radio.openReadingPipe(1,addresses[0]); 00678 * report_failure(); // Blink leds, send a message, etc. to indicate failure 00679 * } 00680 * @endcode 00681 */ 00682 //#if defined (FAILURE_HANDLING) 00683 bool failureDetected; 00684 //#endif 00685 00686 /**@}*/ 00687 00688 /**@}*/ 00689 /** 00690 * @name Optional Configurators 00691 * 00692 * Methods you can use to get or set the configuration of the chip. 00693 * None are required. Calling begin() sets up a reasonable set of 00694 * defaults. 00695 */ 00696 /**@{*/ 00697 00698 /** 00699 * Set the address width from 3 to 5 bytes (24, 32 or 40 bit) 00700 * 00701 * @param a_width The address width to use: 3,4 or 5 00702 */ 00703 00704 void setAddressWidth(uint8_t a_width); 00705 00706 /** 00707 * Set the number and delay of retries upon failed submit 00708 * 00709 * @param delay How long to wait between each retry, in multiples of 250us, 00710 * max is 15. 0 means 250us, 15 means 4000us. 00711 * @param count How many retries before giving up, max 15 00712 */ 00713 void setRetries(uint8_t delay, uint8_t count); 00714 00715 /** 00716 * Set RF communication channel 00717 * 00718 * @param channel Which RF channel to communicate on, 0-125 00719 */ 00720 void setChannel(uint8_t channel); 00721 00722 /** 00723 * Get RF communication channel 00724 * 00725 * @return The currently configured RF Channel 00726 */ 00727 uint8_t getChannel(void); 00728 00729 /** 00730 * Set Static Payload Size 00731 * 00732 * This implementation uses a pre-stablished fixed payload size for all 00733 * transmissions. If this method is never called, the driver will always 00734 * transmit the maximum payload size (32 bytes), no matter how much 00735 * was sent to write(). 00736 * 00737 * @todo Implement variable-sized payloads feature 00738 * 00739 * @param size The number of bytes in the payload 00740 */ 00741 void setPayloadSize(uint8_t size); 00742 00743 /** 00744 * Get Static Payload Size 00745 * 00746 * @see setPayloadSize() 00747 * 00748 * @return The number of bytes in the payload 00749 */ 00750 uint8_t getPayloadSize(void); 00751 00752 /** 00753 * Get Dynamic Payload Size 00754 * 00755 * For dynamic payloads, this pulls the size of the payload off 00756 * the chip 00757 * 00758 * @note Corrupt packets are now detected and flushed per the 00759 * manufacturer. 00760 * @code 00761 * if(radio.available()){ 00762 * if(radio.getDynamicPayloadSize() < 1){ 00763 * // Corrupt payload has been flushed 00764 * return; 00765 * } 00766 * radio.read(&data,sizeof(data)); 00767 * } 00768 * @endcode 00769 * 00770 * @return Payload length of last-received dynamic payload 00771 */ 00772 uint8_t getDynamicPayloadSize(void); 00773 00774 /** 00775 * Enable custom payloads on the acknowledge packets 00776 * 00777 * Ack payloads are a handy way to return data back to senders without 00778 * manually changing the radio modes on both units. 00779 * 00780 * @note Ack payloads are dynamic payloads. This only works on pipes 0&1 by default. Call 00781 * enableDynamicPayloads() to enable on all pipes. 00782 */ 00783 void enableAckPayload(void); 00784 00785 /** 00786 * Enable dynamically-sized payloads 00787 * 00788 * This way you don't always have to send large packets just to send them 00789 * once in a while. This enables dynamic payloads on ALL pipes. 00790 * 00791 */ 00792 void enableDynamicPayloads(void); 00793 00794 /** 00795 * Enable dynamic ACKs (single write multicast or unicast) for chosen messages 00796 * 00797 * @note To enable full multicast or per-pipe multicast, use setAutoAck() 00798 * 00799 * @warning This MUST be called prior to attempting single write NOACK calls 00800 * @code 00801 * radio.enableDynamicAck(); 00802 * radio.write(&data,32,1); // Sends a payload with no acknowledgement requested 00803 * radio.write(&data,32,0); // Sends a payload using auto-retry/autoACK 00804 * @endcode 00805 */ 00806 void enableDynamicAck(); 00807 00808 /** 00809 * Determine whether the hardware is an nRF24L01+ or not. 00810 * 00811 * @return true if the hardware is nRF24L01+ (or compatible) and false 00812 * if its not. 00813 */ 00814 bool isPVariant(void) ; 00815 00816 /** 00817 * Enable or disable auto-acknowlede packets 00818 * 00819 * This is enabled by default, so it's only needed if you want to turn 00820 * it off for some reason. 00821 * 00822 * @param enable Whether to enable (true) or disable (false) auto-acks 00823 */ 00824 void setAutoAck(bool enable); 00825 00826 /** 00827 * Enable or disable auto-acknowlede packets on a per pipeline basis. 00828 * 00829 * AA is enabled by default, so it's only needed if you want to turn 00830 * it off/on for some reason on a per pipeline basis. 00831 * 00832 * @param pipe Which pipeline to modify 00833 * @param enable Whether to enable (true) or disable (false) auto-acks 00834 */ 00835 void setAutoAck( uint8_t pipe, bool enable ) ; 00836 00837 /** 00838 * Set Power Amplifier (PA) level to one of four levels: 00839 * RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX 00840 * 00841 * The power levels correspond to the following output levels respectively: 00842 * NRF24L01: -18dBm, -12dBm,-6dBM, and 0dBm 00843 * 00844 * SI24R1: -6dBm, 0dBm, 3dBM, and 7dBm. 00845 * 00846 * @param level Desired PA level. 00847 */ 00848 void setPALevel ( uint8_t level ); 00849 00850 /** 00851 * Fetches the current PA level. 00852 * 00853 * NRF24L01: -18dBm, -12dBm, -6dBm and 0dBm 00854 * SI24R1: -6dBm, 0dBm, 3dBm, 7dBm 00855 * 00856 * @return Returns values 0 to 3 representing the PA Level. 00857 */ 00858 uint8_t getPALevel( void ); 00859 00860 /** 00861 * Set the transmission data rate 00862 * 00863 * @warning setting RF24_250KBPS will fail for non-plus units 00864 * 00865 * @param speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps 00866 * @return true if the change was successful 00867 */ 00868 bool setDataRate(rf24_datarate_e speed); 00869 00870 /** 00871 * Fetches the transmission data rate 00872 * 00873 * @return Returns the hardware's currently configured datarate. The value 00874 * is one of 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS, as defined in the 00875 * rf24_datarate_e enum. 00876 */ 00877 rf24_datarate_e getDataRate( void ) ; 00878 00879 /** 00880 * Set the CRC length 00881 * <br>CRC checking cannot be disabled if auto-ack is enabled 00882 * @param length RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit 00883 */ 00884 void setCRCLength(rf24_crclength_e length); 00885 00886 /** 00887 * Get the CRC length 00888 * <br>CRC checking cannot be disabled if auto-ack is enabled 00889 * @return RF24_DISABLED if disabled or RF24_CRC_8 for 8-bit or RF24_CRC_16 for 16-bit 00890 */ 00891 rf24_crclength_e getCRCLength(void); 00892 00893 /** 00894 * Disable CRC validation 00895 * 00896 * @warning CRC cannot be disabled if auto-ack/ESB is enabled. 00897 */ 00898 void disableCRC( void ) ; 00899 00900 /** 00901 * The radio will generate interrupt signals when a transmission is complete, 00902 * a transmission fails, or a payload is received. This allows users to mask 00903 * those interrupts to prevent them from generating a signal on the interrupt 00904 * pin. Interrupts are enabled on the radio chip by default. 00905 * 00906 * @code 00907 * Mask all interrupts except the receive interrupt: 00908 * 00909 * radio.maskIRQ(1,1,0); 00910 * @endcode 00911 * 00912 * @param tx_ok Mask transmission complete interrupts 00913 * @param tx_fail Mask transmit failure interrupts 00914 * @param rx_ready Mask payload received interrupts 00915 */ 00916 void maskIRQ(bool tx_ok,bool tx_fail,bool rx_ready); 00917 00918 /**@}*/ 00919 /** 00920 * @name Deprecated 00921 * 00922 * Methods provided for backwards compabibility. 00923 */ 00924 /**@{*/ 00925 00926 00927 /** 00928 * Open a pipe for reading 00929 * @note For compatibility with old code only, see new function 00930 * 00931 * @warning Pipes 1-5 should share the first 32 bits. 00932 * Only the least significant byte should be unique, e.g. 00933 * @code 00934 * openReadingPipe(1,0xF0F0F0F0AA); 00935 * openReadingPipe(2,0xF0F0F0F066); 00936 * @endcode 00937 * 00938 * @warning Pipe 0 is also used by the writing pipe. So if you open 00939 * pipe 0 for reading, and then startListening(), it will overwrite the 00940 * writing pipe. Ergo, do an openWritingPipe() again before write(). 00941 * 00942 * @param number Which pipe# to open, 0-5. 00943 * @param address The 40-bit address of the pipe to open. 00944 */ 00945 void openReadingPipe(uint8_t number, uint64_t address); 00946 00947 /** 00948 * Open a pipe for writing 00949 * @note For compatibility with old code only, see new function 00950 * 00951 * Addresses are 40-bit hex values, e.g.: 00952 * 00953 * @code 00954 * openWritingPipe(0xF0F0F0F0F0); 00955 * @endcode 00956 * 00957 * @param address The 40-bit address of the pipe to open. 00958 */ 00959 void openWritingPipe(uint64_t address); 00960 00961 private: 00962 00963 /** 00964 * @name Low-level internal interface. 00965 * 00966 * Protected methods that address the chip directly. Regular users cannot 00967 * ever call these. They are documented for completeness and for developers who 00968 * may want to extend this class. 00969 */ 00970 /**@{*/ 00971 00972 /** 00973 * Set chip select pin 00974 * 00975 * Running SPI bus at PI_CLOCK_DIV2 so we don't waste time transferring data 00976 * and best of all, we make use of the radio's FIFO buffers. A lower speed 00977 * means we're less likely to effectively leverage our FIFOs and pay a higher 00978 * AVR runtime cost as toll. 00979 * 00980 * @param mode HIGH to take this unit off the SPI bus, LOW to put it on 00981 */ 00982 void csn(bool mode); 00983 00984 /** 00985 * Set chip enable 00986 * 00987 * @param level HIGH to actively begin transmission or LOW to put in standby. Please see data sheet 00988 * for a much more detailed description of this pin. 00989 */ 00990 void ce(bool level); 00991 00992 /** 00993 * Read a chunk of data in from a register 00994 * 00995 * @param reg Which register. Use constants from nRF24L01.h 00996 * @param buf Where to put the data 00997 * @param len How many bytes of data to transfer 00998 * @return Current value of status register 00999 */ 01000 uint8_t read_register(uint8_t reg, uint8_t* buf, uint8_t len); 01001 01002 /** 01003 * Read single byte from a register 01004 * 01005 * @param reg Which register. Use constants from nRF24L01.h 01006 * @return Current value of register @p reg 01007 */ 01008 uint8_t read_register(uint8_t reg); 01009 01010 /** 01011 * Write a chunk of data to a register 01012 * 01013 * @param reg Which register. Use constants from nRF24L01.h 01014 * @param buf Where to get the data 01015 * @param len How many bytes of data to transfer 01016 * @return Current value of status register 01017 */ 01018 uint8_t write_register(uint8_t reg, const uint8_t* buf, uint8_t len); 01019 01020 /** 01021 * Write a single byte to a register 01022 * 01023 * @param reg Which register. Use constants from nRF24L01.h 01024 * @param value The new value to write 01025 * @return Current value of status register 01026 */ 01027 uint8_t write_register(uint8_t reg, uint8_t value); 01028 01029 /** 01030 * Write the transmit payload 01031 * 01032 * The size of data written is the fixed payload size, see getPayloadSize() 01033 * 01034 * @param buf Where to get the data 01035 * @param len Number of bytes to be sent 01036 * @return Current value of status register 01037 */ 01038 uint8_t write_payload(const void* buf, uint8_t len, const uint8_t writeType); 01039 01040 /** 01041 * Read the receive payload 01042 * 01043 * The size of data read is the fixed payload size, see getPayloadSize() 01044 * 01045 * @param buf Where to put the data 01046 * @param len Maximum number of bytes to read 01047 * @return Current value of status register 01048 */ 01049 uint8_t read_payload(void* buf, uint8_t len); 01050 01051 /** 01052 * Empty the receive buffer 01053 * 01054 * @return Current value of status register 01055 */ 01056 uint8_t flush_rx(void); 01057 01058 /** 01059 * Retrieve the current status of the chip 01060 * 01061 * @return Current value of status register 01062 */ 01063 uint8_t get_status(void); 01064 01065 #if !defined (MINIMAL) 01066 /** 01067 * Decode and print the given status to stdout 01068 * 01069 * @param status Status value to print 01070 * 01071 * @warning Does nothing if stdout is not defined. See fdevopen in stdio.h 01072 */ 01073 void print_status(uint8_t status); 01074 01075 /** 01076 * Decode and print the given 'observe_tx' value to stdout 01077 * 01078 * @param value The observe_tx value to print 01079 * 01080 * @warning Does nothing if stdout is not defined. See fdevopen in stdio.h 01081 */ 01082 void print_observe_tx(uint8_t value); 01083 01084 /** 01085 * Print the name and value of an 8-bit register to stdout 01086 * 01087 * Optionally it can print some quantity of successive 01088 * registers on the same line. This is useful for printing a group 01089 * of related registers on one line. 01090 * 01091 * @param name Name of the register 01092 * @param reg Which register. Use constants from nRF24L01.h 01093 * @param qty How many successive registers to print 01094 */ 01095 void print_byte_register(const char* name, uint8_t reg, uint8_t qty = 1); 01096 01097 /** 01098 * Print the name and value of a 40-bit address register to stdout 01099 * 01100 * Optionally it can print some quantity of successive 01101 * registers on the same line. This is useful for printing a group 01102 * of related registers on one line. 01103 * 01104 * @param name Name of the register 01105 * @param reg Which register. Use constants from nRF24L01.h 01106 * @param qty How many successive registers to print 01107 */ 01108 void print_address_register(const char* name, uint8_t reg, uint8_t qty = 1); 01109 #endif 01110 /** 01111 * Turn on or off the special features of the chip 01112 * 01113 * The chip has certain 'features' which are only available when the 'features' 01114 * are enabled. See the datasheet for details. 01115 */ 01116 void toggle_features(void); 01117 01118 /** 01119 * Built in spi transfer function to simplify repeating code repeating code 01120 */ 01121 01122 uint8_t spiTrans(uint8_t cmd); 01123 01124 #if defined (FAILURE_HANDLING) || defined (RF24_LINUX) 01125 void errNotify(void); 01126 #endif 01127 01128 /**@}*/ 01129 01130 }; 01131 01132 01133 /** 01134 * @example GettingStarted.ino 01135 * <b>For Arduino</b><br> 01136 * <b>Updated: TMRh20 2014 </b><br> 01137 * 01138 * This is an example of how to use the RF24 class to communicate on a basic level. Configure and write this sketch to two 01139 * different nodes. Put one of the nodes into 'transmit' mode by connecting with the serial monitor and <br> 01140 * sending a 'T'. The ping node sends the current time to the pong node, which responds by sending the value 01141 * back. The ping node can then see how long the whole cycle took. <br> 01142 * @note For a more efficient call-response scenario see the GettingStarted_CallResponse.ino example. 01143 * @note When switching between sketches, the radio may need to be powered down to clear settings that are not "un-set" otherwise 01144 */ 01145 01146 /** 01147 * @example GettingStarted.cpp 01148 * <b>For Raspberry Pi</b><br> 01149 * <b>Updated: TMRh20 2014 </b><br> 01150 * 01151 * This is an example of how to use the RF24 class to communicate on a basic level. Configure and write this sketch to two 01152 * different nodes. Put one of the nodes into 'transmit' mode by connecting with the serial monitor and <br> 01153 * sending a 'T'. The ping node sends the current time to the pong node, which responds by sending the value 01154 * back. The ping node can then see how long the whole cycle took. <br> 01155 * @note For a more efficient call-response scenario see the GettingStarted_CallResponse.ino example. 01156 */ 01157 01158 /** 01159 * @example GettingStarted_CallResponse.ino 01160 * <b>For Arduino</b><br> 01161 * <b>New: TMRh20 2014</b><br> 01162 * 01163 * This example continues to make use of all the normal functionality of the radios including 01164 * the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well. <br> 01165 * This allows very fast call-response communication, with the responding radio never having to 01166 * switch out of Primary Receiver mode to send back a payload, but having the option to switch to <br> 01167 * primary transmitter if wanting to initiate communication instead of respond to a commmunication. 01168 */ 01169 01170 /** 01171 * @example GettingStarted_Call_Response.cpp 01172 * <b>For Raspberry Pi</b><br> 01173 * <b>New: TMRh20 2014</b><br> 01174 * 01175 * This example continues to make use of all the normal functionality of the radios including 01176 * the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well. <br> 01177 * This allows very fast call-response communication, with the responding radio never having to 01178 * switch out of Primary Receiver mode to send back a payload, but having the option to switch to <br> 01179 * primary transmitter if wanting to initiate communication instead of respond to a commmunication. 01180 */ 01181 01182 /** 01183 * @example GettingStarted_HandlingData.ino 01184 * <b>Dec 2014 - TMRh20</b><br> 01185 * 01186 * This example demonstrates how to send multiple variables in a single payload and work with data. As usual, it is 01187 * generally important to include an incrementing value like millis() in the payloads to prevent errors. 01188 */ 01189 01190 /** 01191 * @example Transfer.ino 01192 * <b>For Arduino</b><br> 01193 * This example demonstrates half-rate transfer using the FIFO buffers<br> 01194 * 01195 * It is an example of how to use the RF24 class. Write this sketch to two 01196 * different nodes. Put one of the nodes into 'transmit' mode by connecting <br> 01197 * with the serial monitor and sending a 'T'. The data transfer will begin, 01198 * with the receiver displaying the payload count. (32Byte Payloads) <br> 01199 */ 01200 01201 /** 01202 * @example Transfer.cpp 01203 * <b>For Raspberry Pi</b><br> 01204 * This example demonstrates half-rate transfer using the FIFO buffers<br> 01205 * 01206 * It is an example of how to use the RF24 class. Write this sketch to two 01207 * different nodes. Put one of the nodes into 'transmit' mode by connecting <br> 01208 * with the serial monitor and sending a 'T'. The data transfer will begin, 01209 * with the receiver displaying the payload count. (32Byte Payloads) <br> 01210 */ 01211 01212 /** 01213 * @example TransferTimeouts.ino 01214 * <b>New: TMRh20 </b><br> 01215 * This example demonstrates the use of and extended timeout period and 01216 * auto-retries/auto-reUse to increase reliability in noisy or low signal scenarios. <br> 01217 * 01218 * Write this sketch to two different nodes. Put one of the nodes into 'transmit' 01219 * mode by connecting with the serial monitor and sending a 'T'. The data <br> 01220 * transfer will begin, with the receiver displaying the payload count and the 01221 * data transfer rate. 01222 */ 01223 01224 /** 01225 * @example starping.pde 01226 * 01227 * This sketch is a more complex example of using the RF24 library for Arduino. 01228 * Deploy this on up to six nodes. Set one as the 'pong receiver' by tying the 01229 * role_pin low, and the others will be 'ping transmit' units. The ping units 01230 * unit will send out the value of millis() once a second. The pong unit will 01231 * respond back with a copy of the value. Each ping unit can get that response 01232 * back, and determine how long the whole cycle took. 01233 * 01234 * This example requires a bit more complexity to determine which unit is which. 01235 * The pong receiver is identified by having its role_pin tied to ground. 01236 * The ping senders are further differentiated by a byte in eeprom. 01237 */ 01238 01239 /** 01240 * @example pingpair_ack.ino 01241 * <b>Update: TMRh20</b><br> 01242 * This example continues to make use of all the normal functionality of the radios including 01243 * the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well.<br> 01244 * This allows very fast call-response communication, with the responding radio never having to 01245 * switch out of Primary Receiver mode to send back a payload, but having the option to if wanting<br> 01246 * to initiate communication instead of respond to a commmunication. 01247 */ 01248 01249 /** 01250 * @example pingpair_irq.ino 01251 * <b>Update: TMRh20</b><br> 01252 * This is an example of how to user interrupts to interact with the radio, and a demonstration 01253 * of how to use them to sleep when receiving, and not miss any payloads.<br> 01254 * The pingpair_sleepy example expands on sleep functionality with a timed sleep option for the transmitter. 01255 * Sleep functionality is built directly into my fork of the RF24Network library<br> 01256 */ 01257 01258 /** 01259 * @example pingpair_irq_simple.ino 01260 * <b>Dec 2014 - TMRh20</b><br> 01261 * This is an example of how to user interrupts to interact with the radio, with bidirectional communication. 01262 */ 01263 01264 /** 01265 * @example pingpair_sleepy.ino 01266 * <b>Update: TMRh20</b><br> 01267 * This is an example of how to use the RF24 class to create a battery- 01268 * efficient system. It is just like the GettingStarted_CallResponse example, but the<br> 01269 * ping node powers down the radio and sleeps the MCU after every 01270 * ping/pong cycle, and the receiver sleeps between payloads. <br> 01271 */ 01272 01273 /** 01274 * @example rf24ping85.ino 01275 * <b>New: Contributed by https://github.com/tong67</b><br> 01276 * This is an example of how to use the RF24 class to communicate with ATtiny85 and other node. <br> 01277 */ 01278 01279 /** 01280 * @example timingSearch3pin.ino 01281 * <b>New: Contributed by https://github.com/tong67</b><br> 01282 * This is an example of how to determine the correct timing for ATtiny when using only 3-pins 01283 */ 01284 01285 /** 01286 * @example pingpair_dyn.ino 01287 * 01288 * This is an example of how to use payloads of a varying (dynamic) size on Arduino. 01289 */ 01290 01291 /** 01292 * @example pingpair_dyn.cpp 01293 * 01294 * This is an example of how to use payloads of a varying (dynamic) size on Raspberry Pi. 01295 */ 01296 01297 /** 01298 * @example pingpair_dyn.py 01299 * 01300 * This is a python example for RPi of how to use payloads of a varying (dynamic) size. 01301 */ 01302 01303 /** 01304 * @example pingpair_dyn.ino 01305 * 01306 * This is an example of how to use payloads of a varying (dynamic) size. 01307 */ 01308 01309 /** 01310 * @example pingpair_dyn.ino 01311 * 01312 * This is an example of how to use payloads of a varying (dynamic) size. 01313 */ 01314 01315 /** 01316 * @example scanner.ino 01317 * 01318 * Example to detect interference on the various channels available. 01319 * This is a good diagnostic tool to check whether you're picking a 01320 * good channel for your application. 01321 * 01322 * Inspired by cpixip. 01323 * See http://arduino.cc/forum/index.php/topic,54795.0.html 01324 */ 01325 01326 /** 01327 * @mainpage Optimized High Speed Driver for nRF24L01(+) 2.4GHz Wireless Transceiver 01328 * 01329 * @section Goals Design Goals 01330 * 01331 * This library fork is designed to be... 01332 * @li More compliant with the manufacturer specified operation of the chip, while allowing advanced users 01333 * to work outside the recommended operation. 01334 * @li Utilize the capabilities of the radio to their full potential via Arduino 01335 * @li More reliable, responsive, bug-free and feature rich 01336 * @li Easy for beginners to use, with well documented examples and features 01337 * @li Consumed with a public interface that's similar to other Arduino standard libraries 01338 * 01339 * @section News News 01340 * 01341 * **Dec 2015**<br> 01342 * - ESP8266 support via Arduino IDE 01343 * - <a href="https://github.com/stewarthou/Particle-RF24">Particle Photon/Core</a> fork available 01344 * - ATTiny2313/4313 support added 01345 * - Python 3 support added 01346 * - RF24 added to Arduino library manager 01347 * - RF24 added to PlatformIO library manager 01348 * 01349 * **March 2015**<br> 01350 * - Uses SPI transactions on Arduino 01351 * - New layout for <a href="Portability.html">easier portability:</a> Break out defines & includes for individual platforms to RF24/utility 01352 * - <a href="MRAA.html">MRAA</a> support added ( Galileo, Edison, etc) 01353 * - <a href="BBB.html">BBB/Generic Linux </a> support via spidev & MRAA 01354 * - Support for RPi 2 added 01355 * - Major Documentation cleanup & update (Move all docs to github.io) 01356 * 01357 * 01358 * If issues are discovered with the documentation, please report them <a href="https://github.com/TMRh20/tmrh20.github.io/issues"> here</a> 01359 * 01360 * <br> 01361 * @section Useful Useful References 01362 * 01363 * 01364 * @li <a href="http://tmrh20.github.io/RF24/classRF24.html"><b>RF24</b> Class Documentation</a> 01365 * @li <a href="https://github.com/TMRh20/RF24/archive/master.zip"><b>Download</b></a> 01366 * @li <a href="https://github.com/tmrh20/RF24/"><b>Source Code</b></a> 01367 * @li <a href="http://tmrh20.blogspot.com/2014/03/high-speed-data-transfers-and-wireless.html"><b>My Blog:</b> RF24 Optimization Overview</a> 01368 * @li <a href="http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf">Chip Datasheet</a> 01369 * 01370 * **Additional Information and Add-ons** 01371 * 01372 * @li <a href="http://tmrh20.github.io/RF24Network"> <b>RF24Network:</b> OSI Network Layer for multi-device communication. Create a home sensor network.</a> 01373 * @li <a href="http://tmrh20.github.io/RF24Mesh"> <b>RF24Mesh:</b> Dynamic Mesh Layer for RF24Network</a> 01374 * @li <a href="http://tmrh20.github.io/RF24Ethernet"> <b>RF24Ethernet:</b> TCP/IP Radio Mesh Networking (shares Arduino Ethernet API)</a> 01375 * @li <a href="http://tmrh20.github.io/RF24Audio"> <b>RF24Audio:</b> Realtime Wireless Audio streaming</a> 01376 * @li <a href="http://tmrh20.github.io/">All TMRh20 Documentation Main Page</a> 01377 * 01378 * **More Information and RF24 Based Projects** 01379 * 01380 * @li <a href="http://TMRh20.blogspot.com"> Project Blog: TMRh20.blogspot.com </a> 01381 * @li <a href="http://maniacalbits.blogspot.ca/"> Maniacal Bits Blog</a> 01382 * @li <a href="http://www.mysensors.org/">MySensors.org (User friendly sensor networks/IoT)</a> 01383 * @li <a href="https://github.com/mannkind/RF24Node_MsgProto"> RF24Node_MsgProto (MQTT)</a> 01384 * @li <a href="https://bitbucket.org/pjhardy/rf24sensornet/"> RF24SensorNet </a> 01385 * @li <a href="http://www.homeautomationforgeeks.com/rf24software.shtml">Home Automation for Geeks</a> 01386 * @li <a href="https://maniacbug.wordpress.com/2012/03/30/rf24network/"> Original Maniacbug RF24Network Blog Post</a> 01387 * @li <a href="https://github.com/maniacbug/RF24"> ManiacBug on GitHub (Original Library Author)</a> 01388 * 01389 * 01390 * <br> 01391 * 01392 * @section Platform_Support Platform Support Pages 01393 * 01394 * @li <a href="Arduino.html"><b>Arduino</b></a> (Uno, Nano, Mega, Due, Galileo, etc) 01395 * @li <a href="ATTiny.html"><b>ATTiny</b></a> 01396 * @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)) 01397 * @li <a href="Python.html"><b>Python</b></a> wrapper available for RPi 01398 * 01399 * <br> 01400 * **General µC Pin layout** (See the individual board support pages for more info) 01401 * 01402 * The table below shows how to connect the the pins of the NRF24L01(+) to different boards. 01403 * CE and CSN are configurable. 01404 * 01405 * | PIN | NRF24L01 | Arduino UNO | ATtiny25/45/85 [0] | ATtiny44/84 [1] | LittleWire [2] | RPI | RPi -P1 Connector | 01406 * |-----|----------|-------------|--------------------|-----------------|-------------------------|------------|-------------------| 01407 * | 1 | GND | GND | pin 4 | pin 14 | GND | rpi-gnd | (25) | 01408 * | 2 | VCC | 3.3V | pin 8 | pin 1 | regulator 3.3V required | rpi-3v3 | (17) | 01409 * | 3 | CE | digIO 7 | pin 2 | pin 12 | pin to 3.3V | rpi-gpio22 | (15) | 01410 * | 4 | CSN | digIO 8 | pin 3 | pin 11 | RESET | rpi-gpio8 | (24) | 01411 * | 5 | SCK | digIO 13 | pin 7 | pin 9 | SCK | rpi-sckl | (23) | 01412 * | 6 | MOSI | digIO 11 | pin 6 | pin 7 | MOSI | rpi-mosi | (19) | 01413 * | 7 | MISO | digIO 12 | pin 5 | pin 8 | MISO | rpi-miso | (21) | 01414 * | 8 | IRQ | - | - | - | - | - | - | 01415 * 01416 * @li [0] https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/attiny85-use-hints 01417 * @li [1] http://highlowtech.org/?p=1695 01418 * @li [2] http://littlewire.cc/ 01419 * <br><br><br> 01420 * 01421 * 01422 * 01423 * 01424 * @page Arduino Arduino 01425 * 01426 * RF24 is fully compatible with Arduino boards <br> 01427 * See <b> http://www.arduino.cc/en/Reference/Board </b> and <b> http://arduino.cc/en/Reference/SPI </b> for more information 01428 * 01429 * RF24 makes use of the standard hardware SPI pins (MISO,MOSI,SCK) and requires two additional pins, to control 01430 * the chip-select and chip-enable functions.<br> 01431 * These pins must be chosen and designated by the user, in RF24 radio(ce_pin,cs_pin); and can use any 01432 * available pins. 01433 * 01434 * <br> 01435 * @section ARD_DUE Arduino Due 01436 * 01437 * RF24 makes use of the extended SPI functionality available on the Arduino Due, and requires one of the 01438 * defined hardware SS/CS pins to be designated in RF24 radio(ce_pin,cs_pin);<br> 01439 * See http://arduino.cc/en/Reference/DueExtendedSPI for more information 01440 * 01441 * Initial Due support taken from https://github.com/mcrosson/RF24/tree/due 01442 * 01443 * <br> 01444 * @section Alternate_SPI Alternate SPI Support 01445 * 01446 * RF24 supports alternate SPI methods, in case the standard hardware SPI pins are otherwise unavailable. 01447 * 01448 * <br> 01449 * **Software Driven SPI** 01450 * 01451 * Software driven SPI is provided by the <a href=https://github.com/greiman/DigitalIO>DigitalIO</a> library 01452 * 01453 * Setup:<br> 01454 * 1. Install the digitalIO library<br> 01455 * 2. Open RF24_config.h in a text editor. Uncomment the line #define SOFTSPI<br> 01456 * 3. In your sketch, add #include DigitalIO.h 01457 * 01458 * @note Note: Pins are listed as follows and can be modified by editing the RF24_config.h file<br> 01459 * 01460 * const uint8_t SOFT_SPI_MISO_PIN = 16; 01461 * const uint8_t SOFT_SPI_MOSI_PIN = 15; 01462 * const uint8_t SOFT_SPI_SCK_PIN = 14; 01463 * 01464 * <br> 01465 * **Alternate Hardware (UART) Driven SPI** 01466 * 01467 * The Serial Port (UART) on Arduino can also function in SPI mode, and can double-buffer data, while the 01468 * default SPI hardware cannot. 01469 * 01470 * The SPI_UART library is available at https://github.com/TMRh20/Sketches/tree/master/SPI_UART 01471 * 01472 * Enabling: 01473 * 1. Install the SPI_UART library 01474 * 2. Edit RF24_config.h and uncomment #define SPI_UART 01475 * 3. In your sketch, add @code #include <SPI_UART.h> @endcode 01476 * 01477 * SPI_UART SPI Pin Connections: 01478 * | NRF |Arduino Uno Pin| 01479 * |-----|---------------| 01480 * | MOSI| TX(0) | 01481 * | MISO| RX(1) | 01482 * | SCK | XCK(4) | 01483 * | CE | User Specified| 01484 * | CSN | User Specified| 01485 * 01486 * 01487 * @note SPI_UART on Mega boards requires soldering to an unused pin on the chip. <br>See 01488 * https://github.com/TMRh20/RF24/issues/24 for more information on SPI_UART. 01489 * 01490 * @page ATTiny ATTiny 01491 * 01492 * ATTiny support is built into the library, so users are not required to include SPI.h in their sketches<br> 01493 * See the included rf24ping85 example for pin info and usage 01494 * 01495 * Some versions of Arduino IDE may require a patch to allow use of the full program space on ATTiny<br> 01496 * See https://github.com/TCWORLD/ATTinyCore/tree/master/PCREL%20Patch%20for%20GCC for ATTiny patch 01497 * 01498 * ATTiny board support initially added from https://github.com/jscrane/RF24 01499 * 01500 * @section Hardware Hardware Configuration 01501 * By tong67 ( https://github.com/tong67 ) 01502 * 01503 * **ATtiny25/45/85 Pin map with CE_PIN 3 and CSN_PIN 4** 01504 * @code 01505 * +-\/-+ 01506 * NC PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 --- LED --- 5V 01507 * nRF24L01 CE, pin3 --- PB3 2| |7 PB2 --- nRF24L01 SCK, pin5 01508 * nRF24L01 CSN, pin4 --- PB4 3| |6 PB1 --- nRF24L01 MOSI, pin6 01509 * nRF24L01 GND, pin1 --- GND 4| |5 PB0 --- nRF24L01 MISO, pin7 01510 * +----+ 01511 * @endcode 01512 * 01513 * <br> 01514 * **ATtiny25/45/85 Pin map with CE_PIN 3 and CSN_PIN 3** => PB3 and PB4 are free to use for application <br> 01515 * Circuit idea from http://nerdralph.blogspot.ca/2014/01/nrf24l01-control-with-3-attiny85-pins.html <br> 01516 * Original RC combination was 1K/100nF. 22K/10nF combination worked better. <br> 01517 * For best settletime delay value in RF24::csn() the timingSearch3pin.ino sketch can be used. <br> 01518 * This configuration is enabled when CE_PIN and CSN_PIN are equal, e.g. both 3 <br> 01519 * Because CE is always high the power consumption is higher than for 5 pins solution <br> 01520 * @code 01521 * ^^ 01522 * +-\/-+ nRF24L01 CE, pin3 ------| // 01523 * PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 ------x----------x--|<|-- 5V 01524 * NC PB3 2| |7 PB2 --- nRF24L01 SCK, pin5 --|<|---x-[22k]--| LED 01525 * NC PB4 3| |6 PB1 --- nRF24L01 MOSI, pin6 1n4148 | 01526 * nRF24L01 GND, pin1 -x- GND 4| |5 PB0 --- nRF24L01 MISO, pin7 | 01527 * | +----+ | 01528 * |-----------------------------------------------||----x-- nRF24L01 CSN, pin4 01529 * 10nF 01530 * @endcode 01531 * 01532 * <br> 01533 * **ATtiny24/44/84 Pin map with CE_PIN 8 and CSN_PIN 7** <br> 01534 * Schematic provided and successfully tested by Carmine Pastore (https://github.com/Carminepz) <br> 01535 * @code 01536 * +-\/-+ 01537 * nRF24L01 VCC, pin2 --- VCC 1|o |14 GND --- nRF24L01 GND, pin1 01538 * PB0 2| |13 AREF 01539 * PB1 3| |12 PA1 01540 * PB3 4| |11 PA2 --- nRF24L01 CE, pin3 01541 * PB2 5| |10 PA3 --- nRF24L01 CSN, pin4 01542 * PA7 6| |9 PA4 --- nRF24L01 SCK, pin5 01543 * nRF24L01 MISO, pin7 --- PA6 7| |8 PA5 --- nRF24L01 MOSI, pin6 01544 * +----+ 01545 * @endcode 01546 * 01547 * <br> 01548 * **ATtiny2313/4313 Pin map with CE_PIN 12 and CSN_PIN 13** <br> 01549 * @code 01550 * +-\/-+ 01551 * PA2 1|o |20 VCC --- nRF24L01 VCC, pin2 01552 * PD0 2| |19 PB7 --- nRF24L01 SCK, pin5 01553 * PD1 3| |18 PB6 --- nRF24L01 MOSI, pin6 01554 * PA1 4| |17 PB5 --- nRF24L01 MISO, pin7 01555 * PA0 5| |16 PB4 --- nRF24L01 CSN, pin4 01556 * PD2 6| |15 PB3 --- nRF24L01 CE, pin3 01557 * PD3 7| |14 PB2 01558 * PD4 8| |13 PB1 01559 * PD5 9| |12 PB0 01560 * nRF24L01 GND, pin1 --- GND 10| |11 PD6 01561 * +----+ 01562 * @endcode 01563 * 01564 * <br><br><br> 01565 * 01566 * 01567 * 01568 * 01569 * 01570 * 01571 * @page BBB BeagleBone Black 01572 * 01573 * BeagleBone Black is supported via MRAA or SPIDEV. 01574 * 01575 * @note The SPIDEV option should work with most Linux systems supporting SPIDEV. <br> 01576 * 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"; ) 01577 * 01578 * <br> 01579 * @section AutoInstall Automated Install 01580 *(**Designed & Tested on RPi** - Defaults to SPIDEV on BBB) 01581 * 01582 * 01583 * 1. Download the install.sh file from http://tmrh20.github.io/RF24Installer/RPi/install.sh 01584 * @code wget http://tmrh20.github.io/RF24Installer/RPi/install.sh @endcode 01585 * 2. Make it executable: 01586 * @code chmod +x install.sh @endcode 01587 * 3. Run it and choose your options 01588 * @code ./install.sh @endcode 01589 * 4. Run an example from one of the libraries 01590 * @code 01591 * cd rf24libs/RF24/examples_RPi 01592 * @endcode 01593 * Edit the gettingstarted example, to set your pin configuration 01594 * @code nano gettingstarted.cpp 01595 * make 01596 * sudo ./gettingstarted 01597 * @endcode 01598 * 01599 * <br> 01600 * @section ManInstall Manual Install 01601 * 1. Make a directory to contain the RF24 and possibly RF24Network lib and enter it: 01602 * @code 01603 * mkdir ~/rf24libs 01604 * cd ~/rf24libs 01605 * @endcode 01606 * 2. Clone the RF24 repo: 01607 * @code git clone https://github.com/tmrh20/RF24.git RF24 @endcode 01608 * 3. Change to the new RF24 directory 01609 * @code cd RF24 @endcode 01610 * 4. Build the library, and run an example file: 01611 * **Note:** See the <a href="http://iotdk.intel.com/docs/master/mraa/index.html">MRAA </a> documentation for more info on installing MRAA 01612 * @code sudo make install OR sudo make install RF24_MRAA=1 @endcode 01613 * @code 01614 * cd examples_RPi 01615 * @endcode 01616 * Edit the gettingstarted example, to set your pin configuration 01617 * @code nano gettingstarted.cpp 01618 * make 01619 * sudo ./gettingstarted 01620 * @endcode 01621 * 01622 * <br><br> 01623 * 01624 * @page MRAA MRAA 01625 * 01626 * MRAA is a Low Level Skeleton Library for Communication on GNU/Linux platforms <br> 01627 * See http://iotdk.intel.com/docs/master/mraa/index.html for more information 01628 * 01629 * RF24 supports all MRAA supported platforms, but might not be tested on each individual platform due to the wide range of hardware support:<br> 01630 * <a href="https://github.com/TMRh20/RF24/issues">Report an RF24 bug or issue </a> 01631 * 01632 * @section Setup Setup 01633 * 1. Install the MRAA lib 01634 * 2. As per your device, SPI may need to be enabled 01635 * 01636 * @section MRAA_Install Install 01637 * 01638 * 1. Make a directory to contain the RF24 and possibly RF24Network lib and enter it: 01639 * @code 01640 * mkdir ~/rf24libs 01641 * cd ~/rf24libs 01642 * @endcode 01643 * 2. Clone the RF24 repo: 01644 * @code git clone https://github.com/tmrh20/RF24.git RF24 @endcode 01645 * 3. Change to the new RF24 directory 01646 * @code cd RF24 @endcode 01647 * 4. Build the library: 01648 * @code sudo make install -B RF24_MRAA=1 @endcode 01649 * 5. Configure the correct pins in gettingstarted.cpp (See http://iotdk.intel.com/docs/master/mraa/index.html ) 01650 * @code 01651 * cd examples_RPi 01652 * nano gettingstarted.cpp 01653 * @endcode 01654 * 6. Build an example 01655 * @code 01656 * make 01657 * sudo ./gettingstarted 01658 * @endcode 01659 * 01660 * <br><br><br> 01661 * 01662 * 01663 * 01664 * 01665 * @page RPi Raspberry Pi 01666 * 01667 * RF24 supports a variety of Linux based devices via various drivers. Some boards like RPi can utilize multiple methods 01668 * to drive the GPIO and SPI functionality. 01669 * 01670 * <br> 01671 * @section PreConfig Potential PreConfiguration 01672 * 01673 * If SPI is not already enabled, load it on boot: 01674 * @code sudo raspi-config @endcode 01675 * A. Update the tool via the menu as required<br> 01676 * B. Select **Advanced** and **enable the SPI kernel module** <br> 01677 * C. Update other software and libraries: 01678 * @code sudo apt-get update @endcode 01679 * @code sudo apt-get upgrade @endcode 01680 * <br> 01681 * @section AutoInstall Automated Install 01682 * 01683 * 1. Download the install.sh file from http://tmrh20.github.io/RF24Installer/RPi/install.sh 01684 * @code wget http://tmrh20.github.io/RF24Installer/RPi/install.sh @endcode 01685 * 2. Make it executable: 01686 * @code chmod +x install.sh @endcode 01687 * 3. Run it and choose your options 01688 * @code ./install.sh @endcode 01689 * 4. Run an example from one of the libraries 01690 * @code 01691 * cd rf24libs/RF24/examples_RPi 01692 * make 01693 * sudo ./gettingstarted 01694 * @endcode 01695 * <br><br> 01696 * @section ManInstall Manual Install 01697 * 1. Make a directory to contain the RF24 and possibly RF24Network lib and enter it: 01698 * @code 01699 * mkdir ~/rf24libs 01700 * cd ~/rf24libs 01701 * @endcode 01702 * 2. Clone the RF24 repo: 01703 * @code git clone https://github.com/tmrh20/RF24.git RF24 @endcode 01704 * 3. Change to the new RF24 directory 01705 * @code cd RF24 @endcode 01706 * 4. Build the library, and run an example file: 01707 * @code sudo make install 01708 * cd examples_RPi 01709 * make 01710 * sudo ./gettingstarted 01711 * @endcode 01712 * 01713 * <br><br> 01714 * @section Build Build Options 01715 * The default build on Raspberry Pi utilizes the included **BCM2835** driver from http://www.airspayce.com/mikem/bcm2835 01716 * 1. @code sudo make install -B @endcode 01717 * 01718 * Build using the **MRAA** library from http://iotdk.intel.com/docs/master/mraa/index.html <br> 01719 * MRAA is not included. See the <a href="MRAA.html">MRAA</a> platform page for more information. 01720 * 01721 * 1. Install, and build MRAA: 01722 * @code 01723 * git clone https://github.com/intel-iot-devkit/mraa.git 01724 * cd mraa 01725 * mkdir build 01726 * cd build 01727 * cmake .. -DBUILDSWIGNODE=OFF 01728 * sudo make install 01729 * @endcode 01730 * 01731 * 2. Complete the install <br> 01732 * @code nano /etc/ld.so.conf @endcode 01733 * Add the line @code /usr/local/lib/arm-linux-gnueabihf @endcode 01734 * Run @code sudo ldconfig @endcode 01735 * 01736 * 3. Install RF24, using MRAA 01737 * @code sudo make install -B RF24_MRAA=1 @endcode 01738 * See the gettingstarted example for an example of pin configuration 01739 * 01740 * Build using **spidev**: 01741 * 01742 * 1. Edit the RF24/utility/BBB/spi.cpp file 01743 * 2. Change the default device definition to @code this->device = "/dev/spidev0.0";; @endcode 01744 * 3. Run @code sudo make install -B RF24_SPIDEV=1 @endcode 01745 * 4. See the gettingstarted example for an example of pin configuration 01746 * 01747 * <br> 01748 * @section Pins Connections and Pin Configuration 01749 * 01750 * 01751 * Using pin 15/GPIO 22 for CE, pin 24/GPIO8 (CE0) for CSN 01752 * 01753 * Can use either RPi CE0 or CE1 pins for radio CSN.<br> 01754 * Choose any RPi output pin for radio CE pin. 01755 * 01756 * **BCM2835 Constructor:** 01757 * @code 01758 * RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ); 01759 * or 01760 * RF24 radio(RPI_V2_GPIO_P1_15,BCM2835_SPI_CS1, BCM2835_SPI_SPEED_8MHZ); 01761 * 01762 * RPi B+: 01763 * RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ); 01764 * or 01765 * RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_26, BCM2835_SPI_SPEED_8MHZ); 01766 * 01767 * General: 01768 * RF24 radio(22,0); 01769 * or 01770 * RF24 radio(22,1); 01771 * 01772 * @endcode 01773 * See the gettingstarted example for an example of pin configuration 01774 * 01775 * See http://www.airspayce.com/mikem/bcm2835/index.html for BCM2835 class documentation. 01776 * <br><br> 01777 * **MRAA Constructor:** 01778 * 01779 * @code RF24 radio(15,0); @endcode 01780 * 01781 * See http://iotdk.intel.com/docs/master/mraa/rasppi.html 01782 * <br><br> 01783 * **SPI_DEV Constructor** 01784 * 01785 * @code RF24 radio(22,0); @endcode 01786 * 01787 * See http://pi.gadgetoid.com/pinout 01788 * 01789 * **Pins:** 01790 * 01791 * | PIN | NRF24L01 | RPI | RPi -P1 Connector | 01792 * |-----|----------|------------|-------------------| 01793 * | 1 | GND | rpi-gnd | (25) | 01794 * | 2 | VCC | rpi-3v3 | (17) | 01795 * | 3 | CE | rpi-gpio22 | (15) | 01796 * | 4 | CSN | rpi-gpio8 | (24) | 01797 * | 5 | SCK | rpi-sckl | (23) | 01798 * | 6 | MOSI | rpi-mosi | (19) | 01799 * | 7 | MISO | rpi-miso | (21) | 01800 * | 8 | IRQ | - | - | 01801 * 01802 * 01803 * 01804 * 01805 * <br><br> 01806 **************** 01807 * 01808 * Based on the arduino lib from J. Coliz <maniacbug@ymail.com> <br> 01809 * the library was berryfied by Purinda Gunasekara <purinda@gmail.com> <br> 01810 * then forked from github stanleyseow/RF24 to https://github.com/jscrane/RF24-rpi <br> 01811 * Network lib also based on https://github.com/farconada/RF24Network 01812 * 01813 * 01814 * 01815 * 01816 * <br><br><br> 01817 * 01818 * 01819 * 01820 * @page Python Python Wrapper (by https://github.com/mz-fuzzy) 01821 * 01822 * @section Install Installation: 01823 * 01824 * Install the boost libraries: (Note: Only the python libraries should be needed, this is just for simplicity) 01825 * 01826 * @code sudo apt-get install libboost1.50-all @endcode 01827 * 01828 * Build the library: 01829 * 01830 * @code ./setup.py build @endcode 01831 * 01832 * Install the library 01833 * 01834 * @code sudo ./setup.py install @endcode 01835 * 01836 * 01837 * See the additional <a href="pages.html">Platform Support</a> pages for information on connecting your hardware <br> 01838 * See the included <a href="pingpair_dyn_8py-example.html">example </a> for usage information. 01839 * 01840 * Running the Example: 01841 * 01842 * Edit the pingpair_dyn.py example to configure the appropriate pins per the above documentation: 01843 * 01844 * @code nano pingpair_dyn.py @endcode 01845 * 01846 * Configure another device, Arduino or RPi with the <a href="pingpair_dyn_8py-example.html">pingpair_dyn</a> example 01847 * 01848 * Run the example 01849 * 01850 * @code sudo ./pingpair_dyn.py @endcode 01851 * 01852 * <br><br><br> 01853 * 01854 * 01855 * @page Portability RF24 Portability 01856 * 01857 * 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 01858 * on various platforms. <br>Support files for these platforms are stored under RF24/utility, and can be modified to provide 01859 * the required functionality. 01860 * 01861 * <br> 01862 * @section Hardware_Templates Basic Hardware Template 01863 * 01864 * **RF24/utility** 01865 * 01866 * The RF24 library now includes a basic hardware template to assist in porting to various platforms. <br> The following files can be included 01867 * to replicate standard Arduino functions as needed, allowing devices from ATTiny to Raspberry Pi to utilize the same core RF24 driver. 01868 * 01869 * | File | Purpose | 01870 * |--------------------|------------------------------------------------------------------------------| 01871 * | RF24_arch_config.h | Basic Arduino/AVR compatibility, includes for remaining support files, etc | 01872 * | includes.h | Linux only. Defines specific platform, include correct RF24_arch_config file | 01873 * | spi.h | Provides standardized SPI ( transfer() ) methods | 01874 * | gpio.h | Provides standardized GPIO ( digitalWrite() ) methods | 01875 * | compatibility.h | Provides standardized timing (millis(), delay()) methods | 01876 * | your_custom_file.h | Provides access to custom drivers for spi,gpio, etc | 01877 * 01878 * <br> 01879 * Examples are provided via the included hardware support templates in **RF24/utility** <br> 01880 * See the <a href="modules.html">modules</a> page for examples of class declarations 01881 * 01882 *<br> 01883 * @section Device_Detection Device Detection 01884 * 01885 * 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> 01886 * 2. Secondary detection is completed in RF24_config.h, causing the include.h file to be included for all supported Linux devices <br> 01887 * 3. RF24.h contains the declaration for SPI and GPIO objects 'spi' and 'gpio' to be used for porting-in related functions. 01888 * 01889 * <br> 01890 * @section Ported_Code Code 01891 * 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 01892 * 01893 * 01894 *<br><br><br> 01895 */ 01896 01897 #endif // __RF24_H__ 01898
Generated on Wed Jul 13 2022 11:49:08 by
1.7.2
