Skip to content

Commit

Permalink
[gps] call gps_periodic_check from module
Browse files Browse the repository at this point in the history
  • Loading branch information
flixr committed Jun 15, 2016
1 parent 2374f82 commit 6cc4d59
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion conf/modules/gps_furuno.xml
Expand Up @@ -14,7 +14,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_nmea_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_nmea.state)" freq="1." autorun="TRUE"/>
<event fun="gps_nmea_event()"/>
<makefile target="ap">
<configure name="FURUNO_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_mediatek_diy.xml
Expand Up @@ -14,7 +14,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_mtk_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_mtk.state)" freq="1." autorun="TRUE"/>
<event fun="gps_mtk_event()"/>
<makefile target="ap">
<configure name="MTK_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_nmea.xml
Expand Up @@ -14,7 +14,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_nmea_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_nmea.state)" freq="1." autorun="TRUE"/>
<event fun="gps_nmea_event()"/>
<makefile target="ap">
<configure name="NMEA_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_nps.xml
Expand Up @@ -12,7 +12,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_nps_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_nps)" freq="1." autorun="TRUE"/>
<makefile target="nps">
<file name="gps.c" dir="subsystems"/>
<file name="gps_sim_nps.c" dir="subsystems/gps"/>
Expand Down
3 changes: 1 addition & 2 deletions conf/modules/gps_piksi.xml
Expand Up @@ -13,9 +13,8 @@
<header>
<file name="gps.h" dir="subsystems"/>
</header>
<!-- uncomment these when not called explicitly from main anymore -->
<init fun="gps_piksi_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_piksi)" freq="1." autorun="TRUE"/>
<event fun="gps_piksi_event()"/>
<makefile target="ap">
<configure name="PIKSI_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_sim.xml
Expand Up @@ -11,7 +11,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_sim_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps)" freq="1." autorun="TRUE"/>
<makefile target="sim">
<file name="gps.c" dir="subsystems"/>
<file name="gps_sim.c" dir="subsystems/gps"/>
Expand Down
1 change: 0 additions & 1 deletion conf/modules/gps_sim_hitl.xml
Expand Up @@ -12,7 +12,6 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_sim_hitl_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<event fun="gps_sim_hitl_event()"/>
<makefile target="ap" firmware="rotorcraft">
<configure name="GPS_LED" default="none"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_sirf.xml
Expand Up @@ -14,7 +14,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_sirf_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_sirf.state)" freq="1." autorun="TRUE"/>
<event fun="gps_sirf_event()"/>
<makefile target="ap">
<configure name="SIRF_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_skytraq.xml
Expand Up @@ -14,7 +14,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_skytraq_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_skytraq.state)" freq="1." autorun="TRUE"/>
<event fun="gps_skytraq_event()"/>
<makefile target="ap">
<configure name="SKYTRAQ_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
3 changes: 1 addition & 2 deletions conf/modules/gps_ublox.xml
Expand Up @@ -13,9 +13,8 @@
<header>
<file name="gps.h" dir="subsystems"/>
</header>
<!-- uncomment these when not called explicitly from main anymore -->
<init fun="gps_ubx_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_ubx.state)" freq="1." autorun="TRUE"/>
<event fun="gps_ubx_event()"/>
<makefile target="ap">
<configure name="UBX_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_udp.xml
Expand Up @@ -13,7 +13,7 @@
<file name="gps.h" dir="subsystems"/>
</header>
<init fun="gps_udp_init()"/>
<!--periodic fun="gps_periodic_check()" freq="1." autorun="TRUE"/-->
<periodic fun="gps_periodic_check(&gps_udp)" freq="1." autorun="TRUE"/>
<makefile target="ap">
<configure name="GPS_LED" default="none"/>

Expand Down
4 changes: 0 additions & 4 deletions sw/airborne/firmwares/fixedwing/main_ap.c
Expand Up @@ -638,10 +638,6 @@ void sensors_task(void)
update_ahrs_from_sim();
#endif

#if USE_GPS
gps_periodic_check();
#endif

//FIXME: temporary hack, remove me
#ifdef InsPeriodic
InsPeriodic();
Expand Down
1 change: 0 additions & 1 deletion sw/airborne/firmwares/rotorcraft/main.c
Expand Up @@ -340,7 +340,6 @@ STATIC_INLINE void failsafe_check(void)
#endif

#if USE_GPS
gps_periodic_check();
if (autopilot_mode == AP_MODE_NAV &&
autopilot_motors_on &&
#if NO_GPS_LOST_WITH_RC_VALID
Expand Down
6 changes: 3 additions & 3 deletions sw/airborne/subsystems/gps.c
Expand Up @@ -160,10 +160,10 @@ static void send_gps_sol(struct transport_tx *trans, struct link_device *dev)
}
#endif

void gps_periodic_check(void)
void gps_periodic_check(struct GpsState *gps_s)
{
if (sys_time.nb_sec - gps.last_msg_time > GPS_TIMEOUT) {
gps.fix = GPS_FIX_NONE;
if (sys_time.nb_sec - gps_s->last_msg_time > GPS_TIMEOUT) {
gps_s->fix = GPS_FIX_NONE;
}
}

Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/subsystems/gps.h
Expand Up @@ -151,7 +151,7 @@ static inline bool gps_has_been_good(void)
/** Periodic GPS check.
* Marks GPS as lost when no GPS message was received for GPS_TIMEOUT seconds
*/
extern void gps_periodic_check(void);
extern void gps_periodic_check(struct GpsState *gps_s);

/**
* GPS Reset
Expand Down
2 changes: 2 additions & 0 deletions sw/airborne/subsystems/gps/gps_piksi.h
Expand Up @@ -36,6 +36,8 @@
#define PRIMARY_GPS GPS_PIKSI
#endif

extern struct GpsState gps_piksi;

extern void gps_piksi_event(void);
extern void gps_piksi_init(void);

Expand Down
1 change: 1 addition & 0 deletions sw/airborne/subsystems/gps/gps_sim_nps.h
Expand Up @@ -7,6 +7,7 @@
#define PRIMARY_GPS GPS_SIM
#endif

extern struct GpsState gps_nps;
extern bool gps_has_fix;

extern void gps_feed_value();
Expand Down
2 changes: 2 additions & 0 deletions sw/airborne/subsystems/gps/gps_udp.c
Expand Up @@ -37,6 +37,8 @@
unsigned char gps_udp_read_buffer[256];
struct FmsNetwork *gps_network = NULL;

struct GpsState gps_udp;

void gps_udp_init(void)
{
gps_udp.fix = GPS_FIX_NONE;
Expand Down

0 comments on commit 6cc4d59

Please sign in to comment.