This is a work in progress for an NRF2401P

Dependencies:   mbed

Fork of NRF2401P by Malcolm McCulloch

Committer:
epgmdm
Date:
Thu Jun 11 23:38:01 2015 +0000
Revision:
3:afe8d307b5c3
Parent:
2:ca0a3c0bba70
Child:
5:7e253c677a1f
No debug, transmitData returns bool not char - flushesTX if max RT

Who changed what in which revision?

UserRevisionLine numberNew contents of line
epgmdm 0:8fd0531ae0be 1 /**
epgmdm 0:8fd0531ae0be 2 *@section DESCRIPTION
epgmdm 0:8fd0531ae0be 3 * mbed NRF2401+ Library
epgmdm 0:8fd0531ae0be 4 *@section LICENSE
epgmdm 0:8fd0531ae0be 5 * Copyright (c) 2015, Malcolm McCulloch
epgmdm 0:8fd0531ae0be 6 *
epgmdm 0:8fd0531ae0be 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
epgmdm 0:8fd0531ae0be 8 * of this software and associated documentation files (the "Software"), to deal
epgmdm 0:8fd0531ae0be 9 * in the Software without restriction, including without limitation the rights
epgmdm 0:8fd0531ae0be 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
epgmdm 0:8fd0531ae0be 11 * copies of the Software, and to permit persons to whom the Software is
epgmdm 0:8fd0531ae0be 12 * furnished to do so, subject to the following conditions:
epgmdm 0:8fd0531ae0be 13 *
epgmdm 0:8fd0531ae0be 14 * The above copyright notice and this permission notice shall be included in
epgmdm 0:8fd0531ae0be 15 * all copies or substantial portions of the Software.
epgmdm 0:8fd0531ae0be 16 *
epgmdm 0:8fd0531ae0be 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
epgmdm 0:8fd0531ae0be 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
epgmdm 0:8fd0531ae0be 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
epgmdm 0:8fd0531ae0be 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
epgmdm 0:8fd0531ae0be 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
epgmdm 0:8fd0531ae0be 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
epgmdm 0:8fd0531ae0be 23 * THE SOFTWARE.
epgmdm 0:8fd0531ae0be 24 * @file "NRF2401P.h"
epgmdm 0:8fd0531ae0be 25 */
epgmdm 0:8fd0531ae0be 26 class NRF2401P
epgmdm 0:8fd0531ae0be 27 {
epgmdm 0:8fd0531ae0be 28 public:
epgmdm 0:8fd0531ae0be 29 SPI *spi;
epgmdm 0:8fd0531ae0be 30 DigitalOut csn,ce;
epgmdm 0:8fd0531ae0be 31 char addressWidth;
epgmdm 0:8fd0531ae0be 32 char logMsg[80];
epgmdm 0:8fd0531ae0be 33 char status;
epgmdm 0:8fd0531ae0be 34 char statusS[32];
epgmdm 2:ca0a3c0bba70 35 char pipe0Add[5];
epgmdm 2:ca0a3c0bba70 36 char txAdd[5];
epgmdm 0:8fd0531ae0be 37 bool dynamic,debug;
epgmdm 0:8fd0531ae0be 38 Serial *pc;
epgmdm 0:8fd0531ae0be 39
epgmdm 0:8fd0531ae0be 40 NRF2401P (PinName mosi, PinName miso, PinName sclk, PinName _csn, PinName _ce);
epgmdm 0:8fd0531ae0be 41
epgmdm 0:8fd0531ae0be 42 char acknowledgeData( char *data, char width, char pipe);
epgmdm 1:ff53b1ac3bad 43 char checkStatus();
epgmdm 0:8fd0531ae0be 44 bool clearStatus();
epgmdm 0:8fd0531ae0be 45 bool flushRx();
epgmdm 0:8fd0531ae0be 46 bool flushTx();
epgmdm 0:8fd0531ae0be 47 char getRxData(char * buffer);
epgmdm 0:8fd0531ae0be 48 char getRxWidth();
epgmdm 1:ff53b1ac3bad 49 bool isAckData();
epgmdm 0:8fd0531ae0be 50 bool isRxData();
epgmdm 0:8fd0531ae0be 51 void log (char *msg);
epgmdm 0:8fd0531ae0be 52 void quickRxSetup(int channel,long long addr);
epgmdm 0:8fd0531ae0be 53 void quickTxSetup(int channel,long long addr);
epgmdm 0:8fd0531ae0be 54 char readReg(char address, char *data);
epgmdm 0:8fd0531ae0be 55 char testReceive();
epgmdm 0:8fd0531ae0be 56 char testTransmit();
epgmdm 3:afe8d307b5c3 57 bool transmitData( char *data, char width );
epgmdm 0:8fd0531ae0be 58
epgmdm 0:8fd0531ae0be 59 bool setAddressWidth(char width);
epgmdm 0:8fd0531ae0be 60 char setChannel(char chan);
epgmdm 2:ca0a3c0bba70 61 void setDynamicPayload();
epgmdm 0:8fd0531ae0be 62 bool setPwrUp();
epgmdm 0:8fd0531ae0be 63 char setRadio(char speed,char power);
epgmdm 0:8fd0531ae0be 64 char setRxAddress(char *address, char pipe);
epgmdm 0:8fd0531ae0be 65 char setRxAddress(long long address, char pipe);
epgmdm 0:8fd0531ae0be 66 bool setRxMode();
epgmdm 0:8fd0531ae0be 67 char setTxAddress(char *address);
epgmdm 0:8fd0531ae0be 68 char setTxAddress(long long address);
epgmdm 0:8fd0531ae0be 69 bool setTxMode();
epgmdm 2:ca0a3c0bba70 70 void setTxRetry(char delay, char numTries);
epgmdm 2:ca0a3c0bba70 71 void start();
epgmdm 0:8fd0531ae0be 72 char * statusString();
epgmdm 0:8fd0531ae0be 73 char writeReg(char address, char *data, char width);
epgmdm 0:8fd0531ae0be 74 char writeReg(char address, char data);
epgmdm 0:8fd0531ae0be 75
epgmdm 0:8fd0531ae0be 76 void scratch();
epgmdm 0:8fd0531ae0be 77
epgmdm 0:8fd0531ae0be 78
epgmdm 0:8fd0531ae0be 79 };