mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-26 16:30:07 +08:00
gps: uint32_t for last_fix_time, and read sys_time.nb_sec instead of old cpu_time_sec
This commit is contained in:
@@ -81,7 +81,7 @@ struct GpsState {
|
||||
struct SVinfo svinfos[GPS_NB_CHANNELS]; ///< holds information from the Space Vehicles (Satellites)
|
||||
|
||||
uint32_t last_fix_ticks; ///< cpu time in ticks at last valid fix
|
||||
uint16_t last_fix_time; ///< cpu time in sec at last valid fix
|
||||
uint32_t last_fix_time; ///< cpu time in sec at last valid fix
|
||||
uint16_t reset; ///< hotstart, warmstart, coldstart
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ extern void gps_impl_init(void);
|
||||
#ifndef GPS_TIMEOUT
|
||||
#define GPS_TIMEOUT 5
|
||||
#endif
|
||||
#define GpsIsLost() (cpu_time_sec - gps.last_fix_time > GPS_TIMEOUT)
|
||||
#define GpsIsLost() (sys_time.nb_sec - gps.last_fix_time > GPS_TIMEOUT)
|
||||
|
||||
|
||||
//TODO
|
||||
|
||||
@@ -144,7 +144,7 @@ void gps_mtk_read_message(void) {
|
||||
gps.lla_pos.lat = RadOfDeg(MTK_DIY14_NAV_LAT(gps_mtk.msg_buf))*10;
|
||||
gps.lla_pos.lon = RadOfDeg(MTK_DIY14_NAV_LON(gps_mtk.msg_buf))*10;
|
||||
// FIXME: with MTK you do not receive vertical speed
|
||||
if (cpu_time_sec - gps.last_fix_time < 2) {
|
||||
if (sys_time.nb_sec - gps.last_fix_time < 2) {
|
||||
gps.ned_vel.z = ((gps.hmsl -
|
||||
MTK_DIY14_NAV_HEIGHT(gps_mtk.msg_buf)*10)*OUTPUT_RATE)/10;
|
||||
} else gps.ned_vel.z = 0;
|
||||
@@ -208,7 +208,7 @@ void gps_mtk_read_message(void) {
|
||||
gps.lla_pos.lat = RadOfDeg(MTK_DIY16_NAV_LAT(gps_mtk.msg_buf))*10;
|
||||
gps.lla_pos.lon = RadOfDeg(MTK_DIY16_NAV_LON(gps_mtk.msg_buf))*10;
|
||||
// FIXME: with MTK you do not receive vertical speed
|
||||
if (cpu_time_sec - gps.last_fix_time < 2) {
|
||||
if (sys_time.nb_sec - gps.last_fix_time < 2) {
|
||||
gps.ned_vel.z = ((gps.hmsl -
|
||||
MTK_DIY16_NAV_HEIGHT(gps_mtk.msg_buf)*10)*OUTPUT_RATE)/10;
|
||||
} else gps.ned_vel.z = 0;
|
||||
|
||||
@@ -80,15 +80,15 @@ extern bool_t gps_configuring;
|
||||
if (gps_mtk.msg_class == MTK_DIY14_ID && \
|
||||
gps_mtk.msg_id == MTK_DIY14_NAV_ID) { \
|
||||
if (gps.fix == GPS_FIX_3D) { \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
gps.last_fix_time = sys_time.nb_sec; \
|
||||
} \
|
||||
_sol_available_callback(); \
|
||||
} \
|
||||
if (gps_mtk.msg_class == MTK_DIY16_ID && \
|
||||
gps_mtk.msg_id == MTK_DIY16_NAV_ID) { \
|
||||
if (gps.fix == GPS_FIX_3D) { \
|
||||
gps.last_fix_ticks = cpu_time_ticks; \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
gps.last_fix_ticks = sys_time.nb_sec_rem; \
|
||||
gps.last_fix_time = sys_time.nb_sec; \
|
||||
} \
|
||||
_sol_available_callback(); \
|
||||
} \
|
||||
|
||||
@@ -70,7 +70,7 @@ extern struct GpsNmea gps_nmea;
|
||||
if (gps_nmea.pos_available) { \
|
||||
if (gps.fix == GPS_FIX_3D) { \
|
||||
gps.last_fix_ticks = cpu_time_ticks; \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
gps.last_fix_time = sys_time.nb_sec; \
|
||||
} \
|
||||
_sol_available_callback(); \
|
||||
} \
|
||||
|
||||
@@ -14,7 +14,7 @@ extern void gps_impl_init(void);
|
||||
#define GpsEvent(_sol_available_callback) { \
|
||||
if (gps_available) { \
|
||||
if (gps.fix == GPS_FIX_3D) { \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
gps.last_fix_time = sys_time.nb_sec; \
|
||||
} \
|
||||
_sol_available_callback(); \
|
||||
gps_available = FALSE; \
|
||||
|
||||
@@ -14,7 +14,7 @@ extern void gps_impl_init();
|
||||
#define GpsEvent(_sol_available_callback) { \
|
||||
if (gps_available) { \
|
||||
if (gps.fix == GPS_FIX_3D) \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
gps.last_fix_time = sys_time_.nb_sec; \
|
||||
_sol_available_callback(); \
|
||||
gps_available = FALSE; \
|
||||
} \
|
||||
|
||||
@@ -95,9 +95,10 @@ extern struct GpsSkytraq gps_skytraq;
|
||||
if (gps_skytraq.msg_available) { \
|
||||
gps_skytraq_read_message(); \
|
||||
if (gps_skytraq.msg_id == SKYTRAQ_ID_NAVIGATION_DATA) { \
|
||||
if (gps.fix == GPS_FIX_3D) \
|
||||
gps.last_fix_ticks = cpu_time_ticks; \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
if (gps.fix == GPS_FIX_3D) { \
|
||||
gps.last_fix_ticks = sys_time.nb_sec_rem; \
|
||||
gps.last_fix_time = sys_time.nb_sec; \
|
||||
} \
|
||||
_sol_available_callback(); \
|
||||
} \
|
||||
gps_skytraq.msg_available = FALSE; \
|
||||
|
||||
@@ -91,8 +91,8 @@ extern struct GpsUbx gps_ubx;
|
||||
(gps_ubx.msg_id == UBX_NAV_SOL_ID && \
|
||||
gps_ubx.have_velned == 0))) { \
|
||||
if (gps.fix == GPS_FIX_3D) { \
|
||||
gps.last_fix_ticks = cpu_time_ticks; \
|
||||
gps.last_fix_time = cpu_time_sec; \
|
||||
gps.last_fix_ticks = sys_time.nb_sec_rem; \
|
||||
gps.last_fix_time = sys_time.nb_sec; \
|
||||
} \
|
||||
_sol_available_callback(); \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user