projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Reduce flash temp buffer to make space for Em v1.0 ISR stack
[fw/altos]
/
src
/
drivers
/
ao_gps_ublox.c
diff --git
a/src/drivers/ao_gps_ublox.c
b/src/drivers/ao_gps_ublox.c
index 01169522f2ae49f53852098b8c2e9d797dc25a3f..89b1c4d2c2da20374b30e4bdc3a34f58db0c6af3 100644
(file)
--- a/
src/drivers/ao_gps_ublox.c
+++ b/
src/drivers/ao_gps_ublox.c
@@
-3,7
+3,8
@@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-25,11
+26,11
@@
#include <stdarg.h>
#include <stdarg.h>
-
__xdata
uint8_t ao_gps_new;
-
__xdata
uint8_t ao_gps_mutex;
-
__pdata
uint16_t ao_gps_tick;
-
__xdata
struct ao_telemetry_location ao_gps_data;
-
__xdata
struct ao_telemetry_satellite ao_gps_tracking_data;
+uint8_t ao_gps_new;
+uint8_t ao_gps_mutex;
+uint16_t ao_gps_tick;
+struct ao_telemetry_location ao_gps_data;
+struct ao_telemetry_satellite ao_gps_tracking_data;
#undef AO_SERIAL_SPEED_UBLOX
#undef AO_SERIAL_SPEED_UBLOX
@@
-57,8
+58,8
@@
struct ao_ublox_cksum {
uint8_t a, b;
};
uint8_t a, b;
};
-static
__pdata
struct ao_ublox_cksum ao_ublox_cksum;
-static
__pdata
uint16_t ao_ublox_len;
+static struct ao_ublox_cksum ao_ublox_cksum;
+static uint16_t ao_ublox_len;
#if AO_UBLOX_DEBUG
#if AO_UBLOX_DEBUG
@@
-151,11
+152,11
@@
static uint8_t data_byte(void)
return header_byte();
}
return header_byte();
}
-static char
__xdata
*ublox_target;
+static char *ublox_target;
static void ublox_u16(uint8_t offset)
{
static void ublox_u16(uint8_t offset)
{
- uint16_t
__xdata *ptr = (uint16_t __xdata
*) (ublox_target + offset);
+ uint16_t
*ptr = (uint16_t *) (void
*) (ublox_target + offset);
uint16_t val;
val = data_byte();
uint16_t val;
val = data_byte();
@@
-165,16
+166,16
@@
static void ublox_u16(uint8_t offset)
static void ublox_u8(uint8_t offset)
{
static void ublox_u8(uint8_t offset)
{
- uint8_t
__xdata *ptr = (uint8_t __xdata
*) (ublox_target + offset);
+ uint8_t
*ptr = (uint8_t
*) (ublox_target + offset);
uint8_t val;
val = data_byte ();
*ptr = val;
}
uint8_t val;
val = data_byte ();
*ptr = val;
}
-static void ublox_u32(uint8_t offset)
__reentrant
+static void ublox_u32(uint8_t offset)
{
{
- uint32_t
__xdata *ptr = (uint32_t __xdata
*) (ublox_target + offset);
+ uint32_t
*ptr = (uint32_t *) (void
*) (ublox_target + offset);
uint32_t val;
val = ((uint32_t) data_byte ());
uint32_t val;
val = ((uint32_t) data_byte ());
@@
-202,7
+203,7
@@
struct ublox_packet_parse {
};
static void
};
static void
-ao_ublox_parse(void
__xdata *target, const struct ublox_packet_parse *parse) __reentrant
+ao_ublox_parse(void
*target, const struct ublox_packet_parse *parse)
{
uint8_t i, offset;
{
uint8_t i, offset;
@@
-601,11
+602,21
@@
static const uint8_t ublox_enable_nav[] = {
};
void
};
void
-ao_gps(void) __reentrant
+ao_gps_set_rate(uint8_t rate)
+{
+ uint8_t i;
+ for (i = 0; i < sizeof (ublox_enable_nav); i++)
+ ao_ublox_set_message_rate(UBLOX_NAV, ublox_enable_nav[i], rate);
+}
+
+void
+ao_gps(void)
{
uint8_t class, id;
struct ao_ublox_cksum cksum;
uint8_t i;
{
uint8_t class, id;
struct ao_ublox_cksum cksum;
uint8_t i;
+ AO_TICK_TYPE packet_start_tick;
+ AO_TICK_TYPE solution_tick = 0;
ao_gps_setup();
ao_gps_setup();
@@
-616,8
+627,7
@@
ao_gps(void) __reentrant
ao_ublox_set_message_rate(UBLOX_NAV, ublox_disable_nav[i], 0);
/* Enable all of the messages we want */
ao_ublox_set_message_rate(UBLOX_NAV, ublox_disable_nav[i], 0);
/* Enable all of the messages we want */
- for (i = 0; i < sizeof (ublox_enable_nav); i++)
- ao_ublox_set_message_rate(UBLOX_NAV, ublox_enable_nav[i], 1);
+ ao_gps_set_rate(1);
ao_ublox_set_navigation_settings((1 << UBLOX_CFG_NAV5_MASK_DYN) | (1 << UBLOX_CFG_NAV5_MASK_FIXMODE),
UBLOX_CFG_NAV5_DYNMODEL_AIRBORNE_4G,
ao_ublox_set_navigation_settings((1 << UBLOX_CFG_NAV5_MASK_DYN) | (1 << UBLOX_CFG_NAV5_MASK_FIXMODE),
UBLOX_CFG_NAV5_DYNMODEL_AIRBORNE_4G,
@@
-637,6
+647,8
@@
ao_gps(void) __reentrant
/* Locate the begining of the next record */
while (ao_ublox_byte() != (uint8_t) 0xb5)
;
/* Locate the begining of the next record */
while (ao_ublox_byte() != (uint8_t) 0xb5)
;
+ packet_start_tick = ao_tick_count;
+
if (ao_ublox_byte() != (uint8_t) 0x62)
continue;
if (ao_ublox_byte() != (uint8_t) 0x62)
continue;
@@
-649,7
+661,7
@@
ao_gps(void) __reentrant
ao_ublox_len = header_byte();
ao_ublox_len |= header_byte() << 8;
ao_ublox_len = header_byte();
ao_ublox_len |= header_byte() << 8;
- ao_gps_dbg(DBG_PROTO, "
class %02x id %02x len %d\n"
, class, id, ao_ublox_len);
+ ao_gps_dbg(DBG_PROTO, "
%6u class %02x id %02x len %d\n", packet_start_tick
, class, id, ao_ublox_len);
if (ao_ublox_len > 1023)
continue;
if (ao_ublox_len > 1023)
continue;
@@
-671,6
+683,7
@@
ao_gps(void) __reentrant
if (ao_ublox_len != 52)
break;
ao_ublox_parse_nav_sol();
if (ao_ublox_len != 52)
break;
ao_ublox_parse_nav_sol();
+ solution_tick = packet_start_tick;
break;
case UBLOX_NAV_SVINFO:
if (ao_ublox_len < 8)
break;
case UBLOX_NAV_SVINFO:
if (ao_ublox_len < 8)
@@
-707,13
+720,13
@@
ao_gps(void) __reentrant
switch (id) {
case UBLOX_NAV_TIMEUTC:
ao_mutex_get(&ao_gps_mutex);
switch (id) {
case UBLOX_NAV_TIMEUTC:
ao_mutex_get(&ao_gps_mutex);
- ao_gps_tick =
ao_time()
;
+ ao_gps_tick =
solution_tick
;
ao_gps_data.flags = 0;
ao_gps_data.flags |= AO_GPS_RUNNING;
if (nav_sol.gps_fix & (1 << NAV_SOL_FLAGS_GPSFIXOK)) {
uint8_t nsat = nav_sol.nsat;
ao_gps_data.flags = 0;
ao_gps_data.flags |= AO_GPS_RUNNING;
if (nav_sol.gps_fix & (1 << NAV_SOL_FLAGS_GPSFIXOK)) {
uint8_t nsat = nav_sol.nsat;
- ao_gps_data.flags |= AO_GPS_VALID;
+ ao_gps_data.flags |= AO_GPS_VALID
| AO_GPS_COURSE_VALID
;
if (nsat > 15)
nsat = 15;
ao_gps_data.flags |= nsat;
if (nsat > 15)
nsat = 15;
ao_gps_data.flags |= nsat;
@@
-721,7
+734,7
@@
ao_gps(void) __reentrant
if (nav_timeutc.valid & (1 << NAV_TIMEUTC_VALID_UTC))
ao_gps_data.flags |= AO_GPS_DATE_VALID;
if (nav_timeutc.valid & (1 << NAV_TIMEUTC_VALID_UTC))
ao_gps_data.flags |= AO_GPS_DATE_VALID;
-
ao_gps_data.altitude = nav_posllh.alt_msl / 1000
;
+
AO_TELEMETRY_LOCATION_SET_ALTITUDE(&ao_gps_data, nav_posllh.alt_msl / 1000)
;
ao_gps_data.latitude = nav_posllh.lat;
ao_gps_data.longitude = nav_posllh.lon;
ao_gps_data.latitude = nav_posllh.lat;
ao_gps_data.longitude = nav_posllh.lon;
@@
-733,11
+746,11
@@
ao_gps(void) __reentrant
ao_gps_data.minute = nav_timeutc.min;
ao_gps_data.second = nav_timeutc.sec;
ao_gps_data.minute = nav_timeutc.min;
ao_gps_data.second = nav_timeutc.sec;
- ao_gps_data.pdop = nav_dop.pdop;
- ao_gps_data.hdop = nav_dop.hdop;
- ao_gps_data.
vdop = nav_dop.vdop
;
-
- /* mode is not set */
+ /* we report dop scaled by 10, but ublox provides dop scaled by 100
+ */
+ ao_gps_data.
pdop = nav_dop.pdop / 10
;
+ ao_gps_data.hdop = nav_dop.hdop / 10;
+ ao_gps_data.vdop = nav_dop.vdop / 10;
ao_gps_data.ground_speed = nav_velned.g_speed;
ao_gps_data.climb_rate = -nav_velned.vel_d;
ao_gps_data.ground_speed = nav_velned.g_speed;
ao_gps_data.climb_rate = -nav_velned.vel_d;
@@
-775,12
+788,12
@@
ao_gps(void) __reentrant
#if AO_UBLOX_DEBUG
static void ao_gps_option(void)
{
#if AO_UBLOX_DEBUG
static void ao_gps_option(void)
{
- ao_cmd_hex();
+
uint16_t r =
ao_cmd_hex();
if (ao_cmd_status != ao_cmd_success) {
ao_cmd_status = ao_cmd_success;
ao_gps_show();
} else {
if (ao_cmd_status != ao_cmd_success) {
ao_cmd_status = ao_cmd_success;
ao_gps_show();
} else {
- ao_gps_dbg_enable =
ao_cmd_lex_i
;
+ ao_gps_dbg_enable =
r
;
printf ("gps debug set to %d\n", ao_gps_dbg_enable);
}
}
printf ("gps debug set to %d\n", ao_gps_dbg_enable);
}
}
@@
-788,12
+801,12
@@
static void ao_gps_option(void)
#define ao_gps_option ao_gps_show
#endif
#define ao_gps_option ao_gps_show
#endif
-
__code
struct ao_cmds ao_gps_cmds[] = {
+
const
struct ao_cmds ao_gps_cmds[] = {
{ ao_gps_option, "g\0Display GPS" },
{ 0, NULL },
};
{ ao_gps_option, "g\0Display GPS" },
{ 0, NULL },
};
-
__xdata
struct ao_task ao_gps_task;
+struct ao_task ao_gps_task;
void
ao_gps_init(void)
void
ao_gps_init(void)