This is a work in progress for an NRF2401P
Dependencies: mbed
Fork of NRF2401P by
Diff: NRF2401P.h
- Revision:
- 5:7e253c677a1f
- Parent:
- 3:afe8d307b5c3
--- a/NRF2401P.h Fri Jun 12 08:07:53 2015 +0000 +++ b/NRF2401P.h Fri Jun 12 09:55:02 2015 +0000 @@ -23,6 +23,62 @@ * THE SOFTWARE. * @file "NRF2401P.h" */ + +/** \brief A library to drive the nRF24l01+ +* +* This library is a simple way to get the nRF24l01+ up and running. +* +*- Use case: For a simple transmitter +*@code +*int main() { +* +* long long addr1=0xAB00CD; // setup address - any 5 byte number - same as RX +* int channel =0x12; // [0-126] setup channel, must be same as RX +* bool txOK; +* char msg[32]; +* char ackData[32]; +* char len; +* +* // Setup +* NRF2401P nrf1(PTD6,PTD7, PTD5,PTD4, PTC12); //mosi, miso, sclk, csn, ce) +* nrf1.quickTxSetup(channel, addr1); // sets nrf24l01+ as transmitter +* +* // transmit +* strcpy (msg, "Hello"); +* txOK= nrf1.transmitData(msg,strlen(msg)); +* +* // read ack data if available +* if (nrf1.isAckData()) { +* len= nrf1.getRxData(ackData); // len is number of bytes in ackData +* } +*} +*@endcode +*- Use case: For a simple receiver +*@code +*int main(){ +* +* long long addr1=0xAB00CD; // setup address - any 5 byte number - same as TX +* int channel =0x12; // [0-126] setup channel, must be same as TX +* bool txOK; +* char msg[32]; +* char ackData[32]; +* char len; +* +* // Setup +* NRF2401P nrf1(PTD6,PTD7, PTD5,PTD4, PTC12); //mosi, miso, sclk, csn, ce) +* nrf1.quickRxSetup(channel, addr1); // sets nrf24l01+ as receiver, using pipe 1 +* +* // set ack data +* sprintf(ackData,"Ack data"); +* nrf1.acknowledgeData(ackData, strlen(ackData),1); // ack for pipe 1 +* +* // receive +* while (! nrf1.isRxData()); // note this blocks until RX data +* len= nrf1.getRxData(msg); // gets the message, len is length of msg +* +*} +*@endcode +*/ class NRF2401P { public: