The field version of the solarnano grid on the ionQubes
Fork of SolarNanoGridv3 by
Diff: SolarNanoGrid.cpp
- Revision:
- 11:87ab310924f0
- Parent:
- 10:30c9e8df0032
- Child:
- 13:de43f28c0365
--- a/SolarNanoGrid.cpp Fri Jun 03 14:55:12 2016 +0000 +++ b/SolarNanoGrid.cpp Wed Jun 08 22:12:52 2016 +0000 @@ -25,14 +25,12 @@ */ #include <mbed.h> #include "SolarNanoGrid.h" -#define FUNCNAME "SNGC" -#include "defs.h" // Constructor: /** * Constructor. */ -SolarNanoGrid::SolarNanoGrid(FILE *fp=NULL):_fp(fp){ +SolarNanoGrid::SolarNanoGrid(FILE *fp=NULL, Serial *pc=NULL):_fp(fp),pc(pc){ // Save the sd card pointer: DBG("Solar init"); // Leds @@ -57,20 +55,6 @@ ce = new DigitalOut(PTB20); nrf = new NRF2401P(PTD6, PTD7, PTD5, PTD4, PTB20); // Rev E //nrf1 = new NRF2401P(PTD6,PTD7, PTD5,PTD4, PTC12); //mosi, miso, sclk, csn, ce) REV D // irq ptc18 on k64f - - // initialize all of the variables: - sdVersion=0; - id=0; - communityID=0; - chan=0; - - - *ledRed=NULL; - *ledGreen=NULL; - *ledBlue=NULL; - _fp=NULL; - nrf=NULL; - } @@ -102,7 +86,7 @@ * Flushes the rx and tx buffers and resets the status. */ void SolarNanoGrid::nrfFlush() { - spiNrf(); + spiNRF(); if(nrf!=NULL){ nrf->clearStatus(); nrf->flushRx(); @@ -125,10 +109,38 @@ /** * Turns SPI on for nrf */ -void SolarNanoGrid::spiNrf(void) +void SolarNanoGrid::spiNRF(void) { //sd.deselect(); pin_function(PTE1, 1); //pin function 1 is GPIO pin_function(PTD7, 7); //Set SD_MISO as SPI, this is the same as the last number in those tables return; } + +/** + * Set NRF as RX and flush + */ +void SolarNanoGrid::setAsRX(long long addr){ + + spiNRF(); + nrf->quickRxSetup(chan, addr); // Pipe 0 + nrf->setRadio(0x01, 0x03); // 2MB/S 0dB + nrfFlush(); +} + +/** + * Sets NRF as TX and flushes the NRF + */ +void SolarNanoGrid::setAsTX(long long addr){ + DBG("setAsTx"); + spiNRF(); + nrf->quickTxSetup(chan, addr); + nrf->setRadio(0x01, 0x03); // 2MB/S 0dB + nrf->setTxRetry(0x0F, 0x0F); + nrfFlush(); + DBG("Nrf Details:"); +#ifdef DEBUG + nrf->printDetails(); +#endif + +} \ No newline at end of file