summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-11-30 16:10:43 -0800
committerKeith Packard <keithp@keithp.com>2012-11-30 16:10:43 -0800
commit860d0526737295c695f8e6a790d72b49eb4a686d (patch)
treeeb21241d7407fffb61da74162cd40f58144cd1c9 /src
parentc90ece979f3c95cc6c557c5a2ba8f4a0ce78e173 (diff)
altos: Add support for reflashing skytraq GPS chips
This simply switches the skytraq port to 115200 baud and then essentially connects it directly to the USB port by forwarding bytes in both directions. Once started, the only way out is to reboot the board. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/ao_gps_skytraq.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/drivers/ao_gps_skytraq.c b/src/drivers/ao_gps_skytraq.c
index d80da97c..b7dc0a86 100644
--- a/src/drivers/ao_gps_skytraq.c
+++ b/src/drivers/ao_gps_skytraq.c
@@ -21,6 +21,7 @@
#ifndef ao_gps_getchar
#define ao_gps_getchar ao_serial1_getchar
+#define ao_gps_fifo ao_serial1_rx_fifo
#endif
#ifndef ao_gps_putchar
@@ -453,6 +454,8 @@ ao_gps_nmea_parse(void)
}
}
+static uint8_t ao_gps_updating;
+
void
ao_gps(void) __reentrant
{
@@ -468,6 +471,13 @@ ao_gps(void) __reentrant
if (ao_gps_getchar() == '$') {
ao_gps_nmea_parse();
}
+#ifndef AO_GPS_TEST
+ while (ao_gps_updating) {
+ ao_usb_putchar(ao_gps_getchar());
+ if (ao_fifo_empty(ao_gps_fifo))
+ flush();
+ }
+#endif
}
}
@@ -492,8 +502,29 @@ gps_dump(void) __reentrant
ao_mutex_put(&ao_gps_mutex);
}
+static __code uint8_t ao_gps_115200[] = {
+ SKYTRAQ_MSG_3(5,0,5,0) /* Set to 115200 baud */
+};
+
+static void
+gps_update(void) __reentrant
+{
+ ao_gps_updating = 1;
+ ao_task_minimize_latency = 1;
+#if HAS_ADC
+ ao_timer_set_adc_interval(0);
+#endif
+ ao_skytraq_sendstruct(ao_gps_115200);
+ ao_gps_set_speed(AO_SERIAL_SPEED_115200);
+
+ /* It's a binary protocol; abandon attempts to escape */
+ for (;;)
+ ao_gps_putchar(ao_usb_getchar());
+}
+
__code struct ao_cmds ao_gps_cmds[] = {
{ gps_dump, "g\0Display GPS" },
+ { gps_update, "U\0Update GPS firmware" },
{ 0, NULL },
};