2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Files at this revision

API Documentation at this revision

Comitter:
shimniok
Date:
Mon Dec 17 22:26:34 2018 +0000
Parent:
21:020f4ebbb13a
Child:
23:5e61cf4a8c34
Commit message:
gps parse into separate thread via EventQueue

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Dec 16 04:19:47 2018 +0000
+++ b/main.cpp	Mon Dec 17 22:26:34 2018 +0000
@@ -28,13 +28,21 @@
 
 RawSerial s(UART1TX, UART1RX, 38400);
 
-void read_gps();
+EventQueue gpsQueue(32 * EVENTS_EVENT_SIZE);
 
+// thread / eventqueue wrapper for gps parse
+void gps_parse(int c) {
+    if (ublox.parse(c)) {
+        led3 = !led3;
+    }
+}
+
+// ISR for GPS serial, passes off to thread
 void gps_handler() {
-    if (s.readable()) {
-        if (ublox.parse(s.getc())) {
-            led3 = !led3;
-        }
+    while (s.readable()) {
+        int c = s.getc();
+        //gpsQueue.call(gps_parse, c);
+        gpsQueue.call(&ublox, &Ublox6::parse, c);
     }
 }
 
@@ -141,18 +149,13 @@
     printf("Starting updater...\n");
     Updater *u = Updater::instance();
     u->setInterval(20);
-    Thread updaterThread;
-    updaterThread.set_priority(osPriorityRealtime);
+    Thread updaterThread(osPriorityRealtime);
     updaterThread.start(callback(u, &Updater::start));
-
+    
     printf("Starting gps...\n");
-    s.attach(&gps_handler);
-
-    /*
-    Thread gpsThread;
-    gpsThread.set_priority(osPriorityHigh);
-    gpsThread.start(&do_gps);
-    */
+    Thread gpsThread(osPriorityHigh);
+    gpsThread.start(callback(&gpsQueue, &EventQueue::dispatch_forever));
+    s.attach(gps_handler);
     
     /*
     FILE *fp;