NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gps.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <platform.h>
#include "build_config.h"
#include "debug.h"
#include "common/maths.h"
#include "common/axis.h"
#include "common/utils.h"
#include "config/config.h"
#include "config/feature.h"
#include "drivers/system.h"
#include "drivers/serial.h"
#include "drivers/serial_uart.h"
#include "drivers/light_led.h"
#include "io/serial.h"
#include "gps.h"
Include dependency graph for gps.c:

Data Structures

struct  gpsInitData_s
 
struct  ubloxSbas_s
 
struct  gpsDataNmea_s
 
struct  ubx_header
 
struct  ubx_nav_posllh
 
struct  ubx_nav_status
 
struct  ubx_nav_solution
 
struct  ubx_nav_velned
 
struct  ubx_nav_svinfo_channel
 
struct  ubx_nav_svinfo
 

Macros

#define LOG_ERROR   '?'
 
#define LOG_IGNORED   '!'
 
#define LOG_SKIPPED   '>'
 
#define LOG_NMEA_GGA   'g'
 
#define LOG_NMEA_RMC   'r'
 
#define LOG_UBLOX_SOL   'O'
 
#define LOG_UBLOX_STATUS   'S'
 
#define LOG_UBLOX_SVINFO   'I'
 
#define LOG_UBLOX_POSLLH   'P'
 
#define LOG_UBLOX_VELNED   'V'
 
#define GPS_SV_MAXSATS   16
 
#define GPS_TIMEOUT   (2500)
 
#define GPS_INIT_ENTRIES   (GPS_BAUDRATE_MAX + 1)
 
#define GPS_BAUDRATE_CHANGE_DELAY   (200)
 
#define GPS_INIT_DATA_ENTRY_COUNT   (sizeof(gpsInitData) / sizeof(gpsInitData[0]))
 
#define DEFAULT_BAUD_RATE_INDEX   0
 
#define UBLOX_SBAS_MESSAGE_LENGTH   16
 
#define NO_FRAME   0
 
#define FRAME_GGA   1
 
#define FRAME_RMC   2
 
#define FRAME_GSV   3
 
#define MAX_UBLOX_PAYLOAD_SIZE   344
 
#define UBLOX_BUFFER_SIZE   MAX_UBLOX_PAYLOAD_SIZE
 

Typedefs

typedef struct gpsInitData_s gpsInitData_t
 
typedef struct ubloxSbas_s ubloxSbas_t
 
typedef struct gpsDataNmea_s gpsDataNmea_t
 

Enumerations

enum  gpsState_e {
  GPS_UNKNOWN, GPS_INITIALIZING, GPS_CHANGE_BAUD, GPS_CONFIGURE,
  GPS_RECEIVING_DATA, GPS_LOST_COMMUNICATION
}
 
enum  {
  PREAMBLE1 = 0xb5, PREAMBLE2 = 0x62, CLASS_NAV = 0x01, CLASS_ACK = 0x05,
  CLASS_CFG = 0x06, MSG_ACK_NACK = 0x00, MSG_ACK_ACK = 0x01, MSG_POSLLH = 0x2,
  MSG_STATUS = 0x3, MSG_SOL = 0x6, MSG_VELNED = 0x12, MSG_SVINFO = 0x30,
  MSG_CFG_PRT = 0x00, MSG_CFG_RATE = 0x08, MSG_CFG_SET_RATE = 0x01, MSG_CFG_NAV_SETTINGS = 0x24
}
 
enum  {
  FIX_NONE = 0, FIX_DEAD_RECKONING = 1, FIX_2D = 2, FIX_3D = 3,
  FIX_GPS_DEAD_RECKONING = 4, FIX_TIME = 5
}
 
enum  { NAV_STATUS_FIX_VALID = 1 }
 

Functions

int gps_init (struct gps *self, const struct system_calls *system, const struct config *config)
 
void gps_update (struct gps *self)
 
void gps_enable_passthrough (struct gps *self, serialPort_t *gpsPassthroughPort)
 

Variables

gpsData_t gpsData
 
enum { ... }  ubx_protocol_bytes
 
enum { ... }  ubs_nav_fix_type
 
enum { ... }  ubx_nav_status_bits
 

Macro Definition Documentation

#define DEFAULT_BAUD_RATE_INDEX   0
#define FRAME_GGA   1
#define FRAME_GSV   3
#define FRAME_RMC   2
#define GPS_BAUDRATE_CHANGE_DELAY   (200)
#define GPS_INIT_DATA_ENTRY_COUNT   (sizeof(gpsInitData) / sizeof(gpsInitData[0]))
#define GPS_INIT_ENTRIES   (GPS_BAUDRATE_MAX + 1)
#define GPS_SV_MAXSATS   16
#define GPS_TIMEOUT   (2500)
#define LOG_ERROR   '?'
#define LOG_IGNORED   '!'
#define LOG_NMEA_GGA   'g'
#define LOG_NMEA_RMC   'r'
#define LOG_SKIPPED   '>'
#define LOG_UBLOX_POSLLH   'P'
#define LOG_UBLOX_SOL   'O'
#define LOG_UBLOX_STATUS   'S'
#define LOG_UBLOX_SVINFO   'I'
#define LOG_UBLOX_VELNED   'V'
#define MAX_UBLOX_PAYLOAD_SIZE   344
#define NO_FRAME   0
#define UBLOX_BUFFER_SIZE   MAX_UBLOX_PAYLOAD_SIZE
#define UBLOX_SBAS_MESSAGE_LENGTH   16

Typedef Documentation

typedef struct gpsDataNmea_s gpsDataNmea_t
typedef struct gpsInitData_s gpsInitData_t
typedef struct ubloxSbas_s ubloxSbas_t

Enumeration Type Documentation

anonymous enum
Enumerator
PREAMBLE1 
PREAMBLE2 
CLASS_NAV 
CLASS_ACK 
CLASS_CFG 
MSG_ACK_NACK 
MSG_ACK_ACK 
MSG_POSLLH 
MSG_STATUS 
MSG_SOL 
MSG_VELNED 
MSG_SVINFO 
MSG_CFG_PRT 
MSG_CFG_RATE 
MSG_CFG_SET_RATE 
MSG_CFG_NAV_SETTINGS 
anonymous enum
Enumerator
FIX_NONE 
FIX_DEAD_RECKONING 
FIX_2D 
FIX_3D 
FIX_GPS_DEAD_RECKONING 
FIX_TIME 
anonymous enum
Enumerator
NAV_STATUS_FIX_VALID 
enum gpsState_e
Enumerator
GPS_UNKNOWN 
GPS_INITIALIZING 
GPS_CHANGE_BAUD 
GPS_CONFIGURE 
GPS_RECEIVING_DATA 
GPS_LOST_COMMUNICATION 

Function Documentation

void gps_enable_passthrough ( struct gps self,
serialPort_t gpsPassthroughPort 
)

Here is the call graph for this function:

int gps_init ( struct gps self,
const struct system_calls system,
const struct config config 
)

Here is the call graph for this function:

void gps_update ( struct gps self)

Here is the call graph for this function:

Variable Documentation

uint8_t bytes[UBLOX_BUFFER_SIZE]
gpsData_t gpsData
ubx_nav_solution solution
enum { ... } ubs_nav_fix_type
enum { ... } ubx_nav_status_bits
enum { ... } ubx_protocol_bytes