2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: main.cpp
- Revision:
- 20:043987d06f8d
- Parent:
- 19:0d1728091519
- Child:
- 21:020f4ebbb13a
--- a/main.cpp Sat Dec 15 21:38:11 2018 +0000 +++ b/main.cpp Sun Dec 16 04:18:42 2018 +0000 @@ -26,20 +26,18 @@ DigitalOut led1(LED1); DigitalOut led3(LED3); +RawSerial s(UART1TX, UART1RX, 38400); + void read_gps(); -void do_gps() { - RawSerial s(UART1TX, UART1RX, 38400); - while (1) { - int c = s.getc(); - if (ublox.parse(c)) { +void gps_handler() { + if (s.readable()) { + if (ublox.parse(s.getc())) { led3 = !led3; - read_gps(); } } } - /******** SHELL COMMANDS ********/ void test() { @@ -80,6 +78,15 @@ printf("Encoder: %d\n", u->encoder()); } +void bridge_uart1() { + RawSerial s(UART1TX, UART1RX, 38400); + while (1) { + if (pc.readable()) s.putc(pc.getc()); + if (s.readable()) pc.putc(s.getc()); + } +} + + void reset() { NVIC_SystemReset(); @@ -90,12 +97,11 @@ // main() runs in its own thread in the OS int main() { + //bridge_uart1(); + printf("Bootup...\n"); fflush(stdout); - do_gps(); - while(1); - printf("Loading config...\n"); config.add("intercept_distance", Config::DOUBLE); config.add("waypoint_threshold", Config::DOUBLE); @@ -140,11 +146,15 @@ updaterThread.start(callback(u, &Updater::start)); printf("Starting gps...\n"); + s.attach(&gps_handler); + + /* Thread gpsThread; gpsThread.set_priority(osPriorityHigh); gpsThread.start(&do_gps); + */ -/* + /* FILE *fp; char buf[128]; printf("Initializing the block device... ");