Increase the initial accel/baro average to 1000 samples
[fw/altos] / ao_gps.c
index 83f44d55f42f80c0c738b5f754d04b6c3f40d610..e5a5a8842d9c38f76504afef3d5a65ba1508e385 100644 (file)
--- a/ao_gps.c
+++ b/ao_gps.c
 
 #include "ao.h"
 
-__xdata struct ao_task ao_gps_task;
-
 #define AO_GPS_LEADER          6
 
-static const uint8_t ao_gps_header[] = "GPGGA,";
+static const char ao_gps_header[] = "GPGGA,";
 __xdata uint8_t ao_gps_mutex;
-static __xdata uint8_t ao_gps_char;
+static __xdata char ao_gps_char;
 static __xdata uint8_t ao_gps_cksum;
 static __xdata uint8_t ao_gps_error;
 
 __xdata struct ao_gps_data     ao_gps_data;
 static __xdata struct ao_gps_data      ao_gps_next;
 
-const uint8_t ao_gps_config[] =
+const char ao_gps_config[] =
        "$PSRF103,00,00,01,01*25\r\n"   /* GGA 1 per sec */
        "$PSRF103,01,00,00,01*25\r\n"   /* GLL disable */
        "$PSRF103,02,00,00,01*26\r\n"   /* GSA disable */
@@ -139,7 +137,7 @@ ao_gps_parse_pos(__xdata struct ao_gps_pos * pos, uint8_t deg_width) __reentrant
 }
 
 static void
-ao_gps_parse_flag(uint8_t yes_c, uint8_t yes, uint8_t no_c, uint8_t no) __reentrant
+ao_gps_parse_flag(char yes_c, uint8_t yes, char no_c, uint8_t no) __reentrant
 {
        ao_gps_skip_sep();
        if (ao_gps_char == yes_c)
@@ -155,7 +153,7 @@ ao_gps_parse_flag(uint8_t yes_c, uint8_t yes, uint8_t no_c, uint8_t no) __reentr
 void
 ao_gps(void) __reentrant
 {
-       uint8_t c;
+       char    c;
        uint8_t i;
 
        for (i = 0; (c = ao_gps_config[i]); i++)
@@ -240,23 +238,38 @@ ao_gps(void) __reentrant
                        ao_gps_skip_field();
                }
                if (ao_gps_char == '*') {
-                       c = ao_gps_cksum ^ '*';
-                       i = ao_gps_hex(2);
-                       if (c != i)
+                       uint8_t cksum = ao_gps_cksum ^ '*';
+                       if (cksum != ao_gps_hex(2))
                                ao_gps_error = 1;
                } else 
                        ao_gps_error = 1;
                if (!ao_gps_error) {
                        ao_mutex_get(&ao_gps_mutex);
-                       memcpy(&ao_gps_data, &ao_gps_next, sizeof (ao_gps_data));
+                       memcpy(&ao_gps_data, &ao_gps_next, sizeof (struct ao_gps_data));
                        ao_mutex_put(&ao_gps_mutex);
                        ao_wakeup(&ao_gps_data);
                }
        }
 }
 
+__xdata struct ao_task ao_gps_task;
+
+static void
+gps_dump(void) __reentrant
+{
+       ao_mutex_get(&ao_gps_mutex);
+       ao_gps_print(&ao_gps_data);
+       ao_mutex_put(&ao_gps_mutex);
+}
+
+__code struct ao_cmds ao_gps_cmds[] = {
+       { 'g', gps_dump,        "g                                  Display current GPS values" },
+       { 0, gps_dump, NULL },
+};
+
 void
 ao_gps_init(void)
 {
        ao_add_task(&ao_gps_task, ao_gps, "gps");
+       ao_cmd_register(&ao_gps_cmds[0]);
 }