Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
gps_piksi.c File Reference

Driver for Piksi modules from Swift-Nav. More...

#include "modules/gps/gps_piksi.h"
#include "modules/gps/gps.h"
#include "modules/core/abi.h"
#include "mcu_periph/uart.h"
#include "math/pprz_geodetic_double.h"
#include "generated/flight_plan.h"
#include <libsbp/sbp.h>
#include <libsbp/navigation.h>
#include <libsbp/observation.h>
#include <libsbp/tracking.h>
#include <libsbp/system.h>
#include <libsbp/settings.h>
#include <libsbp/piksi.h>
#include "modules/datalink/telemetry.h"
+ Include dependency graph for gps_piksi.c:

Go to the source code of this file.

Macros

#define SBP_FIX_MODE_SPP   0X00
 
#define SBP_FIX_MODE_FLOAT   0X02
 
#define SPB_FIX_MODE_FIXED   0X01
 
#define POS_ECEF_TIMEOUT   1000
 

Functions

static void send_piksi_heartbeat (struct transport_tx *trans, struct link_device *dev)
 
static void gps_piksi_publish (void)
 
static uint8_t get_fix_mode (uint8_t flags)
 
uint32_t gps_piksi_read (uint8_t *buff, uint32_t n, void *context)
 
uint32_t gps_piksi_write (uint8_t *buff, uint32_t n, void *context)
 
static void sbp_pos_ecef_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_vel_ecef_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_pos_llh_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_vel_ned_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_dops_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_gps_time_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_tracking_state_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void sbp_tracking_state_dep_a_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
static void spb_heartbeat_callback (uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
 
void gps_piksi_init (void)
 
void gps_piksi_event (void)
 
void gps_inject_data (uint8_t packet_id, uint8_t length, uint8_t *data)
 Override the default GPS packet injector to inject the data trough UART. More...
 

Variables

struct GpsState gps_piksi
 
struct GpsTimeSync gps_piksi_time_sync
 
static uint32_t time_since_last_heartbeat
 
static const char SBP_ANT_SET [] = "frontend""\x00""antenna_selection""\x00""Patch"
 
static const char SBP_UART_SET1 [] = "uart_uartb""\x00""mode""\x00""SBP"
 
static const char SBP_UART_SET2 [] = "uart_uartb""\x00""sbp_message_mask""\x00""784"
 
static const char SBP_UART_SET3 [] = "uart_uartb""\x00""configure_telemetry_radio_on_boot""\x00""False"
 
sbp_state_t sbp_state
 
sbp_msg_callbacks_node_t pos_ecef_node
 
sbp_msg_callbacks_node_t vel_ecef_node
 
sbp_msg_callbacks_node_t pos_llh_node
 
sbp_msg_callbacks_node_t vel_ned_node
 
sbp_msg_callbacks_node_t dops_node
 
sbp_msg_callbacks_node_t gps_time_node
 
sbp_msg_callbacks_node_t tracking_state_node
 
sbp_msg_callbacks_node_t tracking_state_dep_a_node
 
sbp_msg_callbacks_node_t heartbeat_node
 
static uint32_t time_since_last_pos_update
 

Detailed Description

Macro Definition Documentation

◆ POS_ECEF_TIMEOUT

#define POS_ECEF_TIMEOUT   1000

Definition at line 54 of file gps_piksi.c.

◆ SBP_FIX_MODE_FLOAT

#define SBP_FIX_MODE_FLOAT   0X02

Definition at line 51 of file gps_piksi.c.

◆ SBP_FIX_MODE_SPP

#define SBP_FIX_MODE_SPP   0X00

Definition at line 50 of file gps_piksi.c.

◆ SPB_FIX_MODE_FIXED

#define SPB_FIX_MODE_FIXED   0X01

Definition at line 52 of file gps_piksi.c.

Function Documentation

◆ get_fix_mode()

static uint8_t get_fix_mode ( uint8_t  flags)
static

Definition at line 283 of file gps_piksi.c.

References GpsState::fix, gps, GPS_FIX_3D, GPS_FIX_DGPS, GPS_FIX_NONE, GPS_FIX_RTK, SBP_FIX_MODE_FLOAT, SBP_FIX_MODE_SPP, and SPB_FIX_MODE_FIXED.

Referenced by sbp_pos_ecef_callback().

+ Here is the caller graph for this function:

◆ gps_inject_data()

void gps_inject_data ( uint8_t  packet_id,
uint8_t  length,
uint8_t data 
)

Override the default GPS packet injector to inject the data trough UART.

GPS packet injection (default empty)

Definition at line 408 of file gps_piksi.c.

References gps_piksi_write(), and sbp_state.

+ Here is the call graph for this function:

◆ gps_piksi_event()

void gps_piksi_event ( void  )

Definition at line 349 of file gps_piksi.c.

References GpsState::fix, get_sys_time_msec(), GPS_FIX_NONE, gps_piksi, gps_piksi_read(), POS_ECEF_TIMEOUT, sbp_state, time_since_last_pos_update, and uart_char_available().

+ Here is the call graph for this function:

◆ gps_piksi_init()

◆ gps_piksi_publish()

static void gps_piksi_publish ( void  )
static

Definition at line 362 of file gps_piksi.c.

References GpsState::fix, get_sys_time_usec(), GPS_FIX_3D, gps_piksi, GPS_PIKSI_ID, GpsState::last_3dfix_ticks, GpsState::last_3dfix_time, GpsState::last_msg_ticks, GpsState::last_msg_time, sys_time::nb_sec, and sys_time::nb_sec_rem.

Referenced by sbp_pos_ecef_callback(), and sbp_vel_ecef_callback().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gps_piksi_read()

uint32_t gps_piksi_read ( uint8_t buff,
uint32_t  n,
void *  context 
)

Definition at line 380 of file gps_piksi.c.

References buff, uart_char_available(), and uart_getch().

Referenced by gps_piksi_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gps_piksi_write()

uint32_t gps_piksi_write ( uint8_t buff,
uint32_t  n,
void *  context 
)

Definition at line 396 of file gps_piksi.c.

References buff, and uart_put_byte().

Referenced by gps_inject_data(), and gps_piksi_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sbp_dops_callback()

static void sbp_dops_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 221 of file gps_piksi.c.

References gps_piksi, msg, and GpsState::pdop.

Referenced by gps_piksi_init().

+ Here is the caller graph for this function:

◆ sbp_gps_time_callback()

static void sbp_gps_time_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 230 of file gps_piksi.c.

References gps_piksi, msg, GpsState::tow, and GpsState::week.

Referenced by gps_piksi_init().

+ Here is the caller graph for this function:

◆ sbp_pos_ecef_callback()

static void sbp_pos_ecef_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

◆ sbp_pos_llh_callback()

static void sbp_pos_llh_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 173 of file gps_piksi.c.

References LlaCoor_i::alt, gps_piksi, GPS_VALID_HMSL_BIT, GPS_VALID_POS_LLA_BIT, GpsState::hmsl, LlaCoor_i::lat, GpsState::lla_pos, LlaCoor_i::lon, msg, and GpsState::valid_fields.

Referenced by gps_piksi_init().

+ Here is the caller graph for this function:

◆ sbp_tracking_state_callback()

static void sbp_tracking_state_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 240 of file gps_piksi.c.

References SVinfo::cno, gps_piksi, msg, SVinfo::svid, and GpsState::svinfos.

Referenced by gps_piksi_init().

+ Here is the caller graph for this function:

◆ sbp_tracking_state_dep_a_callback()

static void sbp_tracking_state_dep_a_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 256 of file gps_piksi.c.

References SVinfo::cno, gps_piksi, msg, SVinfo::svid, and GpsState::svinfos.

Referenced by gps_piksi_init().

+ Here is the caller graph for this function:

◆ sbp_vel_ecef_callback()

static void sbp_vel_ecef_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 157 of file gps_piksi.c.

References GpsState::ecef_vel, gps_piksi, gps_piksi_publish(), GPS_VALID_VEL_ECEF_BIT, msg, GpsState::sacc, GpsState::valid_fields, EcefCoor_i::x, EcefCoor_i::y, and EcefCoor_i::z.

Referenced by gps_piksi_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sbp_vel_ned_callback()

static void sbp_vel_ned_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 205 of file gps_piksi.c.

References GpsState::course, gps_piksi, GPS_VALID_COURSE_BIT, GPS_VALID_VEL_NED_BIT, GpsState::gspeed, int32_sqrt(), msg, GpsState::ned_vel, GpsState::valid_fields, NedCoor_i::x, NedCoor_i::y, and NedCoor_i::z.

Referenced by gps_piksi_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_piksi_heartbeat()

static void send_piksi_heartbeat ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 67 of file gps_piksi.c.

References dev, and time_since_last_heartbeat.

Referenced by gps_piksi_init().

+ Here is the caller graph for this function:

◆ spb_heartbeat_callback()

static void spb_heartbeat_callback ( uint16_t  sender_id,
uint8_t  len,
uint8_t  msg[],
void *  context 
)
static

Definition at line 272 of file gps_piksi.c.

References get_sys_time_msec(), and time_since_last_heartbeat.

Referenced by gps_piksi_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ dops_node

sbp_msg_callbacks_node_t dops_node

Definition at line 113 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ gps_piksi

◆ gps_piksi_time_sync

struct GpsTimeSync gps_piksi_time_sync

Definition at line 1 of file gps_piksi.c.

◆ gps_time_node

sbp_msg_callbacks_node_t gps_time_node

Definition at line 114 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ heartbeat_node

sbp_msg_callbacks_node_t heartbeat_node

Definition at line 117 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ pos_ecef_node

sbp_msg_callbacks_node_t pos_ecef_node

Definition at line 109 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ pos_llh_node

sbp_msg_callbacks_node_t pos_llh_node

Definition at line 111 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ SBP_ANT_SET

const char SBP_ANT_SET[] = "frontend""\x00""antenna_selection""\x00""Patch"
static

Definition at line 83 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ sbp_state

sbp_state_t sbp_state

Definition at line 103 of file gps_piksi.c.

Referenced by gps_inject_data(), gps_piksi_event(), and gps_piksi_init().

◆ SBP_UART_SET1

const char SBP_UART_SET1[] = "uart_uartb""\x00""mode""\x00""SBP"
static

Definition at line 94 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ SBP_UART_SET2

const char SBP_UART_SET2[] = "uart_uartb""\x00""sbp_message_mask""\x00""784"
static

Definition at line 95 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ SBP_UART_SET3

const char SBP_UART_SET3[] = "uart_uartb""\x00""configure_telemetry_radio_on_boot""\x00""False"
static

Definition at line 96 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ time_since_last_heartbeat

uint32_t time_since_last_heartbeat
static

Definition at line 62 of file gps_piksi.c.

Referenced by send_piksi_heartbeat(), and spb_heartbeat_callback().

◆ time_since_last_pos_update

uint32_t time_since_last_pos_update
static

Definition at line 124 of file gps_piksi.c.

Referenced by gps_piksi_event(), and sbp_pos_ecef_callback().

◆ tracking_state_dep_a_node

sbp_msg_callbacks_node_t tracking_state_dep_a_node

Definition at line 116 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ tracking_state_node

sbp_msg_callbacks_node_t tracking_state_node

Definition at line 115 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ vel_ecef_node

sbp_msg_callbacks_node_t vel_ecef_node

Definition at line 110 of file gps_piksi.c.

Referenced by gps_piksi_init().

◆ vel_ned_node

sbp_msg_callbacks_node_t vel_ned_node

Definition at line 112 of file gps_piksi.c.

Referenced by gps_piksi_init().