Latest
Dependencies: serial_terminal sample_hardware PLL_Config SDCard BMP280 Networkbits TextLCD SDBlockDevice
Diff: main.cpp
- Revision:
- 18:3edfb9152b05
- Parent:
- 17:ead43c1b729d
- Child:
- 19:88d8359306a4
--- a/main.cpp Fri Nov 30 13:52:44 2018 +0000 +++ b/main.cpp Fri Nov 30 14:39:10 2018 +0000 @@ -17,7 +17,7 @@ //Shared mutable variables struct tm* timeData; -char buffer[256]; +char cmdBuffer[256]; RawSerial* pc; //Queues @@ -44,25 +44,21 @@ int main() { timeData = new tm; pc = new RawSerial(USBTX, USBRX); - - //Move threads into a thread init function? - SDqueue_thread.start(callback(&SDqueue, &EventQueue::dispatch_forever)); - LCDqueue_thread.start(callback(&LCDqueue, &EventQueue::dispatch_forever)); - //sterm_thread.start(serialterm); - sample_thread.start(samples); - - //Initialise, move into initialise function + //Initialisations SDcard(); //Power on self test post(); - - pc->printf("Send commands\n\r"); + + //Start threads + SDqueue_thread.start(callback(&SDqueue, &EventQueue::dispatch_forever)); + LCDqueue_thread.start(callback(&LCDqueue, &EventQueue::dispatch_forever)); + serialthread.start(callback(&serialqueue, &EventQueue::dispatch_forever)); + sample_thread.start(samples); - sample.attach(&sampleISR, sample_rate); - - serialthread.start(callback(&serialqueue, &EventQueue::dispatch_forever)); + //Attach ISRs + sample.attach(&sampleISR, sample_rate); pc->attach(serialISR, Serial::RxIrq); //Flash to indicate goodness @@ -107,12 +103,11 @@ static int i = 0; if (pc->readable()) { - buffer[i] = pc->getc(); - if (buffer[i] == '\r') + cmdBuffer[i] = pc->getc(); + if (cmdBuffer[i] == '\r') { i = 0; - serialqueue.call(serialterm); - + serialqueue.call(serialterm); } else i++; }