#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 */
}
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)
void
ao_gps(void) __reentrant
{
- uint8_t c;
+ char c;
uint8_t i;
for (i = 0; (c = ao_gps_config[i]); i++)
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;
}
}
-void
-ao_gps_report(void)
-{
- static __xdata struct ao_log_record gps_log;
- static __xdata struct ao_telemetry gps_telemetry;
- static __xdata struct ao_gps_data gps_data;
-
- for (;;) {
- ao_sleep(&ao_gps_data);
- ao_mutex_get(&ao_gps_mutex);
- memcpy(&gps_data, &ao_gps_data, sizeof (struct ao_gps_data));
- ao_mutex_put(&ao_gps_mutex);
-
- gps_log.tick = ao_time();
- gps_log.type = AO_LOG_GPS_TIME;
- gps_log.u.gps_time.hour = gps_data.hour;
- gps_log.u.gps_time.minute = gps_data.minute;
- gps_log.u.gps_time.second = gps_data.second;
- gps_log.u.gps_time.flags = gps_data.flags;
- ao_log_data(&gps_log);
- gps_log.type = AO_LOG_GPS_LAT;
- gps_log.u.gps_latitude.degrees = gps_data.latitude.degrees;
- gps_log.u.gps_latitude.minutes = gps_data.latitude.minutes;
- gps_log.u.gps_latitude.minutes_fraction = gps_data.latitude.minutes_fraction;
- ao_log_data(&gps_log);
- gps_log.type = AO_LOG_GPS_LON;
- gps_log.u.gps_longitude.degrees = gps_data.longitude.degrees;
- gps_log.u.gps_longitude.minutes = gps_data.longitude.minutes;
- gps_log.u.gps_longitude.minutes_fraction = gps_data.longitude.minutes_fraction;
- ao_log_data(&gps_log);
- gps_log.type = AO_LOG_GPS_ALT;
- gps_log.u.gps_altitude.altitude = gps_data.altitude;
- gps_log.u.gps_altitude.unused = 0xffff;
- ao_log_data(&gps_log);
- gps_telemetry.type = AO_TELEMETRY_GPS;
- memcpy(&gps_telemetry.u.gps, &gps_data, sizeof (struct ao_gps_data));
- ao_telemetry_send(&gps_telemetry);
- }
-
-}
-
__xdata struct ao_task ao_gps_task;
-__xdata struct ao_task ao_gps_report_task;
static void
gps_dump(void) __reentrant
}
__code struct ao_cmds ao_gps_cmds[] = {
- { 'g', gps_dump, "g Display current GPS values\n" },
+ { 'g', gps_dump, "g Display current GPS values" },
{ 0, gps_dump, NULL },
};
ao_gps_init(void)
{
ao_add_task(&ao_gps_task, ao_gps, "gps");
- ao_add_task(&ao_gps_report_task, ao_gps_report, "gps_report");
ao_cmd_register(&ao_gps_cmds[0]);
}