The field version of the solarnano grid on the ionQubes
Fork of SolarNanoGridv3 by
SolarNanoGrid.h@13:de43f28c0365, 2016-06-10 (annotated)
- Committer:
- defrost
- Date:
- Fri Jun 10 14:17:38 2016 +0000
- Revision:
- 13:de43f28c0365
- Parent:
- 11:87ab310924f0
- Child:
- 15:e719c1cb0ea2
- File transmission is starting to work, it still does not complete.; - Fixed all of the warnings in the code. Many of them were related to 'regular' string format specifiers being used with 'long' variables. %x -> %llx.
Who changed what in which revision?
User | Revision | Line number | New 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> |
epgmdm | 11:87ab310924f0 | 31 | #include <RawSerial.h> |
defrost | 1:df924e0126d1 | 32 | #include "NRF2401P.h" |
defrost | 1:df924e0126d1 | 33 | #include "SDFileSystem.h" |
defrost | 5:57b06b4b47c6 | 34 | |
defrost | 5:57b06b4b47c6 | 35 | |
defrost | 10:30c9e8df0032 | 36 | |
defrost | 13:de43f28c0365 | 37 | |
defrost | 13:de43f28c0365 | 38 | |
defrost | 5:57b06b4b47c6 | 39 | |
defrost | 5:57b06b4b47c6 | 40 | /** \brief A library for the base of the solar nano grid controllers. |
defrost | 5:57b06b4b47c6 | 41 | * |
defrost | 5:57b06b4b47c6 | 42 | * This library contains the code to drive batteries, hub etc. |
defrost | 5:57b06b4b47c6 | 43 | */ |
defrost | 5:57b06b4b47c6 | 44 | class SolarNanoGrid { |
defrost | 5:57b06b4b47c6 | 45 | public: |
defrost | 5:57b06b4b47c6 | 46 | // ********************* |
defrost | 5:57b06b4b47c6 | 47 | // * Public variables: * |
defrost | 5:57b06b4b47c6 | 48 | // ********************* |
defrost | 7:5db9aeec9c2e | 49 | int sdVersion; |
defrost | 7:5db9aeec9c2e | 50 | unsigned int id; |
defrost | 7:5db9aeec9c2e | 51 | unsigned int communityID; |
defrost | 7:5db9aeec9c2e | 52 | int chan; |
defrost | 5:57b06b4b47c6 | 53 | char dataRx[33]; |
defrost | 5:57b06b4b47c6 | 54 | char dataTx[33]; |
epgmdm | 11:87ab310924f0 | 55 | Serial *pc; |
defrost | 5:57b06b4b47c6 | 56 | |
epgmdm | 11:87ab310924f0 | 57 | DigitalOut *ledRed, *ledGreen, *ledBlue; |
defrost | 5:57b06b4b47c6 | 58 | |
defrost | 5:57b06b4b47c6 | 59 | // ********************* |
defrost | 5:57b06b4b47c6 | 60 | // * Public functions: * |
defrost | 5:57b06b4b47c6 | 61 | // ********************* |
defrost | 5:57b06b4b47c6 | 62 | |
defrost | 5:57b06b4b47c6 | 63 | // Constructor: |
defrost | 5:57b06b4b47c6 | 64 | |
defrost | 5:57b06b4b47c6 | 65 | /** |
defrost | 5:57b06b4b47c6 | 66 | * Reads in config.ini and sets up the CommunityId, UserId, and the channel. |
defrost | 5:57b06b4b47c6 | 67 | */ |
defrost | 5:57b06b4b47c6 | 68 | |
epgmdm | 11:87ab310924f0 | 69 | SolarNanoGrid(FILE* fp, Serial *pc); |
defrost | 5:57b06b4b47c6 | 70 | /** |
defrost | 5:57b06b4b47c6 | 71 | * Asks the user for the time and sets the real time clock |
defrost | 5:57b06b4b47c6 | 72 | */ |
defrost | 5:57b06b4b47c6 | 73 | void userSetRTCpc(); |
defrost | 0:dc8a45ec969a | 74 | |
defrost | 5:57b06b4b47c6 | 75 | // Main loop function: |
defrost | 13:de43f28c0365 | 76 | virtual void loop(void) = 0; |
defrost | 5:57b06b4b47c6 | 77 | |
defrost | 5:57b06b4b47c6 | 78 | // spi pin assignments: |
defrost | 5:57b06b4b47c6 | 79 | /** |
defrost | 5:57b06b4b47c6 | 80 | * Turns SPI on for SD card |
defrost | 5:57b06b4b47c6 | 81 | */ |
defrost | 5:57b06b4b47c6 | 82 | void spiSD(void); |
defrost | 5:57b06b4b47c6 | 83 | |
defrost | 5:57b06b4b47c6 | 84 | /** |
defrost | 5:57b06b4b47c6 | 85 | * Turns SPI on for nrf |
defrost | 5:57b06b4b47c6 | 86 | */ |
epgmdm | 11:87ab310924f0 | 87 | void spiNRF(void); |
defrost | 5:57b06b4b47c6 | 88 | |
defrost | 5:57b06b4b47c6 | 89 | protected: |
defrost | 5:57b06b4b47c6 | 90 | // ********************* |
defrost | 5:57b06b4b47c6 | 91 | // * Protected interrupts: * |
defrost | 5:57b06b4b47c6 | 92 | // ********************* |
defrost | 5:57b06b4b47c6 | 93 | InterruptIn* nrfInt; |
defrost | 1:df924e0126d1 | 94 | |
defrost | 5:57b06b4b47c6 | 95 | // ********************** |
defrost | 5:57b06b4b47c6 | 96 | // * Protected variables: * |
defrost | 5:57b06b4b47c6 | 97 | // ********************** |
defrost | 5:57b06b4b47c6 | 98 | DigitalOut* ce; |
defrost | 7:5db9aeec9c2e | 99 | FILE* _fp; |
defrost | 7:5db9aeec9c2e | 100 | NRF2401P* nrf; |
defrost | 5:57b06b4b47c6 | 101 | |
defrost | 1:df924e0126d1 | 102 | |
defrost | 5:57b06b4b47c6 | 103 | // ********************* |
defrost | 5:57b06b4b47c6 | 104 | // * Protected functions: * |
defrost | 5:57b06b4b47c6 | 105 | // ********************* |
defrost | 5:57b06b4b47c6 | 106 | /** |
defrost | 5:57b06b4b47c6 | 107 | * Flushes the rx and tx buffers and resets the status. |
defrost | 5:57b06b4b47c6 | 108 | */ |
defrost | 5:57b06b4b47c6 | 109 | void nrfFlush(); |
defrost | 5:57b06b4b47c6 | 110 | |
epgmdm | 11:87ab310924f0 | 111 | /** |
epgmdm | 11:87ab310924f0 | 112 | * Set NRF as RX and flush |
epgmdm | 11:87ab310924f0 | 113 | */ |
epgmdm | 11:87ab310924f0 | 114 | void setAsRX(long long addr); |
epgmdm | 11:87ab310924f0 | 115 | |
epgmdm | 11:87ab310924f0 | 116 | /** |
epgmdm | 11:87ab310924f0 | 117 | * Sets NRF as TX and flushes the NRF |
epgmdm | 11:87ab310924f0 | 118 | */ |
epgmdm | 11:87ab310924f0 | 119 | void setAsTX(long long addr); |
epgmdm | 11:87ab310924f0 | 120 | |
defrost | 5:57b06b4b47c6 | 121 | private: |
defrost | 5:57b06b4b47c6 | 122 | // ********************** |
defrost | 5:57b06b4b47c6 | 123 | // * Private variables: * |
defrost | 5:57b06b4b47c6 | 124 | // ********************** |
defrost | 5:57b06b4b47c6 | 125 | |
defrost | 1:df924e0126d1 | 126 | }; |
defrost | 0:dc8a45ec969a | 127 | |
defrost | 5:57b06b4b47c6 | 128 | #endif /* SOLARNANOGRID_H */ |