dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ubx_cfg.c
Go to the documentation of this file.
1 
17 /*
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful, but
24  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26  * for more details.
27  *
28  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, see <http://www.gnu.org/licenses/>
30  */
31 
32 #include "openpilot.h"
33 #include "pios_com.h"
34 #include "pios_thread.h"
35 
36 #include "GPS.h"
37 #include "UBX.h"
38 
39 #include "gpsposition.h"
40 #include "modulesettings.h"
41 
42 /*
43  * The format of UBX Packets is documented in the UBX Protocol
44  * documentation and is summarized below. Links to the original
45  * documentation can be found here:
46  *
47  * http://www.u-blox.com/en/download/documents-a-resources/u-blox-6-gps-modules-resources.html
48  *
49  * 1 byte - SYNC_CHAR1 (UBLOX_SYNC1 = 0xB5)
50  * 1 byte - SYNC_CHAR2 (UBLOX_SYNC2 = 0x62)
51  * 1 byte - CLASS
52  * 1 byte - ID
53  * 2 byte - length (little endian)
54  * N bytes - payload
55  * 2 bytes - checksum
56  *
57  * The checksum is calculated from the class to the last byte of
58  * the payload
59  */
60 #define UBLOX_SYNC1 0xB5
61 #define UBLOX_SYNC2 0x62
62 
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
69 
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
78 
79 #define UBLOX_AID_REQ 0x00
80 
81 #define UBLOX_RXM_RAW 0x10
82 #define UBLOX_RXM_SFRB 0x11
83 
84 #define UBLOX_MON_VER 0x04
85 #define UBLOX_MON_HW 0x09
86 
87 #define UBLOX_TIM_TP 0x01
88 
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
96 
97 #define UBLOX_SBAS_AUTO 0x00000000
98 // TODO: Reverify these constants-- seems they have more bits set than they
99 // should.
100 #define UBLOX_SBAS_WAAS 0x0004E004
101 #define UBLOX_SBAS_EGNOS 0x00000851
102 #define UBLOX_SBAS_MSAS 0x00020200
103 #define UBLOX_SBAS_GAGAN 0x00000108
104 
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
113 
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
119 
120 #define UBLOX_MAX_PAYLOAD 384
121 #define UBLOX_WAIT_MS 50
122 
124 static char *gps_rx_buffer;
125 
126 static void ubx_cfg_send_checksummed(uintptr_t gps_port, const uint8_t *dat, uint16_t len);
127 
129 static void ubloxTxChecksumReset(void) {
130  ubloxTxCK_A = 0;
131  ubloxTxCK_B = 0;
132 }
133 
135 static void ubloxTxChecksum(uint8_t c) {
136  ubloxTxCK_A += c;
138 }
139 
141 static void ubx_cfg_enable_message(uintptr_t gps_port,
142  uint8_t c, uint8_t i, uint8_t rate) {
143 
144  const uint8_t msg[] = {
145  UBLOX_CFG_CLASS, // CFG
146  UBLOX_CFG_MSG, // MSG
147  0x03, // length lsb
148  0x00, // length msb
149  c, // class
150  i, // id
151  rate, // rate
152  };
153  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
154 }
155 
157 static void ubx_cfg_set_rate(uintptr_t gps_port, uint16_t ms) {
158 
159  const uint8_t msg[] = {
160  UBLOX_CFG_CLASS, // CFG
161  UBLOX_CFG_RATE, // RATE
162  0x06, // length lsb
163  0x00, // length msb
164  ms, // rate lsb
165  ms >> 8, // rate msb
166  0x01, // cycles
167  0x00,
168  0x01, // timeref 1 = GPS time
169  0x00,
170  };
171  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
172 }
173 
175 static void ubx_cfg_set_mode(uintptr_t gps_port,
176  ModuleSettingsGPSDynamicsModeOptions dyn_mode) {
177  uint8_t dyn_const;
178 
179  // Omitted: Stationary and at sea. At sea assumes sea level, we basically
180  // never want that.
181 
182  switch (dyn_mode) {
183  case MODULESETTINGS_GPSDYNAMICSMODE_PORTABLE:
184  dyn_const = UBLOX_DYN_PORTABLE;
185  break;
186  case MODULESETTINGS_GPSDYNAMICSMODE_PEDESTRIAN:
187  dyn_const = UBLOX_DYN_PED;
188  break;
189  case MODULESETTINGS_GPSDYNAMICSMODE_AUTOMOTIVE:
190  dyn_const = UBLOX_DYN_AUTOMOTIVE;
191  break;
192  case MODULESETTINGS_GPSDYNAMICSMODE_AIRBORNE1G:
193  dyn_const = UBLOX_DYN_AIR1G;
194  break;
195  case MODULESETTINGS_GPSDYNAMICSMODE_AIRBORNE2G:
196  default:
197  dyn_const = UBLOX_DYN_AIR2G;
198  break;
199  case MODULESETTINGS_GPSDYNAMICSMODE_AIRBORNE4G:
200  dyn_const = UBLOX_DYN_AIR4G;
201  break;
202  }
203 
204  const uint8_t msg[] = {
205  UBLOX_CFG_CLASS, // CFG
206  UBLOX_CFG_NAV5, // NAV5 mode
207  0x24, // length lsb - 36 bytes
208  0x00, // length msb
209  0b0000101, // mask LSB (fixMode, dyn)
210  0x00, // mask MSB (reserved)
211  dyn_const, // dynamic model (7 - airborne < 2g)
212  0x02, // fixmode (2 - 3D only)
213  0,0,0,0,0,0,0,0,
214  0,0,0,0,0,0,0,0,
215  0,0,0,0,0,0,0,0,
216  0,0,0,0,0,0,0,0, // padded with 32 zeros
217  };
218  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
219 }
220 
222 static void ubx_cfg_set_timepulse(uintptr_t gps_port) {
223  const uint8_t TP_POLARITY = 1;
224  const uint32_t int_us = 1000000;
225  const uint32_t len_us = 100000;
226 
227  const uint8_t msg[] = {
228  UBLOX_CFG_CLASS, // CFG
229  UBLOX_CFG_TP, // TP
230  0x14, // length lsb
231  0x00, // length msb
232  int_us & 0xff,
233  int_us >> 8 & 0xff, // interval (us)
234  int_us >> 16 & 0xff,
235  int_us >> 24 & 0xff,
236  len_us & 0xff,
237  len_us >> 8 & 0xff, // length (us)
238  len_us >> 16 & 0xff,
239  len_us >> 24 & 0xff,
240  TP_POLARITY, // polarity - zero off
241  0x01, // 1 - GPS time
242  0x00, // bitmask
243  0x00, // reserved
244  0x00, 0x00, // antenna delay
245  0x00, 0x00, // rf group delay
246  0, 0, 0, 0 // user delay
247  };
248  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
249 }
250 
252 static void ubx_cfg_set_sbas(uintptr_t gps_port,
253  ModuleSettingsGPSSBASConstellationOptions sbas_const) {
254  bool enable = sbas_const != MODULESETTINGS_GPSSBASCONSTELLATION_NONE;
255 
256  uint32_t sv_mask;
257 
258  switch (sbas_const) {
259  case MODULESETTINGS_GPSSBASCONSTELLATION_WAAS:
260  sv_mask = UBLOX_SBAS_WAAS;
261  break;
262  case MODULESETTINGS_GPSSBASCONSTELLATION_EGNOS:
263  sv_mask = UBLOX_SBAS_EGNOS;
264  break;
265  case MODULESETTINGS_GPSSBASCONSTELLATION_MSAS:
266  sv_mask = UBLOX_SBAS_MSAS;
267  break;
268  case MODULESETTINGS_GPSSBASCONSTELLATION_GAGAN:
269  sv_mask = UBLOX_SBAS_GAGAN;
270  break;
271  case MODULESETTINGS_GPSSBASCONSTELLATION_ALL:
272  case MODULESETTINGS_GPSSBASCONSTELLATION_NONE:
273  default:
274  sv_mask = UBLOX_SBAS_AUTO;
275  break;
276  }
277 
278  const uint8_t msg[] = {
279  UBLOX_CFG_CLASS, // CFG
280  UBLOX_CFG_SBAS, // SBAS
281  0x08, // length lsb
282  0x00, // length msb
283  enable, // enable flag
284  0b011, // mode
285  3, // # SBAS tracking channels
286  0,
287  sv_mask,
288  sv_mask >> 8,
289  sv_mask >> 16,
290  sv_mask >> 24,
291  };
292 
293  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
294 }
295 
296 
302 static void ubx_cfg_clear_cfg(uintptr_t gps_port) {
303 
304  // Reset the messges and navigation settings
305  const uint32_t MASK = 0b00001110;
306  const uint8_t msg[] = {
307  UBLOX_CFG_CLASS, // CFG
308  UBLOX_CFG_CFG, // CFG-CFG
309  0x0C, // length lsb
310  0x00, // length msb
311  MASK, // clear mask (U4)
312  MASK >> 8,
313  MASK >> 16,
314  MASK >> 24,
315  0,0,0,0, // load mask
316  0,0,0,0 // save mask
317  };
318 
319  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
320 }
321 
323 static void ubx_cfg_poll_version(uintptr_t gps_port) {
324  const uint8_t msg[] = {UBLOX_MON_CLASS, UBLOX_MON_VER, 0x00, 0x00};
325  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
326 }
327 
328 #define MAX_CH_PER_CATEGORY 16
329 static void ubx_cfg_set_constellation(uintptr_t gps_port,
330  ModuleSettingsGPSConstellationOptions constellation,
331  ModuleSettingsGPSSBASConstellationOptions sbas_const) {
332  // Do all this stuff upfront so we don't need to use ternary everywhere.
333  uint8_t sbas_chan = 3;
334  bool enable_gps = true;
335  bool enable_glonass = false;
336 
337  uint8_t max_glonass_ch = 0;
338  uint8_t max_gps_ch = MAX_CH_PER_CATEGORY;
339  uint8_t min_gps_ch = 10; // We have 32 channels, so always reserving
340  // at least 10 for GPS is no big deal (if
341  // enabled)
342 
343  bool enable_sbas = (sbas_const != MODULESETTINGS_GPSSBASCONSTELLATION_NONE);
344 
345  // Don't save channels for SBAS when we're not using it.
346  if (!enable_sbas) sbas_chan = 0;
347 
348  switch (constellation) {
349  case MODULESETTINGS_GPSCONSTELLATION_GLONASS:
350  enable_gps = false; // fall through
351  case MODULESETTINGS_GPSCONSTELLATION_ALL:
352  enable_glonass = true;
353  break;
354  case MODULESETTINGS_GPSCONSTELLATION_GPS:
355  default:
356  // Nothing to see here. Defaults are good.
357  break;
358  }
359 
360  if (enable_glonass) max_glonass_ch = MAX_CH_PER_CATEGORY;
361 
362  if (!enable_gps) {
363  max_gps_ch = 0;
364  min_gps_ch = 0;
365  }
366 
367  const uint8_t msg[] = {
368  UBLOX_CFG_CLASS, // CFG
369  UBLOX_CFG_GNSS, // GNSS
370  28, // length lsb 4 + 8 x 3 = 28
371  0, // length msb
372  0, // msgver = 0
373  0, // numTrkChHw (ro)
374  32, // numTrkChUse
375  3, // 3 config blocks here
376 
377  UBLOX_GNSSID_GPS, // Configuration for GPS
378  min_gps_ch, // Minimum number of channels to reserve.
379  max_gps_ch, // maximum number of channels used
380  0, // reserved1
381  enable_gps, // flags, 1 here means enable
382  0,
383  enable_gps, // flags, sigcfgmask, 1 sane for all sat systems
384  enable_gps, // UNKNOWN-- but ucenter sets it?
385 
386  UBLOX_GNSSID_SBAS, // This chunk is always for SBAS/DGPS
387  sbas_chan, // How many to save for SBAS?
388  sbas_chan, // Maximum sbas channels
389  0, // reserved1
390  enable_sbas, // flags, 1 here means enable
391  0,
392  enable_sbas, // flags, sigcfgmask, SBAS L1CA
393  enable_sbas,
394 
395  // If this next one is used, it's always GLONASS.
396  UBLOX_GNSSID_GLONASS, // GLONASS.
397  0, // Minimum num channels reserved
398  max_glonass_ch, // Maximum sbas channels
399  0, // reserved1
400  enable_glonass, // flags, 1 here means enable
401  0,
402  enable_glonass, // flags, sigcfgmask, GLONASS L1OF
403  enable_glonass
404  };
405 
406  ubx_cfg_send_checksummed(gps_port, msg, sizeof(msg));
407 }
408 
410 static void ubx_cfg_version_specific(uintptr_t gps_port, uint8_t ver,
411  ModuleSettingsGPSConstellationOptions constellation,
412  ModuleSettingsGPSSBASConstellationOptions sbas_const) {
413  // Enable satellite-based differential GPS.
414  ubx_cfg_set_sbas(gps_port, sbas_const);
415 
416  if (ver >= 8) {
417  // 10Hz for ver 8, unless 'ALL' constellations in which case we
418  // are 5Hz
419  // TODO: Detect modules where we can ask for 18/10Hz instead
420  if (constellation == MODULESETTINGS_GPSCONSTELLATION_ALL) {
421  ubx_cfg_set_rate(gps_port, (uint16_t)200);
422  } else {
423  ubx_cfg_set_rate(gps_port, (uint16_t)100);
424  }
425 
426  ubx_cfg_set_constellation(gps_port, constellation, sbas_const);
427  } else if (ver == 7) {
428  // 10Hz for ver 7
429  ubx_cfg_set_rate(gps_port, (uint16_t)100);
430  } else if (ver == 6) {
431  // 10Hz seems to work on 6
432  ubx_cfg_set_rate(gps_port, (uint16_t)100);
433  } else {
434  // 5Hz
435  ubx_cfg_set_rate(gps_port, (uint16_t)200);
436  }
437 }
438 
440 static void ubx_cfg_pause_parse(uintptr_t gps_port, uint32_t delay_ticks)
441 {
442  struct GPS_RX_STATS gpsRxStats;
443  GPSPositionData gpsPosition;
444 
445  uint8_t c;
446  uint32_t enterTime = PIOS_Thread_Systime();
447  while ((PIOS_Thread_Systime() - enterTime) < delay_ticks)
448  {
449  int32_t received = PIOS_COM_ReceiveBuffer(gps_port, &c, 1, 1);
450  if (received > 0)
451  parse_ubx_stream (c, gps_rx_buffer, &gpsPosition, &gpsRxStats);
452  }
453 }
454 
456 static void ubx_cfg_send_checksummed(uintptr_t gps_port,
457  const uint8_t *dat, uint16_t len)
458 {
459  // Calculate checksum
461  for (uint16_t i = 0; i < len; i++) {
462  ubloxTxChecksum(dat[i]);
463  }
464 
465  // Send buffer followed by checksum
466  PIOS_COM_SendChar(gps_port, UBLOX_SYNC1);
467  PIOS_COM_SendChar(gps_port, UBLOX_SYNC2);
468  PIOS_COM_SendBuffer(gps_port, dat, len);
469  PIOS_COM_SendChar(gps_port, ubloxTxCK_A);
470  PIOS_COM_SendChar(gps_port, ubloxTxCK_B);
471 
473 }
474 
479 void ubx_cfg_send_configuration(uintptr_t gps_port, char *buffer,
480  ModuleSettingsGPSConstellationOptions constellation,
481  ModuleSettingsGPSSBASConstellationOptions sbas_const,
482  ModuleSettingsGPSDynamicsModeOptions dyn_mode)
483 {
484  gps_rx_buffer = buffer;
485 
486  // Enable this to clear GPS. Not done by default
487  // because we don't want to keep writing to the
488  // persistent storage
489  if (false) ubx_cfg_clear_cfg(gps_port);
490 
491  ubx_cfg_set_timepulse(gps_port);
492 
493  UBloxInfoData ublox;
494 
495  // Poll the version number and parse some data
496  uint32_t i = 0;
497  do {
498  ubx_cfg_poll_version(gps_port);
500  UBloxInfoGet(&ublox);
501  } while (ublox.swVersion == 0 && i++ < 10);
502 
503  ubx_cfg_enable_message(gps_port, UBLOX_NAV_CLASS, UBLOX_NAV_VELNED, 1); // NAV-VELNED
504  ubx_cfg_enable_message(gps_port, UBLOX_NAV_CLASS, UBLOX_NAV_POSLLH, 1); // NAV-POSLLH
505  ubx_cfg_enable_message(gps_port, UBLOX_NAV_CLASS, UBLOX_NAV_SOL, 1); // NAV-SOL
506  ubx_cfg_enable_message(gps_port, UBLOX_NAV_CLASS, UBLOX_NAV_TIMEUTC, 5); // NAV-TIMEUTC
507  ubx_cfg_enable_message(gps_port, UBLOX_NAV_CLASS, UBLOX_NAV_DOP, 1); // NAV-DOP
508  ubx_cfg_enable_message(gps_port, UBLOX_NAV_CLASS, UBLOX_NAV_SVINFO, 5); // NAV-SVINFO
509 
510  ubx_cfg_set_mode(gps_port, dyn_mode);
511 
512  // Hardcoded version. The poll version method should fetch the
513  // data but we need to link to that.
514  if (ublox.hwVersion > 0)
515  ubx_cfg_version_specific(gps_port, floorf(ublox.hwVersion),
516  constellation, sbas_const);
517  else
518  ubx_cfg_version_specific(gps_port, 6,
519  constellation, sbas_const);
520 }
521 
523 void ubx_cfg_set_baudrate(uintptr_t gps_port, ModuleSettingsGPSSpeedOptions baud_rate)
524 {
525  // UBX,41 msg
526  // 1 - portID
527  // 0007 - input protocol (all)
528  // 0001 - output protocol (ubx only)
529  // 0 - no attempt to autobaud
530  // number - baudrate
531  // *XX - checksum
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";
540 
541  const char *msg;
542  uint32_t baud;
543  switch (baud_rate) {
544  case MODULESETTINGS_GPSSPEED_2400:
545  msg = msg_2400;
546  baud = 2400;
547  break;
548  case MODULESETTINGS_GPSSPEED_4800:
549  msg = msg_4800;
550  baud = 4800;
551  break;
552  case MODULESETTINGS_GPSSPEED_9600:
553  msg = msg_9600;
554  baud = 9600;
555  break;
556  case MODULESETTINGS_GPSSPEED_19200:
557  msg = msg_19200;
558  baud = 19200;
559  break;
560  case MODULESETTINGS_GPSSPEED_38400:
561  msg = msg_38400;
562  baud = 38400;
563  break;
564  default:
565  case MODULESETTINGS_GPSSPEED_57600:
566  msg = msg_57600;
567  baud = 57600;
568  break;
569  case MODULESETTINGS_GPSSPEED_115200:
570  msg = msg_115200;
571  baud = 115200;
572  break;
573  case MODULESETTINGS_GPSSPEED_230400:
574  msg = msg_230400;
575  baud = 230400;
576  break;
577  }
578 
579  // Attempt to set baud rate to desired value from a number of
580  // common rates. So this configures the physical baudrate and
581  // tries to send the configuration string to the GPS.
582  const uint32_t baud_rates[] = {2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400};
583  for (uint32_t i = 0; i < NELEMENTS(baud_rates); i++) {
584  PIOS_COM_ChangeBaud(gps_port, baud_rates[i]);
586 
587  // Send the baud rate change message
588  PIOS_COM_SendString(gps_port, msg);
589 
590  // Wait until the message has been fully transmitted including all start+stop bits
591  // 34 bytes * 10bits/byte = 340 bits
592  // At 2400bps, that's (340 / 2400) = 142ms
593  // add some margin and we end up with 200ms
594  PIOS_Thread_Sleep(200);
595  }
596 
597  // Set to proper baud rate
598  PIOS_COM_ChangeBaud(gps_port, baud);
599 }
600 
static void ubx_cfg_set_rate(uintptr_t gps_port, uint16_t ms)
Set the rate of all messages.
Definition: ubx_cfg.c:157
#define UBLOX_MON_CLASS
Definition: ubx_cfg.c:66
static void ubx_cfg_set_sbas(uintptr_t gps_port, ModuleSettingsGPSSBASConstellationOptions sbas_const)
Enable or disable SBAS satellites.
Definition: ubx_cfg.c:252
#define UBLOX_GNSSID_SBAS
Definition: ubx_cfg.c:115
#define UBLOX_GNSSID_GPS
Definition: ubx_cfg.c:114
uint32_t PIOS_Thread_Systime(void)
Definition: pios_thread.c:212
int32_t PIOS_COM_SendString(uintptr_t com_id, const char *str)
static char * gps_rx_buffer
Definition: ubx_cfg.c:124
static void ubx_cfg_poll_version(uintptr_t gps_port)
Request a MON-VER message with the firmware version.
Definition: ubx_cfg.c:323
static void ubx_cfg_pause_parse(uintptr_t gps_port, uint32_t delay_ticks)
Parse incoming data while paused.
Definition: ubx_cfg.c:440
static void ubloxTxChecksumReset(void)
Reset the TX checksum calculation.
Definition: ubx_cfg.c:129
#define UBLOX_DYN_PORTABLE
Definition: ubx_cfg.c:105
#define UBLOX_SBAS_EGNOS
Definition: ubx_cfg.c:101
#define UBLOX_WAIT_MS
Definition: ubx_cfg.c:121
void ubx_cfg_send_configuration(uintptr_t gps_port, char *buffer, ModuleSettingsGPSConstellationOptions constellation, ModuleSettingsGPSSBASConstellationOptions sbas_const, ModuleSettingsGPSDynamicsModeOptions dyn_mode)
Definition: ubx_cfg.c:479
#define UBLOX_NAV_TIMEUTC
Definition: ubx_cfg.c:75
#define NELEMENTS(x)
Definition: pios.h:192
uint8_t ubloxTxCK_A
Definition: ubx_cfg.c:123
#define UBLOX_DYN_AIR1G
Definition: ubx_cfg.c:110
COM layer functions header.
#define UBLOX_CFG_CLASS
Definition: ubx_cfg.c:65
#define UBLOX_MON_VER
Definition: ubx_cfg.c:84
static void ubx_cfg_version_specific(uintptr_t gps_port, uint8_t ver, ModuleSettingsGPSConstellationOptions constellation, ModuleSettingsGPSSBASConstellationOptions sbas_const)
Apply firmware version specific configuration tweaks.
Definition: ubx_cfg.c:410
#define UBLOX_CFG_CFG
Definition: ubx_cfg.c:92
#define UBLOX_SBAS_MSAS
Definition: ubx_cfg.c:102
static void ubloxTxChecksum(uint8_t c)
Update the checksum calculation.
Definition: ubx_cfg.c:135
#define UBLOX_CFG_MSG
Definition: ubx_cfg.c:89
static void ubx_cfg_set_mode(uintptr_t gps_port, ModuleSettingsGPSDynamicsModeOptions dyn_mode)
Configure the navigation mode and minimum fix.
Definition: ubx_cfg.c:175
#define UBLOX_NAV_CLASS
Definition: ubx_cfg.c:63
#define UBLOX_SBAS_WAAS
Definition: ubx_cfg.c:100
uint8_t ubloxTxCK_B
Definition: ubx_cfg.c:123
#define UBLOX_SYNC1
Definition: ubx_cfg.c:60
#define UBLOX_NAV_SVINFO
Definition: ubx_cfg.c:77
#define UBLOX_SYNC2
Definition: ubx_cfg.c:61
#define UBLOX_GNSSID_GLONASS
Definition: ubx_cfg.c:118
#define UBLOX_CFG_GNSS
Definition: ubx_cfg.c:95
int32_t PIOS_COM_SendChar(uintptr_t com_id, char c)
#define UBLOX_CFG_RATE
Definition: ubx_cfg.c:91
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.
Definition: ubx_cfg.c:523
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.
Definition: ubx_cfg.c:456
#define UBLOX_NAV_SOL
Definition: ubx_cfg.c:73
uint8_t i
Definition: msp_messages.h:97
int parse_ubx_stream(uint8_t, char *, GPSPositionData *, struct GPS_RX_STATS *)
#define UBLOX_SBAS_AUTO
Definition: ubx_cfg.c:97
#define MAX_CH_PER_CATEGORY
Definition: ubx_cfg.c:328
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.
Definition: ubx_cfg.c:141
#define UBLOX_NAV_POSLLH
Definition: ubx_cfg.c:70
#define UBLOX_CFG_SBAS
Definition: ubx_cfg.c:93
void PIOS_Thread_Sleep(uint32_t time_ms)
Definition: pios_thread.c:229
#define UBLOX_DYN_PED
Definition: ubx_cfg.c:107
PIOS_COM_SendBuffer(shub_global->frsky_port, shub_global->serial_buf, msg_length)
#define UBLOX_CFG_TP
Definition: ubx_cfg.c:90
uint8_t rate
Definition: msp_messages.h:99
#define UBLOX_DYN_AIR2G
Definition: ubx_cfg.c:111
#define UBLOX_DYN_AUTOMOTIVE
Definition: ubx_cfg.c:108
#define UBLOX_CFG_NAV5
Definition: ubx_cfg.c:94
#define UBLOX_DYN_AIR4G
Definition: ubx_cfg.c:112
Includes PiOS and core architecture components.
static void ubx_cfg_set_timepulse(uintptr_t gps_port)
Configure the timepulse output pin.
Definition: ubx_cfg.c:222
Include file for UBX processing.
#define UBLOX_NAV_VELNED
Definition: ubx_cfg.c:74
static void ubx_cfg_set_constellation(uintptr_t gps_port, ModuleSettingsGPSConstellationOptions constellation, ModuleSettingsGPSSBASConstellationOptions sbas_const)
Definition: ubx_cfg.c:329
#define UBLOX_SBAS_GAGAN
Definition: ubx_cfg.c:103
#define UBLOX_NAV_DOP
Definition: ubx_cfg.c:72
static void ubx_cfg_clear_cfg(uintptr_t gps_port)
Definition: ubx_cfg.c:302
int32_t PIOS_COM_ChangeBaud(uintptr_t com_id, uint32_t baud)