The field version of the solarnano grid on the ionQubes

Fork of SolarNanoGridv3 by SONG Project

Committer:
defrost
Date:
Thu Jun 02 16:41:40 2016 +0000
Revision:
5:57b06b4b47c6
Parent:
2:929cf7fc6998
Child:
6:93ca8321f83e
- updated to v3.0 from Malcolm's email

Who changed what in which revision?

UserRevisionLine numberNew contents of line
defrost 0:dc8a45ec969a 1 /**
defrost 5:57b06b4b47c6 2 *@section DESCRIPTION
defrost 5:57b06b4b47c6 3 * mbed SolarNanogrid Library
defrost 5:57b06b4b47c6 4 *@section LICENSE
defrost 5:57b06b4b47c6 5 * Copyright (c) 2016, Malcolm McCulloch
defrost 5:57b06b4b47c6 6 *
defrost 5:57b06b4b47c6 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
defrost 5:57b06b4b47c6 8 * of this software and associated documentation files (the "Software"), to deal
defrost 5:57b06b4b47c6 9 * in the Software without restriction, including without limitation the rights
defrost 5:57b06b4b47c6 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
defrost 5:57b06b4b47c6 11 * copies of the Software, and to permit persons to whom the Software is
defrost 5:57b06b4b47c6 12 * furnished to do so, subject to the following conditions:
defrost 5:57b06b4b47c6 13 *
defrost 5:57b06b4b47c6 14 * The above copyright notice and this permission notice shall be included in
defrost 5:57b06b4b47c6 15 * all copies or substantial portions of the Software.
defrost 5:57b06b4b47c6 16 *
defrost 5:57b06b4b47c6 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
defrost 5:57b06b4b47c6 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
defrost 5:57b06b4b47c6 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
defrost 5:57b06b4b47c6 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
defrost 5:57b06b4b47c6 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
defrost 5:57b06b4b47c6 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
defrost 5:57b06b4b47c6 23 * THE SOFTWARE.
defrost 5:57b06b4b47c6 24 * @file "SolarNanoGrid.h"
defrost 5:57b06b4b47c6 25 */
defrost 0:dc8a45ec969a 26
defrost 0:dc8a45ec969a 27 #ifndef SOLARNANOGRID_H
defrost 0:dc8a45ec969a 28 #define SOLARNANOGRID_H
defrost 5:57b06b4b47c6 29 #include <mbed.h>
defrost 5:57b06b4b47c6 30 #include <pinmap.h>
defrost 1:df924e0126d1 31 #include "NRF2401P.h"
defrost 1:df924e0126d1 32 #include "SDFileSystem.h"
defrost 5:57b06b4b47c6 33
defrost 5:57b06b4b47c6 34
defrost 5:57b06b4b47c6 35 #define FUNCNAME "SNGC"
defrost 5:57b06b4b47c6 36 #include "defs.h"
defrost 5:57b06b4b47c6 37
defrost 5:57b06b4b47c6 38 /** \brief A library for the base of the solar nano grid controllers.
defrost 5:57b06b4b47c6 39 *
defrost 5:57b06b4b47c6 40 * This library contains the code to drive batteries, hub etc.
defrost 5:57b06b4b47c6 41 */
defrost 5:57b06b4b47c6 42 class SolarNanoGrid {
defrost 5:57b06b4b47c6 43 public:
defrost 5:57b06b4b47c6 44 // *********************
defrost 5:57b06b4b47c6 45 // * Public variables: *
defrost 5:57b06b4b47c6 46 // *********************
defrost 5:57b06b4b47c6 47 int sdVersion=0;
defrost 5:57b06b4b47c6 48 unsigned int id=0;
defrost 5:57b06b4b47c6 49 unsigned int communityID=0;
defrost 5:57b06b4b47c6 50 int chan=0;
defrost 5:57b06b4b47c6 51 char dataRx[33];
defrost 5:57b06b4b47c6 52 char dataTx[33];
defrost 5:57b06b4b47c6 53
defrost 5:57b06b4b47c6 54 DigitalOut *ledRed=NULL, *ledGreen=NULL, *ledBlue=NULL;
defrost 5:57b06b4b47c6 55
defrost 5:57b06b4b47c6 56 // *********************
defrost 5:57b06b4b47c6 57 // * Public functions: *
defrost 5:57b06b4b47c6 58 // *********************
defrost 5:57b06b4b47c6 59
defrost 5:57b06b4b47c6 60 // Constructor:
defrost 5:57b06b4b47c6 61
defrost 5:57b06b4b47c6 62 /**
defrost 5:57b06b4b47c6 63 * Reads in config.ini and sets up the CommunityId, UserId, and the channel.
defrost 5:57b06b4b47c6 64 */
defrost 5:57b06b4b47c6 65
defrost 5:57b06b4b47c6 66 SolarNanoGrid(FILE* fp);
defrost 5:57b06b4b47c6 67 /**
defrost 5:57b06b4b47c6 68 * Asks the user for the time and sets the real time clock
defrost 5:57b06b4b47c6 69 */
defrost 5:57b06b4b47c6 70 void userSetRTCpc();
defrost 0:dc8a45ec969a 71
defrost 5:57b06b4b47c6 72 // Main loop function:
defrost 5:57b06b4b47c6 73 void loop(void);
defrost 5:57b06b4b47c6 74
defrost 5:57b06b4b47c6 75 // spi pin assignments:
defrost 5:57b06b4b47c6 76 /**
defrost 5:57b06b4b47c6 77 * Turns SPI on for SD card
defrost 5:57b06b4b47c6 78 */
defrost 5:57b06b4b47c6 79 void spiSD(void);
defrost 5:57b06b4b47c6 80
defrost 5:57b06b4b47c6 81 /**
defrost 5:57b06b4b47c6 82 * Turns SPI on for nrf
defrost 5:57b06b4b47c6 83 */
defrost 5:57b06b4b47c6 84 void spiNrf(void);
defrost 5:57b06b4b47c6 85
defrost 5:57b06b4b47c6 86 protected:
defrost 5:57b06b4b47c6 87 // *********************
defrost 5:57b06b4b47c6 88 // * Protected interrupts: *
defrost 5:57b06b4b47c6 89 // *********************
defrost 5:57b06b4b47c6 90 InterruptIn* nrfInt;
defrost 1:df924e0126d1 91
defrost 5:57b06b4b47c6 92 // **********************
defrost 5:57b06b4b47c6 93 // * Protected variables: *
defrost 5:57b06b4b47c6 94 // **********************
defrost 5:57b06b4b47c6 95 DigitalOut* ce;
defrost 5:57b06b4b47c6 96 FILE* _fp=NULL;
defrost 5:57b06b4b47c6 97 NRF2401P* nrf=NULL;
defrost 5:57b06b4b47c6 98
defrost 1:df924e0126d1 99
defrost 5:57b06b4b47c6 100 // *********************
defrost 5:57b06b4b47c6 101 // * Protected functions: *
defrost 5:57b06b4b47c6 102 // *********************
defrost 5:57b06b4b47c6 103 /**
defrost 5:57b06b4b47c6 104 * Flushes the rx and tx buffers and resets the status.
defrost 5:57b06b4b47c6 105 */
defrost 5:57b06b4b47c6 106 void nrfFlush();
defrost 5:57b06b4b47c6 107
defrost 5:57b06b4b47c6 108 private:
defrost 5:57b06b4b47c6 109 // **********************
defrost 5:57b06b4b47c6 110 // * Private variables: *
defrost 5:57b06b4b47c6 111 // **********************
defrost 5:57b06b4b47c6 112
defrost 1:df924e0126d1 113 };
defrost 0:dc8a45ec969a 114
defrost 5:57b06b4b47c6 115 #endif /* SOLARNANOGRID_H */