154359Sroberto/* 2182007Sroberto * /src/NTP/REPOSITORY/ntp4-dev/include/mbg_gps166.h,v 4.7 2006/06/22 18:41:43 kardel RELEASE_20060622_A 354359Sroberto * 4182007Sroberto * mbg_gps166.h,v 4.7 2006/06/22 18:41:43 kardel RELEASE_20060622_A 5182007Sroberto * 654359Sroberto * $Created: Sun Jul 20 09:20:50 1997 $ 754359Sroberto * 8182007Sroberto * File GPSSERIO.H Copyright (c) by Meinberg Funkuhren (www.meinberg.de) 9182007Sroberto * 10182007Sroberto * Linkage to PARSE: 11182007Sroberto * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org> 12182007Sroberto * 13182007Sroberto * Redistribution and use in source and binary forms, with or without 14182007Sroberto * modification, are permitted provided that the following conditions 15182007Sroberto * are met: 16182007Sroberto * 1. Redistributions of source code must retain the above copyright 17182007Sroberto * notice, this list of conditions and the following disclaimer. 18182007Sroberto * 2. Redistributions in binary form must reproduce the above copyright 19182007Sroberto * notice, this list of conditions and the following disclaimer in the 20182007Sroberto * documentation and/or other materials provided with the distribution. 21182007Sroberto * 3. Neither the name of the author nor the names of its contributors 22182007Sroberto * may be used to endorse or promote products derived from this software 23182007Sroberto * without specific prior written permission. 24182007Sroberto * 25182007Sroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 26182007Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27182007Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28182007Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 29182007Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30182007Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31182007Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32182007Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33182007Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34182007Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35182007Sroberto * SUCH DAMAGE. 36182007Sroberto * 3754359Sroberto */ 3854359Sroberto#ifndef MBG_GPS166_H 3954359Sroberto#define MBG_GPS166_H 4054359Sroberto 4154359Sroberto 42290001Sglebius/*************************************************************************** 43290001Sglebius * 44290001Sglebius * Definitions taken from Meinberg's gpsserio.h and gpsdefs.h files. 45290001Sglebius * 46290001Sglebius * Author: Martin Burnicki, Meinberg Funkuhren 47290001Sglebius * 48290001Sglebius * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany 49290001Sglebius * 50290001Sglebius * Description: 51290001Sglebius * Structures and codes to be used to access Meinberg GPS clocks via 52290001Sglebius * their serial interface COM0. COM0 should be set to a high baud rate, 53290001Sglebius * default is 19200. 54290001Sglebius * 55290001Sglebius * Standard Meinberg GPS serial operation is to send the Meinberg 56290001Sglebius * standard time string automatically once per second, once per 57290001Sglebius * minute, or on request per ASCII '?'. 58290001Sglebius * 59290001Sglebius * GPS parameter setup or parameter readout uses blocks of binary 60290001Sglebius * data which have to be isolated from the standard string. A block 61290001Sglebius * of data starts with a SOH code (ASCII Start Of Header, 0x01) 62290001Sglebius * followed by a message header with constant length and a block of 63290001Sglebius * data with variable length. 64290001Sglebius * 65290001Sglebius * The first field (cmd) of the message header holds the command 66290001Sglebius * code resp. the type of data to be transmitted. The next field (len) 67290001Sglebius * gives the number of data bytes that follow the header. This number 68290001Sglebius * ranges from 0 to sizeof( MSG_DATA ). The third field (data_csum) 69290001Sglebius * holds a checksum of all data bytes and the last field of the header 70290001Sglebius * finally holds the checksum of the header itself. 71290001Sglebius * 72290001Sglebius ***************************************************************************/ 7354359Sroberto 74290001Sglebius/** 75290001Sglebius * @brief GPS epoch bias from ordinary time_t epoch 76290001Sglebius * 77290001Sglebius * The Unix time_t epoch is usually 1970-01-01 00:00 whereas 78290001Sglebius * the GPS epoch is 1980-01-06 00:00, so the difference is 10 years, 79290001Sglebius * plus 2 days due to leap years (1972 and 1976), plus the difference 80290001Sglebius * of the day-of-month (6 - 1), so:<br> 81290001Sglebius * 82290001Sglebius * time_t t = ( gps_week * ::SECS_PER_WEEK ) + sec_of_week + ::GPS_SEC_BIAS 83290001Sglebius */ 84290001Sglebius#define GPS_SEC_BIAS 315964800UL // ( ( ( 10UL * 365UL ) + 2 + 5 ) * SECS_PER_DAY ) 8554359Sroberto 8654359Sroberto 87290001Sglebius#ifndef _COM_HS_DEFINED 88290001Sglebius /** 89290001Sglebius * @brief Enumeration of handshake modes 90290001Sglebius */ 91290001Sglebius enum COM_HANSHAKE_MODES { HS_NONE, HS_XONXOFF, HS_RTSCTS, N_COM_HS }; 92290001Sglebius #define _COM_HS_DEFINED 93290001Sglebius#endif 9454359Sroberto 95290001Sglebius#ifndef _COM_PARM_DEFINED 96290001Sglebius /** 97290001Sglebius * @brief A data type to configure a serial port's baud rate 98290001Sglebius * 99290001Sglebius * @see ::MBG_BAUD_RATES 100290001Sglebius */ 101290001Sglebius typedef int32_t BAUD_RATE; 10254359Sroberto 103290001Sglebius /** 104290001Sglebius * @brief Indices used to identify a parameter in the framing string 105290001Sglebius * 106290001Sglebius * @see ::MBG_FRAMING_STRS 107290001Sglebius */ 108290001Sglebius enum MBG_FRAMING_STR_IDXS { F_DBITS, F_PRTY, F_STBITS }; 10954359Sroberto 110290001Sglebius /** 111290001Sglebius * @brief A structure to store the configuration of a serial port 112290001Sglebius */ 113290001Sglebius typedef struct 114290001Sglebius { 115290001Sglebius BAUD_RATE baud_rate; ///< transmission speed, e.g. 19200L, see ::MBG_BAUD_RATES 116290001Sglebius char framing[4]; ///< ASCIIZ framing string, e.g. "8N1" or "7E2", see ::MBG_FRAMING_STRS 117290001Sglebius int16_t handshake; ///< handshake mode, yet only ::HS_NONE supported 11854359Sroberto 119290001Sglebius } COM_PARM; 120290001Sglebius 121290001Sglebius #define _COM_PARM_DEFINED 122290001Sglebius#endif 123290001Sglebius 124290001Sglebius 125290001Sglebius/** 126290001Sglebius * @brief Enumeration of modes supported for time string transmission 127290001Sglebius * 128290001Sglebius * This determines e.g. at which point in time a string starts 129290001Sglebius * to be transmitted via the serial port. 130290001Sglebius * Used with ::PORT_SETTINGS::mode. 131290001Sglebius * 132290001Sglebius * @see ::STR_MODE_MASKS 133290001Sglebius */ 134290001Sglebiusenum STR_MODES 135290001Sglebius{ 136290001Sglebius STR_ON_REQ, ///< transmission on request by received '?' character only 137290001Sglebius STR_PER_SEC, ///< transmission automatically if second changes 138290001Sglebius STR_PER_MIN, ///< transmission automatically if minute changes 139290001Sglebius STR_AUTO, ///< transmission automatically if required, e.g. on capture event 140290001Sglebius STR_ON_REQ_SEC, ///< transmission if second changes and a request has been received before 141290001Sglebius N_STR_MODE ///< the number of known modes 14254359Sroberto}; 14354359Sroberto 144290001Sglebius 145290001Sglebius/** 146290001Sglebius * The number of serial ports which are at least available 147290001Sglebius * even with very old GPS receiver models. For devices providing 148290001Sglebius * a ::RECEIVER_INFO structure the number of provided COM ports 149290001Sglebius * is available in ::RECEIVER_INFO::n_com_ports. 15054359Sroberto */ 151290001Sglebius#define DEFAULT_N_COM 2 15254359Sroberto 153290001Sglebius 154290001Sglebius/** 155290001Sglebius * @brief A The structure used to store the configuration of two serial ports 156290001Sglebius * 157290001Sglebius * @deprecated This structure is deprecated, ::PORT_SETTINGS and related structures 158290001Sglebius * should be used instead, if supported by the device. 159290001Sglebius */ 160290001Sglebiustypedef struct 161290001Sglebius{ 162290001Sglebius COM_PARM com[DEFAULT_N_COM]; ///< COM0 and COM1 settings 163290001Sglebius uint8_t mode[DEFAULT_N_COM]; ///< COM0 and COM1 output mode 164290001Sglebius 165290001Sglebius} PORT_PARM; 166290001Sglebius 167290001Sglebius 168290001Sglebius/** 169290001Sglebius * @brief The type of a GPS command code 170290001Sglebius * 171290001Sglebius * @see ::GPS_CMD_CODES 172290001Sglebius */ 173290001Sglebiustypedef uint16_t GPS_CMD; 174290001Sglebius 175290001Sglebius 176290001Sglebius/** 177290001Sglebius * @brief Control codes to be or'ed with a particular command/type code 178290001Sglebius */ 179290001Sglebiusenum GPS_CMD_CTRL_CODES 180290001Sglebius{ 181290001Sglebius GPS_REQACK = 0x8000, ///< to device: request acknowledge 182290001Sglebius GPS_ACK = 0x4000, ///< from device: acknowledge a command 183290001Sglebius GPS_NACK = 0x2000, ///< from device: error evaluating a command 184290001Sglebius}; 185290001Sglebius 186290001Sglebius#define GPS_CTRL_MSK 0xF000 ///< bit mask of all ::GPS_CMD_CTRL_CODES 187290001Sglebius 188290001Sglebius 189290001Sglebius/** 190290001Sglebius * @brief Command codes for the binary protocol 191290001Sglebius * 192290001Sglebius * These codes specify commands and associated data types used by Meinberg's 193290001Sglebius * binary protocol to exchange data with a device via serial port, direct USB, 194290001Sglebius * or socket I/O. 195290001Sglebius * 196290001Sglebius * Some commands and associated data structures can be read (r) from a device, others 197290001Sglebius * can be written (w) to the device, and some can also be sent automatically (a) by 198290001Sglebius * a device after a ::GPS_AUTO_ON command has been sent to the device. 199290001Sglebius * The individual command codes are marked with (rwa) accordingly, where '-' is used 200290001Sglebius * to indicate that a particular mode is not supported. 201290001Sglebius * 202290001Sglebius * @note Not all command code are supported by all devices. 203290001Sglebius * See the hints for a particular command. 204290001Sglebius * 205290001Sglebius * @note If ::GPS_ALM, ::GPS_EPH or a code named ..._IDX is sent to retrieve 206290001Sglebius * some data from a device then an uint16_t parameter must be also supplied 207290001Sglebius * in order to specify the index number of the data set to be returned. 208290001Sglebius * The valid index range depends on the command code. 209290001Sglebius * For ::GPS_ALM and ::GPS_EPH the index is the SV number which may be 0 or 210290001Sglebius * ::MIN_SVNO_GPS to ::MAX_SVNO_GPS. If the number is 0 then all ::N_SVNO_GPS 211290001Sglebius * almanacs or ephemeris data structures are returned. 212290001Sglebius * 213290001Sglebius * @see ::GPS_CMD_CODES_TABLE 214290001Sglebius */ 215290001Sglebiusenum GPS_CMD_CODES 216290001Sglebius{ /* system data */ 217290001Sglebius GPS_AUTO_ON = 0x000, ///< (-w-) no data, enable auto-msgs from device 218290001Sglebius GPS_AUTO_OFF, ///< (-w-) no data, disable auto-msgs from device 219290001Sglebius GPS_SW_REV, ///< (r--) deprecated, ::SW_REV, software revision, use only if ::GPS_RECEIVER_INFO not supp. 220290001Sglebius GPS_BVAR_STAT, ///< (r--) ::BVAR_STAT, status of buffered variables, only if ::GPS_MODEL_HAS_BVAR_STAT 221290001Sglebius GPS_TIME, ///< (-wa) ::TTM, current time or capture, or init board time 222290001Sglebius GPS_POS_XYZ, ///< (rw-) ::XYZ, current position in ECEF coordinates, only if ::GPS_MODEL_HAS_POS_XYZ 223290001Sglebius GPS_POS_LLA, ///< (rw-) ::LLA, current position in geographic coordinates, only if ::GPS_MODEL_HAS_POS_LLA 224290001Sglebius GPS_TZDL, ///< (rw-) ::TZDL, time zone / daylight saving, only if ::GPS_MODEL_HAS_TZDL 225290001Sglebius GPS_PORT_PARM, ///< (rw-) deprecated, ::PORT_PARM, use ::PORT_SETTINGS etc. if ::GPS_RECEIVER_INFO supported 226290001Sglebius GPS_SYNTH, ///< (rw-) ::SYNTH, synthesizer settings, only if ::GPS_HAS_SYNTH 227290001Sglebius GPS_ANT_INFO, ///< (r-a) ::ANT_INFO, time diff after antenna disconnect, only if ::GPS_MODEL_HAS_ANT_INFO 228290001Sglebius GPS_UCAP, ///< (r-a) ::TTM, user capture events, only if ::RECEIVER_INFO::n_ucaps > 0 229290001Sglebius 230290001Sglebius /* GPS data */ 231290001Sglebius GPS_CFGH = 0x100, ///< (rw-) ::CFGH, SVs' configuration and health codes 232290001Sglebius GPS_ALM, ///< (rw-) req: uint16_t SV num, ::SV_ALM, one SV's almanac 233290001Sglebius GPS_EPH, ///< (rw-) req: uint16_t SV num, ::SV_EPH, one SV's ephemeris 234290001Sglebius GPS_UTC, ///< (rw-) ::UTC, GPS %UTC correction parameters 235290001Sglebius GPS_IONO, ///< (rw-) ::IONO, GPS ionospheric correction parameters 236290001Sglebius GPS_ASCII_MSG ///< (r--) ::ASCII_MSG, the GPS ASCII message 237290001Sglebius}; 238290001Sglebius 239290001Sglebius 24054359Sroberto#ifndef _CSUM_DEFINED 241290001Sglebius typedef uint16_t CSUM; /* checksum used by some structures stored in non-volatile memory */ 242290001Sglebius #define _CSUM_DEFINED 24354359Sroberto#endif 24454359Sroberto 24554359Sroberto 246290001Sglebius/** 247290001Sglebius * @brief The header of a binary message. 248290001Sglebius */ 249290001Sglebiustypedef struct 250290001Sglebius{ 251290001Sglebius GPS_CMD cmd; ///< see ::GPS_CMD_CODES 252290001Sglebius uint16_t len; ///< length of the data portion appended after the header 253290001Sglebius CSUM data_csum; ///< checksum of the data portion appended after the header 254290001Sglebius CSUM hdr_csum; ///< checksum of the preceding header bytes 255290001Sglebius 25654359Sroberto} GPS_MSG_HDR; 25754359Sroberto 25854359Sroberto 259290001Sglebius#define GPS_ID_STR_LEN 16 260290001Sglebius#define GPS_ID_STR_SIZE ( GPS_ID_STR_LEN + 1 ) 261290001Sglebius 262290001Sglebius/** 263290001Sglebius * @brief Software revision information 264290001Sglebius * 265290001Sglebius * Contains a software revision code, plus an optional 266290001Sglebius * identifier for a customized version. 267290001Sglebius */ 268290001Sglebiustypedef struct 269290001Sglebius{ 270290001Sglebius uint16_t code; ///< Version number, e.g. 0x0120 means v1.20 271290001Sglebius char name[GPS_ID_STR_SIZE]; ///< Optional string identifying a customized version 272290001Sglebius uint8_t reserved; ///< Reserved field to yield even structure size 273290001Sglebius 27454359Sroberto} SW_REV; 27554359Sroberto 27654359Sroberto 277290001Sglebius/** 278290001Sglebius * @brief GNSS satellite numbers 279290001Sglebius * 280290001Sglebius * @todo: Check if MAX_SVNO_GLN is 94 instead of 95, and thus 281290001Sglebius * N_SVNO_GLN is 30 instead of 31, as reported by Wikipedia. 282290001Sglebius */ 283290001Sglebiusenum GNSS_SVNOS 284290001Sglebius{ 285290001Sglebius MIN_SVNO_GPS = 1, ///< min. GPS satellite PRN number 286290001Sglebius MAX_SVNO_GPS = 32, ///< max. GPS satellite PRN number 287290001Sglebius N_SVNO_GPS = 32, ///< max. number of active GPS satellites 28854359Sroberto 289290001Sglebius MIN_SVNO_WAAS = 33, ///< min. WAAS satellite number 290290001Sglebius MAX_SVNO_WAAS = 64, ///< max. WAAS satellite number 291290001Sglebius N_SVNO_WAAS = 32, ///< max. number of active WAAS satellites 29254359Sroberto 293290001Sglebius MIN_SVNO_GLONASS = 65, ///< min. Glonass satellite number (64 + sat slot ID) 294290001Sglebius MAX_SVNO_GLONASS = 95, ///< max. Glonass satellite number (64 + sat slot ID) 295290001Sglebius N_SVNO_GLONASS = 31 ///< max. number of active Glonass satellites 296290001Sglebius}; 29754359Sroberto 29854359Sroberto 299290001Sglebiustypedef uint16_t SVNO; ///< the number of an SV (Space Vehicle, i.e. satellite) 300290001Sglebiustypedef uint16_t HEALTH; ///< an SV's 6 bit health code 301290001Sglebiustypedef uint16_t CFG; ///< an SV's 4 bit configuration code 302290001Sglebiustypedef uint16_t IOD; ///< Issue-Of-Data code 30354359Sroberto 304290001Sglebius 305290001Sglebius/** 306290001Sglebius * @brief Status flags of battery buffered data 307290001Sglebius * 308290001Sglebius * Related to data received from the satellites, or data derived thereof. 309290001Sglebius * 310290001Sglebius * All '0' means OK, single bits set to '1' indicate 311290001Sglebius * the associated type of GPS data is not available. 312290001Sglebius * 313290001Sglebius * @see ::BVAR_FLAGS 314290001Sglebius */ 315290001Sglebiustypedef uint16_t BVAR_STAT; 316290001Sglebius 317290001Sglebius#define _mbg_swab_bvar_stat( _p ) _mbg_swab16( (_p) ) 318290001Sglebius 319290001Sglebius 320290001Sglebius/** 321290001Sglebius * @brief Enumeration of flag bits used to define ::BVAR_FLAGS 322290001Sglebius * 323290001Sglebius * For each bit which is set this means the associated data set in 324290001Sglebius * non-volatile memory is not available, or incomplete. 325290001Sglebius * Most data sets will just be re-collected from the data streams sent 326290001Sglebius * by the satellites. However, the receiver position has usually been 327290001Sglebius * computed earlier during normal operation, and will be re-computed 328290001Sglebius * when a sufficient number of satellites can be received. 329290001Sglebius * 330290001Sglebius * @see ::BVAR_STAT 331290001Sglebius * @see ::BVAR_FLAGS 332290001Sglebius * @see ::BVAR_FLAG_NAMES 333290001Sglebius */ 334290001Sglebiusenum BVAR_FLAG_BITS 335290001Sglebius{ 336290001Sglebius BVAR_BIT_CFGH_INVALID, ///< Satellite configuration and health parameters incomplete 337290001Sglebius BVAR_BIT_ALM_NOT_COMPLETE, ///< Almanac parameters incomplete 338290001Sglebius BVAR_BIT_UTC_INVALID, ///< %UTC offset parameters incomplete 339290001Sglebius BVAR_BIT_IONO_INVALID, ///< Ionospheric correction parameters incomplete 340290001Sglebius BVAR_BIT_RCVR_POS_INVALID, ///< No valid receiver position available 341290001Sglebius N_BVAR_BIT ///< number of defined ::BVAR_STAT bits 342290001Sglebius}; 343290001Sglebius 344290001Sglebius 345290001Sglebius/** 346290001Sglebius * @brief Bit masks associated with ::BVAR_FLAG_BITS 347290001Sglebius * 348290001Sglebius * Used with ::BVAR_STAT. 349290001Sglebius * 350290001Sglebius * @see ::BVAR_STAT 351290001Sglebius * @see ::BVAR_FLAG_BITS 352290001Sglebius * @see ::BVAR_FLAG_NAMES 353290001Sglebius */ 354290001Sglebiusenum BVAR_FLAGS 355290001Sglebius{ 356290001Sglebius BVAR_CFGH_INVALID = ( 1UL << BVAR_BIT_CFGH_INVALID ), ///< see ::BVAR_BIT_CFGH_INVALID 357290001Sglebius BVAR_ALM_NOT_COMPLETE = ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ), ///< see ::BVAR_BIT_ALM_NOT_COMPLETE 358290001Sglebius BVAR_UTC_INVALID = ( 1UL << BVAR_BIT_UTC_INVALID ), ///< see ::BVAR_BIT_UTC_INVALID 359290001Sglebius BVAR_IONO_INVALID = ( 1UL << BVAR_BIT_IONO_INVALID ), ///< see ::BVAR_BIT_IONO_INVALID 360290001Sglebius BVAR_RCVR_POS_INVALID = ( 1UL << BVAR_BIT_RCVR_POS_INVALID ), ///< see ::BVAR_BIT_RCVR_POS_INVALID 361290001Sglebius}; 362290001Sglebius 363290001Sglebius 364290001Sglebius/** 365290001Sglebius * @brief A structure used to hold time in GPS format 366290001Sglebius * 367290001Sglebius * Date and time refer to the linear time scale defined by GPS, with 368290001Sglebius * the epoch starting at %UTC midnight at the beginning of January 6, 1980. 369290001Sglebius * 370290001Sglebius * GPS time is counted by the week numbers since the epoch, plus second 371290001Sglebius * of the week, plus fraction of the second. The week number transmitted 372290001Sglebius * by the satellites rolls over from 1023 to 0, but Meinberg devices 373290001Sglebius * just continue to count the weeks beyond the 1024 week limit to keep 374290001Sglebius * the receiver's internal time. 375290001Sglebius * 376290001Sglebius * %UTC time differs from GPS time since a number of leap seconds have 377290001Sglebius * been inserted in the %UTC time scale after the GPS epoche. The number 378290001Sglebius * of leap seconds is disseminated by the satellites using the ::UTC 379290001Sglebius * parameter set, which also provides info on pending leap seconds. 380290001Sglebius */ 381290001Sglebiustypedef struct 382290001Sglebius{ 383290001Sglebius uint16_t wn; ///< the week number since GPS has been installed 384290001Sglebius uint32_t sec; ///< the second of that week 385290001Sglebius uint32_t tick; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units 386290001Sglebius 38754359Sroberto} T_GPS; 38854359Sroberto 38954359Sroberto 390290001Sglebius/** 391290001Sglebius * @brief Local date and time computed from GPS time 392290001Sglebius * 393290001Sglebius * The current number of leap seconds have to be added to get %UTC 394290001Sglebius * from GPS time. Additional corrections could have been made according 395290001Sglebius * to the time zone/daylight saving parameters ::TZDL defined by the user. 396290001Sglebius * The status field can be checked to see which corrections 397290001Sglebius * have actually been applied. 398290001Sglebius * 399290001Sglebius * @note Conversion from GPS time to %UTC and/or local time can only be 400290001Sglebius * done if some valid ::UTC correction parameters are available in the 401290001Sglebius * receiver's non-volatile memory. 402290001Sglebius */ 403290001Sglebiustypedef struct 404290001Sglebius{ 405290001Sglebius int16_t year; ///< year number, 0..9999 406290001Sglebius int8_t month; ///< month, 1..12 407290001Sglebius int8_t mday; ///< day of month, 1..31 408290001Sglebius int16_t yday; ///< day of year, 1..365, or 366 in case of leap year 409290001Sglebius int8_t wday; ///< day of week, 0..6 == Sun..Sat 410290001Sglebius int8_t hour; ///< hours, 0..23 411290001Sglebius int8_t min; ///< minutes, 0..59 412290001Sglebius int8_t sec; ///< seconds, 0..59, or 60 in case of inserted leap second 413290001Sglebius int32_t frac; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units 414290001Sglebius int32_t offs_from_utc; ///< local time offset from %UTC [sec] 415290001Sglebius uint16_t status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS 41654359Sroberto 417290001Sglebius} TM_GPS; 41854359Sroberto 41954359Sroberto 42054359Sroberto 421290001Sglebius/** 422290001Sglebius * @brief Status flag bits used to define ::TM_GPS_STATUS_BIT_MASKS 423290001Sglebius * 424290001Sglebius * These bits report info on the time conversion from GPS time to %UTC 425290001Sglebius * and/or local time as well as device status info. 426290001Sglebius * 427290001Sglebius * @see ::TM_GPS_STATUS_BIT_MASKS 428290001Sglebius */ 429290001Sglebiusenum TM_GPS_STATUS_BITS 430290001Sglebius{ 431290001Sglebius TM_BIT_UTC, ///< %UTC correction has been made 432290001Sglebius TM_BIT_LOCAL, ///< %UTC has been converted to local time according to ::TZDL settings 433290001Sglebius TM_BIT_DL_ANN, ///< state of daylight saving is going to change 434290001Sglebius TM_BIT_DL_ENB, ///< daylight saving is in effect 435290001Sglebius TM_BIT_LS_ANN, ///< leap second pending 436290001Sglebius TM_BIT_LS_ENB, ///< current second is leap second 437290001Sglebius TM_BIT_LS_ANN_NEG, ///< set in addition to ::TM_BIT_LS_ANN if leap sec is negative 438290001Sglebius TM_BIT_INVT, ///< invalid time, e.g. if RTC battery bas been empty 43954359Sroberto 440290001Sglebius TM_BIT_EXT_SYNC, ///< synchronized externally 441290001Sglebius TM_BIT_HOLDOVER, ///< in holdover mode after previous synchronization 442290001Sglebius TM_BIT_ANT_SHORT, ///< antenna cable short circuited 443290001Sglebius TM_BIT_NO_WARM, ///< OCXO has not warmed up 444290001Sglebius TM_BIT_ANT_DISCONN, ///< antenna currently disconnected 445290001Sglebius TM_BIT_SYN_FLAG, ///< TIME_SYN output is low 446290001Sglebius TM_BIT_NO_SYNC, ///< time sync actually not verified 447290001Sglebius TM_BIT_NO_POS ///< position actually not verified, LOCK LED off 448290001Sglebius}; 44954359Sroberto 45054359Sroberto 451290001Sglebius/** 452290001Sglebius * @brief Status flag masks used with ::TM_GPS::status 453290001Sglebius * 454290001Sglebius * These bits report info on the time conversion from GPS time to %UTC 455290001Sglebius * and/or local time as well as device status info. 456290001Sglebius * 457290001Sglebius * @see ::TM_GPS_STATUS_BITS 458290001Sglebius */ 459290001Sglebiusenum TM_GPS_STATUS_BIT_MASKS 460290001Sglebius{ 461290001Sglebius TM_UTC = ( 1UL << TM_BIT_UTC ), ///< see ::TM_BIT_UTC 462290001Sglebius TM_LOCAL = ( 1UL << TM_BIT_LOCAL ), ///< see ::TM_BIT_LOCAL 463290001Sglebius TM_DL_ANN = ( 1UL << TM_BIT_DL_ANN ), ///< see ::TM_BIT_DL_ANN 464290001Sglebius TM_DL_ENB = ( 1UL << TM_BIT_DL_ENB ), ///< see ::TM_BIT_DL_ENB 465290001Sglebius TM_LS_ANN = ( 1UL << TM_BIT_LS_ANN ), ///< see ::TM_BIT_LS_ANN 466290001Sglebius TM_LS_ENB = ( 1UL << TM_BIT_LS_ENB ), ///< see ::TM_BIT_LS_ENB 467290001Sglebius TM_LS_ANN_NEG = ( 1UL << TM_BIT_LS_ANN_NEG ), ///< see ::TM_BIT_LS_ANN_NEG 468290001Sglebius TM_INVT = ( 1UL << TM_BIT_INVT ), ///< see ::TM_BIT_INVT 46954359Sroberto 470290001Sglebius TM_EXT_SYNC = ( 1UL << TM_BIT_EXT_SYNC ), ///< see ::TM_BIT_EXT_SYNC 471290001Sglebius TM_HOLDOVER = ( 1UL << TM_BIT_HOLDOVER ), ///< see ::TM_BIT_HOLDOVER 472290001Sglebius TM_ANT_SHORT = ( 1UL << TM_BIT_ANT_SHORT ), ///< see ::TM_BIT_ANT_SHORT 473290001Sglebius TM_NO_WARM = ( 1UL << TM_BIT_NO_WARM ), ///< see ::TM_BIT_NO_WARM 474290001Sglebius TM_ANT_DISCONN = ( 1UL << TM_BIT_ANT_DISCONN ), ///< see ::TM_BIT_ANT_DISCONN 475290001Sglebius TM_SYN_FLAG = ( 1UL << TM_BIT_SYN_FLAG ), ///< see ::TM_BIT_SYN_FLAG 476290001Sglebius TM_NO_SYNC = ( 1UL << TM_BIT_NO_SYNC ), ///< see ::TM_BIT_NO_SYNC 477290001Sglebius TM_NO_POS = ( 1UL << TM_BIT_NO_POS ) ///< see ::TM_BIT_NO_POS 478290001Sglebius}; 47954359Sroberto 480290001Sglebius 481290001Sglebius/** 482290001Sglebius * @brief A structure used to transmit information on date and time 483290001Sglebius * 484290001Sglebius * This structure can be used to transfer the current time, in which 485290001Sglebius * case the channel field has to be set to -1, or an event capture time 486290001Sglebius * retrieved from the on-board FIFO, in which case the channel field 487290001Sglebius * contains the index of the time capture input, e.g. 0 or 1. 488290001Sglebius */ 489290001Sglebiustypedef struct 490290001Sglebius{ 491290001Sglebius int16_t channel; ///< -1: the current on-board time; >= 0 the capture channel number 492290001Sglebius T_GPS t; ///< time in GPS scale and format 493290001Sglebius TM_GPS tm; ///< time converted to %UTC and/or local time according to ::TZDL settings 494290001Sglebius 49554359Sroberto} TTM; 49654359Sroberto 49754359Sroberto 49854359Sroberto 49954359Sroberto/* Two types of variables used to store a position. Type XYZ is */ 50054359Sroberto/* used with a position in earth centered, earth fixed (ECEF) */ 50154359Sroberto/* coordinates whereas type LLA holds such a position converted */ 50254359Sroberto/* to geographic coordinates as defined by WGS84 (World Geodetic */ 50354359Sroberto/* System from 1984). */ 50454359Sroberto 505290001Sglebius/** 506290001Sglebius * @brief Sequence and number of components of a cartesian position 507290001Sglebius */ 508290001Sglebiusenum XYZ_FIELDS { XP, YP, ZP, N_XYZ }; // x, y, z 50954359Sroberto 510290001Sglebius/** 511290001Sglebius * @brief A position in cartesian coordinates 512290001Sglebius * 513290001Sglebius * Usually earth centered, earth fixed (ECEF) coordinates, 514290001Sglebius * in [m]. 515290001Sglebius * 516290001Sglebius * @note In the original code this is an array of double. 517290001Sglebius * 518290001Sglebius * @see ::XYZ_FIELDS 519290001Sglebius */ 520290001Sglebiustypedef l_fp XYZ[N_XYZ]; 52154359Sroberto 52254359Sroberto 523290001Sglebius/** 524290001Sglebius * @brief Sequence and number of components of a geographic position 525290001Sglebius */ 526290001Sglebiusenum LLA_FIELDS { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */ 52754359Sroberto 528290001Sglebius/** 529290001Sglebius * @brief A geographic position based on latitude, longitude, and altitude 530290001Sglebius * 531290001Sglebius * The geographic position associated to specific cartesian coordinates 532290001Sglebius * depends on the characteristics of the ellipsoid used for the computation, 533290001Sglebius * the so-called geographic datum. GPS uses the WGS84 (World Geodetic System 534290001Sglebius * from 1984) ellipsoid by default. 535290001Sglebius * 536290001Sglebius * lon, lat in [rad], alt in [m] 537290001Sglebius * 538290001Sglebius * @note In the original code this is an array of double. 539290001Sglebius * 540290001Sglebius * @see ::LLA_FIELDS 541290001Sglebius */ 542290001Sglebiustypedef l_fp LLA[N_LLA]; 54354359Sroberto 54454359Sroberto 545290001Sglebius/** 546290001Sglebius * @defgroup group_synth Synthesizer parameters 547290001Sglebius * 548290001Sglebius * Synthesizer frequency is expressed as a 549290001Sglebius * four digit decimal number (freq) to be multiplied by 0.1 Hz and an 550290001Sglebius * base 10 exponent (range). If the effective frequency is less than 551290001Sglebius * 10 kHz its phase is synchronized corresponding to the variable phase. 552290001Sglebius * Phase may be in a range from -360 deg to +360 deg with a resolution 553290001Sglebius * of 0.1 deg, so the resulting numbers to be stored are in a range of 554290001Sglebius * -3600 to +3600. 555290001Sglebius * 556290001Sglebius * Example:<br> 557290001Sglebius * Assume the value of freq is 2345 (decimal) and the value of phase is 900. 558290001Sglebius * If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg. 559290001Sglebius * If range == 1 the synthesizer will generate a 2345 Hz output frequency 560290001Sglebius * and so on. 561290001Sglebius * 562290001Sglebius * Limitations:<br> 563290001Sglebius * If freq == 0 the synthesizer is disabled. If range == 0 the least 564290001Sglebius * significant digit of freq is limited to 0, 3, 5 or 6. The resulting 565290001Sglebius * frequency is shown in the examples below: 566290001Sglebius * - freq == 1230 --> 123.0 Hz 567290001Sglebius * - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) 568290001Sglebius * - freq == 1235 --> 123.5 Hz 569290001Sglebius * - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) 570290001Sglebius * 571290001Sglebius * If range == ::MAX_SYNTH_RANGE the value of freq must not exceed 1000, so 572290001Sglebius * the output frequency is limited to 10 MHz (see ::MAX_SYNTH_FREQ_VAL). 573290001Sglebius * 574290001Sglebius * @{ */ 57554359Sroberto 576290001Sglebius#define N_SYNTH_FREQ_DIGIT 4 ///< number of digits to edit 577290001Sglebius#define MAX_SYNTH_FREQ 1000 ///< if range == ::MAX_SYNTH_RANGE 57854359Sroberto 579290001Sglebius#define MIN_SYNTH_RANGE 0 580290001Sglebius#define MAX_SYNTH_RANGE 5 581290001Sglebius#define N_SYNTH_RANGE ( MAX_SYNTH_RANGE - MIN_SYNTH_RANGE + 1 ) 58254359Sroberto 583290001Sglebius#define N_SYNTH_PHASE_DIGIT 4 584290001Sglebius#define MAX_SYNTH_PHASE 3600 58554359Sroberto 58654359Sroberto 587290001Sglebius#define MAX_SYNTH_FREQ_EDIT 9999 ///< max sequence of digits when editing 58854359Sroberto 58954359Sroberto 590290001Sglebius/** 591290001Sglebius * @brief The maximum frequency that can be configured for the synthesizer 592290001Sglebius */ 593290001Sglebius#define MAX_SYNTH_FREQ_VAL 10000000UL ///< 10 MHz 594290001Sglebius/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */ 59554359Sroberto 596290001Sglebius/** 597290001Sglebius * @brief The synthesizer's phase is only be synchronized if the frequency is below this limit 598290001Sglebius */ 599290001Sglebius#define SYNTH_PHASE_SYNC_LIMIT 10000UL ///< 10 kHz 60054359Sroberto 601290001Sglebius/** 602290001Sglebius * A Macro used to determine the position of the decimal point 603290001Sglebius * when printing the synthesizer frequency as 4 digit value 604290001Sglebius */ 605290001Sglebius#define _synth_dp_pos_from_range( _r ) \ 606290001Sglebius ( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 ) 60754359Sroberto 608290001Sglebius/** 609290001Sglebius * @brief Synthesizer frequency units 610290001Sglebius * 611290001Sglebius * An initializer for commonly displayed synthesizer frequency units 612290001Sglebius * (::N_SYNTH_RANGE strings) 613290001Sglebius */ 614290001Sglebius#define DEFAULT_FREQ_RANGES \ 615290001Sglebius{ \ 616290001Sglebius "Hz", \ 617290001Sglebius "kHz", \ 618290001Sglebius "kHz", \ 619290001Sglebius "kHz", \ 620290001Sglebius "MHz", \ 621290001Sglebius "MHz", \ 622290001Sglebius} 62354359Sroberto 62454359Sroberto 62554359Sroberto 626290001Sglebius/** 627290001Sglebius * @brief Synthesizer configuration parameters 628290001Sglebius */ 629290001Sglebiustypedef struct 630290001Sglebius{ 631290001Sglebius int16_t freq; ///< four digits used; scale: 0.1 Hz; e.g. 1234 -> 123.4 Hz 632290001Sglebius int16_t range; ///< scale factor for freq; 0..::MAX_SYNTH_RANGE 633290001Sglebius int16_t phase; ///< -::MAX_SYNTH_PHASE..+::MAX_SYNTH_PHASE; >0 -> pulses later 63454359Sroberto 635290001Sglebius} SYNTH; 63654359Sroberto 637290001Sglebius#define _mbg_swab_synth( _p ) \ 638290001Sglebius{ \ 639290001Sglebius _mbg_swab16( &(_p)->freq ); \ 640290001Sglebius _mbg_swab16( &(_p)->range ); \ 641290001Sglebius _mbg_swab16( &(_p)->phase ); \ 642290001Sglebius} 64354359Sroberto 64454359Sroberto 645290001Sglebius/** 646290001Sglebius * @brief Enumeration of synthesizer states 647290001Sglebius */ 648290001Sglebiusenum SYNTH_STATES 649290001Sglebius{ 650290001Sglebius SYNTH_DISABLED, ///< disbled by cfg, i.e. freq == 0.0 651290001Sglebius SYNTH_OFF, ///< not enabled after power-up 652290001Sglebius SYNTH_FREE, ///< enabled, but not synchronized 653290001Sglebius SYNTH_DRIFTING, ///< has initially been sync'd, but now running free 654290001Sglebius SYNTH_SYNC, ///< fully synchronized 655290001Sglebius N_SYNTH_STATE ///< the number of known states 656290001Sglebius}; 65754359Sroberto 65854359Sroberto 659290001Sglebius/** 660290001Sglebius * @brief A structure used to report the synthesizer state 661290001Sglebius */ 662290001Sglebiustypedef struct 663290001Sglebius{ 664290001Sglebius uint8_t state; ///< state code as enumerated in ::SYNTH_STATES 665290001Sglebius uint8_t flags; ///< reserved, currently always 0 66654359Sroberto 667290001Sglebius} SYNTH_STATE; 66854359Sroberto 669290001Sglebius#define _mbg_swab_synth_state( _p ) _nop_macro_fnc() 67054359Sroberto 671290001Sglebius#define SYNTH_FLAG_PHASE_IGNORED 0x01 67254359Sroberto 673290001Sglebius/** @} defgroup group_synth */ 67454359Sroberto 67554359Sroberto 67654359Sroberto 677290001Sglebius/** 678290001Sglebius * @defgroup group_tzdl Time zone / daylight saving parameters 679290001Sglebius * 680290001Sglebius * Example: <br> 681290001Sglebius * For automatic daylight saving enable/disable in Central Europe, 682290001Sglebius * the variables are to be set as shown below: <br> 683290001Sglebius * - offs = 3600L one hour from %UTC 684290001Sglebius * - offs_dl = 3600L one additional hour if daylight saving enabled 685290001Sglebius * - tm_on = first Sunday from March 25, 02:00:00h ( year |= ::DL_AUTO_FLAG ) 686290001Sglebius * - tm_off = first Sunday from October 25, 03:00:00h ( year |= ::DL_AUTO_FLAG ) 687290001Sglebius * - name[0] == "CET " name if daylight saving not enabled 688290001Sglebius * - name[1] == "CEST " name if daylight saving is enabled 689290001Sglebius * 690290001Sglebius * @{ */ 69154359Sroberto 692290001Sglebius/** 693290001Sglebius * @brief The name of a time zone 694290001Sglebius * 695290001Sglebius * @note Up to 5 printable characters, plus trailing zero 696290001Sglebius */ 697290001Sglebiustypedef char TZ_NAME[6]; 69854359Sroberto 699290001Sglebius/** 700290001Sglebius * @brief Time zone / daylight saving parameters 701290001Sglebius * 702290001Sglebius * This structure is used to specify how a device converts on-board %UTC 703290001Sglebius * to local time, including computation of beginning and end of daylight 704290001Sglebius * saving time (DST), if required. 705290001Sglebius * 706290001Sglebius * @note The ::TZDL structure contains members of type ::TM_GPS to specify 707290001Sglebius * the times for beginning and end of DST. However, the ::TM_GPS::frac, 708290001Sglebius * ::TM_GPS::offs_from_utc, and ::TM_GPS::status fields of these ::TZDL::tm_on 709290001Sglebius * and ::TZDL::tm_off members are ignored for the conversion to local time, 710290001Sglebius * and thus should be 0. 711290001Sglebius */ 712290001Sglebiustypedef struct 713290001Sglebius{ 714290001Sglebius int32_t offs; ///< standard offset from %UTC to local time [sec] 715290001Sglebius int32_t offs_dl; ///< additional offset if daylight saving enabled [sec] 716290001Sglebius TM_GPS tm_on; ///< date/time when daylight saving starts 717290001Sglebius TM_GPS tm_off; ///< date/time when daylight saving ends 718290001Sglebius TZ_NAME name[2]; ///< names without and with daylight saving enabled 71954359Sroberto 720290001Sglebius} TZDL; 72154359Sroberto 722290001Sglebius/** 723290001Sglebius * @brief A flag indicating automatic computation of DST 724290001Sglebius * 725290001Sglebius * If this flag is or'ed to the year numbers in ::TZDL::tm_on and ::TZDL::tm_off 726290001Sglebius * then daylight saving is computed automatically year by year. 727290001Sglebius */ 728290001Sglebius#define DL_AUTO_FLAG 0x8000 72954359Sroberto 730290001Sglebius/** @} defgroup group_tzdl */ 73154359Sroberto 73254359Sroberto 73354359Sroberto 734290001Sglebius/** 735290001Sglebius * @brief Antenna status and error at reconnect information 736290001Sglebius * 737290001Sglebius * The structure below reflects the status of the antenna, 738290001Sglebius * the times of last disconnect/reconnect, and the board's 739290001Sglebius * clock offset when it has synchronized again after the 740290001Sglebius * disconnection interval. 741290001Sglebius * 742290001Sglebius * @note ::ANT_INFO::status changes back to ::ANT_RECONN only 743290001Sglebius * after the antenna has been reconnected <b>and</b> the 744290001Sglebius * receiver has re-synchronized to the satellite signal. 745290001Sglebius * In this case ::ANT_INFO::delta_t reports the time offset 746290001Sglebius * before resynchronization, i.e. how much the internal 747290001Sglebius * time has drifted while the antenna was disconnected. 748290001Sglebius */ 749290001Sglebiustypedef struct 750290001Sglebius{ 751290001Sglebius int16_t status; ///< current status of antenna, see ::ANT_STATUS_CODES 752290001Sglebius TM_GPS tm_disconn; ///< time of antenna disconnect 753290001Sglebius TM_GPS tm_reconn; ///< time of antenna reconnect 754290001Sglebius int32_t delta_t; ///< clock offs at reconn. time in 1/::RECEIVER_INFO::ticks_per_sec units 75554359Sroberto 756290001Sglebius} ANT_INFO; 75754359Sroberto 75854359Sroberto 759290001Sglebius/** 760290001Sglebius * @brief Status code used with ::ANT_INFO::status 761290001Sglebius */ 762290001Sglebiusenum ANT_STATUS_CODES 763290001Sglebius{ 764290001Sglebius ANT_INVALID, ///< No other fields valid since antenna has not yet been disconnected 765290001Sglebius ANT_DISCONN, ///< Antenna is disconnected, tm_reconn and delta_t not yet set 766290001Sglebius ANT_RECONN, ///< Antenna has been disconnect, and receiver sync. after reconnect, so all fields valid 767290001Sglebius N_ANT_STATUS_CODES ///< the number of known status codes 768290001Sglebius}; 76954359Sroberto 77054359Sroberto 77154359Sroberto 772290001Sglebius/** 773290001Sglebius * @brief Summary of configuration and health data of all satellites 774290001Sglebius */ 775290001Sglebiustypedef struct 776290001Sglebius{ 777290001Sglebius CSUM csum; ///< checksum of the remaining bytes 778290001Sglebius int16_t valid; ///< flag data are valid 77954359Sroberto 780290001Sglebius T_GPS tot_51; ///< time of transmission, page 51 781290001Sglebius T_GPS tot_63; ///< time of transmission, page 63 782290001Sglebius T_GPS t0a; ///< complete reference time almanac 78354359Sroberto 784290001Sglebius CFG cfg[N_SVNO_GPS]; ///< 4 bit SV configuration code from page 63 785290001Sglebius HEALTH health[N_SVNO_GPS]; ///< 6 bit SV health codes from pages 51, 63 78654359Sroberto 787290001Sglebius} CFGH; 78854359Sroberto 78954359Sroberto 79054359Sroberto 791290001Sglebius/** 792290001Sglebius * @brief GPS %UTC correction parameters 793290001Sglebius * 794290001Sglebius * %UTC correction parameters basically as sent by the GPS satellites. 795290001Sglebius * 796290001Sglebius * The csum field is only used by the card's firmware to check the 797290001Sglebius * consistency of the structure in non-volatile memory. 798290001Sglebius * 799290001Sglebius * The field labeled valid indicates if the parameter set is valid, i.e. 800290001Sglebius * if it contains data received from the satellites. 801290001Sglebius * 802290001Sglebius * t0t, A0 and A1 contain fractional correction parameters for the current 803290001Sglebius * GPS-%UTC time offset in addition to the whole seconds. This is evaluated 804290001Sglebius * by the receivers' firmware to convert GPS time to %UTC time. 805290001Sglebius * 806290001Sglebius * The delta_tls field contains the current full seconds offset between 807290001Sglebius * GPS time and %UTC, which corresponds to the number of leap seconds inserted 808290001Sglebius * into the %UTC time scale since GPS was put into operation in January 1980. 809290001Sglebius * 810290001Sglebius * delta_tlfs holds the number of "future" leap seconds, i.e. the %UTC offset 811290001Sglebius * after the next leap second event defined by WNlsf and DNt. 812290001Sglebius * 813290001Sglebius * The fields WNlsf and DNt specify the GPS week number and the day number 814290001Sglebius * in that week for the end of which a leap second has been scheduled. 815290001Sglebius * 816290001Sglebius * @note: The satellites transmit WNlsf only as a signed 8 bit value, so it 817290001Sglebius * can only define a point in time which is +/- 127 weeks off the current time. 818290001Sglebius * The firmware tries to expand this based on the current week number, but 819290001Sglebius * the result is ambiguous if the leap second occurs or occurred more 820290001Sglebius * than 127 weeks in the future or past. 821290001Sglebius * 822290001Sglebius * So the leap second date should <b>only</b> be evaluated and displayed 823290001Sglebius * in a user interface if the fields delta_tls and delta_tlsf have 824290001Sglebius * different values, in which case there is indeed a leap second announcement 825290001Sglebius * inside the +/- 127 week range. 826290001Sglebius * 827290001Sglebius * @note In the original code the type of A0 and A1 is double. 828290001Sglebius */ 829290001Sglebiustypedef struct 830290001Sglebius{ 831290001Sglebius CSUM csum; ///< Checksum of the remaining bytes 832290001Sglebius int16_t valid; ///< Flag indicating %UTC parameters are valid 83354359Sroberto 834290001Sglebius T_GPS t0t; ///< Reference Time %UTC Parameters [wn|sec] 835290001Sglebius l_fp A0; ///< +- Clock Correction Coefficient 0 [sec] 836290001Sglebius l_fp A1; ///< +- Clock Correction Coefficient 1 [sec/sec] 83754359Sroberto 838290001Sglebius uint16_t WNlsf; ///< Week number of nearest leap second 839290001Sglebius int16_t DNt; ///< The day number at the end of which a leap second occurs 840290001Sglebius int8_t delta_tls; ///< Current %UTC offset to GPS system time [sec] 841290001Sglebius int8_t delta_tlsf; ///< Future %UTC offset to GPS system time after next leap second transition [sec] 84254359Sroberto 843290001Sglebius} UTC; 84454359Sroberto 84554359Sroberto 846290001Sglebius/** 847290001Sglebius * @brief GPS ASCII message 848290001Sglebius */ 849290001Sglebiustypedef struct 850290001Sglebius{ 851290001Sglebius CSUM csum; ///< checksum of the remaining bytes */ 852290001Sglebius int16_t valid; ///< flag data are valid 853290001Sglebius char s[23]; ///< 22 chars GPS ASCII message plus trailing zero 85454359Sroberto 855290001Sglebius} ASCII_MSG; 85654359Sroberto 85754359Sroberto 858290001Sglebius/** 859290001Sglebius * @brief Ephemeris parameters of one specific satellite 860290001Sglebius * 861290001Sglebius * Needed to compute the position of a satellite at a given time with 862290001Sglebius * high precision. Valid for an interval of 4 to 6 hours from start 863290001Sglebius * of transmission. 864290001Sglebius */ 865290001Sglebiustypedef struct 866290001Sglebius{ 867290001Sglebius CSUM csum; ///< checksum of the remaining bytes 868290001Sglebius int16_t valid; ///< flag data are valid 86954359Sroberto 870290001Sglebius HEALTH health; ///< health indication of transmitting SV [---] 871290001Sglebius IOD IODC; ///< Issue Of Data, Clock 872290001Sglebius IOD IODE2; ///< Issue of Data, Ephemeris (Subframe 2) 873290001Sglebius IOD IODE3; ///< Issue of Data, Ephemeris (Subframe 3) 874290001Sglebius T_GPS tt; ///< time of transmission 875290001Sglebius T_GPS t0c; ///< Reference Time Clock [---] 876290001Sglebius T_GPS t0e; ///< Reference Time Ephemeris [---] 87754359Sroberto 878290001Sglebius l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)] 879290001Sglebius l_fp e; ///< Eccentricity [---] 880290001Sglebius l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad] 881290001Sglebius l_fp omega; ///< +- Argument of Perigee [rad] 882290001Sglebius l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad] 883290001Sglebius l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec] 884290001Sglebius l_fp deltan; ///< +- Mean Motion Diff. from computed value [rad/sec] 885290001Sglebius l_fp i0; ///< +- Inclination Angle [rad] 886290001Sglebius l_fp idot; ///< +- Rate of Inclination Angle [rad/sec] 887290001Sglebius l_fp crc; ///< +- Cosine Corr. Term to Orbit Radius [m] 888290001Sglebius l_fp crs; ///< +- Sine Corr. Term to Orbit Radius [m] 889290001Sglebius l_fp cuc; ///< +- Cosine Corr. Term to Arg. of Latitude [rad] 890290001Sglebius l_fp cus; ///< +- Sine Corr. Term to Arg. of Latitude [rad] 891290001Sglebius l_fp cic; ///< +- Cosine Corr. Term to Inclination Angle [rad] 892290001Sglebius l_fp cis; ///< +- Sine Corr. Term to Inclination Angle [rad] 89354359Sroberto 894290001Sglebius l_fp af0; ///< +- Clock Correction Coefficient 0 [sec] 895290001Sglebius l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec] 896290001Sglebius l_fp af2; ///< +- Clock Correction Coefficient 2 [sec/sec^2] 897290001Sglebius l_fp tgd; ///< +- estimated group delay differential [sec] 898290001Sglebius 899290001Sglebius uint16_t URA; ///< predicted User Range Accuracy 900290001Sglebius 901290001Sglebius uint8_t L2code; ///< code on L2 channel [---] 902290001Sglebius uint8_t L2flag; ///< L2 P data flag [---] 903290001Sglebius 90454359Sroberto} EPH; 90554359Sroberto 90654359Sroberto 90754359Sroberto 908290001Sglebius/** 909290001Sglebius * @brief Almanac parameters of one specific satellite 910290001Sglebius * 911290001Sglebius * A reduced precision set of parameters used to check if a satellite 912290001Sglebius * is in view at a given time. Valid for an interval of more than 7 days 913290001Sglebius * from start of transmission. 914290001Sglebius */ 915290001Sglebiustypedef struct 916290001Sglebius{ 917290001Sglebius CSUM csum; ///< checksum of the remaining bytes 918290001Sglebius int16_t valid; ///< flag data are valid 91954359Sroberto 920290001Sglebius HEALTH health; ///< [---] 921290001Sglebius T_GPS t0a; ///< Reference Time Almanac [sec] 92254359Sroberto 923290001Sglebius l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)] 924290001Sglebius l_fp e; ///< Eccentricity [---] 925290001Sglebius 926290001Sglebius l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad] 927290001Sglebius l_fp omega; ///< +- Argument of Perigee [rad] 928290001Sglebius l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad] 929290001Sglebius l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec] 930290001Sglebius l_fp deltai; ///< +- [rad] 931290001Sglebius l_fp af0; ///< +- Clock Correction Coefficient 0 [sec] 932290001Sglebius l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec] 933290001Sglebius 93454359Sroberto} ALM; 93554359Sroberto 93654359Sroberto 93754359Sroberto 938290001Sglebius/** 939290001Sglebius * @brief Ionospheric correction parameters 940290001Sglebius */ 941290001Sglebiustypedef struct 942290001Sglebius{ 943290001Sglebius CSUM csum; ///< checksum of the remaining bytes 944290001Sglebius int16_t valid; ///< flag data are valid 94554359Sroberto 946290001Sglebius l_fp alpha_0; ///< Ionosph. Corr. Coeff. Alpha 0 [sec] 947290001Sglebius l_fp alpha_1; ///< Ionosph. Corr. Coeff. Alpha 1 [sec/deg] 948290001Sglebius l_fp alpha_2; ///< Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2] 949290001Sglebius l_fp alpha_3; ///< Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3] 95054359Sroberto 951290001Sglebius l_fp beta_0; ///< Ionosph. Corr. Coeff. Beta 0 [sec] 952290001Sglebius l_fp beta_1; ///< Ionosph. Corr. Coeff. Beta 1 [sec/deg] 953290001Sglebius l_fp beta_2; ///< Ionosph. Corr. Coeff. Beta 2 [sec/deg^2] 954290001Sglebius l_fp beta_3; ///< Ionosph. Corr. Coeff. Beta 3 [sec/deg^3] 95554359Sroberto 95654359Sroberto} IONO; 95754359Sroberto 95854359Sroberto 95954359Sroberto 960290001Sglebiusvoid mbg_tm_str (char **, TM_GPS *, int, int); 961290001Sglebiusvoid mbg_tgps_str (char **, T_GPS *, int); 962290001Sglebiusvoid get_mbg_header (unsigned char **, GPS_MSG_HDR *); 963290001Sglebiusvoid put_mbg_header (unsigned char **, GPS_MSG_HDR *); 964290001Sglebiusvoid get_mbg_sw_rev (unsigned char **, SW_REV *); 965290001Sglebiusvoid get_mbg_ascii_msg (unsigned char **, ASCII_MSG *); 966290001Sglebiusvoid get_mbg_svno (unsigned char **, SVNO *); 967290001Sglebiusvoid get_mbg_health (unsigned char **, HEALTH *); 968290001Sglebiusvoid get_mbg_cfg (unsigned char **, CFG *); 969290001Sglebiusvoid get_mbg_tgps (unsigned char **, T_GPS *); 970290001Sglebiusvoid get_mbg_tm (unsigned char **, TM_GPS *); 971290001Sglebiusvoid get_mbg_ttm (unsigned char **, TTM *); 972290001Sglebiusvoid get_mbg_synth (unsigned char **, SYNTH *); 973290001Sglebiusvoid get_mbg_tzdl (unsigned char **, TZDL *); 974290001Sglebiusvoid get_mbg_antinfo (unsigned char **, ANT_INFO *); 975290001Sglebiusvoid get_mbg_cfgh (unsigned char **, CFGH *); 976290001Sglebiusvoid get_mbg_utc (unsigned char **, UTC *); 977290001Sglebiusvoid get_mbg_lla (unsigned char **, LLA); 978290001Sglebiusvoid get_mbg_xyz (unsigned char **, XYZ); 979290001Sglebiusvoid get_mbg_portparam (unsigned char **, PORT_PARM *); 980290001Sglebiusvoid get_mbg_eph (unsigned char **, EPH *); 981290001Sglebiusvoid get_mbg_alm (unsigned char **, ALM *); 982290001Sglebiusvoid get_mbg_iono (unsigned char **, IONO *); 983290001Sglebius 984290001SglebiusCSUM mbg_csum (unsigned char *, unsigned int); 985290001Sglebius 98654359Sroberto#endif 98754359Sroberto/* 988182007Sroberto * History: 989182007Sroberto * 99054359Sroberto * mbg_gps166.h,v 991182007Sroberto * Revision 4.7 2006/06/22 18:41:43 kardel 992182007Sroberto * clean up signedness (gcc 4) 993182007Sroberto * 994182007Sroberto * Revision 4.6 2005/10/07 22:11:56 kardel 995182007Sroberto * bounded buffer implementation 996182007Sroberto * 997182007Sroberto * Revision 4.5.2.1 2005/09/25 10:23:48 kardel 998182007Sroberto * support bounded buffers 999182007Sroberto * 1000182007Sroberto * Revision 4.5 2005/06/25 10:58:45 kardel 1001182007Sroberto * add missing log keywords 1002182007Sroberto * 100354359Sroberto * Revision 4.1 1998/06/12 15:07:30 kardel 100454359Sroberto * fixed prototyping 100554359Sroberto * 100654359Sroberto * Revision 4.0 1998/04/10 19:50:42 kardel 100754359Sroberto * Start 4.0 release version numbering 100854359Sroberto * 100954359Sroberto * Revision 1.1 1998/04/10 19:27:34 kardel 101054359Sroberto * initial NTP VERSION 4 integration of PARSE with GPS166 binary support 101154359Sroberto * 101254359Sroberto * Revision 1.1 1997/10/06 20:55:38 kardel 101354359Sroberto * new parse structure 101454359Sroberto * 101554359Sroberto */ 1016