44 #include "generated/settings.h"
49 #error "PRIMARY_GPS not set!"
55 PRINT_CONFIG_VAR(SECONDARY_GPS)
59 #define __GpsId(_x) _x ## _ID
60 #define _GpsId(_x) __GpsId(_x)
61 #define GpsId(_x) _GpsId(_x)
67 #ifndef GPS_POWER_GPIO_ON
68 #define GPS_POWER_GPIO_ON gpio_set
72 #define MSEC_PER_WEEK (1000*60*60*24*7)
73 #define TIME_TO_SWITCH 5000 //ten s in ms
88 #if PERIODIC_TELEMETRY
95 pprz_msg_send_SVINFO(trans, dev, AC_ID, &svid,
131 static void send_gps(
struct transport_tx *trans,
struct link_device *
dev)
137 #if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
139 struct pprzlink_msg msg;
142 msg.sender_id = AC_ID;
143 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
144 msg.component_id = 0;
145 pprzlink_msg_send_GPS(&msg,
147 pprz_msg_send_GPS(trans, dev, AC_ID,
159 pprz_msg_send_GPS_RTK(trans, dev, AC_ID,
173 pprz_msg_send_GPS_RXMRTCM(trans, dev, AC_ID,
184 #if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
186 struct pprzlink_msg msg;
189 msg.sender_id = AC_ID;
190 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
191 msg.component_id = 0;
192 pprzlink_msg_send_GPS_INT(&msg,
194 pprz_msg_send_GPS_INT(trans, dev, AC_ID,
215 #if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
217 struct pprzlink_msg msg;
220 msg.sender_id = AC_ID;
221 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
222 msg.component_id = 0;
223 pprzlink_msg_send_GPS_LLA(&msg,
225 pprz_msg_send_GPS_LLA(trans, dev, AC_ID,
242 static uint32_t time_since_last_gps_switch = 0;
247 return GpsId(SECONDARY_GPS);
256 current_gps_id = gps_s->
comp_id;
265 return current_gps_id;
277 current_gps_id = gps_multi_switch(gps_s);
278 if (gps_s->
comp_id == current_gps_id) {
289 uint32_t stamp __attribute__((unused)),
298 current_gps_id = gps_multi_switch(gps_s);
299 if (gps_s->
comp_id == current_gps_id) {
330 #ifdef GPS_POWER_GPIO
340 #if PERIODIC_TELEMETRY
410 utm.
alt = gps_s->hmsl/1000.;
433 utm.
alt = gps_s->hmsl;
uint8_t qi
quality bitfield (GPS receiver specific)
static void send_gps_int(struct transport_tx *trans, struct link_device *dev)
Event structure to store callbacks in a linked list.
uint32_t t0_tow
GPS time of week in ms from last message.
int32_t north
in centimeters
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
int16_t azim
azimuth in deg
uint32_t pacc
position accuracy in cm
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
static void send_svinfo_id(struct transport_tx *trans, struct link_device *dev, uint8_t svid)
uint8_t nb_channels
Number of scanned satellites.
uint32_t t0_ticks
hw clock ticks when GPS message is received
Periodic telemetry system header (includes downlink utility and generated code).
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
Some architecture independent helper functions for GPIOs.
static uint32_t msec_of_sys_time_ticks(uint32_t ticks)
Main include for ABI (AirBorneInterface).
static void send_gps_sol(struct transport_tx *trans, struct link_device *dev)
static void send_gps(struct transport_tx *trans, struct link_device *dev)
#define UTM_FLOAT_OF_BFP(_o, _i)
position in UTM coordinates Units: meters
int32_t east
in centimeters
uint8_t svid
Satellite ID.
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
#define GPS_FIX_3D
3D GPS fix
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
int8_t elev
elevation in deg
int32_t alt
in millimeters above WGS84 reference ellipsoid
uint32_t sacc
speed accuracy in cm/s
uint32_t last_msg_time
cpu time in sec at last received GPS message
uint32_t cacc
course accuracy in rad*1e7
uint8_t zone
UTM zone number.
struct UtmCoor_i utm_int_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience function to get utm position in int from GPS structure.
static void send_svinfo_available(struct transport_tx *trans, struct link_device *dev)
send SVINFO message if updated.
int32_t hmsl
height above mean sea level (MSL) in mm
void WEAK gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
Default parser for GPS injected data.
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
data structure for GPS information
static void send_gps_lla(struct transport_tx *trans, struct link_device *dev)
uint32_t tow
GPS time of week in ms.
#define GPS_FIX_NONE
No GPS fix.
Device independent GPS code (interface)
uint16_t pdop
position dilution of precision scaled by 100
static void send_gps_rxmrtcm(struct transport_tx *trans, struct link_device *dev)
struct EcefCoor_i ecef_pos
position in ECEF in cm
#define GPS_VALID_HMSL_BIT
#define DefaultPeriodic
Set default periodic telemetry.
int32_t lon
in degrees*1e7
void utm_of_lla_i(struct UtmCoor_i *utm, struct LlaCoor_i *lla)
Convert a LLA to UTM.
uint8_t zone
UTM zone number.
struct GpsRelposNED gps_relposned
static const struct usb_device_descriptor dev
static void send_gps_rtk(struct transport_tx *trans, struct link_device *dev)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
int32_t alt
in millimeters (above WGS84 reference ellipsoid or above MSL)
Paparazzi generic macros for geodetic calculations.
static void send_svinfo(struct transport_tx *trans, struct link_device *dev)
send SVINFO message (regardless of state)
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience functions to get utm position from GPS state.
API to get/set the generic vehicle states.
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Persistent settings interface.
uint8_t comp_id
id of current gps
volatile uint32_t nb_sec
full seconds since startup
#define GPS_MODE_SECONDARY
data structures for GPS with RTK capabilities
uint8_t flags
bitfield with GPS receiver specific flags
struct GpsTimeSync gps_time_sync
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
#define GPS_VALID_POS_LLA_BIT
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
uint8_t num_sv
number of sat in fix
arch independent LED (Light Emitting Diodes) API
#define ABI_BROADCAST
Broadcast address.
uint16_t gspeed
norm of 2d ground speed in cm/s
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
data structure for GPS time sync
#define GPS_TIMEOUT
GPS timeout in seconds.
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
int32_t lat
in degrees*1e7
#define GPS_VALID_POS_UTM_BIT
struct NedCoor_i ned_vel
speed NED in cm/s
struct GpsState gps
global GPS state
void gps_init(void)
initialize the global GPS state
static int32_t wgs84_ellipsoid_to_geoid_i(int32_t lat, int32_t lon)
Get WGS84 ellipsoid/geoid separation.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void gps_periodic_check(struct GpsState *gps_s)
Periodic GPS check.
position in UTM coordinates
#define UTM_COPY(_u1, _u2)