The field version of the solarnano grid on the ionQubes

Fork of SolarNanoGridv3 by SONG Project

Committer:
defrost
Date:
Fri Jun 03 14:55:12 2016 +0000
Revision:
10:30c9e8df0032
Parent:
7:5db9aeec9c2e
Child:
11:87ab310924f0
- Warnings all cleared up

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 10:30c9e8df0032 35
defrost 5:57b06b4b47c6 36
defrost 5:57b06b4b47c6 37 /** \brief A library for the base of the solar nano grid controllers.
defrost 5:57b06b4b47c6 38 *
defrost 5:57b06b4b47c6 39 * This library contains the code to drive batteries, hub etc.
defrost 5:57b06b4b47c6 40 */
defrost 5:57b06b4b47c6 41 class SolarNanoGrid {
defrost 5:57b06b4b47c6 42 public:
defrost 5:57b06b4b47c6 43 // *********************
defrost 5:57b06b4b47c6 44 // * Public variables: *
defrost 5:57b06b4b47c6 45 // *********************
defrost 7:5db9aeec9c2e 46 int sdVersion;
defrost 7:5db9aeec9c2e 47 unsigned int id;
defrost 7:5db9aeec9c2e 48 unsigned int communityID;
defrost 7:5db9aeec9c2e 49 int chan;
defrost 5:57b06b4b47c6 50 char dataRx[33];
defrost 5:57b06b4b47c6 51 char dataTx[33];
defrost 5:57b06b4b47c6 52
defrost 7:5db9aeec9c2e 53 DigitalOut *ledRed, *ledGreen, *ledBlue;
defrost 5:57b06b4b47c6 54
defrost 5:57b06b4b47c6 55 // *********************
defrost 5:57b06b4b47c6 56 // * Public functions: *
defrost 5:57b06b4b47c6 57 // *********************
defrost 5:57b06b4b47c6 58
defrost 5:57b06b4b47c6 59 // Constructor:
defrost 5:57b06b4b47c6 60
defrost 5:57b06b4b47c6 61 /**
defrost 5:57b06b4b47c6 62 * Reads in config.ini and sets up the CommunityId, UserId, and the channel.
defrost 5:57b06b4b47c6 63 */
defrost 5:57b06b4b47c6 64
defrost 5:57b06b4b47c6 65 SolarNanoGrid(FILE* fp);
defrost 5:57b06b4b47c6 66 /**
defrost 5:57b06b4b47c6 67 * Asks the user for the time and sets the real time clock
defrost 5:57b06b4b47c6 68 */
defrost 5:57b06b4b47c6 69 void userSetRTCpc();
defrost 0:dc8a45ec969a 70
defrost 5:57b06b4b47c6 71 // Main loop function:
defrost 5:57b06b4b47c6 72 void loop(void);
defrost 5:57b06b4b47c6 73
defrost 5:57b06b4b47c6 74 // spi pin assignments:
defrost 5:57b06b4b47c6 75 /**
defrost 5:57b06b4b47c6 76 * Turns SPI on for SD card
defrost 5:57b06b4b47c6 77 */
defrost 5:57b06b4b47c6 78 void spiSD(void);
defrost 5:57b06b4b47c6 79
defrost 5:57b06b4b47c6 80 /**
defrost 5:57b06b4b47c6 81 * Turns SPI on for nrf
defrost 5:57b06b4b47c6 82 */
defrost 5:57b06b4b47c6 83 void spiNrf(void);
defrost 5:57b06b4b47c6 84
defrost 5:57b06b4b47c6 85 protected:
defrost 5:57b06b4b47c6 86 // *********************
defrost 5:57b06b4b47c6 87 // * Protected interrupts: *
defrost 5:57b06b4b47c6 88 // *********************
defrost 5:57b06b4b47c6 89 InterruptIn* nrfInt;
defrost 1:df924e0126d1 90
defrost 5:57b06b4b47c6 91 // **********************
defrost 5:57b06b4b47c6 92 // * Protected variables: *
defrost 5:57b06b4b47c6 93 // **********************
defrost 5:57b06b4b47c6 94 DigitalOut* ce;
defrost 7:5db9aeec9c2e 95 FILE* _fp;
defrost 7:5db9aeec9c2e 96 NRF2401P* nrf;
defrost 5:57b06b4b47c6 97
defrost 1:df924e0126d1 98
defrost 5:57b06b4b47c6 99 // *********************
defrost 5:57b06b4b47c6 100 // * Protected functions: *
defrost 5:57b06b4b47c6 101 // *********************
defrost 5:57b06b4b47c6 102 /**
defrost 5:57b06b4b47c6 103 * Flushes the rx and tx buffers and resets the status.
defrost 5:57b06b4b47c6 104 */
defrost 5:57b06b4b47c6 105 void nrfFlush();
defrost 5:57b06b4b47c6 106
defrost 5:57b06b4b47c6 107 private:
defrost 5:57b06b4b47c6 108 // **********************
defrost 5:57b06b4b47c6 109 // * Private variables: *
defrost 5:57b06b4b47c6 110 // **********************
defrost 5:57b06b4b47c6 111
defrost 1:df924e0126d1 112 };
defrost 0:dc8a45ec969a 113
defrost 6:93ca8321f83e 114
defrost 5:57b06b4b47c6 115 #endif /* SOLARNANOGRID_H */