39 #include "gpsposition.h"
40 #include "modulesettings.h"
60 #define UBLOX_SYNC1 0xB5
61 #define UBLOX_SYNC2 0x62
63 #define UBLOX_NAV_CLASS 0x01
64 #define UBLOX_RXM_CLASS 0x02
65 #define UBLOX_CFG_CLASS 0x06
66 #define UBLOX_MON_CLASS 0x0a
67 #define UBLOX_AID_CLASS 0x0b
68 #define UBLOX_TIM_CLASS 0x0d
70 #define UBLOX_NAV_POSLLH 0x02
71 #define UBLOX_NAV_STATUS 0x03
72 #define UBLOX_NAV_DOP 0x04
73 #define UBLOX_NAV_SOL 0x06
74 #define UBLOX_NAV_VELNED 0x12
75 #define UBLOX_NAV_TIMEUTC 0x21
76 #define UBLOX_NAV_SBAS 0x32
77 #define UBLOX_NAV_SVINFO 0x30
79 #define UBLOX_AID_REQ 0x00
81 #define UBLOX_RXM_RAW 0x10
82 #define UBLOX_RXM_SFRB 0x11
84 #define UBLOX_MON_VER 0x04
85 #define UBLOX_MON_HW 0x09
87 #define UBLOX_TIM_TP 0x01
89 #define UBLOX_CFG_MSG 0x01
90 #define UBLOX_CFG_TP 0x07
91 #define UBLOX_CFG_RATE 0x08
92 #define UBLOX_CFG_CFG 0x09
93 #define UBLOX_CFG_SBAS 0x16
94 #define UBLOX_CFG_NAV5 0x24
95 #define UBLOX_CFG_GNSS 0x3E
97 #define UBLOX_SBAS_AUTO 0x00000000
100 #define UBLOX_SBAS_WAAS 0x0004E004
101 #define UBLOX_SBAS_EGNOS 0x00000851
102 #define UBLOX_SBAS_MSAS 0x00020200
103 #define UBLOX_SBAS_GAGAN 0x00000108
105 #define UBLOX_DYN_PORTABLE 0
106 #define UBLOX_DYN_STATIONARY 2
107 #define UBLOX_DYN_PED 3
108 #define UBLOX_DYN_AUTOMOTIVE 4
109 #define UBLOX_DYN_SEA 5
110 #define UBLOX_DYN_AIR1G 6
111 #define UBLOX_DYN_AIR2G 7
112 #define UBLOX_DYN_AIR4G 8
114 #define UBLOX_GNSSID_GPS 0
115 #define UBLOX_GNSSID_SBAS 1
116 #define UBLOX_GNSSID_BEIDOU 3
117 #define UBLOX_GNSSID_QZSS 5
118 #define UBLOX_GNSSID_GLONASS 6
120 #define UBLOX_MAX_PAYLOAD 384
121 #define UBLOX_WAIT_MS 50
142 uint8_t c, uint8_t
i, uint8_t
rate) {
144 const uint8_t msg[] = {
159 const uint8_t msg[] = {
176 ModuleSettingsGPSDynamicsModeOptions dyn_mode) {
183 case MODULESETTINGS_GPSDYNAMICSMODE_PORTABLE:
186 case MODULESETTINGS_GPSDYNAMICSMODE_PEDESTRIAN:
189 case MODULESETTINGS_GPSDYNAMICSMODE_AUTOMOTIVE:
192 case MODULESETTINGS_GPSDYNAMICSMODE_AIRBORNE1G:
195 case MODULESETTINGS_GPSDYNAMICSMODE_AIRBORNE2G:
199 case MODULESETTINGS_GPSDYNAMICSMODE_AIRBORNE4G:
204 const uint8_t msg[] = {
223 const uint8_t TP_POLARITY = 1;
224 const uint32_t int_us = 1000000;
225 const uint32_t len_us = 100000;
227 const uint8_t msg[] = {
253 ModuleSettingsGPSSBASConstellationOptions sbas_const) {
254 bool enable = sbas_const != MODULESETTINGS_GPSSBASCONSTELLATION_NONE;
258 switch (sbas_const) {
259 case MODULESETTINGS_GPSSBASCONSTELLATION_WAAS:
262 case MODULESETTINGS_GPSSBASCONSTELLATION_EGNOS:
265 case MODULESETTINGS_GPSSBASCONSTELLATION_MSAS:
268 case MODULESETTINGS_GPSSBASCONSTELLATION_GAGAN:
271 case MODULESETTINGS_GPSSBASCONSTELLATION_ALL:
272 case MODULESETTINGS_GPSSBASCONSTELLATION_NONE:
278 const uint8_t msg[] = {
305 const uint32_t MASK = 0b00001110;
306 const uint8_t msg[] = {
328 #define MAX_CH_PER_CATEGORY 16
330 ModuleSettingsGPSConstellationOptions constellation,
331 ModuleSettingsGPSSBASConstellationOptions sbas_const) {
333 uint8_t sbas_chan = 3;
334 bool enable_gps =
true;
335 bool enable_glonass =
false;
337 uint8_t max_glonass_ch = 0;
339 uint8_t min_gps_ch = 10;
343 bool enable_sbas = (sbas_const != MODULESETTINGS_GPSSBASCONSTELLATION_NONE);
346 if (!enable_sbas) sbas_chan = 0;
348 switch (constellation) {
349 case MODULESETTINGS_GPSCONSTELLATION_GLONASS:
351 case MODULESETTINGS_GPSCONSTELLATION_ALL:
352 enable_glonass =
true;
354 case MODULESETTINGS_GPSCONSTELLATION_GPS:
367 const uint8_t msg[] = {
411 ModuleSettingsGPSConstellationOptions constellation,
412 ModuleSettingsGPSSBASConstellationOptions sbas_const) {
420 if (constellation == MODULESETTINGS_GPSCONSTELLATION_ALL) {
427 }
else if (ver == 7) {
430 }
else if (ver == 6) {
443 GPSPositionData gpsPosition;
457 const uint8_t *dat, uint16_t len)
461 for (uint16_t
i = 0;
i < len;
i++) {
480 ModuleSettingsGPSConstellationOptions constellation,
481 ModuleSettingsGPSSBASConstellationOptions sbas_const,
482 ModuleSettingsGPSDynamicsModeOptions dyn_mode)
500 UBloxInfoGet(&ublox);
501 }
while (ublox.swVersion == 0 && i++ < 10);
514 if (ublox.hwVersion > 0)
516 constellation, sbas_const);
519 constellation, sbas_const);
532 const char * msg_2400 =
"$PUBX,41,1,0007,0001,2400,0*1B\r\n";
533 const char * msg_4800 =
"$PUBX,41,1,0007,0001,4800,0*11\r\n";
534 const char * msg_9600 =
"$PUBX,41,1,0007,0001,9600,0*12\r\n";
535 const char * msg_19200 =
"$PUBX,41,1,0007,0001,19200,0*27\r\n";
536 const char * msg_38400 =
"$PUBX,41,1,0007,0001,38400,0*22\r\n";
537 const char * msg_57600 =
"$PUBX,41,1,0007,0001,57600,0*29\r\n";
538 const char * msg_115200 =
"$PUBX,41,1,0007,0001,115200,0*1A\r\n";
539 const char * msg_230400 =
"$PUBX,41,1,0007,0001,230400,0*18\r\n";
544 case MODULESETTINGS_GPSSPEED_2400:
548 case MODULESETTINGS_GPSSPEED_4800:
552 case MODULESETTINGS_GPSSPEED_9600:
556 case MODULESETTINGS_GPSSPEED_19200:
560 case MODULESETTINGS_GPSSPEED_38400:
565 case MODULESETTINGS_GPSSPEED_57600:
569 case MODULESETTINGS_GPSSPEED_115200:
573 case MODULESETTINGS_GPSSPEED_230400:
582 const uint32_t baud_rates[] = {2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400};
static void ubx_cfg_set_rate(uintptr_t gps_port, uint16_t ms)
Set the rate of all messages.
static void ubx_cfg_set_sbas(uintptr_t gps_port, ModuleSettingsGPSSBASConstellationOptions sbas_const)
Enable or disable SBAS satellites.
#define UBLOX_GNSSID_SBAS
uint32_t PIOS_Thread_Systime(void)
int32_t PIOS_COM_SendString(uintptr_t com_id, const char *str)
static char * gps_rx_buffer
static void ubx_cfg_poll_version(uintptr_t gps_port)
Request a MON-VER message with the firmware version.
static void ubx_cfg_pause_parse(uintptr_t gps_port, uint32_t delay_ticks)
Parse incoming data while paused.
static void ubloxTxChecksumReset(void)
Reset the TX checksum calculation.
#define UBLOX_DYN_PORTABLE
void ubx_cfg_send_configuration(uintptr_t gps_port, char *buffer, ModuleSettingsGPSConstellationOptions constellation, ModuleSettingsGPSSBASConstellationOptions sbas_const, ModuleSettingsGPSDynamicsModeOptions dyn_mode)
#define UBLOX_NAV_TIMEUTC
COM layer functions header.
static void ubx_cfg_version_specific(uintptr_t gps_port, uint8_t ver, ModuleSettingsGPSConstellationOptions constellation, ModuleSettingsGPSSBASConstellationOptions sbas_const)
Apply firmware version specific configuration tweaks.
static void ubloxTxChecksum(uint8_t c)
Update the checksum calculation.
static void ubx_cfg_set_mode(uintptr_t gps_port, ModuleSettingsGPSDynamicsModeOptions dyn_mode)
Configure the navigation mode and minimum fix.
#define UBLOX_GNSSID_GLONASS
int32_t PIOS_COM_SendChar(uintptr_t com_id, char c)
uint16_t PIOS_COM_ReceiveBuffer(uintptr_t com_id, uint8_t *buf, uint16_t buf_len, uint32_t timeout_ms)
Include file of the GPS module.
void ubx_cfg_set_baudrate(uintptr_t gps_port, ModuleSettingsGPSSpeedOptions baud_rate)
Make sure the GPS is set to the same baud.
static void ubx_cfg_send_checksummed(uintptr_t gps_port, const uint8_t *dat, uint16_t len)
Send a stream of data followed by checksum.
int parse_ubx_stream(uint8_t, char *, GPSPositionData *, struct GPS_RX_STATS *)
#define MAX_CH_PER_CATEGORY
static void ubx_cfg_enable_message(uintptr_t gps_port, uint8_t c, uint8_t i, uint8_t rate)
Enable the selected UBX message at the specified rate.
void PIOS_Thread_Sleep(uint32_t time_ms)
PIOS_COM_SendBuffer(shub_global->frsky_port, shub_global->serial_buf, msg_length)
#define UBLOX_DYN_AUTOMOTIVE
Includes PiOS and core architecture components.
static void ubx_cfg_set_timepulse(uintptr_t gps_port)
Configure the timepulse output pin.
Include file for UBX processing.
static void ubx_cfg_set_constellation(uintptr_t gps_port, ModuleSettingsGPSConstellationOptions constellation, ModuleSettingsGPSSBASConstellationOptions sbas_const)
static void ubx_cfg_clear_cfg(uintptr_t gps_port)
int32_t PIOS_COM_ChangeBaud(uintptr_t com_id, uint32_t baud)