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 42282408Scy/*************************************************************************** 43282408Scy * 44282408Scy * Definitions taken from Meinberg's gpsserio.h and gpsdefs.h files. 45282408Scy * 46282408Scy * Author: Martin Burnicki, Meinberg Funkuhren 47282408Scy * 48282408Scy * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany 49282408Scy * 50282408Scy * Description: 51282408Scy * Structures and codes to be used to access Meinberg GPS clocks via 52282408Scy * their serial interface COM0. COM0 should be set to a high baud rate, 53282408Scy * default is 19200. 54282408Scy * 55282408Scy * Standard Meinberg GPS serial operation is to send the Meinberg 56282408Scy * standard time string automatically once per second, once per 57282408Scy * minute, or on request per ASCII '?'. 58282408Scy * 59282408Scy * GPS parameter setup or parameter readout uses blocks of binary 60282408Scy * data which have to be isolated from the standard string. A block 61282408Scy * of data starts with a SOH code (ASCII Start Of Header, 0x01) 62282408Scy * followed by a message header with constant length and a block of 63282408Scy * data with variable length. 64282408Scy * 65282408Scy * The first field (cmd) of the message header holds the command 66282408Scy * code resp. the type of data to be transmitted. The next field (len) 67282408Scy * gives the number of data bytes that follow the header. This number 68282408Scy * ranges from 0 to sizeof( MSG_DATA ). The third field (data_csum) 69282408Scy * holds a checksum of all data bytes and the last field of the header 70282408Scy * finally holds the checksum of the header itself. 71282408Scy * 72282408Scy ***************************************************************************/ 7354359Sroberto 74282408Scy/** 75282408Scy * @brief GPS epoch bias from ordinary time_t epoch 76282408Scy * 77282408Scy * The Unix time_t epoch is usually 1970-01-01 00:00 whereas 78282408Scy * the GPS epoch is 1980-01-06 00:00, so the difference is 10 years, 79282408Scy * plus 2 days due to leap years (1972 and 1976), plus the difference 80282408Scy * of the day-of-month (6 - 1), so:<br> 81282408Scy * 82282408Scy * time_t t = ( gps_week * ::SECS_PER_WEEK ) + sec_of_week + ::GPS_SEC_BIAS 83282408Scy */ 84282408Scy#define GPS_SEC_BIAS 315964800UL // ( ( ( 10UL * 365UL ) + 2 + 5 ) * SECS_PER_DAY ) 8554359Sroberto 8654359Sroberto 87282408Scy#ifndef _COM_HS_DEFINED 88282408Scy /** 89282408Scy * @brief Enumeration of handshake modes 90282408Scy */ 91282408Scy enum COM_HANSHAKE_MODES { HS_NONE, HS_XONXOFF, HS_RTSCTS, N_COM_HS }; 92282408Scy #define _COM_HS_DEFINED 93282408Scy#endif 9454359Sroberto 95282408Scy#ifndef _COM_PARM_DEFINED 96282408Scy /** 97282408Scy * @brief A data type to configure a serial port's baud rate 98282408Scy * 99282408Scy * @see ::MBG_BAUD_RATES 100282408Scy */ 101282408Scy typedef int32_t BAUD_RATE; 10254359Sroberto 103282408Scy /** 104282408Scy * @brief Indices used to identify a parameter in the framing string 105282408Scy * 106282408Scy * @see ::MBG_FRAMING_STRS 107282408Scy */ 108282408Scy enum MBG_FRAMING_STR_IDXS { F_DBITS, F_PRTY, F_STBITS }; 10954359Sroberto 110282408Scy /** 111282408Scy * @brief A structure to store the configuration of a serial port 112282408Scy */ 113282408Scy typedef struct 114282408Scy { 115282408Scy BAUD_RATE baud_rate; ///< transmission speed, e.g. 19200L, see ::MBG_BAUD_RATES 116282408Scy char framing[4]; ///< ASCIIZ framing string, e.g. "8N1" or "7E2", see ::MBG_FRAMING_STRS 117282408Scy int16_t handshake; ///< handshake mode, yet only ::HS_NONE supported 11854359Sroberto 119282408Scy } COM_PARM; 120282408Scy 121282408Scy #define _COM_PARM_DEFINED 122282408Scy#endif 123282408Scy 124282408Scy 125282408Scy/** 126282408Scy * @brief Enumeration of modes supported for time string transmission 127282408Scy * 128282408Scy * This determines e.g. at which point in time a string starts 129282408Scy * to be transmitted via the serial port. 130282408Scy * Used with ::PORT_SETTINGS::mode. 131282408Scy * 132282408Scy * @see ::STR_MODE_MASKS 133282408Scy */ 134282408Scyenum STR_MODES 135282408Scy{ 136282408Scy STR_ON_REQ, ///< transmission on request by received '?' character only 137282408Scy STR_PER_SEC, ///< transmission automatically if second changes 138282408Scy STR_PER_MIN, ///< transmission automatically if minute changes 139282408Scy STR_AUTO, ///< transmission automatically if required, e.g. on capture event 140282408Scy STR_ON_REQ_SEC, ///< transmission if second changes and a request has been received before 141282408Scy N_STR_MODE ///< the number of known modes 14254359Sroberto}; 14354359Sroberto 144282408Scy 145282408Scy/** 146282408Scy * The number of serial ports which are at least available 147282408Scy * even with very old GPS receiver models. For devices providing 148282408Scy * a ::RECEIVER_INFO structure the number of provided COM ports 149282408Scy * is available in ::RECEIVER_INFO::n_com_ports. 15054359Sroberto */ 151282408Scy#define DEFAULT_N_COM 2 15254359Sroberto 153282408Scy 154282408Scy/** 155282408Scy * @brief A The structure used to store the configuration of two serial ports 156282408Scy * 157282408Scy * @deprecated This structure is deprecated, ::PORT_SETTINGS and related structures 158282408Scy * should be used instead, if supported by the device. 159282408Scy */ 160282408Scytypedef struct 161282408Scy{ 162282408Scy COM_PARM com[DEFAULT_N_COM]; ///< COM0 and COM1 settings 163282408Scy uint8_t mode[DEFAULT_N_COM]; ///< COM0 and COM1 output mode 164282408Scy 165282408Scy} PORT_PARM; 166282408Scy 167282408Scy 168282408Scy/** 169282408Scy * @brief The type of a GPS command code 170282408Scy * 171282408Scy * @see ::GPS_CMD_CODES 172282408Scy */ 173282408Scytypedef uint16_t GPS_CMD; 174282408Scy 175282408Scy 176282408Scy/** 177282408Scy * @brief Control codes to be or'ed with a particular command/type code 178282408Scy */ 179282408Scyenum GPS_CMD_CTRL_CODES 180282408Scy{ 181282408Scy GPS_REQACK = 0x8000, ///< to device: request acknowledge 182282408Scy GPS_ACK = 0x4000, ///< from device: acknowledge a command 183282408Scy GPS_NACK = 0x2000, ///< from device: error evaluating a command 184282408Scy}; 185282408Scy 186282408Scy#define GPS_CTRL_MSK 0xF000 ///< bit mask of all ::GPS_CMD_CTRL_CODES 187282408Scy 188282408Scy 189282408Scy/** 190282408Scy * @brief Command codes for the binary protocol 191282408Scy * 192282408Scy * These codes specify commands and associated data types used by Meinberg's 193282408Scy * binary protocol to exchange data with a device via serial port, direct USB, 194282408Scy * or socket I/O. 195282408Scy * 196282408Scy * Some commands and associated data structures can be read (r) from a device, others 197282408Scy * can be written (w) to the device, and some can also be sent automatically (a) by 198282408Scy * a device after a ::GPS_AUTO_ON command has been sent to the device. 199282408Scy * The individual command codes are marked with (rwa) accordingly, where '-' is used 200282408Scy * to indicate that a particular mode is not supported. 201282408Scy * 202282408Scy * @note Not all command code are supported by all devices. 203282408Scy * See the hints for a particular command. 204282408Scy * 205282408Scy * @note If ::GPS_ALM, ::GPS_EPH or a code named ..._IDX is sent to retrieve 206282408Scy * some data from a device then an uint16_t parameter must be also supplied 207282408Scy * in order to specify the index number of the data set to be returned. 208282408Scy * The valid index range depends on the command code. 209282408Scy * For ::GPS_ALM and ::GPS_EPH the index is the SV number which may be 0 or 210282408Scy * ::MIN_SVNO_GPS to ::MAX_SVNO_GPS. If the number is 0 then all ::N_SVNO_GPS 211282408Scy * almanacs or ephemeris data structures are returned. 212282408Scy * 213282408Scy * @see ::GPS_CMD_CODES_TABLE 214282408Scy */ 215282408Scyenum GPS_CMD_CODES 216282408Scy{ /* system data */ 217282408Scy GPS_AUTO_ON = 0x000, ///< (-w-) no data, enable auto-msgs from device 218282408Scy GPS_AUTO_OFF, ///< (-w-) no data, disable auto-msgs from device 219282408Scy GPS_SW_REV, ///< (r--) deprecated, ::SW_REV, software revision, use only if ::GPS_RECEIVER_INFO not supp. 220282408Scy GPS_BVAR_STAT, ///< (r--) ::BVAR_STAT, status of buffered variables, only if ::GPS_MODEL_HAS_BVAR_STAT 221282408Scy GPS_TIME, ///< (-wa) ::TTM, current time or capture, or init board time 222282408Scy GPS_POS_XYZ, ///< (rw-) ::XYZ, current position in ECEF coordinates, only if ::GPS_MODEL_HAS_POS_XYZ 223282408Scy GPS_POS_LLA, ///< (rw-) ::LLA, current position in geographic coordinates, only if ::GPS_MODEL_HAS_POS_LLA 224282408Scy GPS_TZDL, ///< (rw-) ::TZDL, time zone / daylight saving, only if ::GPS_MODEL_HAS_TZDL 225282408Scy GPS_PORT_PARM, ///< (rw-) deprecated, ::PORT_PARM, use ::PORT_SETTINGS etc. if ::GPS_RECEIVER_INFO supported 226282408Scy GPS_SYNTH, ///< (rw-) ::SYNTH, synthesizer settings, only if ::GPS_HAS_SYNTH 227282408Scy GPS_ANT_INFO, ///< (r-a) ::ANT_INFO, time diff after antenna disconnect, only if ::GPS_MODEL_HAS_ANT_INFO 228282408Scy GPS_UCAP, ///< (r-a) ::TTM, user capture events, only if ::RECEIVER_INFO::n_ucaps > 0 229282408Scy 230282408Scy /* GPS data */ 231282408Scy GPS_CFGH = 0x100, ///< (rw-) ::CFGH, SVs' configuration and health codes 232282408Scy GPS_ALM, ///< (rw-) req: uint16_t SV num, ::SV_ALM, one SV's almanac 233282408Scy GPS_EPH, ///< (rw-) req: uint16_t SV num, ::SV_EPH, one SV's ephemeris 234282408Scy GPS_UTC, ///< (rw-) ::UTC, GPS %UTC correction parameters 235282408Scy GPS_IONO, ///< (rw-) ::IONO, GPS ionospheric correction parameters 236282408Scy GPS_ASCII_MSG ///< (r--) ::ASCII_MSG, the GPS ASCII message 237282408Scy}; 238282408Scy 239282408Scy 24054359Sroberto#ifndef _CSUM_DEFINED 241282408Scy typedef uint16_t CSUM; /* checksum used by some structures stored in non-volatile memory */ 242282408Scy #define _CSUM_DEFINED 24354359Sroberto#endif 24454359Sroberto 24554359Sroberto 246282408Scy/** 247282408Scy * @brief The header of a binary message. 248282408Scy */ 249282408Scytypedef struct 250282408Scy{ 251282408Scy GPS_CMD cmd; ///< see ::GPS_CMD_CODES 252282408Scy uint16_t len; ///< length of the data portion appended after the header 253282408Scy CSUM data_csum; ///< checksum of the data portion appended after the header 254282408Scy CSUM hdr_csum; ///< checksum of the preceding header bytes 255282408Scy 25654359Sroberto} GPS_MSG_HDR; 25754359Sroberto 25854359Sroberto 259282408Scy#define GPS_ID_STR_LEN 16 260282408Scy#define GPS_ID_STR_SIZE ( GPS_ID_STR_LEN + 1 ) 261282408Scy 262282408Scy/** 263282408Scy * @brief Software revision information 264282408Scy * 265282408Scy * Contains a software revision code, plus an optional 266282408Scy * identifier for a customized version. 267282408Scy */ 268282408Scytypedef struct 269282408Scy{ 270282408Scy uint16_t code; ///< Version number, e.g. 0x0120 means v1.20 271282408Scy char name[GPS_ID_STR_SIZE]; ///< Optional string identifying a customized version 272282408Scy uint8_t reserved; ///< Reserved field to yield even structure size 273282408Scy 27454359Sroberto} SW_REV; 27554359Sroberto 27654359Sroberto 277282408Scy/** 278282408Scy * @brief GNSS satellite numbers 279282408Scy * 280282408Scy * @todo: Check if MAX_SVNO_GLN is 94 instead of 95, and thus 281282408Scy * N_SVNO_GLN is 30 instead of 31, as reported by Wikipedia. 282282408Scy */ 283282408Scyenum GNSS_SVNOS 284282408Scy{ 285282408Scy MIN_SVNO_GPS = 1, ///< min. GPS satellite PRN number 286282408Scy MAX_SVNO_GPS = 32, ///< max. GPS satellite PRN number 287282408Scy N_SVNO_GPS = 32, ///< max. number of active GPS satellites 28854359Sroberto 289282408Scy MIN_SVNO_WAAS = 33, ///< min. WAAS satellite number 290282408Scy MAX_SVNO_WAAS = 64, ///< max. WAAS satellite number 291282408Scy N_SVNO_WAAS = 32, ///< max. number of active WAAS satellites 29254359Sroberto 293282408Scy MIN_SVNO_GLONASS = 65, ///< min. Glonass satellite number (64 + sat slot ID) 294282408Scy MAX_SVNO_GLONASS = 95, ///< max. Glonass satellite number (64 + sat slot ID) 295282408Scy N_SVNO_GLONASS = 31 ///< max. number of active Glonass satellites 296282408Scy}; 29754359Sroberto 29854359Sroberto 299282408Scytypedef uint16_t SVNO; ///< the number of an SV (Space Vehicle, i.e. satellite) 300282408Scytypedef uint16_t HEALTH; ///< an SV's 6 bit health code 301282408Scytypedef uint16_t CFG; ///< an SV's 4 bit configuration code 302282408Scytypedef uint16_t IOD; ///< Issue-Of-Data code 30354359Sroberto 304282408Scy 305282408Scy/** 306282408Scy * @brief Status flags of battery buffered data 307282408Scy * 308282408Scy * Related to data received from the satellites, or data derived thereof. 309282408Scy * 310282408Scy * All '0' means OK, single bits set to '1' indicate 311282408Scy * the associated type of GPS data is not available. 312282408Scy * 313282408Scy * @see ::BVAR_FLAGS 314282408Scy */ 315282408Scytypedef uint16_t BVAR_STAT; 316282408Scy 317282408Scy#define _mbg_swab_bvar_stat( _p ) _mbg_swab16( (_p) ) 318282408Scy 319282408Scy 320282408Scy/** 321282408Scy * @brief Enumeration of flag bits used to define ::BVAR_FLAGS 322282408Scy * 323282408Scy * For each bit which is set this means the associated data set in 324282408Scy * non-volatile memory is not available, or incomplete. 325282408Scy * Most data sets will just be re-collected from the data streams sent 326282408Scy * by the satellites. However, the receiver position has usually been 327282408Scy * computed earlier during normal operation, and will be re-computed 328282408Scy * when a sufficient number of satellites can be received. 329282408Scy * 330282408Scy * @see ::BVAR_STAT 331282408Scy * @see ::BVAR_FLAGS 332282408Scy * @see ::BVAR_FLAG_NAMES 333282408Scy */ 334282408Scyenum BVAR_FLAG_BITS 335282408Scy{ 336282408Scy BVAR_BIT_CFGH_INVALID, ///< Satellite configuration and health parameters incomplete 337282408Scy BVAR_BIT_ALM_NOT_COMPLETE, ///< Almanac parameters incomplete 338282408Scy BVAR_BIT_UTC_INVALID, ///< %UTC offset parameters incomplete 339282408Scy BVAR_BIT_IONO_INVALID, ///< Ionospheric correction parameters incomplete 340282408Scy BVAR_BIT_RCVR_POS_INVALID, ///< No valid receiver position available 341282408Scy N_BVAR_BIT ///< number of defined ::BVAR_STAT bits 342282408Scy}; 343282408Scy 344282408Scy 345282408Scy/** 346282408Scy * @brief Bit masks associated with ::BVAR_FLAG_BITS 347282408Scy * 348282408Scy * Used with ::BVAR_STAT. 349282408Scy * 350282408Scy * @see ::BVAR_STAT 351282408Scy * @see ::BVAR_FLAG_BITS 352282408Scy * @see ::BVAR_FLAG_NAMES 353282408Scy */ 354282408Scyenum BVAR_FLAGS 355282408Scy{ 356282408Scy BVAR_CFGH_INVALID = ( 1UL << BVAR_BIT_CFGH_INVALID ), ///< see ::BVAR_BIT_CFGH_INVALID 357282408Scy BVAR_ALM_NOT_COMPLETE = ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ), ///< see ::BVAR_BIT_ALM_NOT_COMPLETE 358282408Scy BVAR_UTC_INVALID = ( 1UL << BVAR_BIT_UTC_INVALID ), ///< see ::BVAR_BIT_UTC_INVALID 359282408Scy BVAR_IONO_INVALID = ( 1UL << BVAR_BIT_IONO_INVALID ), ///< see ::BVAR_BIT_IONO_INVALID 360282408Scy BVAR_RCVR_POS_INVALID = ( 1UL << BVAR_BIT_RCVR_POS_INVALID ), ///< see ::BVAR_BIT_RCVR_POS_INVALID 361282408Scy}; 362282408Scy 363282408Scy 364282408Scy/** 365282408Scy * @brief A structure used to hold time in GPS format 366282408Scy * 367282408Scy * Date and time refer to the linear time scale defined by GPS, with 368282408Scy * the epoch starting at %UTC midnight at the beginning of January 6, 1980. 369282408Scy * 370282408Scy * GPS time is counted by the week numbers since the epoch, plus second 371282408Scy * of the week, plus fraction of the second. The week number transmitted 372282408Scy * by the satellites rolls over from 1023 to 0, but Meinberg devices 373282408Scy * just continue to count the weeks beyond the 1024 week limit to keep 374282408Scy * the receiver's internal time. 375282408Scy * 376282408Scy * %UTC time differs from GPS time since a number of leap seconds have 377282408Scy * been inserted in the %UTC time scale after the GPS epoche. The number 378282408Scy * of leap seconds is disseminated by the satellites using the ::UTC 379282408Scy * parameter set, which also provides info on pending leap seconds. 380282408Scy */ 381282408Scytypedef struct 382282408Scy{ 383282408Scy uint16_t wn; ///< the week number since GPS has been installed 384282408Scy uint32_t sec; ///< the second of that week 385282408Scy uint32_t tick; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units 386282408Scy 38754359Sroberto} T_GPS; 38854359Sroberto 38954359Sroberto 390282408Scy/** 391282408Scy * @brief Local date and time computed from GPS time 392282408Scy * 393282408Scy * The current number of leap seconds have to be added to get %UTC 394282408Scy * from GPS time. Additional corrections could have been made according 395282408Scy * to the time zone/daylight saving parameters ::TZDL defined by the user. 396282408Scy * The status field can be checked to see which corrections 397282408Scy * have actually been applied. 398282408Scy * 399282408Scy * @note Conversion from GPS time to %UTC and/or local time can only be 400282408Scy * done if some valid ::UTC correction parameters are available in the 401282408Scy * receiver's non-volatile memory. 402282408Scy */ 403282408Scytypedef struct 404282408Scy{ 405282408Scy int16_t year; ///< year number, 0..9999 406282408Scy int8_t month; ///< month, 1..12 407282408Scy int8_t mday; ///< day of month, 1..31 408282408Scy int16_t yday; ///< day of year, 1..365, or 366 in case of leap year 409282408Scy int8_t wday; ///< day of week, 0..6 == Sun..Sat 410282408Scy int8_t hour; ///< hours, 0..23 411282408Scy int8_t min; ///< minutes, 0..59 412282408Scy int8_t sec; ///< seconds, 0..59, or 60 in case of inserted leap second 413282408Scy int32_t frac; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units 414282408Scy int32_t offs_from_utc; ///< local time offset from %UTC [sec] 415282408Scy uint16_t status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS 41654359Sroberto 417282408Scy} TM_GPS; 41854359Sroberto 41954359Sroberto 42054359Sroberto 421282408Scy/** 422282408Scy * @brief Status flag bits used to define ::TM_GPS_STATUS_BIT_MASKS 423282408Scy * 424282408Scy * These bits report info on the time conversion from GPS time to %UTC 425282408Scy * and/or local time as well as device status info. 426282408Scy * 427282408Scy * @see ::TM_GPS_STATUS_BIT_MASKS 428282408Scy */ 429282408Scyenum TM_GPS_STATUS_BITS 430282408Scy{ 431282408Scy TM_BIT_UTC, ///< %UTC correction has been made 432282408Scy TM_BIT_LOCAL, ///< %UTC has been converted to local time according to ::TZDL settings 433282408Scy TM_BIT_DL_ANN, ///< state of daylight saving is going to change 434282408Scy TM_BIT_DL_ENB, ///< daylight saving is in effect 435282408Scy TM_BIT_LS_ANN, ///< leap second pending 436282408Scy TM_BIT_LS_ENB, ///< current second is leap second 437282408Scy TM_BIT_LS_ANN_NEG, ///< set in addition to ::TM_BIT_LS_ANN if leap sec is negative 438282408Scy TM_BIT_INVT, ///< invalid time, e.g. if RTC battery bas been empty 43954359Sroberto 440282408Scy TM_BIT_EXT_SYNC, ///< synchronized externally 441282408Scy TM_BIT_HOLDOVER, ///< in holdover mode after previous synchronization 442282408Scy TM_BIT_ANT_SHORT, ///< antenna cable short circuited 443282408Scy TM_BIT_NO_WARM, ///< OCXO has not warmed up 444282408Scy TM_BIT_ANT_DISCONN, ///< antenna currently disconnected 445282408Scy TM_BIT_SYN_FLAG, ///< TIME_SYN output is low 446282408Scy TM_BIT_NO_SYNC, ///< time sync actually not verified 447282408Scy TM_BIT_NO_POS ///< position actually not verified, LOCK LED off 448282408Scy}; 44954359Sroberto 45054359Sroberto 451282408Scy/** 452282408Scy * @brief Status flag masks used with ::TM_GPS::status 453282408Scy * 454282408Scy * These bits report info on the time conversion from GPS time to %UTC 455282408Scy * and/or local time as well as device status info. 456282408Scy * 457282408Scy * @see ::TM_GPS_STATUS_BITS 458282408Scy */ 459282408Scyenum TM_GPS_STATUS_BIT_MASKS 460282408Scy{ 461282408Scy TM_UTC = ( 1UL << TM_BIT_UTC ), ///< see ::TM_BIT_UTC 462282408Scy TM_LOCAL = ( 1UL << TM_BIT_LOCAL ), ///< see ::TM_BIT_LOCAL 463282408Scy TM_DL_ANN = ( 1UL << TM_BIT_DL_ANN ), ///< see ::TM_BIT_DL_ANN 464282408Scy TM_DL_ENB = ( 1UL << TM_BIT_DL_ENB ), ///< see ::TM_BIT_DL_ENB 465282408Scy TM_LS_ANN = ( 1UL << TM_BIT_LS_ANN ), ///< see ::TM_BIT_LS_ANN 466282408Scy TM_LS_ENB = ( 1UL << TM_BIT_LS_ENB ), ///< see ::TM_BIT_LS_ENB 467282408Scy TM_LS_ANN_NEG = ( 1UL << TM_BIT_LS_ANN_NEG ), ///< see ::TM_BIT_LS_ANN_NEG 468282408Scy TM_INVT = ( 1UL << TM_BIT_INVT ), ///< see ::TM_BIT_INVT 46954359Sroberto 470282408Scy TM_EXT_SYNC = ( 1UL << TM_BIT_EXT_SYNC ), ///< see ::TM_BIT_EXT_SYNC 471282408Scy TM_HOLDOVER = ( 1UL << TM_BIT_HOLDOVER ), ///< see ::TM_BIT_HOLDOVER 472282408Scy TM_ANT_SHORT = ( 1UL << TM_BIT_ANT_SHORT ), ///< see ::TM_BIT_ANT_SHORT 473282408Scy TM_NO_WARM = ( 1UL << TM_BIT_NO_WARM ), ///< see ::TM_BIT_NO_WARM 474282408Scy TM_ANT_DISCONN = ( 1UL << TM_BIT_ANT_DISCONN ), ///< see ::TM_BIT_ANT_DISCONN 475282408Scy TM_SYN_FLAG = ( 1UL << TM_BIT_SYN_FLAG ), ///< see ::TM_BIT_SYN_FLAG 476282408Scy TM_NO_SYNC = ( 1UL << TM_BIT_NO_SYNC ), ///< see ::TM_BIT_NO_SYNC 477282408Scy TM_NO_POS = ( 1UL << TM_BIT_NO_POS ) ///< see ::TM_BIT_NO_POS 478282408Scy}; 47954359Sroberto 480282408Scy 481282408Scy/** 482282408Scy * @brief A structure used to transmit information on date and time 483282408Scy * 484282408Scy * This structure can be used to transfer the current time, in which 485282408Scy * case the channel field has to be set to -1, or an event capture time 486282408Scy * retrieved from the on-board FIFO, in which case the channel field 487282408Scy * contains the index of the time capture input, e.g. 0 or 1. 488282408Scy */ 489282408Scytypedef struct 490282408Scy{ 491282408Scy int16_t channel; ///< -1: the current on-board time; >= 0 the capture channel number 492282408Scy T_GPS t; ///< time in GPS scale and format 493282408Scy TM_GPS tm; ///< time converted to %UTC and/or local time according to ::TZDL settings 494282408Scy 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 505282408Scy/** 506282408Scy * @brief Sequence and number of components of a cartesian position 507282408Scy */ 508282408Scyenum XYZ_FIELDS { XP, YP, ZP, N_XYZ }; // x, y, z 50954359Sroberto 510282408Scy/** 511282408Scy * @brief A position in cartesian coordinates 512282408Scy * 513282408Scy * Usually earth centered, earth fixed (ECEF) coordinates, 514282408Scy * in [m]. 515282408Scy * 516282408Scy * @note In the original code this is an array of double. 517282408Scy * 518282408Scy * @see ::XYZ_FIELDS 519282408Scy */ 520282408Scytypedef l_fp XYZ[N_XYZ]; 52154359Sroberto 52254359Sroberto 523282408Scy/** 524282408Scy * @brief Sequence and number of components of a geographic position 525282408Scy */ 526282408Scyenum LLA_FIELDS { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */ 52754359Sroberto 528282408Scy/** 529282408Scy * @brief A geographic position based on latitude, longitude, and altitude 530282408Scy * 531282408Scy * The geographic position associated to specific cartesian coordinates 532282408Scy * depends on the characteristics of the ellipsoid used for the computation, 533282408Scy * the so-called geographic datum. GPS uses the WGS84 (World Geodetic System 534282408Scy * from 1984) ellipsoid by default. 535282408Scy * 536282408Scy * lon, lat in [rad], alt in [m] 537282408Scy * 538282408Scy * @note In the original code this is an array of double. 539282408Scy * 540282408Scy * @see ::LLA_FIELDS 541282408Scy */ 542282408Scytypedef l_fp LLA[N_LLA]; 54354359Sroberto 54454359Sroberto 545282408Scy/** 546282408Scy * @defgroup group_synth Synthesizer parameters 547282408Scy * 548282408Scy * Synthesizer frequency is expressed as a 549282408Scy * four digit decimal number (freq) to be multiplied by 0.1 Hz and an 550282408Scy * base 10 exponent (range). If the effective frequency is less than 551282408Scy * 10 kHz its phase is synchronized corresponding to the variable phase. 552282408Scy * Phase may be in a range from -360 deg to +360 deg with a resolution 553282408Scy * of 0.1 deg, so the resulting numbers to be stored are in a range of 554282408Scy * -3600 to +3600. 555282408Scy * 556282408Scy * Example:<br> 557282408Scy * Assume the value of freq is 2345 (decimal) and the value of phase is 900. 558282408Scy * If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg. 559282408Scy * If range == 1 the synthesizer will generate a 2345 Hz output frequency 560282408Scy * and so on. 561282408Scy * 562282408Scy * Limitations:<br> 563282408Scy * If freq == 0 the synthesizer is disabled. If range == 0 the least 564282408Scy * significant digit of freq is limited to 0, 3, 5 or 6. The resulting 565282408Scy * frequency is shown in the examples below: 566282408Scy * - freq == 1230 --> 123.0 Hz 567282408Scy * - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) 568282408Scy * - freq == 1235 --> 123.5 Hz 569282408Scy * - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) 570282408Scy * 571282408Scy * If range == ::MAX_SYNTH_RANGE the value of freq must not exceed 1000, so 572282408Scy * the output frequency is limited to 10 MHz (see ::MAX_SYNTH_FREQ_VAL). 573282408Scy * 574282408Scy * @{ */ 57554359Sroberto 576282408Scy#define N_SYNTH_FREQ_DIGIT 4 ///< number of digits to edit 577282408Scy#define MAX_SYNTH_FREQ 1000 ///< if range == ::MAX_SYNTH_RANGE 57854359Sroberto 579282408Scy#define MIN_SYNTH_RANGE 0 580282408Scy#define MAX_SYNTH_RANGE 5 581282408Scy#define N_SYNTH_RANGE ( MAX_SYNTH_RANGE - MIN_SYNTH_RANGE + 1 ) 58254359Sroberto 583282408Scy#define N_SYNTH_PHASE_DIGIT 4 584282408Scy#define MAX_SYNTH_PHASE 3600 58554359Sroberto 58654359Sroberto 587282408Scy#define MAX_SYNTH_FREQ_EDIT 9999 ///< max sequence of digits when editing 58854359Sroberto 58954359Sroberto 590282408Scy/** 591282408Scy * @brief The maximum frequency that can be configured for the synthesizer 592282408Scy */ 593282408Scy#define MAX_SYNTH_FREQ_VAL 10000000UL ///< 10 MHz 594282408Scy/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */ 59554359Sroberto 596282408Scy/** 597282408Scy * @brief The synthesizer's phase is only be synchronized if the frequency is below this limit 598282408Scy */ 599282408Scy#define SYNTH_PHASE_SYNC_LIMIT 10000UL ///< 10 kHz 60054359Sroberto 601282408Scy/** 602282408Scy * A Macro used to determine the position of the decimal point 603282408Scy * when printing the synthesizer frequency as 4 digit value 604282408Scy */ 605282408Scy#define _synth_dp_pos_from_range( _r ) \ 606282408Scy ( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 ) 60754359Sroberto 608282408Scy/** 609282408Scy * @brief Synthesizer frequency units 610282408Scy * 611282408Scy * An initializer for commonly displayed synthesizer frequency units 612282408Scy * (::N_SYNTH_RANGE strings) 613282408Scy */ 614282408Scy#define DEFAULT_FREQ_RANGES \ 615282408Scy{ \ 616282408Scy "Hz", \ 617282408Scy "kHz", \ 618282408Scy "kHz", \ 619282408Scy "kHz", \ 620282408Scy "MHz", \ 621282408Scy "MHz", \ 622282408Scy} 62354359Sroberto 62454359Sroberto 62554359Sroberto 626282408Scy/** 627282408Scy * @brief Synthesizer configuration parameters 628282408Scy */ 629282408Scytypedef struct 630282408Scy{ 631282408Scy int16_t freq; ///< four digits used; scale: 0.1 Hz; e.g. 1234 -> 123.4 Hz 632282408Scy int16_t range; ///< scale factor for freq; 0..::MAX_SYNTH_RANGE 633282408Scy int16_t phase; ///< -::MAX_SYNTH_PHASE..+::MAX_SYNTH_PHASE; >0 -> pulses later 63454359Sroberto 635282408Scy} SYNTH; 63654359Sroberto 637282408Scy#define _mbg_swab_synth( _p ) \ 638282408Scy{ \ 639282408Scy _mbg_swab16( &(_p)->freq ); \ 640282408Scy _mbg_swab16( &(_p)->range ); \ 641282408Scy _mbg_swab16( &(_p)->phase ); \ 642282408Scy} 64354359Sroberto 64454359Sroberto 645282408Scy/** 646282408Scy * @brief Enumeration of synthesizer states 647282408Scy */ 648282408Scyenum SYNTH_STATES 649282408Scy{ 650282408Scy SYNTH_DISABLED, ///< disbled by cfg, i.e. freq == 0.0 651282408Scy SYNTH_OFF, ///< not enabled after power-up 652282408Scy SYNTH_FREE, ///< enabled, but not synchronized 653282408Scy SYNTH_DRIFTING, ///< has initially been sync'd, but now running free 654282408Scy SYNTH_SYNC, ///< fully synchronized 655282408Scy N_SYNTH_STATE ///< the number of known states 656282408Scy}; 65754359Sroberto 65854359Sroberto 659282408Scy/** 660282408Scy * @brief A structure used to report the synthesizer state 661282408Scy */ 662282408Scytypedef struct 663282408Scy{ 664282408Scy uint8_t state; ///< state code as enumerated in ::SYNTH_STATES 665282408Scy uint8_t flags; ///< reserved, currently always 0 66654359Sroberto 667282408Scy} SYNTH_STATE; 66854359Sroberto 669282408Scy#define _mbg_swab_synth_state( _p ) _nop_macro_fnc() 67054359Sroberto 671282408Scy#define SYNTH_FLAG_PHASE_IGNORED 0x01 67254359Sroberto 673282408Scy/** @} defgroup group_synth */ 67454359Sroberto 67554359Sroberto 67654359Sroberto 677282408Scy/** 678282408Scy * @defgroup group_tzdl Time zone / daylight saving parameters 679282408Scy * 680282408Scy * Example: <br> 681282408Scy * For automatic daylight saving enable/disable in Central Europe, 682282408Scy * the variables are to be set as shown below: <br> 683282408Scy * - offs = 3600L one hour from %UTC 684282408Scy * - offs_dl = 3600L one additional hour if daylight saving enabled 685282408Scy * - tm_on = first Sunday from March 25, 02:00:00h ( year |= ::DL_AUTO_FLAG ) 686282408Scy * - tm_off = first Sunday from October 25, 03:00:00h ( year |= ::DL_AUTO_FLAG ) 687282408Scy * - name[0] == "CET " name if daylight saving not enabled 688282408Scy * - name[1] == "CEST " name if daylight saving is enabled 689282408Scy * 690282408Scy * @{ */ 69154359Sroberto 692282408Scy/** 693282408Scy * @brief The name of a time zone 694282408Scy * 695282408Scy * @note Up to 5 printable characters, plus trailing zero 696282408Scy */ 697282408Scytypedef char TZ_NAME[6]; 69854359Sroberto 699282408Scy/** 700282408Scy * @brief Time zone / daylight saving parameters 701282408Scy * 702282408Scy * This structure is used to specify how a device converts on-board %UTC 703282408Scy * to local time, including computation of beginning and end of daylight 704282408Scy * saving time (DST), if required. 705282408Scy * 706282408Scy * @note The ::TZDL structure contains members of type ::TM_GPS to specify 707282408Scy * the times for beginning and end of DST. However, the ::TM_GPS::frac, 708282408Scy * ::TM_GPS::offs_from_utc, and ::TM_GPS::status fields of these ::TZDL::tm_on 709282408Scy * and ::TZDL::tm_off members are ignored for the conversion to local time, 710282408Scy * and thus should be 0. 711282408Scy */ 712282408Scytypedef struct 713282408Scy{ 714282408Scy int32_t offs; ///< standard offset from %UTC to local time [sec] 715282408Scy int32_t offs_dl; ///< additional offset if daylight saving enabled [sec] 716282408Scy TM_GPS tm_on; ///< date/time when daylight saving starts 717282408Scy TM_GPS tm_off; ///< date/time when daylight saving ends 718282408Scy TZ_NAME name[2]; ///< names without and with daylight saving enabled 71954359Sroberto 720282408Scy} TZDL; 72154359Sroberto 722282408Scy/** 723282408Scy * @brief A flag indicating automatic computation of DST 724282408Scy * 725282408Scy * If this flag is or'ed to the year numbers in ::TZDL::tm_on and ::TZDL::tm_off 726282408Scy * then daylight saving is computed automatically year by year. 727282408Scy */ 728282408Scy#define DL_AUTO_FLAG 0x8000 72954359Sroberto 730282408Scy/** @} defgroup group_tzdl */ 73154359Sroberto 73254359Sroberto 73354359Sroberto 734282408Scy/** 735282408Scy * @brief Antenna status and error at reconnect information 736282408Scy * 737282408Scy * The structure below reflects the status of the antenna, 738282408Scy * the times of last disconnect/reconnect, and the board's 739282408Scy * clock offset when it has synchronized again after the 740282408Scy * disconnection interval. 741282408Scy * 742282408Scy * @note ::ANT_INFO::status changes back to ::ANT_RECONN only 743282408Scy * after the antenna has been reconnected <b>and</b> the 744282408Scy * receiver has re-synchronized to the satellite signal. 745282408Scy * In this case ::ANT_INFO::delta_t reports the time offset 746282408Scy * before resynchronization, i.e. how much the internal 747282408Scy * time has drifted while the antenna was disconnected. 748282408Scy */ 749282408Scytypedef struct 750282408Scy{ 751282408Scy int16_t status; ///< current status of antenna, see ::ANT_STATUS_CODES 752282408Scy TM_GPS tm_disconn; ///< time of antenna disconnect 753282408Scy TM_GPS tm_reconn; ///< time of antenna reconnect 754282408Scy int32_t delta_t; ///< clock offs at reconn. time in 1/::RECEIVER_INFO::ticks_per_sec units 75554359Sroberto 756282408Scy} ANT_INFO; 75754359Sroberto 75854359Sroberto 759282408Scy/** 760282408Scy * @brief Status code used with ::ANT_INFO::status 761282408Scy */ 762282408Scyenum ANT_STATUS_CODES 763282408Scy{ 764282408Scy ANT_INVALID, ///< No other fields valid since antenna has not yet been disconnected 765282408Scy ANT_DISCONN, ///< Antenna is disconnected, tm_reconn and delta_t not yet set 766282408Scy ANT_RECONN, ///< Antenna has been disconnect, and receiver sync. after reconnect, so all fields valid 767282408Scy N_ANT_STATUS_CODES ///< the number of known status codes 768282408Scy}; 76954359Sroberto 77054359Sroberto 77154359Sroberto 772282408Scy/** 773282408Scy * @brief Summary of configuration and health data of all satellites 774282408Scy */ 775282408Scytypedef struct 776282408Scy{ 777282408Scy CSUM csum; ///< checksum of the remaining bytes 778282408Scy int16_t valid; ///< flag data are valid 77954359Sroberto 780282408Scy T_GPS tot_51; ///< time of transmission, page 51 781282408Scy T_GPS tot_63; ///< time of transmission, page 63 782282408Scy T_GPS t0a; ///< complete reference time almanac 78354359Sroberto 784282408Scy CFG cfg[N_SVNO_GPS]; ///< 4 bit SV configuration code from page 63 785282408Scy HEALTH health[N_SVNO_GPS]; ///< 6 bit SV health codes from pages 51, 63 78654359Sroberto 787282408Scy} CFGH; 78854359Sroberto 78954359Sroberto 79054359Sroberto 791282408Scy/** 792282408Scy * @brief GPS %UTC correction parameters 793282408Scy * 794282408Scy * %UTC correction parameters basically as sent by the GPS satellites. 795282408Scy * 796282408Scy * The csum field is only used by the card's firmware to check the 797282408Scy * consistency of the structure in non-volatile memory. 798282408Scy * 799282408Scy * The field labeled valid indicates if the parameter set is valid, i.e. 800282408Scy * if it contains data received from the satellites. 801282408Scy * 802282408Scy * t0t, A0 and A1 contain fractional correction parameters for the current 803282408Scy * GPS-%UTC time offset in addition to the whole seconds. This is evaluated 804282408Scy * by the receivers' firmware to convert GPS time to %UTC time. 805282408Scy * 806282408Scy * The delta_tls field contains the current full seconds offset between 807282408Scy * GPS time and %UTC, which corresponds to the number of leap seconds inserted 808282408Scy * into the %UTC time scale since GPS was put into operation in January 1980. 809282408Scy * 810282408Scy * delta_tlfs holds the number of "future" leap seconds, i.e. the %UTC offset 811282408Scy * after the next leap second event defined by WNlsf and DNt. 812282408Scy * 813282408Scy * The fields WNlsf and DNt specify the GPS week number and the day number 814282408Scy * in that week for the end of which a leap second has been scheduled. 815282408Scy * 816282408Scy * @note: The satellites transmit WNlsf only as a signed 8 bit value, so it 817282408Scy * can only define a point in time which is +/- 127 weeks off the current time. 818282408Scy * The firmware tries to expand this based on the current week number, but 819282408Scy * the result is ambiguous if the leap second occurs or occurred more 820282408Scy * than 127 weeks in the future or past. 821282408Scy * 822282408Scy * So the leap second date should <b>only</b> be evaluated and displayed 823282408Scy * in a user interface if the fields delta_tls and delta_tlsf have 824282408Scy * different values, in which case there is indeed a leap second announcement 825282408Scy * inside the +/- 127 week range. 826282408Scy * 827282408Scy * @note In the original code the type of A0 and A1 is double. 828282408Scy */ 829282408Scytypedef struct 830282408Scy{ 831282408Scy CSUM csum; ///< Checksum of the remaining bytes 832282408Scy int16_t valid; ///< Flag indicating %UTC parameters are valid 83354359Sroberto 834282408Scy T_GPS t0t; ///< Reference Time %UTC Parameters [wn|sec] 835282408Scy l_fp A0; ///< +- Clock Correction Coefficient 0 [sec] 836282408Scy l_fp A1; ///< +- Clock Correction Coefficient 1 [sec/sec] 83754359Sroberto 838282408Scy uint16_t WNlsf; ///< Week number of nearest leap second 839282408Scy int16_t DNt; ///< The day number at the end of which a leap second occurs 840282408Scy int8_t delta_tls; ///< Current %UTC offset to GPS system time [sec] 841282408Scy int8_t delta_tlsf; ///< Future %UTC offset to GPS system time after next leap second transition [sec] 84254359Sroberto 843282408Scy} UTC; 84454359Sroberto 84554359Sroberto 846282408Scy/** 847282408Scy * @brief GPS ASCII message 848282408Scy */ 849282408Scytypedef struct 850282408Scy{ 851282408Scy CSUM csum; ///< checksum of the remaining bytes */ 852282408Scy int16_t valid; ///< flag data are valid 853282408Scy char s[23]; ///< 22 chars GPS ASCII message plus trailing zero 85454359Sroberto 855282408Scy} ASCII_MSG; 85654359Sroberto 85754359Sroberto 858282408Scy/** 859282408Scy * @brief Ephemeris parameters of one specific satellite 860282408Scy * 861282408Scy * Needed to compute the position of a satellite at a given time with 862282408Scy * high precision. Valid for an interval of 4 to 6 hours from start 863282408Scy * of transmission. 864282408Scy */ 865282408Scytypedef struct 866282408Scy{ 867282408Scy CSUM csum; ///< checksum of the remaining bytes 868282408Scy int16_t valid; ///< flag data are valid 86954359Sroberto 870282408Scy HEALTH health; ///< health indication of transmitting SV [---] 871282408Scy IOD IODC; ///< Issue Of Data, Clock 872282408Scy IOD IODE2; ///< Issue of Data, Ephemeris (Subframe 2) 873282408Scy IOD IODE3; ///< Issue of Data, Ephemeris (Subframe 3) 874282408Scy T_GPS tt; ///< time of transmission 875282408Scy T_GPS t0c; ///< Reference Time Clock [---] 876282408Scy T_GPS t0e; ///< Reference Time Ephemeris [---] 87754359Sroberto 878282408Scy l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)] 879282408Scy l_fp e; ///< Eccentricity [---] 880282408Scy l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad] 881282408Scy l_fp omega; ///< +- Argument of Perigee [rad] 882282408Scy l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad] 883282408Scy l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec] 884282408Scy l_fp deltan; ///< +- Mean Motion Diff. from computed value [rad/sec] 885282408Scy l_fp i0; ///< +- Inclination Angle [rad] 886282408Scy l_fp idot; ///< +- Rate of Inclination Angle [rad/sec] 887282408Scy l_fp crc; ///< +- Cosine Corr. Term to Orbit Radius [m] 888282408Scy l_fp crs; ///< +- Sine Corr. Term to Orbit Radius [m] 889282408Scy l_fp cuc; ///< +- Cosine Corr. Term to Arg. of Latitude [rad] 890282408Scy l_fp cus; ///< +- Sine Corr. Term to Arg. of Latitude [rad] 891282408Scy l_fp cic; ///< +- Cosine Corr. Term to Inclination Angle [rad] 892282408Scy l_fp cis; ///< +- Sine Corr. Term to Inclination Angle [rad] 89354359Sroberto 894282408Scy l_fp af0; ///< +- Clock Correction Coefficient 0 [sec] 895282408Scy l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec] 896282408Scy l_fp af2; ///< +- Clock Correction Coefficient 2 [sec/sec^2] 897282408Scy l_fp tgd; ///< +- estimated group delay differential [sec] 898282408Scy 899282408Scy uint16_t URA; ///< predicted User Range Accuracy 900282408Scy 901282408Scy uint8_t L2code; ///< code on L2 channel [---] 902282408Scy uint8_t L2flag; ///< L2 P data flag [---] 903282408Scy 90454359Sroberto} EPH; 90554359Sroberto 90654359Sroberto 90754359Sroberto 908282408Scy/** 909282408Scy * @brief Almanac parameters of one specific satellite 910282408Scy * 911282408Scy * A reduced precision set of parameters used to check if a satellite 912282408Scy * is in view at a given time. Valid for an interval of more than 7 days 913282408Scy * from start of transmission. 914282408Scy */ 915282408Scytypedef struct 916282408Scy{ 917282408Scy CSUM csum; ///< checksum of the remaining bytes 918282408Scy int16_t valid; ///< flag data are valid 91954359Sroberto 920282408Scy HEALTH health; ///< [---] 921282408Scy T_GPS t0a; ///< Reference Time Almanac [sec] 92254359Sroberto 923282408Scy l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)] 924282408Scy l_fp e; ///< Eccentricity [---] 925282408Scy 926282408Scy l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad] 927282408Scy l_fp omega; ///< +- Argument of Perigee [rad] 928282408Scy l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad] 929282408Scy l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec] 930282408Scy l_fp deltai; ///< +- [rad] 931282408Scy l_fp af0; ///< +- Clock Correction Coefficient 0 [sec] 932282408Scy l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec] 933282408Scy 93454359Sroberto} ALM; 93554359Sroberto 93654359Sroberto 93754359Sroberto 938282408Scy/** 939282408Scy * @brief Ionospheric correction parameters 940282408Scy */ 941282408Scytypedef struct 942282408Scy{ 943282408Scy CSUM csum; ///< checksum of the remaining bytes 944282408Scy int16_t valid; ///< flag data are valid 94554359Sroberto 946282408Scy l_fp alpha_0; ///< Ionosph. Corr. Coeff. Alpha 0 [sec] 947282408Scy l_fp alpha_1; ///< Ionosph. Corr. Coeff. Alpha 1 [sec/deg] 948282408Scy l_fp alpha_2; ///< Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2] 949282408Scy l_fp alpha_3; ///< Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3] 95054359Sroberto 951282408Scy l_fp beta_0; ///< Ionosph. Corr. Coeff. Beta 0 [sec] 952282408Scy l_fp beta_1; ///< Ionosph. Corr. Coeff. Beta 1 [sec/deg] 953282408Scy l_fp beta_2; ///< Ionosph. Corr. Coeff. Beta 2 [sec/deg^2] 954282408Scy l_fp beta_3; ///< Ionosph. Corr. Coeff. Beta 3 [sec/deg^3] 95554359Sroberto 95654359Sroberto} IONO; 95754359Sroberto 958282408Scy 959282408Scy 960282408Scyvoid mbg_tm_str (char **, TM_GPS *, int, int); 961280849Scyvoid mbg_tgps_str (char **, T_GPS *, int); 962280849Scyvoid get_mbg_header (unsigned char **, GPS_MSG_HDR *); 963280849Scyvoid put_mbg_header (unsigned char **, GPS_MSG_HDR *); 964280849Scyvoid get_mbg_sw_rev (unsigned char **, SW_REV *); 965280849Scyvoid get_mbg_ascii_msg (unsigned char **, ASCII_MSG *); 966280849Scyvoid get_mbg_svno (unsigned char **, SVNO *); 967280849Scyvoid get_mbg_health (unsigned char **, HEALTH *); 968280849Scyvoid get_mbg_cfg (unsigned char **, CFG *); 969280849Scyvoid get_mbg_tgps (unsigned char **, T_GPS *); 970282408Scyvoid get_mbg_tm (unsigned char **, TM_GPS *); 971280849Scyvoid get_mbg_ttm (unsigned char **, TTM *); 972280849Scyvoid get_mbg_synth (unsigned char **, SYNTH *); 973280849Scyvoid get_mbg_tzdl (unsigned char **, TZDL *); 974280849Scyvoid get_mbg_antinfo (unsigned char **, ANT_INFO *); 975280849Scyvoid get_mbg_cfgh (unsigned char **, CFGH *); 976280849Scyvoid get_mbg_utc (unsigned char **, UTC *); 977280849Scyvoid get_mbg_lla (unsigned char **, LLA); 978280849Scyvoid get_mbg_xyz (unsigned char **, XYZ); 979280849Scyvoid get_mbg_portparam (unsigned char **, PORT_PARM *); 980280849Scyvoid get_mbg_eph (unsigned char **, EPH *); 981280849Scyvoid get_mbg_alm (unsigned char **, ALM *); 982280849Scyvoid get_mbg_iono (unsigned char **, IONO *); 98354359Sroberto 984282408ScyCSUM mbg_csum (unsigned char *, unsigned int); 98554359Sroberto 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