![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: main.cpp
- Revision:
- 22:4d62bd16f037
- Parent:
- 21:020f4ebbb13a
- Child:
- 23:5e61cf4a8c34
diff -r 020f4ebbb13a -r 4d62bd16f037 main.cpp --- 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;