Latest

Dependencies:   serial_terminal sample_hardware PLL_Config SDCard BMP280 Networkbits TextLCD SDBlockDevice

Revision:
17:ead43c1b729d
Parent:
16:15588fdc5d11
Child:
18:3edfb9152b05
--- a/main.cpp	Fri Nov 23 18:55:35 2018 +0000
+++ b/main.cpp	Fri Nov 30 13:52:44 2018 +0000
@@ -7,55 +7,42 @@
 #include "events/mbed_events.h"
 #include "LCDdisplay.hpp"
 
-
 //Signals
 #define TAKE_SAMPLE 1
 
-
+//Global variables
+float sample_rate = 15;
+FILE* fp;
+FATFileSystem* fs;
 
-float sample_rate = 15;
-//bool sample_enable = true;
+//Shared mutable variables
+struct tm* timeData;
+char buffer[256];
+RawSerial* pc;
 
 //Queues
 EventQueue SDqueue(32*EVENTS_EVENT_SIZE);
 EventQueue LCDqueue(32*EVENTS_EVENT_SIZE);
-
+EventQueue serialqueue(32*EVENTS_EVENT_SIZE);
 
 //Threads
+Thread sample_thread(osPriorityHigh);
+Thread serialthread(osPriorityAboveNormal);
 Thread SDqueue_thread;
 Thread LCDqueue_thread;
-//Thread sterm_thread;
-Thread sample_thread(osPriorityHigh);
-//Thread ntwkthread
 
+//Timers
 Ticker sample;
 
+//Function prototypes
 void sampleISR(void);
 void takesample(void);
 void samples(void);
-
-
-FILE* fp;
-FATFileSystem* fs;
-
-
-//TEST
-Thread serialthread(osPriorityAboveNormal);
-EventQueue serialqueue(32*EVENTS_EVENT_SIZE);
-char buffer[256];
-RawSerial* pc;
 void serialISR(void);
 void serialiser(void);
-int i = 0;
-
-time_t seconds;
-struct tm* t;
-
-//TEST
-
 
 int main() {   
-    t = new tm;
+    timeData = new tm;
     pc = new RawSerial(USBTX, USBRX);
 
     //Move threads into a thread init function?
@@ -66,8 +53,7 @@
     sample_thread.start(samples);
     
     //Initialise, move into initialise function
-    SDcard();
-    
+    SDcard();   
     
     //Power on self test
     post();
@@ -76,15 +62,9 @@
     
     sample.attach(&sampleISR, sample_rate);
     
-    //TEST
     serialthread.start(callback(&serialqueue, &EventQueue::dispatch_forever));
     pc->attach(serialISR, Serial::RxIrq);
     
-    //set_time(1256729737);
-    
-    //TEST
-        
-    
     //Flash to indicate goodness
     while(true) {
         greenLED = !greenLED;
@@ -124,6 +104,7 @@
 
 void serialiser()
 {    
+    static int i = 0;
     if (pc->readable())
     {
         buffer[i] = pc->getc();