Cleaned up documentation.
This commit is contained in:
parent
117678c46f
commit
21057e4608
12
README
12
README
|
@ -1,12 +0,0 @@
|
||||||
Arduino driver for nRF24L01 2.4GHz Wireless Transceiver
|
|
||||||
|
|
||||||
See Datasheet at http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf
|
|
||||||
|
|
||||||
This chip uses the SPI bus, plus two chip control pins. Remember that pin 10 must still remain an output, or
|
|
||||||
the SPI hardware will go into 'slave' mode.
|
|
||||||
|
|
||||||
Design Goals: This library is designed to be...
|
|
||||||
* Maximally compliant with the intended operation of the chip
|
|
||||||
* Easy for beginners to use
|
|
||||||
* Consumed with a public interface that's similiar to other Arduino standard libraries
|
|
||||||
* Built against the standard SPI library.
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Arduino driver for nRF24L01 2.4GHz Wireless Transceiver
|
||||||
|
|
||||||
|
Design Goals: This library is designed to be...
|
||||||
|
* Maximally compliant with the intended operation of the chip
|
||||||
|
* Easy for beginners to use
|
||||||
|
* Consumed with a public interface that's similiar to other Arduino standard libraries
|
||||||
|
* Built against the standard SPI library.
|
||||||
|
|
||||||
|
Please refer to:
|
||||||
|
|
||||||
|
* [Documentation Main Page](http://maniacbug.github.com/RF24)
|
||||||
|
* [RF24 Class Documentation](http://maniacbug.github.com/RF24/classRF24.html)
|
||||||
|
* [Source Code](https://github.com/maniacbug/RF24)
|
||||||
|
* [Downloads](https://github.com/maniacbug/RF24/archives/master)
|
||||||
|
* [Chip Datasheet](http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf)
|
||||||
|
|
||||||
|
This chip uses the SPI bus, plus two chip control pins. Remember that pin 10 must still remain an output, or
|
||||||
|
the SPI hardware will go into 'slave' mode.
|
||||||
|
|
62
RF24.h
62
RF24.h
|
@ -13,21 +13,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Driver for nRF24L01 2.4GHz Wireless Transceiver
|
* Driver for nRF24L01 2.4GHz Wireless Transceiver
|
||||||
*
|
|
||||||
* Please refer to:
|
|
||||||
*
|
|
||||||
* @li <a href="http://maniacbug.github.com/RF24/classRF24.html">Detailed Documentation</a>
|
|
||||||
* @li <a href="https://github.com/maniacbug/RF24/">Source Code</a>
|
|
||||||
* @li <a href="http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf">Chip Datasheet</a>
|
|
||||||
*
|
|
||||||
* This chip uses the SPI bus, plus two chip control pins. Remember that pin 10 must still remain an output, or
|
|
||||||
* the SPI hardware will go into 'slave' mode.
|
|
||||||
*
|
|
||||||
* Design Goals: This library is designed to be...
|
|
||||||
* @li Maximally compliant with the intended operation of the chip
|
|
||||||
* @li Easy for beginners to use
|
|
||||||
* @li Consumed with a public interface that's similiar to other Arduino standard libraries
|
|
||||||
* @li Built against the standard SPI library.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RF24
|
class RF24
|
||||||
|
@ -182,7 +167,9 @@ public:
|
||||||
* Set Payload Size
|
* Set Payload Size
|
||||||
*
|
*
|
||||||
* This implementation uses a pre-stablished fixed payload size for all
|
* This implementation uses a pre-stablished fixed payload size for all
|
||||||
* transmissions.
|
* transmissions. If this method is never called, the driver will always
|
||||||
|
* transmit the maximum payload size (32 bytes), no matter how much
|
||||||
|
* was sent to write().
|
||||||
*
|
*
|
||||||
* @todo Implement variable-sized payloads feature
|
* @todo Implement variable-sized payloads feature
|
||||||
*
|
*
|
||||||
|
@ -197,7 +184,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The number of bytes in the payload
|
* @return The number of bytes in the payload
|
||||||
*/
|
*/
|
||||||
uint8_t getPayloadSize(void) ;
|
uint8_t getPayloadSize(void) ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a giant block of debugging information to stdout
|
* Print a giant block of debugging information to stdout
|
||||||
|
@ -301,8 +288,8 @@ public:
|
||||||
* Only the least significant byte should be unique, e.g.
|
* Only the least significant byte should be unique, e.g.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* openReadingPipe(0xF0F0F0F0AA);
|
* openReadingPipe(1,0xF0F0F0F0AA);
|
||||||
* openReadingPipe(0xF0F0F0F066);
|
* openReadingPipe(2,0xF0F0F0F066);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @todo Enforce the restriction that all pipes must share the top 32 bits
|
* @todo Enforce the restriction that all pipes must share the top 32 bits
|
||||||
|
@ -319,13 +306,44 @@ public:
|
||||||
*
|
*
|
||||||
* This is an example of how to use the RF24 class. Write this sketch to two different nodes,
|
* This is an example of how to use the RF24 class. Write this sketch to two different nodes,
|
||||||
* connect the role_pin to ground on one. The ping node sends the current time to the pong node,
|
* connect the role_pin to ground on one. The ping node sends the current time to the pong node,
|
||||||
* which responds by sending the value back.
|
* which responds by sending the value back. The ping node can then see how long the whole cycle
|
||||||
|
* took.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mainpage Driver Library for nRF24L01
|
* @example starping.pde
|
||||||
*
|
*
|
||||||
* See the RF24 class for details on how to drive this chip.
|
* This sketch is a more complex example of using the RF24 library for Arduino.
|
||||||
|
* Deploy this on up to six nodes. Set one as the 'pong receiver' by tying the
|
||||||
|
* role_pin low, and the others will be 'ping transmit' units. The ping units
|
||||||
|
* unit will send out the value of millis() once a second. The pong unit will
|
||||||
|
* respond back with a copy of the value. Each ping unit can get that response
|
||||||
|
* back, and determine how long the whole cycle took.
|
||||||
|
*
|
||||||
|
* This example requires a bit more complexity to determine which unit is which.
|
||||||
|
* The pong receiver is identified by having its role_pin tied to ground.
|
||||||
|
* The ping senders are further differentiated by a byte in eeprom.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mainpage Driver for nRF24L01 2.4GHz Wireless Transceiver
|
||||||
|
*
|
||||||
|
* Design Goals: This library is designed to be...
|
||||||
|
* @li Maximally compliant with the intended operation of the chip
|
||||||
|
* @li Easy for beginners to use
|
||||||
|
* @li Consumed with a public interface that's similiar to other Arduino standard libraries
|
||||||
|
* @li Built against the standard SPI library.
|
||||||
|
*
|
||||||
|
* Please refer to:
|
||||||
|
*
|
||||||
|
* @li <a href="http://maniacbug.github.com/RF24/">Documentation Main Page</a>
|
||||||
|
* @li <a href="http://maniacbug.github.com/RF24/classRF24.html">RF24 Class Documentation</a>
|
||||||
|
* @li <a href="https://github.com/maniacbug/RF24/">Source Code</a>
|
||||||
|
* @li <a href="https://github.com/maniacbug/RF24/archives/master">Downloads Page</a>
|
||||||
|
* @li <a href="http://www.nordicsemi.com/files/Product/data_sheet/nRF24L01_Product_Specification_v2_0.pdf">Chip Datasheet</a>
|
||||||
|
*
|
||||||
|
* This chip uses the SPI bus, plus two chip control pins. Remember that pin 10 must still remain an output, or
|
||||||
|
* the SPI hardware will go into 'slave' mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif // __RF24_H__
|
#endif // __RF24_H__
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
/**
|
/**
|
||||||
* Example RF Radio Ping Pair
|
* Example RF Radio Ping Pair
|
||||||
*
|
*
|
||||||
* This sketch is an example of using the RF24 library for Arduino. Deploy this on
|
* This is an example of how to use the RF24 class. Write this sketch to two different nodes,
|
||||||
* two nodes, set one as the 'trasmit' and the other the 'receive' unit. The transmit
|
* connect the role_pin to ground on one. The ping node sends the current time to the pong node,
|
||||||
* unit will send out the value of millis() once a second. The receive unit will respond
|
* which responds by sending the value back. The ping node can then see how long the whole cycle
|
||||||
* back with a copy of the value. The transmit unit can get that 'ping' back, and
|
* took.
|
||||||
* determine how long the whole cycle took.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
* Example RF Radio Ping Star Group
|
* Example RF Radio Ping Star Group
|
||||||
*
|
*
|
||||||
* This sketch is a more complex example of using the RF24 library for Arduino.
|
* This sketch is a more complex example of using the RF24 library for Arduino.
|
||||||
* Deploy this on up to six nodes. Set one as the 'pong receiver' and the others
|
* Deploy this on up to six nodes. Set one as the 'pong receiver' by tying the
|
||||||
* as 'ping transmit' units. The ping units unit will send out the value of millis()
|
* role_pin low, and the others will be 'ping transmit' units. The ping units
|
||||||
* once a second. The pong unit will respond back with a copy of the value.
|
* unit will send out the value of millis() once a second. The pong unit will
|
||||||
* The ping unit can get that response back, and
|
* respond back with a copy of the value. Each ping unit can get that response
|
||||||
* determine how long the whole cycle took.
|
* back, and determine how long the whole cycle took.
|
||||||
*
|
*
|
||||||
* This example requires a bit more complexity to determine which unit is
|
* This example requires a bit more complexity to determine which unit is which.
|
||||||
* which. The pong receiver is identified by having its role_pin tied to ground.
|
* The pong receiver is identified by having its role_pin tied to ground.
|
||||||
* The ping senders are further differentiated by a byte in eeprom.
|
* The ping senders are further differentiated by a byte in eeprom.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@
|
||||||
#include "RF24.h"
|
#include "RF24.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
extern EEPROMClass EEPROM;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hardware configuration
|
// Hardware configuration
|
||||||
//
|
//
|
||||||
|
@ -45,9 +43,14 @@ const int role_pin = 7;
|
||||||
// Topology
|
// Topology
|
||||||
//
|
//
|
||||||
|
|
||||||
// Radio pipe addresses for the 6 nodes to communicate
|
// Radio pipe addresses for the nodes to communicate. Only ping nodes need
|
||||||
const uint64_t talking_pipes[6] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL, 0xF0F0F0F0B4LL, 0xF0F0F0F0A5LL, 0xF0F0F0F096LL };
|
// dedicated pipes in this topology. Each ping node has a talking pipe
|
||||||
const uint64_t listening_pipes[6] = { 0x3A3A3A3AE1LL, 0x3A3A3A3AD2LL, 0x3A3A3A3AC3LL, 0x3A3A3A3AB4LL, 0x3A3A3A3AA5LL, 0x3A3A3A3A96LL };
|
// that it will ping into, and a listening pipe that it will listen for
|
||||||
|
// the pong. The pong node listens on all the ping node talking pipes
|
||||||
|
// and sends the pong back on the sending node's specific listening pipe.
|
||||||
|
|
||||||
|
const uint64_t talking_pipes[5] = { 0xF0F0F0F0D2LL, 0xF0F0F0F0C3LL, 0xF0F0F0F0B4LL, 0xF0F0F0F0A5LL, 0xF0F0F0F096LL };
|
||||||
|
const uint64_t listening_pipes[5] = { 0x3A3A3A3AD2LL, 0x3A3A3A3AC3LL, 0x3A3A3A3AB4LL, 0x3A3A3A3AA5LL, 0x3A3A3A3A96LL };
|
||||||
|
|
||||||
//
|
//
|
||||||
// Role management
|
// Role management
|
||||||
|
@ -76,7 +79,8 @@ role_e role;
|
||||||
const uint8_t address_at_eeprom_location = 0;
|
const uint8_t address_at_eeprom_location = 0;
|
||||||
|
|
||||||
// What is our address (SRAM cache of the address from EEPROM)
|
// What is our address (SRAM cache of the address from EEPROM)
|
||||||
// Note that zero is an INVALID address
|
// Note that zero is an INVALID address. The pong back unit takes address
|
||||||
|
// 1, and the rest are 2-6
|
||||||
uint8_t node_address;
|
uint8_t node_address;
|
||||||
|
|
||||||
void setup(void)
|
void setup(void)
|
||||||
|
@ -139,26 +143,26 @@ void setup(void)
|
||||||
//
|
//
|
||||||
// Open pipes to other nodes for communication
|
// Open pipes to other nodes for communication
|
||||||
//
|
//
|
||||||
|
|
||||||
// Open 'our' pipe for writing
|
// The pong node listens on all the ping node talking pipes
|
||||||
// ping nodes open the parent's pipe for reading
|
// and sends the pong back on the sending node's specific listening pipe.
|
||||||
// pong node opens all children's pipes for reading
|
|
||||||
|
|
||||||
if ( role == role_pong_back )
|
if ( role == role_pong_back )
|
||||||
{
|
{
|
||||||
// Listen to all ping nodes' talking pipes
|
radio.openReadingPipe(1,talking_pipes[0]);
|
||||||
radio.openReadingPipe(1,talking_pipes[1]);
|
radio.openReadingPipe(2,talking_pipes[1]);
|
||||||
radio.openReadingPipe(2,talking_pipes[2]);
|
radio.openReadingPipe(3,talking_pipes[2]);
|
||||||
radio.openReadingPipe(3,talking_pipes[3]);
|
radio.openReadingPipe(4,talking_pipes[3]);
|
||||||
radio.openReadingPipe(4,talking_pipes[4]);
|
radio.openReadingPipe(5,talking_pipes[4]);
|
||||||
radio.openReadingPipe(5,talking_pipes[5]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Each ping node has a talking pipe that it will ping into, and a listening
|
||||||
|
// pipe that it will listen for the pong.
|
||||||
if ( role == role_ping_out )
|
if ( role == role_ping_out )
|
||||||
{
|
{
|
||||||
// Write on our talking pipe
|
// Write on our talking pipe
|
||||||
radio.openWritingPipe(talking_pipes[node_address-1]);
|
radio.openWritingPipe(talking_pipes[node_address-2]);
|
||||||
// Listen on our listening pipe
|
// Listen on our listening pipe
|
||||||
radio.openReadingPipe(1,listening_pipes[node_address-1]);
|
radio.openReadingPipe(1,listening_pipes[node_address-2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -172,6 +176,15 @@ void setup(void)
|
||||||
//
|
//
|
||||||
|
|
||||||
radio.printDetails();
|
radio.printDetails();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prompt the user to assign a node address if we don't have one
|
||||||
|
//
|
||||||
|
|
||||||
|
if ( role == role_invalid )
|
||||||
|
{
|
||||||
|
printf("\n\r*** NO NODE ADDRESS ASSIGNED *** Send 1 through 6 to assign an address\n\r");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void)
|
void loop(void)
|
||||||
|
@ -238,7 +251,7 @@ void loop(void)
|
||||||
done = radio.read( &got_time, sizeof(unsigned long) );
|
done = radio.read( &got_time, sizeof(unsigned long) );
|
||||||
|
|
||||||
// Spew it
|
// Spew it
|
||||||
printf("Got payload %lu from %i...",got_time,pipe_num);
|
printf("Got payload %lu from node %i...",got_time,pipe_num+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, stop listening so we can talk
|
// First, stop listening so we can talk
|
||||||
|
@ -277,4 +290,4 @@ void loop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// vim:ai sts=2 sw=2 ft=cpp
|
// vim:ai:ci sts=2 sw=2 ft=cpp
|
||||||
|
|
Loading…
Reference in New Issue