diff options
Diffstat (limited to 'c/mbglib/include/gpsdefs.h')
-rw-r--r-- | c/mbglib/include/gpsdefs.h | 3215 |
1 files changed, 3215 insertions, 0 deletions
diff --git a/c/mbglib/include/gpsdefs.h b/c/mbglib/include/gpsdefs.h new file mode 100644 index 0000000..c638841 --- /dev/null +++ b/c/mbglib/include/gpsdefs.h @@ -0,0 +1,3215 @@ + +/************************************************************************** + * + * $Id: gpsdefs.h 1.72 2008/11/28 09:26:21Z daniel REL_M $ + * + * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany + * + * Description: + * General definitions to be used with Meinberg clocks. + * These definitions have initially be used with GPS devices only. + * However, more and more Meinberg non-GPS devices also use some of + * these definitions. + * + * ----------------------------------------------------------------------- + * $Log: gpsdefs.h $ + * Revision 1.72 2008/11/28 09:26:21Z daniel + * Added definitions to support WWVB511 + * Revision 1.71 2008/10/31 14:31:44Z martin + * Added definitions for TCR170PEX. + * Revision 1.70 2008/09/18 11:14:39 martin + * Added definitions to support GEN170. + * Revision 1.69 2008/09/15 14:16:17 martin + * Added more macros to convert the endianess of structures. + * Added N_COM_HS to the enumeration of handshake modes. + * Added MBG_PS_... codes. + * Revision 1.68 2008/08/25 10:51:13 martin + * Added definitions for PTP270PEX and FRC511PEX. + * Revision 1.67 2008/07/17 08:54:52Z martin + * Added macros to convert the endianess of structures. + * Added multiref fixed frequency source. + * Revision 1.66 2008/05/19 14:49:07 daniel + * Renamed s_addr to start_addr in FPGA_INFO. + * Revision 1.65 2008/05/19 09:00:01Z martin + * Added definitions for GPS162. + * Added FPGA_INFO and GPS_HAS_FPGA. + * Added FPGA_START_INFO and associated definitions. + * Added new XMRS status XMRS_..._NOT_SETTLED. + * Added initializer XMULTI_REF_STATUS_INVALID. + * Revision 1.64 2008/01/17 11:50:33Z daniel + * Made IGNORE_LOCK bit maskable. + * Revision 1.63 2008/01/17 11:42:09Z daniel + * Made comments compatible for Doxygen parser. + * No sourcecode changes. + * Revision 1.62 2007/11/15 13:23:33Z martin + * Decide whether other Meinberg headers are to be included depending on whether + * CLOCK_MEINBERG is defined (as with NTP) or not. Previous versions checked + * for "PACKAGE" which is also defined by the Borland C++ build environment, though. + * Revision 1.61 2007/11/13 13:28:54 daniel + * Added definitions to support GPS170PEX. + * Revision 1.60 2007/09/13 12:37:35Z martin + * Modified and added initializers for TZDL. + * Added multiref source PTP over E1. + * Added codes for MSF511 and GRC170 devices. + * Modified XMULTI_REF_SETTINGS and XMULTI_REF_STATUS structures. + * Avoid inclusion of other Meinberg headers in non-Meinberg projects. + * Added device classification macros _mbg_rcvr_is_...(). + * Modified feature name string initializer for non-GPS devices. + * Updated some comments. + * Removed some obsolete comments. + * Revision 1.59 2007/07/19 07:41:56Z martin + * Added symbol MBG_REF_OFFS_NOT_CFGD. + * Revision 1.58 2007/05/21 15:46:44Z martin + * Fixed a typo. + * Revision 1.57 2007/03/29 12:20:43 martin + * Fixed some TZDL initializers. + * Revision 1.56 2007/02/14 14:17:10Z andre + * bug fixed in mask XMRS_MSK_NO_CONN + * Revision 1.55 2007/02/06 16:23:18Z martin + * Added definitions for AM511. + * Made SVNO unsigned. + * Added support for OPT_SETTINGS. + * Added XMULTI_REF_... definitions. + * Added string initializer DEFAULT_FREQ_RANGES. + * Revision 1.54 2007/01/04 11:39:39Z martin + * Added definitions for TCR511. + * Added definition GPS_FEAT_5_MHZ. + * Updated some comments related to duplicate features/options + * IGNORE_LOCK and EMU_SYNC. + * Revision 1.53 2006/12/13 09:31:49 martin + * Added feature flag for ignore_lock. + * Revision 1.52 2006/12/12 15:47:18 martin + * Added MBG_DEBUG_STATUS type and associated definitions. + * Added definition GPS_HAS_REF_OFFS. + * Moved PCPS_REF_OFFS and associated definitions from pcpsdefs.h here + * and renamed them to MBG_REF_OFFS, etc. + * Revision 1.51 2006/10/23 15:31:27 martin + * Added definitions for GPS170. + * Added definitions for new multi_ref sources IRIG, NTP, and PTP. + * Added some definitions useful when editing synth frequency. + * Revision 1.50 2006/08/25 09:29:28Z martin + * Added structure NANO_TIME. + * Revision 1.49 2006/08/09 07:06:42Z martin + * New TM_GPS status flag TM_EXT_SYNC. + * Revision 1.48 2006/08/08 12:51:20Z martin + * Added definitions for IRIG codes B006/B126 and B007/B127. + * Revision 1.47 2006/07/06 08:41:45Z martin + * Added definition of MEINBERG_MAGIC. + * Revision 1.46 2006/06/21 14:08:53Z martin + * Added masks of IRIG codes which contain time zone information. + * Revision 1.45 2006/06/15 12:13:32Z martin + * Added MULTI_REF_STATUS and associated flags. + * Added ROM_CSUM, RCV_TIMEOUT, and IGNORE_LOCK types. + * Revision 1.44 2006/05/18 09:34:41Z martin + * Added definitions for POUT max. pulse_len and max timeout. + * Changed comment for POUT_SETTINGS::timeout: + * Units are minutes, not seconds. + * Added definition for MAX_POUT_TIME_STR_PORTS. + * Added definitions for POUT mode 10MHz. + * Added hint strings for POUT modes. + * Added definitions for PZF511. + * Revision 1.43 2006/01/24 07:53:29Z martin + * New TM_GPS status flag TM_HOLDOVER. + * Revision 1.42 2005/11/24 14:53:22Z martin + * Added definitions for manchester encoded DC IRIG frames. + * Added POUT_TIMESTR and related definitions. + * Revision 1.41 2005/11/03 15:06:59Z martin + * Added definitions to support GPS170PCI. + * Revision 1.40 2005/10/28 08:58:29Z martin + * Added definitions for OCXO_DHQ. + * Revision 1.39 2005/09/08 14:06:00Z martin + * Added definition SYNTH_PHASE_SYNC_LIMIT. + * Revision 1.38 2005/08/18 10:27:35 andre + * added definitions for GPS164, + * added POUT_TIMECODE, + * struct SCU_STAT changed, + * ulong flags changed into two byte clk_info and ushort flags + * Revision 1.37 2005/05/02 14:44:55Z martin + * Added structure SYNTH_STATE and associated definitions. + * Revision 1.36 2005/03/29 12:44:07Z martin + * New RECEIVER_INFO::flags code: GPS_IRIG_FO_IN + * Revision 1.35 2004/12/09 14:04:38Z martin + * Changed max synth freq from 12 MHz to 10 MHz. + * Revision 1.34 2004/11/23 16:20:09Z martin + * Added bit definitions for the existing TTM status bit masks. + * Revision 1.33 2004/11/09 12:39:59Z martin + * Redefined interface data types using C99 fixed-size definitions. + * Added model code and name for TCR167PCI. + * New type GPS_CMD. + * Defined type BVAR_STAT and associated flags. + * Revision 1.32 2004/09/20 12:46:25 andre + * Added structures and definitions for SCU board. + * Revision 1.31 2004/07/08 08:30:36Z martin + * Added feature GPS_FEAT_RCV_TIMEOUT. + * Revision 1.30 2004/06/21 13:38:42 martin + * New flag MBG_OPT_BIT_EMU_SYNC/MBG_OPT_FLAG_EMU_SYNC + * lets the receicer emulate/pretend to be always synchronized. + * Revision 1.30 2004/06/21 13:35:46Z martin + * Revision 1.29 2004/06/16 12:47:53Z martin + * Moved OPT_SETTINGS related definitions from pcpsdefs.h + * here and renamed symbols from PCPS_.. to to MBG_... + * Revision 1.28 2004/03/26 10:37:00Z martin + * Added definitions to support multiple ref sources. + * Added definitions OSC_DAC_RANGE, OSC_DAC_BIAS. + * Revision 1.27 2004/03/08 14:06:45Z martin + * New model code and name for GPS169PCI. + * Existing feature GPS_FEAT_IRIG has been + * renamed to GPS_FEAT_IRIG_TX. + * Added feature GPS_FEAT_IRIG_RX. + * Added IPv4 LAN interface feature flags. + * Renamed IFLAGS_IGNORE_TFOM to IFLAGS_DISABLE_TFOM. + * Revision 1.26 2003/12/05 12:28:20Z martin + * Added some codes used with IRIG cfg. + * Revision 1.25 2003/10/29 16:18:14Z martin + * Added 7N2 to DEFAULT_GPS_FRAMINGS_GP2021. + * Revision 1.24 2003/09/30 08:49:48Z martin + * New flag TM_LS_ANN_NEG which is set in addition to + * TM_LS_ANN if next leap second is negative. + * Revision 1.23 2003/08/26 14:32:33Z martin + * Added some initializers for commonly used + * TZDL configurations. + * Revision 1.22 2003/04/25 10:18:11 martin + * Fixed typo inside an IRIG name string initializer. + * Revision 1.21 2003/04/15 09:18:48 martin + * New typedef ANT_CABLE_LEN. + * Revision 1.20 2003/04/03 11:03:44Z martin + * Extended definitions for IRIG support. + * Revision 1.19 2003/01/31 13:38:20 MARTIN + * Modified type of RECEIVER_INFO.fixed_freq field. + * Revision 1.18 2002/10/28 09:24:07 MARTIN + * Added/renamed some POUT related symbols. + * Revision 1.17 2002/09/05 10:58:39 MARTIN + * Renamed some symbols related to programmable outputs. + * Revision 1.16 2002/08/29 08:04:47 martin + * Renamed structure POUT_PROG to POUT_SETTINGS. + * New structures POUT_SETTINGS_IDX, POUT_INFO, + * POUT_INFO_IDX and associated definitions. + * Updated some comments. + * Revision 1.15 2002/07/17 07:39:39Z Andre + * comma added in definition DEFAULT_GPS_OSC_NAMES + * Revision 1.14 2002/06/27 12:17:29Z MARTIN + * Added new oscillator code TCXO_MQ. + * Added initializer for oscillator names. + * Added initializer for oscillator list ordered by quality. + * Revision 1.13 2002/05/08 08:16:03 MARTIN + * Added GPS_OSC_CFG_SUPP for RECEIVER_INFO.flags. + * Fixed some comments. + * Revision 1.12 2002/03/14 13:45:56 MARTIN + * Changed type CSUM from short to ushort. + * Revision 1.11 2002/03/01 12:29:30 Andre + * Added GPS_MODEL_GPS161 and GPS_MODEL_NAME_GPS161. + * Revision 1.10 2002/02/25 08:02:33Z MARTIN + * Added array of chars to union IDENT. + * Revision 1.9 2002/01/29 15:21:46 MARTIN + * Added new field "reserved" to struct SW_REV to fix C166 data + * alignment/structure size. Converted structure IDENT to a union. + * The changes above should not affect existing monitoring programs. + * New status flag TM_ANT_SHORT. + * New structure RECEIVER_INFO and associated definitions to + * enhance control from monitoring programs. + * New structures PORT_INFO, STR_TYPE_INFO, and associated + * definitions to simplify and unify configuration from external programs. + * New structures IRIG_INFO and POUT_PROG_IDX to configure an + * optional IRIG interface and programmable pulse outputs. + * Modified some comments. + * Revision 1.8 2001/03/30 11:44:11 MARTIN + * Control alignment of structures from new file use_pack.h. + * Defined initializers with valid baud rate and framing parameters. + * Modified some comments. + * Revision 1.7 2001/03/01 08:09:22 MARTIN + * Modified preprocessor syntax. + * Revision 1.6 2000/07/21 14:04:33 MARTIN + * Added som #if directives to protect structures against being multiply + * defined. + * Modified some comments. + * Comments using characters for +/- and degree now include ASCII + * characters only. + * + **************************************************************************/ + +#ifndef _GPSDEFS_H +#define _GPSDEFS_H + + +/* Other headers to be included */ + +#if defined( HAVE_CONFIG_H ) + // this is mainly to simplify usage in non-Meinberg projects + #include <config.h> +#endif + +// CLOCK_MEINBERG is defined in NTP's config.h if configured +// to support Meinberg clocks. +#if !defined( CLOCK_MEINBERG ) + // avoid having to use these headers in non-Meinberg projects + #include <words.h> + #include <use_pack.h> +#endif + + +#if defined( _USE_PACK ) // set byte alignment + #pragma pack( 1 ) +#endif + + +/* Start of header body */ + +/* "magic" number */ +#define MEINBERG_MAGIC 0x6AAC + +#define MIN_SVNO 1 /* min. SV number */ +#define MAX_SVNO 32 /* max. SV number */ +#define N_SVNO ( MAX_SVNO - MIN_SVNO + 1) /* number of possibly active SVs */ + + +#define GPS_ID_STR_LEN 16 +#define GPS_ID_STR_SIZE ( GPS_ID_STR_LEN + 1 ) + +#define GPS_EPLD_STR_LEN 8 +#define GPS_EPLD_STR_SIZE ( GPS_EPLD_STR_LEN + 1 ) + + +#define DEFAULT_GPS_TICKS_PER_SEC 10000000L /* system time base */ + +#if !defined( GPS_TICKS_PER_SEC ) + /* + * The actual ticks per seconds may vary for different + * GPS receiver models. If this is the case, the receiver + * model support the RECEIVER_INFO structure which contains + * the actual value. + */ + #define GPS_TICKS_PER_SEC DEFAULT_GPS_TICKS_PER_SEC +#endif + + +typedef uint16_t SVNO; /* the number of a SV */ +typedef uint16_t HEALTH; /* a SV's health code */ +typedef uint16_t CFG; /* a SV's configuration code */ +typedef uint16_t IOD; /* Issue-Of-Data code */ + + +/* the type of various checksums */ + +#ifndef _CSUM_DEFINED + typedef uint16_t CSUM; + #define _CSUM_DEFINED +#endif + + +/** + The type which is used to pass a cmd code via serial port, or bus. + The cmd codes are defined in gpsserio.h and pcpsdefs.h. +*/ +typedef uint16_t GPS_CMD; + +#define _mbg_swab_gps_cmd( _p ) _mbg_swab16( _p ) + + +/** + A struct used to hold the software revision information + */ +typedef struct +{ + uint16_t code; /**< e.g. 0x0120 means rev. 1.20 */ + char name[GPS_ID_STR_SIZE]; /**< used to identify customized versions */ + uint8_t reserved; /**< yield even structure size */ +} SW_REV; + +#define _mbg_swab_sw_rev( _p ) \ +{ \ + _mbg_swab16( &(_p)->code ); \ +} + + + +typedef uint16_t BVAR_STAT; /**< holds status of battery buffered vars */ + +#define _mbg_swab_bvar_stat( _p ) _mbg_swab16( (_p) ) + +/** + The bits defined below are set in BVAR_STAT if the corresponding + parameters are NOT valid and complete: +*/ +enum +{ + BVAR_BIT_CFGH_INVALID, + BVAR_BIT_ALM_NOT_COMPLETE, + BVAR_BIT_UTC_INVALID, + BVAR_BIT_IONO_INVALID, + BVAR_BIT_RCVR_POS_INVALID, + N_BVAR_BIT // number of defined bits +}; + +#define BVAR_CFGH_INVALID ( 1UL << BVAR_BIT_CFGH_INVALID ) +#define BVAR_ALM_NOT_COMPLETE ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ) +#define BVAR_UTC_INVALID ( 1UL << BVAR_BIT_UTC_INVALID ) +#define BVAR_IONO_INVALID ( 1UL << BVAR_BIT_IONO_INVALID ) +#define BVAR_RCVR_POS_INVALID ( 1UL << BVAR_BIT_RCVR_POS_INVALID ) + +/**< bit mask for all defined bits */ +#define BVAR_MASK ( ( 1UL << N_BVAR_BIT ) - 1 ) + + + +/* a struct used to hold a fixed frequency value */ +/* frequ[kHz] = khz_val * 10^range */ + +typedef struct +{ + uint16_t khz_val; /* the base frequency in [kHz] */ + int16_t range; /* an optional base 10 exponent */ +} FIXED_FREQ_INFO; + +#define _mbg_swab_fixed_freq_info( _p ) \ +{ \ + _mbg_swab16( &(_p)->khz_val ); \ + _mbg_swab16( &(_p)->range ); \ +} + + + +/* + * The following code defines features and properties + * of the various GPS receivers. Older GPS receivers + * may require a recent firmvare version to support + * this, or may not support this at all. + */ + +/** + * The structure is ordered in a way that all fields + * except chars or arrays of chars are word-aligned. + */ +typedef struct +{ + uint16_t model_code; /**< identifier for receiver model */ + SW_REV sw_rev; /**< software revision and ID */ + char model_name[GPS_ID_STR_SIZE]; /**< ASCIIZ, name of receiver model */ + char sernum[GPS_ID_STR_SIZE]; /**< ASCIIZ, serial number */ + char epld_name[GPS_EPLD_STR_SIZE]; /**< ASCIIZ, file name of EPLD image */ + uint8_t n_channels; /**< number of sats to be tracked simultaneously */ + uint32_t ticks_per_sec; /**< resolution of fractions of seconds */ + uint32_t features; /**< optional features, see below */ + FIXED_FREQ_INFO fixed_freq; /**< optional non-standard fixed frequency */ + uint8_t osc_type; /**< type of installed oscillator, see below */ + uint8_t osc_flags; /**< oscillator flags, see below */ + uint8_t n_ucaps; /**< number of user time capture inputs */ + uint8_t n_com_ports; /**< number of on-board serial ports */ + uint8_t n_str_type; /**< max num of string types supported by any port */ + uint8_t n_prg_out; /**< number of programmable pulse outputs */ + uint16_t flags; /**< additional information, see below */ +} RECEIVER_INFO; + +#define _mbg_swab_receiver_info( _p ) \ +{ \ + _mbg_swab16( &(_p)->model_code ); \ + _mbg_swab_sw_rev( &(_p)->sw_rev ); \ + _mbg_swab16( &(_p)->ticks_per_sec ); \ + _mbg_swab32( &(_p)->features ); \ + _mbg_swab_fixed_freq_info( &(_p)->fixed_freq ); \ + _mbg_swab16( &(_p)->flags ); \ +} + + +/** + * Valid codes for RECEIVER_INFO.model_code: + */ +enum +{ + GPS_MODEL_UNKNOWN, + GPS_MODEL_GPS166, + GPS_MODEL_GPS167, + GPS_MODEL_GPS167SV, + GPS_MODEL_GPS167PC, + GPS_MODEL_GPS167PCI, + GPS_MODEL_GPS163, + GPS_MODEL_GPS168PCI, + GPS_MODEL_GPS161, + GPS_MODEL_GPS169PCI, + GPS_MODEL_TCR167PCI, + GPS_MODEL_GPS164, + GPS_MODEL_GPS170PCI, + GPS_MODEL_PZF511, + GPS_MODEL_GPS170, + GPS_MODEL_TCR511, + GPS_MODEL_AM511, + GPS_MODEL_MSF511, + GPS_MODEL_GRC170, + GPS_MODEL_GPS170PEX, + GPS_MODEL_GPS162, + GPS_MODEL_PTP270PEX, + GPS_MODEL_FRC511PEX, + GPS_MODEL_GEN170, + GPS_MODEL_TCR170PEX, + GPS_MODEL_WWVB511, + N_GPS_MODEL + /* If new model codes are added then care must be taken + * to update the associated string initializers below + * accordingly, and to check whether the classification macros + * also cover the new model names. */ +}; + + + + +/* + * String initializers for each of the GPS + * receiver models enum'ed above: + */ +#define GPS_MODEL_NAME_UNKNOWN "(unknown)" +#define GPS_MODEL_NAME_GPS166 "GPS166" +#define GPS_MODEL_NAME_GPS167 "GPS167" +#define GPS_MODEL_NAME_GPS167SV "GPS167SV" +#define GPS_MODEL_NAME_GPS167PC "GPS167PC" +#define GPS_MODEL_NAME_GPS167PCI "GPS167PCI" +#define GPS_MODEL_NAME_GPS163 "GPS163" +#define GPS_MODEL_NAME_GPS168PCI "GPS168PCI" +#define GPS_MODEL_NAME_GPS161 "GPS161" +#define GPS_MODEL_NAME_GPS169PCI "GPS169PCI" +#define GPS_MODEL_NAME_TCR167PCI "TCR167PCI" +#define GPS_MODEL_NAME_GPS164 "GPS164" +#define GPS_MODEL_NAME_GPS170PCI "GPS170PCI" +#define GPS_MODEL_NAME_PZF511 "PZF511" +#define GPS_MODEL_NAME_GPS170 "GPS170" +#define GPS_MODEL_NAME_TCR511 "TCR511" +#define GPS_MODEL_NAME_AM511 "AM511" +#define GPS_MODEL_NAME_MSF511 "MSF511" +#define GPS_MODEL_NAME_GRC170 "GRC170" +#define GPS_MODEL_NAME_GPS170PEX "GPS170PEX" +#define GPS_MODEL_NAME_GPS162 "GPS162" +#define GPS_MODEL_NAME_PTP270PEX "PTP270PEX" +#define GPS_MODEL_NAME_FRC511PEX "FRC511PEX" +#define GPS_MODEL_NAME_GEN170 "GEN170" +#define GPS_MODEL_NAME_TCR170PEX "TCR170PEX" +#define GPS_MODEL_NAME_WWVB511 "WWVB511" + + +/* + * The definition below can be used to initialize + * an array of N_GPS_MODEL type name strings. + * Including the trailing 0, each name must not + * exceed GPS_ID_STR_SIZE chars. + */ +#define DEFAULT_GPS_MODEL_NAMES \ +{ \ + GPS_MODEL_NAME_UNKNOWN, \ + GPS_MODEL_NAME_GPS166, \ + GPS_MODEL_NAME_GPS167, \ + GPS_MODEL_NAME_GPS167SV, \ + GPS_MODEL_NAME_GPS167PC, \ + GPS_MODEL_NAME_GPS167PCI, \ + GPS_MODEL_NAME_GPS163, \ + GPS_MODEL_NAME_GPS168PCI, \ + GPS_MODEL_NAME_GPS161, \ + GPS_MODEL_NAME_GPS169PCI, \ + GPS_MODEL_NAME_TCR167PCI, \ + GPS_MODEL_NAME_GPS164, \ + GPS_MODEL_NAME_GPS170PCI, \ + GPS_MODEL_NAME_PZF511, \ + GPS_MODEL_NAME_GPS170, \ + GPS_MODEL_NAME_TCR511, \ + GPS_MODEL_NAME_AM511, \ + GPS_MODEL_NAME_MSF511, \ + GPS_MODEL_NAME_GRC170, \ + GPS_MODEL_NAME_GPS170PEX, \ + GPS_MODEL_NAME_GPS162, \ + GPS_MODEL_NAME_PTP270PEX, \ + GPS_MODEL_NAME_FRC511PEX, \ + GPS_MODEL_NAME_GEN170, \ + GPS_MODEL_NAME_TCR170PEX, \ + GPS_MODEL_NAME_WWVB511 \ +} + + +/* + * The macros below can be used to classify a receiver, + * e.g. depending on the time source and/or depending on + * whether it's a plug-in card or an external device. + */ + +#define _mbg_rcvr_is_plug_in( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "PC" ) || \ + ( strstr( (_p_ri)->model_name, "PEX" ) ) + +#define _mbg_rcvr_is_gps( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "GPS" ) ) + +#define _mbg_rcvr_is_gps_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_gps( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_irig( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "TCR" ) ) + +#define _mbg_rcvr_is_irig_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_irig( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_dcf77_am( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "AM" ) ) + +#define _mbg_rcvr_is_dcf77_am_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_dcf77_am( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_dcf77_pzf( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "PZF" ) ) + +#define _mbg_rcvr_is_dcf77_pzf_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_dcf77_pzf( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_any_dcf77( _p_ri ) \ + ( _mbg_rcvr_is_dcf77_am( _p_ri ) || \ + _mbg_rcvr_is_dcf77_pzf( _p_ri ) ) + +#define _mbg_rcvr_is_any_dcf77_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_any_dcf77( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_msf( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "MSF" ) ) + +#define _mbg_rcvr_is_msf_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_msf( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_glonass( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "GRC" ) ) + +#define _mbg_rcvr_is_glonass_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_glonass( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + +#define _mbg_rcvr_is_wwvb( _p_ri ) \ + ( strstr( (_p_ri)->model_name, "WWVB" ) ) + +#define _mbg_rcvr_is_wwvb_plug_in( _p_ri ) \ + ( _mbg_rcvr_is_wwvb( _p_ri ) && \ + _mbg_rcvr_is_plug_in( _p_ri ) ) + + +/** + * The classification codes for oscillators below + * are used with RECEIVER_INFO.osc_type. New codes + * must be appended to the enumeration, so the sequence + * of codes does NOT reflect the order of quality: + */ +enum +{ + GPS_OSC_UNKNOWN, + GPS_OSC_TCXO_LQ, + GPS_OSC_TCXO_HQ, + GPS_OSC_OCXO_LQ, + GPS_OSC_OCXO_MQ, + GPS_OSC_OCXO_HQ, + GPS_OSC_OCXO_XHQ, + GPS_OSC_RUBIDIUM, + GPS_OSC_TCXO_MQ, + GPS_OSC_OCXO_DHQ, + N_GPS_OSC +}; + + +/* + * The sequence and number of oscillator names + * listed below must correspond to the enumeration + * above: + */ +#define DEFAULT_GPS_OSC_NAMES \ +{ \ + "- unknown -", \ + "TCXO LQ", \ + "TCXO HQ", \ + "OCXO LQ", \ + "OCXO MQ", \ + "OCXO HQ", \ + "OCXO XHQ", \ + "RUBIDIUM", \ + "TCXO MQ", \ + "OCXO DHQ" \ +} + + +/* + * The initializer below can be used to initialize + * an array (e.g. "int osc_quality_idx[N_GPS_OSC]") + * which allows to display the oscillator types + * ordered by quality: + */ +#define DEFAULT_GPS_OSC_QUALITY_IDX \ +{ \ + GPS_OSC_UNKNOWN, \ + GPS_OSC_TCXO_LQ, \ + GPS_OSC_TCXO_MQ, \ + GPS_OSC_TCXO_HQ, \ + GPS_OSC_OCXO_LQ, \ + GPS_OSC_OCXO_MQ, \ + GPS_OSC_OCXO_HQ, \ + GPS_OSC_OCXO_DHQ, \ + GPS_OSC_OCXO_XHQ, \ + GPS_OSC_RUBIDIUM \ +} + + + +/* + * Codes to be used with RECEIVER_INFO.osc_flags + * are not yet used/required, so they are reserved + * for future use. + */ + + +/** + * The codes below enumerate some features which may be + * supported by a given clock, or not. + */ +enum +{ + GPS_FEAT_PPS, /* has pulse per second output */ + GPS_FEAT_PPM, /* has pulse per minute output */ + GPS_FEAT_SYNTH, /* has programmable synthesizer output */ + GPS_FEAT_DCFMARKS, /* has DCF77 compatible time mark output */ + GPS_FEAT_IRIG_TX, /* has on-board IRIG output */ + GPS_FEAT_IRIG_RX, /* has on-board IRIG input */ + GPS_FEAT_LAN_IP4, /* has LAN IPv4 interface */ + GPS_FEAT_MULTI_REF, /* has multiple input sources with priorities */ + GPS_FEAT_RCV_TIMEOUT, /* timeout after GPS reception has stopped */ + GPS_FEAT_IGNORE_LOCK, /* supports "ignore lock", alternatively */ + /* MBG_OPT_BIT_EMU_SYNC may be supported */ + GPS_FEAT_5_MHZ, /* output 5 MHz rather than 100 kHz */ + GPS_FEAT_XMULTI_REF, /* has extended multiple input source configuration */ + GPS_FEAT_OPT_SETTINGS, /* supports MBG_OPT_SETTINGS */ + N_GPS_FEATURE /* the number of valid features */ +}; + + +#define DEFAULT_GPS_FEATURE_NAMES \ +{ \ + "Pulse Per Second", \ + "Pulse Per Minute", \ + "Programmable Synth.", \ + "DCF77 Time Marks", \ + "IRIG Out", \ + "IRIG In", \ + "IPv4 LAN Interface", \ + "Multiple Ref. Sources", \ + "Receive Timeout", \ + "Ignore Lock", \ + "5 MHz Output", \ + "Ext. Multiple Ref. Src. Cfg.", \ + "Supp. Optional Settings" \ +} + + +/* + * Bit masks used with RECEIVER_INFO.features + * (others are reserved): + */ +#define GPS_HAS_PPS ( 1UL << GPS_FEAT_PPS ) +#define GPS_HAS_PPM ( 1UL << GPS_FEAT_PPM ) +#define GPS_HAS_SYNTH ( 1UL << GPS_FEAT_SYNTH ) +#define GPS_HAS_DCFMARKS ( 1UL << GPS_FEAT_DCFMARKS ) +#define GPS_HAS_IRIG_TX ( 1UL << GPS_FEAT_IRIG_TX ) +#define GPS_HAS_IRIG_RX ( 1UL << GPS_FEAT_IRIG_RX ) +#define GPS_HAS_LAN_IP4 ( 1UL << GPS_FEAT_LAN_IP4 ) +#define GPS_HAS_MULTI_REF ( 1UL << GPS_FEAT_MULTI_REF ) +#define GPS_HAS_RCV_TIMEOUT ( 1UL << GPS_FEAT_RCV_TIMEOUT ) +#define GPS_HAS_IGNORE_LOCK ( 1UL << GPS_FEAT_IGNORE_LOCK ) +#define GPS_HAS_5_MHZ ( 1UL << GPS_FEAT_5_MHZ ) +#define GPS_HAS_XMULTI_REF ( 1UL << GPS_FEAT_XMULTI_REF ) +#define GPS_HAS_OPT_SETTINGS ( 1UL << GPS_FEAT_OPT_SETTINGS ) + +#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX + + +/* + * The features below are supported by default by older + * C166 based GPS receivers: + */ +#define DEFAULT_GPS_FEATURES_C166 \ +{ \ + GPS_HAS_PPS | \ + GPS_HAS_PPM | \ + GPS_HAS_SYNTH | \ + GPS_HAS_DCFMARKS \ +} + + +/* + * Codes to be used with RECEIVER_INFO.flags: + */ +#define GPS_OSC_CFG_SUPP 0x0001 // GPS_OSC_CFG supported +#define GPS_IRIG_FO_IN 0x0002 // IRIG input via fiber optics +#define GPS_HAS_FPGA 0x0004 // device provides on-board FPGA + + +/* + * If the GPS_HAS_FPGA flag is set in RECEIVER_INFO::flags then the card + * provides an FPGA and the following information about the FPGA is available: + */ +#define FPGA_NAME_LEN 31 // max name length +#define FPGA_NAME_SIZE ( FPGA_NAME_LEN + 1 ) // size including trailing 0 + +#define FPGA_INFO_SIZE 128 + +typedef union +{ + struct + { + CSUM csum; + uint32_t fsize; + uint32_t start_addr; + char name[FPGA_NAME_SIZE]; + } hdr; + + char b[FPGA_INFO_SIZE]; + +} FPGA_INFO; + + + +/* + * The definitions below are used to specify where a FPGA image is located + * in the flash memory: + */ +typedef struct +{ + CSUM csum; + uint16_t fpga_start_seg; // Number of the 4k block where an FPGA image is located +} FPGA_START_INFO; + +#define DEFAULT_FPGA_START_SEG 0x60 + +#define DEFAULT_FPGA_START_INFO \ +{ \ + 0x1234 + DEFAULT_FPGA_START_SEG, \ + DEFAULT_FPGA_START_SEG \ +} + + + +/* Date and time referred to the linear time scale defined by GPS. */ +/* GPS time is defined by the number of weeks since midnight from */ +/* January 5, 1980 to January 6, 1980 plus the number of seconds of */ +/* the current week plus fractions of a second. GPS time differs from */ +/* UTC because UTC is corrected with leap seconds while GPS time scale */ +/* is continuous. */ + +typedef struct +{ + uint16_t wn; /* the week number since GPS has been installed */ + uint32_t sec; /* the second of that week */ + uint32_t tick; /* fractions of a second; scale: 1/GPS_TICKS_PER_SEC */ +} T_GPS; + +#define _mbg_swab_t_gps( _p ) \ +{ \ + _mbg_swab16( &(_p)->wn ); \ + _mbg_swab32( &(_p)->sec ); \ + _mbg_swab32( &(_p)->tick ); \ +} + + +/* Local date and time computed from GPS time. The current number */ +/* of leap seconds have to be added to get UTC from GPS time. */ +/* Additional corrections could have been made according to the */ +/* time zone/daylight saving parameters (TZDL, see below) defined */ +/* by the user. The status field can be checked to see which corrections */ +/* have been applied. */ + +typedef struct +{ + int16_t year; /* 0..9999 */ + int8_t month; /* 1..12 */ + int8_t mday; /* 1..31 */ + int16_t yday; /* 1..366 */ + int8_t wday; /* 0..6 == Sun..Sat */ + int8_t hour; /* 0..23 */ + int8_t min; /* 0..59 */ + int8_t sec; /* 0..59 */ + int32_t frac; /* fractions of a second; scale: 1/GPS_TICKS_PER_SEC*/ + int32_t offs_from_utc; /* local time's offset from UTC */ + uint16_t status; /* flags */ +} TM_GPS; + +#define _mbg_swab_tm_gps( _p ) \ +{ \ + _mbg_swab16( &(_p)->year ); \ + _mbg_swab16( &(_p)->yday ); \ + _mbg_swab32( &(_p)->frac ); \ + _mbg_swab32( &(_p)->offs_from_utc ); \ + _mbg_swab16( &(_p)->status ); \ +} + + +/* status flag bits used with conversion from GPS time to local time */ + +enum +{ + TM_BIT_UTC, /* UTC correction has been made */ + TM_BIT_LOCAL, /* UTC has been converted to local time */ + TM_BIT_DL_ANN, /* state of daylight saving is going to change */ + TM_BIT_DL_ENB, /* daylight saving is enabled */ + TM_BIT_LS_ANN, /* leap second will be inserted */ + TM_BIT_LS_ENB, /* current second is leap second */ + TM_BIT_LS_ANN_NEG, /* set in addition to TM_LS_ANN if leap sec negative */ + /* Bit 7 is reserved and not used, yet. */ + + TM_BIT_EXT_SYNC = 8, /* sync'd externally */ + TM_BIT_HOLDOVER, /* holdover mode after previous sync. */ + TM_BIT_ANT_SHORT, /* antenna cable short circuited */ + TM_BIT_NO_WARM, /* OCXO has not warmed up */ + TM_BIT_ANT_DISCONN, /* antenna currently disconnected */ + TM_BIT_SYN_FLAG, /* TIME_SYN output is low */ + TM_BIT_NO_SYNC, /* time sync actually not verified */ + TM_BIT_NO_POS /* position actually not verified, LOCK LED off */ +}; + + +/* bit masks corresponding to the flag bits above */ + +#define TM_UTC ( 1U << TM_BIT_UTC ) +#define TM_LOCAL ( 1U << TM_BIT_LOCAL ) +#define TM_DL_ANN ( 1U << TM_BIT_DL_ANN ) +#define TM_DL_ENB ( 1U << TM_BIT_DL_ENB ) +#define TM_LS_ANN ( 1U << TM_BIT_LS_ANN ) +#define TM_LS_ENB ( 1U << TM_BIT_LS_ENB ) +#define TM_LS_ANN_NEG ( 1U << TM_BIT_LS_ANN_NEG ) + +#define TM_EXT_SYNC ( 1U << TM_BIT_EXT_SYNC ) +#define TM_HOLDOVER ( 1U << TM_BIT_HOLDOVER ) +#define TM_ANT_SHORT ( 1U << TM_BIT_ANT_SHORT ) +#define TM_NO_WARM ( 1U << TM_BIT_NO_WARM ) +#define TM_ANT_DISCONN ( 1U << TM_BIT_ANT_DISCONN ) +#define TM_SYN_FLAG ( 1U << TM_BIT_SYN_FLAG ) +#define TM_NO_SYNC ( 1U << TM_BIT_NO_SYNC ) +#define TM_NO_POS ( 1U << TM_BIT_NO_POS ) + + +/** + This structure is used to transmit information on date and time + */ +typedef struct +{ + int16_t channel; /**< -1: the current time; 0, 1: capture 0, 1 */ + T_GPS t; /**< time in GPS format */ + TM_GPS tm; /**< that time converted to local time */ +} TTM; + +#define _mbg_swab_ttm( _p ) \ +{ \ + _mbg_swab16( &(_p)->channel ); \ + _mbg_swab_t_gps( &(_p)->t ); \ + _mbg_swab_tm_gps( &(_p)->tm ); \ +} + + + +typedef struct +{ + int32_t nano_secs; // [nanoseconds] + int32_t secs; // [seconds] +} NANO_TIME; + +#define _mbg_swab_nano_time( _p ) \ +{ \ + _mbg_swab32( &(_p)->nano_secs ); \ + _mbg_swab32( &(_p)->secs ); \ +} + + +/* Two types of variables used to store a position. Type XYZ is */ +/* used with a position in earth centered, earth fixed (ECEF) */ +/* coordinates whereas type LLA holds such a position converted */ +/* to geographic coordinates as defined by WGS84 (World Geodetic */ +/* System from 1984). */ + +#ifndef _XYZ_DEFINED + /* sequence and number of components of a cartesian position */ + enum { XP, YP, ZP, N_XYZ }; + + /** a type of array holding a cartesian position */ + typedef double XYZ[N_XYZ]; /**< values are in [m] */ + + #define _XYZ_DEFINED +#endif + +#define _mbg_swab_xyz( _p ) _mbg_swab_doubles( _p, N_XYZ ) + + +#ifndef _LLA_DEFINED + /* sequence and number of components of a geographic position */ + enum { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */ + + /** a type of array holding a geographic position */ + typedef double LLA[N_LLA]; /**< lon, lat in [rad], alt in [m] */ + + #define _LLA_DEFINED +#endif + +#define _mbg_swab_lla( _p ) _mbg_swab_doubles( _p, N_LLA ) + + +/** + @defgroup group_synth Synthesizer parameters. + + Synthesizer frequency is expressed as a + four digit decimal number (freq) to be multiplied by 0.1 Hz and an + base 10 exponent (range). If the effective frequency is less than + 10 kHz its phase is synchronized corresponding to the variable phase. + Phase may be in a range from -360 deg to +360 deg with a resolution + of 0.1 deg, so the resulting numbers to be stored are in a range of + -3600 to +3600. + + Example:<br> + Assume the value of freq is 2345 (decimal) and the value of phase is 900. + If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg. + If range == 1 the synthesizer will generate a 2345 Hz output frequency + and so on. + + Limitations:<br> + If freq == 0 the synthesizer is disabled. If range == 0 the least + significant digit of freq is limited to 0, 3, 5 or 6. The resulting + frequency is shown in the examples below: + - freq == 1230 --> 123.0 Hz + - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) + - freq == 1235 --> 123.5 Hz + - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) + + If range == MAX_RANGE the value of freq must not exceed 1000, so the + output frequency is limited to 10 MHz. + @{ +*/ + +#define N_SYNTH_FREQ_DIGIT 4 /**< number of digits to edit */ +#define MAX_SYNTH_FREQ 1000 /**< if range == MAX_SYNTH_RANGE */ + +#define MIN_SYNTH_RANGE 0 +#define MAX_SYNTH_RANGE 5 +#define N_SYNTH_RANGE ( MAX_SYNTH_RANGE - MIN_SYNTH_RANGE + 1 ) + +#define N_SYNTH_PHASE_DIGIT 4 +#define MAX_SYNTH_PHASE 3600 + + +#define MAX_SYNTH_FREQ_EDIT 9999 /**< max sequence of digits when editing */ + +/** The maximum frequency that can be configured for the synthesizer */ +#define MAX_SYNTH_FREQ_VAL 10000000UL /**< 10 MHz */ +/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */ + +/** + The synthesizer phase will only be synchronized if the frequency + is below this limit: */ +#define SYNTH_PHASE_SYNC_LIMIT 10000UL /**< 10 kHz */ + +/** + the position of the decimal point if the frequency is + printed as 4 digit value */ +#define _synth_dp_pos_from_range( _r ) \ + ( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 ) + +/** + An initializer for commonly displayed synthesizer frequency units + (N_SYNTH_RANGE strings) */ +#define DEFAULT_FREQ_RANGES \ +{ \ + "Hz", \ + "kHz", \ + "kHz", \ + "kHz", \ + "MHz", \ + "MHz", \ +} + + + +typedef struct +{ + int16_t freq; /**< four digits used; scale: 0.1; e.g. 1234 -> 123.4 Hz */ + int16_t range; /**< scale factor for freq; 0..MAX_SYNTH_RANGE */ + int16_t phase; /**< -MAX_SYNTH_PHASE..+MAX_SYNTH_PHASE; >0 -> pulses later */ +} SYNTH; + +#define _mbg_swab_synth( _p ) \ +{ \ + _mbg_swab16( &(_p)->freq ); \ + _mbg_swab16( &(_p)->range ); \ + _mbg_swab16( &(_p)->phase ); \ +} + + +/** + The definitions below can be used to query the + current synthesizer state. + */ +enum +{ + SYNTH_DISABLED, /**< disbled by cfg, i.e. freq == 0.0 */ + SYNTH_OFF, /**< not enabled after power-up */ + SYNTH_FREE, /**< enabled, but not synchronized */ + SYNTH_DRIFTING, /**< has initially been sync'd, but now running free */ + SYNTH_SYNC, /**< fully synchronized */ + N_SYNTH_STATE /**< the number of known states */ +}; + +typedef struct +{ + uint8_t state; /**< state code as enumerated above */ + uint8_t flags; /**< reserved, currently always 0 */ +} SYNTH_STATE; + +#define _mbg_swab_synth_state( _p ) _nop_macro_fnc() + +#define SYNTH_FLAG_PHASE_IGNORED 0x01 + +/** @} */ // endgroup + +/** + @defgroup group_tzdl Time zone/daylight saving parameters. + + Example: <br> + For automatic daylight saving enable/disable in Central Europe, + the variables are to be set as shown below: <br> + - offs = 3600L one hour from UTC + - offs_dl = 3600L one additional hour if daylight saving enabled + - tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG ) + - tm_off = first Sunday from October 25, 03:00:00h ( year |= DL_AUTO_FLAG ) + - name[0] == "CET " name if daylight saving not enabled + - name[1] == "CEST " name if daylight saving is enabled + @{ +*/ + +/** the name of a time zone, 5 characters plus trailing zero */ +typedef char TZ_NAME[6]; + +typedef struct +{ + int32_t offs; /**< offset from UTC to local time [sec] */ + int32_t offs_dl; /**< additional offset if daylight saving enabled [sec] */ + TM_GPS tm_on; /**< date/time when daylight saving starts */ + TM_GPS tm_off; /**< date/time when daylight saving ends */ + TZ_NAME name[2]; /**< names without and with daylight saving enabled */ +} TZDL; + +#define _mbg_swab_tzdl( _p ) \ +{ \ + _mbg_swab32( &(_p)->offs ); \ + _mbg_swab32( &(_p)->offs_dl ); \ + _mbg_swab_tm_gps( &(_p)->tm_on ); \ + _mbg_swab_tm_gps( &(_p)->tm_off ); \ +} + + +/** + If the year in tzdl.tm_on and tzdl.tm_off is or'ed with that constant, + the receiver automatically generates daylight saving year by year. + */ +#define DL_AUTO_FLAG 0x8000 + + + +// Below there are some initializers for commonly used TZDL configurations: + +#define DEFAULT_TZDL_AUTO_YEAR ( 2007 | DL_AUTO_FLAG ) + +#define DEFAULt_TZDL_OFFS_DL 3600L /**< usually DST is +1 hour */ + + +/** + The symbol below can be used to initialize both the tm_on + and tm_off fields for time zones which do not switch to DST: + */ +#define DEFAULT_TZDL_TM_ON_OFF_NO_DST \ + { DEFAULT_TZDL_AUTO_YEAR, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 } + + +// Settings used with UTC: + +#define TZ_INFO_UTC "UTC (Universal Time, Coordinated)" + +#define DEFAULT_TZDL_NAMES_UTC { "UTC ", "UTC " } + +#define DEFAULT_TZDL_UTC \ +{ \ + 0L, /**< offs */ \ + 0L, /**< offs_dl */ \ + DEFAULT_TZDL_TM_ON_OFF_NO_DST, /**< tm_on */ \ + DEFAULT_TZDL_TM_ON_OFF_NO_DST, /**< tm_off */ \ + DEFAULT_TZDL_NAMES_UTC /**< name[] */ \ +} + + +/** + The symbols below specify beginning and end of DST for + Central Europe, as constituted by the European Parliament: + */ + +#define DEFAULT_TZDL_TM_ON_CET_CEST \ + { DEFAULT_TZDL_AUTO_YEAR, 3, 25, 0, 0, 2, 0, 0, 0L, 0L, 0 } + +#define DEFAULT_TZDL_TM_OFF_CET_CEST \ + { DEFAULT_TZDL_AUTO_YEAR, 10, 25, 0, 0, 3, 0, 0, 0L, 0L, 0 } + + +// Settings used with Central European Time: + +#define TZ_INFO_CET_CEST_EN "CET/CEST (Central Europe)" +#define TZ_INFO_CET_CEST_DE "MEZ/MESZ (Mitteleuropa)" + +#define DEFAULT_TZDL_NAMES_CET_CEST_EN { "CET ", "CEST " } +#define DEFAULT_TZDL_NAMES_CET_CEST_DE { "MEZ ", "MESZ " } + +#define DEFAULT_TZDL_OFFS_CET 3600L + +#define DEFAULT_TZDL_CET_CEST_EN \ +{ \ + DEFAULT_TZDL_OFFS_CET, /**< offs */ \ + DEFAULt_TZDL_OFFS_DL, /**< offs_dl */ \ + DEFAULT_TZDL_TM_ON_CET_CEST, /**< tm_on */ \ + DEFAULT_TZDL_TM_OFF_CET_CEST, /**< tm_off */ \ + DEFAULT_TZDL_NAMES_CET_CEST_EN /**< name[] */ \ +} + +#define DEFAULT_TZDL_CET_CEST_DE \ +{ \ + DEFAULT_TZDL_OFFS_CET, /**< offs */ \ + DEFAULt_TZDL_OFFS_DL, /**< offs_dl */ \ + DEFAULT_TZDL_TM_ON_CET_CEST, /**< tm_on */ \ + DEFAULT_TZDL_TM_OFF_CET_CEST, /**< tm_off */ \ + DEFAULT_TZDL_NAMES_CET_CEST_DE /**< name[] */ \ +} + + +// The symbols below specify beginning and end of DST for +// Easter Europe, as constituted by the European Parliament: + +#define DEFAULT_TZDL_TM_ON_EET_EEST \ + { DEFAULT_TZDL_AUTO_YEAR, 3, 25, 0, 0, 3, 0, 0, 0L, 0L, 0 } + +#define DEFAULT_TZDL_TM_OFF_EET_EEST \ + { DEFAULT_TZDL_AUTO_YEAR, 10, 25, 0, 0, 4, 0, 0, 0L, 0L, 0 } + + +// Settings used with Eastern European Time: + +#define TZ_INFO_EET_EEST_EN "EET/EEST (East Europe)" +#define TZ_INFO_EET_EEST_DE "OEZ/OEST (Osteuropa)" + +#define DEFAULT_TZDL_NAMES_EET_EEST_EN { "EET ", "EEST " } +#define DEFAULT_TZDL_NAMES_EET_EEST_DE { "OEZ ", "OESZ " } + +#define DEFAULT_TZDL_OFFS_EET 7200L + +#define DEFAULT_TZDL_EET_EEST_EN \ +{ \ + DEFAULT_TZDL_OFFS_EET, /* offs */ \ + DEFAULt_TZDL_OFFS_DL, /* offs_dl */ \ + DEFAULT_TZDL_TM_ON_EET_EEST, /* tm_on */ \ + DEFAULT_TZDL_TM_OFF_EET_EEST, /* tm_off */ \ + DEFAULT_TZDL_NAMES_EET_EEST_EN /* name[] */ \ +} + +#define DEFAULT_TZDL_EET_EEST_DE \ +{ \ + DEFAULT_TZDL_OFFS_EET, /* offs */ \ + DEFAULt_TZDL_OFFS_DL, /* offs_dl */ \ + DEFAULT_TZDL_TM_ON_EET_EEST, /* tm_on */ \ + DEFAULT_TZDL_TM_OFF_EET_EEST, /* tm_off */ \ + DEFAULT_TZDL_NAMES_EET_EEST_DE /* name[] */ \ +} + +/** @} */ // endgroup + +/** + * The structure below reflects the status of the antenna, + * the times of last disconnect/reconnect, and the board's + * clock offset after the disconnection interval. + */ +typedef struct +{ + int16_t status; /**< current status of antenna */ + TM_GPS tm_disconn; /**< time of antenna disconnect */ + TM_GPS tm_reconn; /**< time of antenna reconnect */ + int32_t delta_t; /**< clock offs. at reconn. time in #GPS_TICKS_PER_SEC */ +} ANT_INFO; + +#define _mbg_swab_ant_info( _p ) \ +{ \ + _mbg_swab16( &(_p)->status ); \ + _mbg_swab_tm_gps( &(_p)->tm_disconn ); \ + _mbg_swab_tm_gps( &(_p)->tm_reconn ); \ + _mbg_swab32( &(_p)->delta_t ); \ +} + + +/** + The status field may be set to one of the values below: +*/ +enum +{ + ANT_INVALID, /**< struct not set yet because ant. has not been disconn. */ + ANT_DISCONN, /**< ant. now disconn., tm_reconn and delta_t not set */ + ANT_RECONN /**< ant. has been disconn. and reconn., all fields valid */ +}; + +/* Defines used with ENABLE_FLAGS */ + +#define EF_OFF 0x00 /**< outputs off until sync'd */ + +#define EF_SERIAL_BOTH 0x03 /**< both serial ports on */ +#define EF_PULSES_BOTH 0x03 /**< both pulses P_SEC and P_MIN on */ +#define EF_FREQ_ALL 0x07 /**< all fixed freq. outputs on */ +#define EF_SYNTH 0x01 /**< synth. on */ + +/** + The structure holds some flags which let + the corresponding outputs be disabled after power-up until + the receiver has synchronized (flag == 0x00, the default) or force + the outputs to be enabled immediately after power-up. The fixed + frequency output is hard-wired to be enabled immediately after + power-up, so the code for freq must always be 0x03. +*/ +typedef struct +{ + uint16_t serial; /**< #EF_OFF or #EF_SERIAL_BOTH */ + uint16_t pulses; /**< #EF_OFF or #EF_PULSES_BOTH */ + uint16_t freq; /**< always #EF_FREQ_ALL */ + uint16_t synth; /**< #EF_OFF or #EF_SYNTH */ +} ENABLE_FLAGS; + +#define _mbg_swab_enable_flags( _p ) \ +{ \ + _mbg_swab16( &(_p)->serial ); \ + _mbg_swab16( &(_p)->pulses ); \ + _mbg_swab16( &(_p)->freq ); \ + _mbg_swab16( &(_p)->synth ); \ +} + + +/* A struct used to hold the settings of a serial port: */ + +#ifndef _COM_HS_DEFINED + /* types of handshake */ + enum { HS_NONE, HS_XONXOFF, HS_RTSCTS, N_COM_HS }; + #define _COM_HS_DEFINED +#endif + +#ifndef _COM_PARM_DEFINED + typedef int32_t BAUD_RATE; + + /* indices used to identify a parameter in the framing string */ + enum { F_DBITS, F_PRTY, F_STBITS }; + + typedef struct + { + BAUD_RATE baud_rate; /* e.g. 19200L */ + char framing[4]; /* e.g. "8N1" */ + int16_t handshake; /* a numeric value, only HS_NONE supported yet */ + } COM_PARM; + + #define _COM_PARM_DEFINED +#endif + +#define _mbg_swab_baud_rate( _p ) _mbg_swab32( _p ) + +#define _mbg_swab_com_parm( _p ) \ +{ \ + _mbg_swab_baud_rate( &(_p)->baud_rate ); \ + _mbg_swab16( &(_p)->handshake ); \ +} + + +/* + * Indices of any supported baud rates. + * Note that not each baud rate must be supported by + * any clock model and/or port: + */ +enum +{ + MBG_BAUD_RATE_300, + MBG_BAUD_RATE_600, + MBG_BAUD_RATE_1200, + MBG_BAUD_RATE_2400, + MBG_BAUD_RATE_4800, + MBG_BAUD_RATE_9600, + MBG_BAUD_RATE_19200, + MBG_BAUD_RATE_38400, + N_MBG_BAUD_RATES /* the number of supported baud rates */ +}; + +/* + * An initializer for a table of baud rate values. + * The values must correspond to the enumeration above. + */ +#define MBG_BAUD_RATES \ +{ \ + 300L, \ + 600L, \ + 1200L, \ + 2400L, \ + 4800L, \ + 9600L, \ + 19200L, \ + 38400L \ +} + +/* + * An initializer for a table of baud rate strings. + * The values must correspond to the enumeration above. + */ +#define MBG_BAUD_STRS \ +{ \ + "300", \ + "600", \ + "1200", \ + "2400", \ + "4800", \ + "9600", \ + "19200", \ + "38400" \ +} + +/* + * The bit masks below can be used to determine which baud rates + * are supported by a serial port. This may vary between + * different ports of the same radio clock since different + * types of UART are used which must not necessarily support + * each baud rate: + */ +#define MBG_PORT_HAS_300 ( 1UL << MBG_BAUD_RATE_300 ) +#define MBG_PORT_HAS_600 ( 1UL << MBG_BAUD_RATE_600 ) +#define MBG_PORT_HAS_1200 ( 1UL << MBG_BAUD_RATE_1200 ) +#define MBG_PORT_HAS_2400 ( 1UL << MBG_BAUD_RATE_2400 ) +#define MBG_PORT_HAS_4800 ( 1UL << MBG_BAUD_RATE_4800 ) +#define MBG_PORT_HAS_9600 ( 1UL << MBG_BAUD_RATE_9600 ) +#define MBG_PORT_HAS_19200 ( 1UL << MBG_BAUD_RATE_19200 ) +#define MBG_PORT_HAS_38400 ( 1UL << MBG_BAUD_RATE_38400 ) + + +/* + * Indices of any supported framings. + * Note that not each framing must be supported by + * any clock model and/or port: + */ +enum +{ + MBG_FRAMING_7N2, + MBG_FRAMING_7E1, + MBG_FRAMING_7E2, + MBG_FRAMING_8N1, + MBG_FRAMING_8N2, + MBG_FRAMING_8E1, + MBG_FRAMING_7O1, + MBG_FRAMING_7O2, + MBG_FRAMING_8O1, + N_MBG_FRAMINGS /* the number of supported framings */ +}; + +/* + * An initializer for a table of framing strings. + * The values must correspond to the enumeration above. + */ +#define MBG_FRAMING_STRS \ +{ \ + "7N2", \ + "7E1", \ + "7E2", \ + "8N1", \ + "8N2", \ + "8E1", \ + "7O1", \ + "7O2", \ + "8O1" \ +} + +/* + * The bit masks below can be used to determine which framings + * are supported by a serial port. This may vary between + * different ports of the same radio clock since different + * types of UART are used which must not necessarily support + * each framing type: + */ +#define MBG_PORT_HAS_7N2 ( 1UL << MBG_FRAMING_7N2 ) +#define MBG_PORT_HAS_7E1 ( 1UL << MBG_FRAMING_7E1 ) +#define MBG_PORT_HAS_7E2 ( 1UL << MBG_FRAMING_7E2 ) +#define MBG_PORT_HAS_8N1 ( 1UL << MBG_FRAMING_8N1 ) +#define MBG_PORT_HAS_8N2 ( 1UL << MBG_FRAMING_8N2 ) +#define MBG_PORT_HAS_8E1 ( 1UL << MBG_FRAMING_8E1 ) +#define MBG_PORT_HAS_7O1 ( 1UL << MBG_FRAMING_7O1 ) +#define MBG_PORT_HAS_7O2 ( 1UL << MBG_FRAMING_7O2 ) +#define MBG_PORT_HAS_8O1 ( 1UL << MBG_FRAMING_8O1 ) + + + +/* + * By default, the baud rates and framings below + * are supported by the UARTs integrated into + * the C166 microcontroller: + */ +#define DEFAULT_GPS_BAUD_RATES_C166 \ +( \ + MBG_PORT_HAS_300 | \ + MBG_PORT_HAS_600 | \ + MBG_PORT_HAS_1200 | \ + MBG_PORT_HAS_2400 | \ + MBG_PORT_HAS_4800 | \ + MBG_PORT_HAS_9600 | \ + MBG_PORT_HAS_19200 \ +) + +#define DEFAULT_GPS_FRAMINGS_C166 \ +( \ + MBG_PORT_HAS_7N2 | \ + MBG_PORT_HAS_7E1 | \ + MBG_PORT_HAS_7E2 | \ + MBG_PORT_HAS_8N1 | \ + MBG_PORT_HAS_8N2 | \ + MBG_PORT_HAS_8E1 \ +) + + +/* + * By default, the baud rates and framings below + * are supported by the UARTs integrated into + * the GP2021 chipset: + */ +#define DEFAULT_GPS_BAUD_RATES_GP2021 \ +( \ + MBG_PORT_HAS_300 | \ + MBG_PORT_HAS_600 | \ + MBG_PORT_HAS_1200 | \ + MBG_PORT_HAS_2400 | \ + MBG_PORT_HAS_4800 | \ + MBG_PORT_HAS_9600 | \ + MBG_PORT_HAS_19200 \ +) + +#define DEFAULT_GPS_FRAMINGS_GP2021 \ +( \ + MBG_PORT_HAS_7N2 | \ + MBG_PORT_HAS_7E2 | \ + MBG_PORT_HAS_8N1 | \ + MBG_PORT_HAS_8E1 | \ + MBG_PORT_HAS_8O1 \ +) + + +/* + * The structure below is more flexible if different receiver + * models have different numbers of serial ports, so the old + * structure PORT_PARM will become obsolete. + */ +typedef struct +{ + COM_PARM parm; /* speed, framing, etc. */ + uint8_t mode; /* per second, per minute, etc. */ + uint8_t str_type; /* type of the output string */ + uint32_t flags; /* reserved for future use, currently 0 */ +} PORT_SETTINGS; + +#define _mbg_swab_port_settings( _p ) \ +{ \ + _mbg_swab_com_parm( &(_p)->parm ); \ + _mbg_swab32( &(_p)->flags ); \ +} + + +/* + * The definitions below can be used to mark specific fields of a + * PORT_SETTINGS structure, e.g. when editing build a mask indicating + * which of the fields have changed or which are not valid. + */ +enum +{ + MBG_PS_BIT_BAUD_RATE_OVR_SW, /* Baud rate index exceeds num supp by driver SW */ + MBG_PS_BIT_BAUD_RATE_OVR_DEV, /* Baud rate index exceeds num supp by device */ + MBG_PS_BIT_BAUD_RATE, /* Baud rate not supp by given port */ + MBG_PS_BIT_FRAMING_OVR_SW, /* Framing index exceeds num supp by driver SW */ + MBG_PS_BIT_FRAMING_OVR_DEV, /* Framing index exceeds num supp by device */ + MBG_PS_BIT_FRAMING, /* Framing not supp by given port */ + MBG_PS_BIT_HS_OVR_SW, /* Handshake index exceeds num supp by driver SW */ + MBG_PS_BIT_HS, /* Handshake mode not supp by given port */ + MBG_PS_BIT_STR_TYPE_OVR_SW, /* String type index exceeds num supp by driver SW */ + MBG_PS_BIT_STR_TYPE_OVR_DEV, /* String type index exceeds num supp by device */ + MBG_PS_BIT_STR_TYPE, /* String type not supp by given port */ + MBG_PS_BIT_STR_MODE_OVR_SW, /* String mode index exceeds num supp by driver SW */ + MBG_PS_BIT_STR_MODE_OVR_DEV, /* String mode index exceeds num supp by device */ + MBG_PS_BIT_STR_MODE, /* String mode not supp by given port and string type */ + MBG_PS_BIT_FLAGS_OVR_SW, /* Flags not supp by driver SW */ + MBG_PS_BIT_FLAGS, /* Flags not supp by device */ + N_MBG_PS_BIT +}; + +#define MBG_PS_MSK_BAUD_RATE_OVR_SW ( 1UL << MBG_PS_BIT_BAUD_RATE_OVR_SW ) +#define MBG_PS_MSK_BAUD_RATE_OVR_DEV ( 1UL << MBG_PS_BIT_BAUD_RATE_OVR_DEV ) +#define MBG_PS_MSK_BAUD_RATE ( 1UL << MBG_PS_BIT_BAUD_RATE ) +#define MBG_PS_MSK_FRAMING_OVR_SW ( 1UL << MBG_PS_BIT_FRAMING_OVR_SW ) +#define MBG_PS_MSK_FRAMING_OVR_DEV ( 1UL << MBG_PS_BIT_FRAMING_OVR_DEV ) +#define MBG_PS_MSK_FRAMING ( 1UL << MBG_PS_BIT_FRAMING ) +#define MBG_PS_MSK_HS_OVR_SW ( 1UL << MBG_PS_BIT_HS_OVR_SW ) +#define MBG_PS_MSK_HS ( 1UL << MBG_PS_BIT_HS ) +#define MBG_PS_MSK_STR_TYPE_OVR_SW ( 1UL << MBG_PS_BIT_STR_TYPE_OVR_SW ) +#define MBG_PS_MSK_STR_TYPE_OVR_DEV ( 1UL << MBG_PS_BIT_STR_TYPE_OVR_DEV ) +#define MBG_PS_MSK_STR_TYPE ( 1UL << MBG_PS_BIT_STR_TYPE ) +#define MBG_PS_MSK_STR_MODE_OVR_SW ( 1UL << MBG_PS_BIT_STR_MODE_OVR_SW ) +#define MBG_PS_MSK_STR_MODE_OVR_DEV ( 1UL << MBG_PS_BIT_STR_MODE_OVR_DEV ) +#define MBG_PS_MSK_STR_MODE ( 1UL << MBG_PS_BIT_STR_MODE ) +#define MBG_PS_MSK_FLAGS_OVR_SW ( 1UL << MBG_PS_BIT_FLAGS_OVR_SW ) +#define MBG_PS_MSK_FLAGS ( 1UL << MBG_PS_BIT_FLAGS ) + + + +/* + * The structure below adds an index number to the structure + * above to allow addressing of several instances: + */ +typedef struct +{ + uint16_t idx; /* 0..RECEIVER_INFO.n_com_port-1 */ + PORT_SETTINGS port_settings; +} PORT_SETTINGS_IDX; + +#define _mbg_swab_port_settings_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_port_settings( &(_p)->port_settings ); \ +} + + +/* + * The structure below holds the current settings + * for a port, plus additional informaton on the + * port's capabilities. This can be read by setup + * programs to allow setup of supported features + * only. + */ +typedef struct +{ + PORT_SETTINGS port_settings; /* COM port settings as defined above */ + uint32_t supp_baud_rates; /* bit mask of baud rates supp. by this port */ + uint32_t supp_framings; /* bit mask of framings supp. by this port */ + uint32_t supp_str_types; /* bit mask, bit 0 set if str_type[0] supp. */ + uint32_t reserved; /* reserved for future use, currently 0 */ + uint32_t flags; /* reserved for future use, currently 0 */ +} PORT_INFO; + +#define _mbg_swab_port_info( _p ) \ +{ \ + _mbg_swab_port_settings( &(_p)->port_settings ); \ + _mbg_swab32( &(_p)->supp_baud_rates ); \ + _mbg_swab32( &(_p)->supp_framings ); \ + _mbg_swab32( &(_p)->supp_str_types ); \ + _mbg_swab32( &(_p)->reserved ); \ + _mbg_swab32( &(_p)->flags ); \ +} + + +/* + * The structure below adds an index number to the structure + * above to allow addressing of several instances: + */ +typedef struct +{ + uint16_t idx; /* 0..RECEIVER_INFO.n_com_port-1 */ + PORT_INFO port_info; +} PORT_INFO_IDX; + +#define _mbg_swab_port_info_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_port_info( &(_p)->port_info ); \ +} + + +/* + * The structure below keeps information for a given + * string type, e.g. which modes can be used with that + * string type: + */ +typedef struct +{ + uint32_t supp_modes; /* bit mask of modes supp. with this string type */ + char long_name[23]; /* long name of the string format */ + char short_name[11]; /* short name of the string format */ + uint16_t flags; /* reserved, currently always 0 */ +} STR_TYPE_INFO; + +#define _mbg_swab_str_type_info( _p ) \ +{ \ + _mbg_swab32( &(_p)->supp_modes ); \ + _mbg_swab16( &(_p)->flags ); \ +} + + + +/* + * The structure below adds an index number to the structure + * above to allow addressing of several instances: + */ +typedef struct +{ + uint16_t idx; /* 0..RECEIVER_INFO.n_str_type-1 */ + STR_TYPE_INFO str_type_info; +} STR_TYPE_INFO_IDX; + +#define _mbg_swab_str_type_info_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_str_type_info( &(_p)->str_type_info ); \ +} + + +/* + * The codes below define valid modes for time strings, + * i.e. the condition when a string is being sent + * via the serial port: + */ +enum +{ + STR_ON_REQ, /* on request only */ + STR_PER_SEC, /* automatically if second changes */ + STR_PER_MIN, /* automatically if minute changes */ + STR_AUTO, /* automatically if required, e.g. on capture event */ + STR_ON_REQ_SEC, /* if second changes and a request has been received */ + N_STR_MODE /* the number of valid modes */ +}; + + +#define DEFAULT_SHORT_MODE_NAMES \ +{ \ + "'?'", \ + "1 sec", \ + "1 min", \ + "auto", \ + "'?' sec" \ +} + + +/* + * Default initializers for English mode string names. Initializers + * for multi-language strings can be found in pcpslstr.h. + */ +#define ENG_MODE_NAME_STR_ON_REQ "on request '?' only" +#define ENG_MODE_NAME_STR_PER_SEC "per second" +#define ENG_MODE_NAME_STR_PER_MIN "per minute" +#define ENG_MODE_NAME_STR_AUTO "automatically" +#define ENG_MODE_NAME_STR_ON_REQ_SEC "sec after request" + +#define DEFAULT_ENG_MODE_NAMES \ +{ \ + ENG_MODE_NAME_STR_ON_REQ, \ + ENG_MODE_NAME_STR_PER_SEC, \ + ENG_MODE_NAME_STR_PER_MIN, \ + ENG_MODE_NAME_STR_AUTO, \ + ENG_MODE_NAME_STR_ON_REQ_SEC \ +} + +/* + * The definitions below are used to set up bit masks + * which restrict the modes which can be used with + * a given string type: + */ +#define MSK_STR_ON_REQ ( 1UL << STR_ON_REQ ) +#define MSK_STR_PER_SEC ( 1UL << STR_PER_SEC ) +#define MSK_STR_PER_MIN ( 1UL << STR_PER_MIN ) +#define MSK_STR_AUTO ( 1UL << STR_AUTO ) +#define MSK_STR_ON_REQ_SEC ( 1UL << STR_ON_REQ_SEC ) + + +/* + * The modes below are supported by most string types: + */ +#define DEFAULT_STR_MODES \ +( \ + MSK_STR_ON_REQ | \ + MSK_STR_PER_SEC | \ + MSK_STR_PER_MIN \ +) + + +/* + * The modes below can be used with the capture string: + */ +#define DEFAULT_STR_MODES_UCAP \ +( \ + MSK_STR_ON_REQ | \ + MSK_STR_AUTO \ +) + + + +/** + * The number of serial ports which were available + * with all GPS receiver models: + */ +#define DEFAULT_N_COM 2 + +/* + * By default that's also the number of ports + * currently available: + */ +#ifndef N_COM + #define N_COM DEFAULT_N_COM +#endif + +/** + * The structure used to store the modes of both serial ports:<br> + * <b>(now obsolete)</b> + */ +typedef struct +{ + COM_PARM com[DEFAULT_N_COM]; /**< COM0 and COM1 settings */ + uint8_t mode[DEFAULT_N_COM]; /**< COM0 and COM1 output mode */ +} PORT_PARM; + +#define _mbg_swab_port_parm( _p ) \ +{ \ + int i; \ + for ( i = 0; i < DEFAULT_N_COM; i++ ) \ + { \ + _mbg_swab_com_parm( &(_p)->com[i] ); \ + /* no need to swap mode byte */ \ + } \ +} + + +/* + * The codes below were used with the obsolete + * PORT_PARM.mode above. They are defined for + * compatibility with older devices only: + */ +enum +{ + /* STR_ON_REQ, defined above */ + /* STR_PER_SEC, defined above */ + /* STR_PER_MIN, defined above */ + N_STR_MODE_0 = STR_AUTO, /* COM0 and COM1 */ + STR_UCAP = N_STR_MODE_0, + STR_UCAP_REQ, + N_STR_MODE_1 /* COM1 only */ +}; + + + +/** + @defgroup group_icode Irig Codes + + The following definitions are used to configure an optional + on-board IRIG input or output. + + A GPS device can generate an IRIG output signal if the bit + #GPS_HAS_IRIG_TX is set in the RECEIVER_INFO.features field. + If a device has an optional IRIG input then the bit + #GPS_HAS_IRIG_RX is set. + + + - Supported IRIG signal code types: + - \b A002: 1000 bps, DC shift, time-of-year + - \b A003: 1000 bps, DC shift, time-of-year, SBS + - \b A132: 1000 bps, 10 kHz carrier, time-of-year + - \b A133: 1000 bps, 10 kHz carrier, time-of-year, SBS + - \b B002: 100 bps, DC shift, time-of-year + - \b B003: 100 bps, DC shift, time-of-year, SBS + - \b B122: 100 bps, 1 kHz carrier, time-of-year + - \b B123: 100 bps, 1 kHz carrier, time-of-year, SBS + - \b AFNOR: 100 bps, 1 kHz carrier, SBS, complete date + - <b> AFNOR DC:</b> 100 bps, DC shift, SBS, complete date + - \b IEEE1344: 100 bps, 1 kHz carrier, time-of-year, SBS, IEEE1344 extensions (B120) + - <b> IEEE1344 DC:</b> 100 bps, DC shift, time-of-year, SBS, IEEE1344 extensions (B000) + - \b B220/1344: 100 bps, DC shift, manchester encoded, IEEE1344 extensions + - \b B222: 100 bps, DC shift, manchester encoded, time-of-year + - \b B223: 100 bps, DC shift, manchester encoded, time-of-year, SBS + + - time-of-year: day-of-year, hours, minutes, seconds + - SBS: straight binary seconds, second-of-day + - IEEE1344 extensions: time zone info + - AFNOR: french standard AFNOR NFS-87500 + + @{ + */ + +/** + * Definitions used with IRIG transmitters which generate + * the same IRIG code both with and without carrier signal + * at the same time. */ +enum +{ + ICODE_TX_B002_B122, + ICODE_TX_B003_B123, + ICODE_TX_A002_A132, + ICODE_TX_A003_A133, + ICODE_TX_AFNOR, + ICODE_TX_IEEE1344, + ICODE_TX_B220_1344, + ICODE_TX_B222, + ICODE_TX_B223, + ICODE_TX_B006_B126, + ICODE_TX_B007_B127, + N_ICODE_TX /**< number of code types */ +}; + + +/** + * Initializers for format name strings. + */ +#define DEFAULT_ICODE_TX_NAMES \ +{ \ + "B002+B122", \ + "B003+B123", \ + "A002+A132", \ + "A003+A133", \ + "AFNOR NFS-87500", \ + "IEEE1344", \ + "B220/1344+IEEE1344", \ + "B222+B122", \ + "B223+B123", \ + "B006+B126", \ + "B007+B127" \ +} + +/** + * Initializers for English format description strings. + */ +#define DEFAULT_ICODE_TX_DESCRIPTIONS_ENG \ +{ \ + "100 bps, DC or 1 kHz carrier", \ + "100 bps, DC or 1 kHz carrier, SBS", \ + "1000 bps, DC or 10 kHz carrier", \ + "1000 bps, DC or 10 kHz carrier, SBS", \ + "100 bps, DC or 1 kHz carrier, SBS, complete date", \ + "100 bps, DC or 1 kHz carrier, SBS, time zone info", \ + "100 bps, DC manchester enc. or 1kHz carrier, SBS, time zone info", \ + "100 bps, DC manchester enc. or 1kHz carrier, time-of-year", \ + "100 bps, DC manchester enc. or 1kHz carrier, time-of-year, SBS", \ + "100 bps, DC or 1 kHz carrier, complete date", \ + "100 bps, DC or 1 kHz carrier, complete date, SBS" \ +} + +/* + * The definitions below are used to set up bit masks + * which restrict the IRIG formats which are supported + * by a given IRIG transmitter device: + */ +#define MSK_ICODE_TX_B002_B122 ( 1UL << ICODE_TX_B002_B122 ) +#define MSK_ICODE_TX_B003_B123 ( 1UL << ICODE_TX_B003_B123 ) +#define MSK_ICODE_TX_A002_A132 ( 1UL << ICODE_TX_A002_A132 ) +#define MSK_ICODE_TX_A003_A133 ( 1UL << ICODE_TX_A003_A133 ) +#define MSK_ICODE_TX_AFNOR ( 1UL << ICODE_TX_AFNOR ) +#define MSK_ICODE_TX_IEEE1344 ( 1UL << ICODE_TX_IEEE1344 ) +#define MSK_ICODE_TX_B220_1344 ( 1UL << ICODE_TX_B220_1344 ) +#define MSK_ICODE_TX_B222 ( 1UL << ICODE_TX_B222 ) +#define MSK_ICODE_TX_B223 ( 1UL << ICODE_TX_B223 ) +#define MSK_ICODE_TX_B006_B126 ( 1UL << ICODE_TX_B006_B126 ) +#define MSK_ICODE_TX_B007_B127 ( 1UL << ICODE_TX_B007_B127 ) + +/** + * A mask of IRIG formats with manchester encoded DC output: + */ +#define MSK_ICODE_TX_DC_MANCH \ +( \ + MSK_ICODE_TX_B220_1344 | \ + MSK_ICODE_TX_B222 | \ + MSK_ICODE_TX_B223 \ +) + +/** + * A mask of IRIG formats with 1 kHz carrier: + */ +#define MSK_ICODE_TX_1KHZ \ +( \ + MSK_ICODE_TX_B002_B122 | \ + MSK_ICODE_TX_B003_B123 | \ + MSK_ICODE_TX_AFNOR | \ + MSK_ICODE_TX_IEEE1344 | \ + MSK_ICODE_TX_B220_1344 | \ + MSK_ICODE_TX_B222 | \ + MSK_ICODE_TX_B223 | \ + MSK_ICODE_TX_B006_B126 | \ + MSK_ICODE_TX_B007_B127 \ +) + +/** + * A mask of IRIG formats with 10 kHz carrier: + */ +#define MSK_ICODE_TX_10KHZ \ +( \ + MSK_ICODE_TX_A002_A132 | \ + MSK_ICODE_TX_A003_A133 \ +) + +/** + * A mask of IRIG formats with 100 bps data rate: + */ +#define MSK_ICODE_TX_100BPS \ +( \ + MSK_ICODE_TX_B002_B122 | \ + MSK_ICODE_TX_B003_B123 | \ + MSK_ICODE_TX_AFNOR | \ + MSK_ICODE_TX_IEEE1344 | \ + MSK_ICODE_TX_B006_B126 | \ + MSK_ICODE_TX_B007_B127 \ +) + +/** + * A mask of IRIG formats with 1000 bps data rate: + */ +#define MSK_ICODE_TX_1000BPS \ +( \ + MSK_ICODE_TX_A002_A132 | \ + MSK_ICODE_TX_A003_A133 \ +) + +/** + * A mask of IRIG formats which support TFOM: + */ +#define MSK_ICODE_TX_HAS_TFOM \ +( \ + MSK_ICODE_TX_IEEE1344 \ +) + +/** + * A mask of IRIG formats which support time zone information: + */ +#define MSK_ICODE_TX_HAS_TZI \ +( \ + MSK_ICODE_TX_IEEE1344 \ +) + +/** + * The default mask of IRIG formats supported by + * IRIG transmitters: + */ +#if !defined( SUPP_MSK_ICODE_TX ) + #define SUPP_MSK_ICODE_TX \ + ( \ + MSK_ICODE_TX_B002_B122 | \ + MSK_ICODE_TX_B003_B123 | \ + MSK_ICODE_TX_A002_A132 | \ + MSK_ICODE_TX_A003_A133 | \ + MSK_ICODE_TX_AFNOR \ + ) +#endif + + + +/** + * Definitions used with IRIG receivers which decode + * two similar IRIG codes + * at the same time. + */ +enum +{ + ICODE_RX_B122_B123, + ICODE_RX_A132_A133, + ICODE_RX_B002_B003, + ICODE_RX_A002_A003, + ICODE_RX_AFNOR, + ICODE_RX_AFNOR_DC, + ICODE_RX_IEEE1344, + ICODE_RX_IEEE1344_DC, + ICODE_RX_B126_B127, + ICODE_RX_B006_B007, + N_ICODE_RX /* the number of valid signal code types */ +}; + +/** + * Initializers for format name strings. + */ +#define DEFAULT_ICODE_RX_NAMES \ +{ \ + "B122/B123", \ + "A132/A133", \ + "B002/B003 (DC)", \ + "A002/A003 (DC)", \ + "AFNOR NFS-87500", \ + "AFNOR NFS-87500 (DC)", \ + "IEEE1344", \ + "IEEE1344 (DC)", \ + "B126/B127", \ + "B006/B007 (DC)" \ +} + +/** + * Initializers for English format description strings. + */ +#define DEFAULT_ICODE_RX_DESCRIPTIONS_ENG \ +{ \ + "100 bps, 1 kHz carrier, SBS optionally", \ + "1000 bps, 10 kHz carrier, SBS optionally", \ + "100 bps, DC shift, SBS optionally", \ + "1000 bps, DC shift, SBS optionally", \ + "100 bps, 1 kHz carrier, SBS, complete date", \ + "100 bps, DC shift, SBS, complete date", \ + "100 bps, 1 kHz carrier, SBS, time zone info", \ + "100 bps, DC shift, SBS, time zone info", \ + "100 bps, 1 kHz carrier, complete date, SBS optionally", \ + "100 bps, DC shift, complete date, SBS optionally" \ +} + +/* + * Bit masks corresponding to the enumeration above: + */ +#define MSK_ICODE_RX_B122_B123 ( 1UL << ICODE_RX_B122_B123 ) +#define MSK_ICODE_RX_A132_A133 ( 1UL << ICODE_RX_A132_A133 ) +#define MSK_ICODE_RX_B002_B003 ( 1UL << ICODE_RX_B002_B003 ) +#define MSK_ICODE_RX_A002_A003 ( 1UL << ICODE_RX_A002_A003 ) +#define MSK_ICODE_RX_AFNOR ( 1UL << ICODE_RX_AFNOR ) +#define MSK_ICODE_RX_AFNOR_DC ( 1UL << ICODE_RX_AFNOR_DC ) +#define MSK_ICODE_RX_IEEE1344 ( 1UL << ICODE_RX_IEEE1344 ) +#define MSK_ICODE_RX_IEEE1344_DC ( 1UL << ICODE_RX_IEEE1344_DC ) +#define MSK_ICODE_RX_B126_B127 ( 1UL << ICODE_RX_B126_B127 ) +#define MSK_ICODE_RX_B006_B007 ( 1UL << ICODE_RX_B006_B007 ) + +/** + * A mask of IRIG formats which have DC shift: + */ +#define MSK_ICODE_RX_DC \ +( \ + MSK_ICODE_RX_B002_B003 | \ + MSK_ICODE_RX_A002_A003 | \ + MSK_ICODE_RX_AFNOR_DC | \ + MSK_ICODE_RX_IEEE1344_DC | \ + MSK_ICODE_RX_B006_B007 \ +) + +/** + * A mask of IRIG formats with 1 kHz carrier: + */ +#define MSK_ICODE_RX_1KHZ \ +( \ + MSK_ICODE_RX_B122_B123 | \ + MSK_ICODE_RX_AFNOR | \ + MSK_ICODE_RX_IEEE1344 | \ + MSK_ICODE_RX_B126_B127 \ +) + +/** + * A mask of IRIG formats with 10 kHz carrier: + */ +#define MSK_ICODE_RX_10KHZ \ +( \ + MSK_ICODE_RX_A132_A133 \ +) + +/** + * A mask of IRIG formats with 100 bps data rate: + */ +#define MSK_ICODE_RX_100BPS \ +( \ + MSK_ICODE_RX_B122_B123 | \ + MSK_ICODE_RX_B002_B003 | \ + MSK_ICODE_RX_AFNOR | \ + MSK_ICODE_RX_AFNOR_DC | \ + MSK_ICODE_RX_IEEE1344 | \ + MSK_ICODE_RX_IEEE1344_DC | \ + MSK_ICODE_RX_B126_B127 | \ + MSK_ICODE_RX_B006_B007 \ +) + +/** + * A mask of IRIG formats with 1000 bps data rate: + */ +#define MSK_ICODE_RX_1000BPS \ +( \ + MSK_ICODE_RX_A132_A133 | \ + MSK_ICODE_RX_A002_A003 \ +) + +/** + * A mask of IRIG formats which support TFOM: + */ +#define MSK_ICODE_RX_HAS_TFOM \ +( \ + MSK_ICODE_RX_IEEE1344 | \ + MSK_ICODE_RX_IEEE1344_DC \ +) + +/** + * A mask of IRIG formats which support time zone information: + */ +#define MSK_ICODE_RX_HAS_TZI \ +( \ + MSK_ICODE_RX_IEEE1344 | \ + MSK_ICODE_RX_IEEE1344_DC \ +) + +/** + * The default mask of IRIG formats supported by + * IRIG receivers: + */ +#if !defined( SUPP_MSK_ICODE_RX ) + #define SUPP_MSK_ICODE_RX \ + ( \ + MSK_ICODE_RX_B122_B123 | \ + MSK_ICODE_RX_A132_A133 | \ + MSK_ICODE_RX_B002_B003 | \ + MSK_ICODE_RX_A002_A003 | \ + MSK_ICODE_RX_AFNOR | \ + MSK_ICODE_RX_AFNOR_DC \ + ) +#endif +/** @} */ + +/** + * The structure below is used to configure an optional + * on-board IRIG output: + */ +typedef struct +{ + uint16_t icode; /**< IRIG signal code, see \ref group_icode */ + uint16_t flags; /**< see \ref group_irig_flags */ +} IRIG_SETTINGS; + +#define _mbg_swab_irig_settings( _p ) \ +{ \ + _mbg_swab16( &(_p)->icode ); \ + _mbg_swab16( &(_p)->flags ); \ +} + + +/** + @defgroup group_irig_flags Bit Masks used with IRIG_SETTINGS.flags + + (others are reserved) +* @{ + */ +#define IFLAGS_DISABLE_TFOM 0x0001 /**< RX ignore/TX don't gen TFOM */ +#define IFLAGS_TX_GEN_LOCAL_TIME 0x0002 /**< gen local time, not UTC */ + +#define IFLAGS_MASK 0x0003 /**< flags above or'ed */ + +/** @} */ + +/** + * The structure is used to query the IRIG configuration + * plus the supported codes: + */ +typedef struct +{ + IRIG_SETTINGS settings; + uint32_t supp_codes; /**< bit mask of supported codes */ +} IRIG_INFO; + +#define _mbg_swab_irig_info( _p ) \ +{ \ + _mbg_swab_irig_settings( &(_p)->settings ); \ + _mbg_swab32( &(_p)->supp_codes ); \ +} + + +// The type below is used to read the board's debug status +// which also include IRIG decoder status: +typedef uint32_t MBG_DEBUG_STATUS; + +// The debug status is bit coded as defined below: +enum +{ + MBG_IRIG_BIT_WARMED_UP, /**< Osc has warmed up */ + MBG_IRIG_BIT_PPS_ACTIVE, /**< PPS output is active */ + MBG_IRIG_BIT_INV_CONFIG, /**< Invalid config, e.g. data csum error */ + MBG_IRIG_BIT_MSG_DECODED, /**< IRIG msg could be decoded */ + MBG_IRIG_BIT_MSG_INCONSISTENT, /**< IRIG msg contains inconsistent data */ + MBG_IRIG_BIT_LOOP_LOCKED, /**< Decoder control loop is locked */ + MBG_IRIG_BIT_JITTER_TOO_LARGE, /**< Phase jitter too large */ + MBG_IRIG_BIT_INV_REF_OFFS, /**< UTC ref offset not configured */ + + MBG_SYS_BIT_INV_TIME, /**< Internal time not valid/set */ + MBG_SYS_BIT_TIME_SET_VIA_API, /**< On board time set externally */ + MBG_SYS_BIT_INV_RTC, /**< On board RTC invalid */ + MBG_SYS_BIT_CPU_PLL_FAILED, /**< The CPU's PLL watchdog */ + + N_MBG_DEBUG_BIT +}; + +/* + * Initializers for IRIG status bit strings. + */ +#define MBG_DEBUG_STATUS_STRS \ +{ \ + "Osc has warmed up", \ + "PPS output is active", \ + "Config set to default", \ + "IRIG msg decoded", \ + "IRIG msg not consistent", \ + "Decoder control loop locked", \ + "Phase jitter too large", \ + "Invalid ref offset" \ + \ + "Internal time not valid" \ + "On board time set via API" \ + "On board RTC invalid" \ + "CPU PLL failure, needs restart" \ +} + + + +#define MBG_IRIG_MSK_WARMED_UP ( 1UL << MBG_IRIG_BIT_WARMED_UP ) +#define MBG_IRIG_MSK_PPS_ACTIVE ( 1UL << MBG_IRIG_BIT_PPS_ACTIVE ) +#define MBG_IRIG_MSK_INV_CONFIG ( 1UL << MBG_IRIG_BIT_INV_CONFIG ) +#define MBG_IRIG_MSK_MSG_DECODED ( 1UL << MBG_IRIG_BIT_MSG_DECODED ) +#define MBG_IRIG_MSK_MSG_INCONSISTENT ( 1UL << MBG_IRIG_BIT_MSG_INCONSISTENT ) +#define MBG_IRIG_MSK_LOOP_LOCKED ( 1UL << MBG_IRIG_BIT_LOOP_LOCKED ) +#define MBG_IRIG_MSK_JITTER_TOO_LARGE ( 1UL << MBG_IRIG_BIT_JITTER_TOO_LARGE ) +#define MBG_IRIG_MSK_INV_REF_OFFS ( 1UL << MBG_IRIG_BIT_INV_REF_OFFS ) + +#define MBG_SYS_MSK_INV_TIME ( 1UL << MBG_SYS_BIT_INV_TIME ) +#define MBG_SYS_MSK_TIME_SET_VIA_API ( 1UL << MBG_SYS_BIT_TIME_SET_VIA_API ) +#define MBG_SYS_MSK_INV_RTC ( 1UL << MBG_SYS_BIT_INV_RTC ) +#define MBG_SYS_MSK_CPU_PLL_FAILED ( 1UL << MBG_SYS_BIT_CPU_PLL_FAILED ) + + + +typedef int16_t MBG_REF_OFFS; /**< -MBG_REF_OFFS_MAX..MBG_REF_OFFS_MAX */ + +#define _mbg_swab_mbg_ref_offs( _p ) _mbg_swab16( (_p) ) + + +/** the maximum allowed positive / negative offset */ +#define MBG_REF_OFFS_MAX ( ( 12L * 60 ) + 30 ) // [minutes] + +/** + * the following value is used to indicate that the ref offset + * value has not yet been configured + */ +#define MBG_REF_OFFS_NOT_CFGD 0x8000 + + +typedef struct +{ + uint32_t flags; +} MBG_OPT_SETTINGS; + +#define _mbg_swab_mbg_opt_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->flags ); \ +} + + +typedef struct +{ + MBG_OPT_SETTINGS settings; + uint32_t supp_flags; +} MBG_OPT_INFO; + +#define _mbg_swab_mbg_opt_info( _p ) \ +{ \ + _mbg_swab_mbg_opt_settings( &(_p)->settings ); \ + _mbg_swab32( &(_p)->supp_flags ); \ +} + + +enum +{ + MBG_OPT_BIT_STR_UTC, /**< serial string contains UTC time */ + MBG_OPT_BIT_EMU_SYNC, /**< emulate/pretend to be synchronized, */ + /**< alternatively GPS_FEAT_IGNORE_LOCK may be supported */ + N_MBG_OPT_BIT +}; + +/* + * Bit masks corresponding to the enumeration above: + */ +#define MBG_OPT_FLAG_STR_UTC ( 1UL << MBG_OPT_BIT_STR_UTC ) +#define MBG_OPT_FLAG_EMU_SYNC ( 1UL << MBG_OPT_BIT_EMU_SYNC ) + + +/* + * The structures below are required to setup the programmable + * pulse outputs which are provided by some GPS receivers. + * The number of programmable pulse outputs supported by a GPS + * receiver is reported in the RECEIVER_INFO.n_str_type field. + */ + +/** + * The structure is used to define a date of year: + */ +typedef struct +{ + uint8_t mday; /* 1..28,29,30,31 */ + uint8_t month; /* 1..12 */ + uint16_t year; /* including century */ +} MBG_DATE; + +#define _mbg_swab_mbg_date( _p ) \ +{ \ + _mbg_swab16( &(_p)->year ); \ +} + + +/** + * The structure is used to define a time of day: + */ +typedef struct +{ + uint8_t hour; /* 0..23 */ + uint8_t min; /* 0..59 */ + uint8_t sec; /* 0..59,60 */ + uint8_t sec100; /* reserved, currently always 0 */ +} MBG_TIME; + +#define _mbg_swab_mbg_time( _p ) \ + _nop_macro_fnc() // nothing to swap + + +/** + * The structure defines a single date and time + * for switching operations: + */ +typedef struct +{ + MBG_DATE d; /* date to switch */ + MBG_TIME t; /* time to switch */ + uint8_t wday; /* reserved, currently always 0 */ + uint8_t flags; /* reserved, currently 0 */ +} MBG_DATE_TIME; + +#define _mbg_swab_mbg_date_time( _p ) \ +{ \ + _mbg_swab_mbg_date( &(_p)->d ); \ + _mbg_swab_mbg_time( &(_p)->t ); \ +} + + +/** + * The structure defines times and dates + * for an on/off cycle: + */ +typedef struct +{ + MBG_DATE_TIME on; /* time and date to switch on */ + MBG_DATE_TIME off; /* time and date to switch off */ +} POUT_TIME; + +#define _mbg_swab_pout_time( _p ) \ +{ \ + _mbg_swab_mbg_date_time( &(_p)->on ); \ + _mbg_swab_mbg_date_time( &(_p)->off ); \ +} + + +/** + * The number of POUT_TIMEs for each programmable pulse output + */ +#define N_POUT_TIMES 3 + +/** + * The structure is used to configure a single programmable + * pulse output. + */ +typedef struct +{ + uint16_t mode; /**< mode of operation, codes defined below */ + uint16_t pulse_len; /**< 10 msec units, or COM port number */ + uint16_t timeout; /**< [min], for dcf_mode */ + uint16_t flags; /**< see below */ + POUT_TIME tm[N_POUT_TIMES]; /**< switching times */ +} POUT_SETTINGS; + +#define _mbg_swab_pout_settings( _p ) \ +{ \ + int i; \ + _mbg_swab16( &(_p)->mode ); \ + _mbg_swab16( &(_p)->pulse_len ); \ + _mbg_swab32( &(_p)->timeout ); \ + _mbg_swab16( &(_p)->flags ); \ + \ + for ( i = 0; i < N_POUT_TIMES; i++ ) \ + _mbg_swab_pout_time( &(_p)->tm[i] ); \ +} + + +#define MAX_POUT_PULSE_LEN 1000 /**< 10 secs, in 10 msec units */ +#define MAX_POUT_DCF_TIMOUT ( 48 * 60 ) /**< 48 hours, in minutes */ + + +/** + * These codes are defined for POUT_SETTINGS.mode to setup + * the basic mode of operation for a single programmable pulse + * output: + */ +enum +{ + POUT_IDLE, /**< always off, or on if POUT_INVERTED */ + POUT_TIMER, /**< switch on/off at configured times */ + POUT_SINGLE_SHOT, /**< pulse at time POUT_SETTINGS.tm[0].on */ + POUT_CYCLIC_PULSE, /**< pulse every POUT_SETTINGS.tm[0].on.t interval */ + POUT_PER_SEC, /**< pulse if second changes */ + POUT_PER_MIN, /**< pulse if minute changes */ + POUT_PER_HOUR, /**< pulse if hour changes */ + POUT_DCF77, /**< emulate DCF77 signal */ + POUT_POS_OK, /**< on if pos. OK (nav_solved) */ + POUT_TIME_SYNC, /**< on if time sync (time_syn) */ + POUT_ALL_SYNC, /**< on if pos. OK and time sync */ + POUT_TIMECODE, /**< IRIG/AFNOR DCLS output */ + POUT_TIMESTR, /**< COM port number in pulse_len field */ + POUT_10MHZ, /**< 10 MHz fixed frequency */ + N_POUT_MODES +}; + + +/* + * Default initializers for English pulse mode names. Initializers + * for multi-language strings can be found in pcpslstr.h. + */ +#define ENG_POUT_NAME_IDLE "Idle" +#define ENG_POUT_NAME_TIMER "Timer" +#define ENG_POUT_NAME_SINGLE_SHOT "Single Shot" +#define ENG_POUT_NAME_CYCLIC_PULSE "Cyclic Pulse" +#define ENG_POUT_NAME_PER_SEC "Pulse Per Second" +#define ENG_POUT_NAME_PER_MIN "Pulse Per Min" +#define ENG_POUT_NAME_PER_HOUR "Pulse Per Hour" +#define ENG_POUT_NAME_DCF77 "DCF77 Marks" +#define ENG_POUT_NAME_POS_OK "Position OK" +#define ENG_POUT_NAME_TIME_SYNC "Time Sync" +#define ENG_POUT_NAME_ALL_SYNC "All Sync" +#define ENG_POUT_NAME_TIMECODE "DCLS Time Code" +#define ENG_POUT_NAME_TIMESTR "COM Time String" +#define ENG_POUT_NAME_10MHZ "10 MHz Frequency" + +#define DEFAULT_ENG_POUT_NAMES \ +{ \ + ENG_POUT_NAME_IDLE, \ + ENG_POUT_NAME_TIMER, \ + ENG_POUT_NAME_SINGLE_SHOT, \ + ENG_POUT_NAME_CYCLIC_PULSE, \ + ENG_POUT_NAME_PER_SEC, \ + ENG_POUT_NAME_PER_MIN, \ + ENG_POUT_NAME_PER_HOUR, \ + ENG_POUT_NAME_DCF77, \ + ENG_POUT_NAME_POS_OK, \ + ENG_POUT_NAME_TIME_SYNC, \ + ENG_POUT_NAME_ALL_SYNC, \ + ENG_POUT_NAME_TIMECODE, \ + ENG_POUT_NAME_TIMESTR, \ + ENG_POUT_NAME_10MHZ \ +} + + +#define ENG_POUT_HINT_IDLE "Constant output level" +#define ENG_POUT_HINT_TIMER "Switch based on configured on/off times" +#define ENG_POUT_HINT_SINGLE_SHOT "Generate a single pulse of determined length" +#define ENG_POUT_HINT_CYCLIC_PULSE "Generate cyclic pulses of determined length" +#define ENG_POUT_HINT_PER_SEC "Generate pulse at beginning of new second" +#define ENG_POUT_HINT_PER_MIN "Generate pulse at beginning of new minute" +#define ENG_POUT_HINT_PER_HOUR "Generate pulse at beginning of new hour" +#define ENG_POUT_HINT_DCF77 "DCF77 compatible time marks" +#define ENG_POUT_HINT_POS_OK "Switch if receiver position has been verified" +#define ENG_POUT_HINT_TIME_SYNC "Switch if time is synchronized" +#define ENG_POUT_HINT_ALL_SYNC "Switch if full sync" +#define ENG_POUT_HINT_TIMECODE "Duplicate IRIG time code signal" +#define ENG_POUT_HINT_TIMESTR "Duplicate serial time string of specified port" +#define ENG_POUT_HINT_10MHZ "10 MHz fixed output frequency" + +#define DEFAULT_ENG_POUT_HINTS \ +{ \ + ENG_POUT_HINT_IDLE, \ + ENG_POUT_HINT_TIMER, \ + ENG_POUT_HINT_SINGLE_SHOT, \ + ENG_POUT_HINT_CYCLIC_PULSE, \ + ENG_POUT_HINT_PER_SEC, \ + ENG_POUT_HINT_PER_MIN, \ + ENG_POUT_HINT_PER_HOUR, \ + ENG_POUT_HINT_DCF77, \ + ENG_POUT_HINT_POS_OK, \ + ENG_POUT_HINT_TIME_SYNC, \ + ENG_POUT_HINT_ALL_SYNC, \ + ENG_POUT_HINT_TIMECODE, \ + ENG_POUT_HINT_TIMESTR, \ + ENG_POUT_HINT_10MHZ \ +} + + +/* + * The definitions below are used to set up bit masks + * which restrict the modes which can be used with + * a given programmable output: + */ +#define MSK_POUT_IDLE ( 1UL << POUT_IDLE ) +#define MSK_POUT_TIMER ( 1UL << POUT_TIMER ) +#define MSK_POUT_SINGLE_SHOT ( 1UL << POUT_SINGLE_SHOT ) +#define MSK_POUT_CYCLIC_PULSE ( 1UL << POUT_CYCLIC_PULSE ) +#define MSK_POUT_PER_SEC ( 1UL << POUT_PER_SEC ) +#define MSK_POUT_PER_MIN ( 1UL << POUT_PER_MIN ) +#define MSK_POUT_PER_HOUR ( 1UL << POUT_PER_HOUR ) +#define MSK_POUT_DCF77 ( 1UL << POUT_DCF77 ) +#define MSK_POUT_POS_OK ( 1UL << POUT_POS_OK ) +#define MSK_POUT_TIME_SYNC ( 1UL << POUT_TIME_SYNC ) +#define MSK_POUT_ALL_SYNC ( 1UL << POUT_ALL_SYNC ) +#define MSK_POUT_TIMECODE ( 1UL << POUT_TIMECODE ) +#define MSK_POUT_TIMESTR ( 1UL << POUT_TIMESTR ) +#define MSK_POUT_10MHZ ( 1UL << POUT_10MHZ ) + + +/* + * The codes below are used with POUT_SETTINGS.flags: + */ +#define POUT_INVERTED 0x0001 + + +/** + Since a clock may support more than one programmable + pulse output, setup tools must use the structure below + to read/set pulse output configuration. + The number of outputs supported by a receiver model + can be queried using the RECEIVER_INFO structure. + */ +typedef struct +{ + uint16_t idx; /**< 0..RECEIVER_INFO.n_prg_out-1 */ + POUT_SETTINGS pout_settings; +} POUT_SETTINGS_IDX; + +#define _mbg_swab_pout_settings_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_pout_settings( &(_p)->pout_settings ); \ +} + + +/** + The structure below holds the current settings + for a programmable pulse output, plus additional + informaton on the output's capabilities. + This can be read by setup programs to allow setup + of supported features only. + */ +typedef struct +{ + POUT_SETTINGS pout_settings; + uint32_t supp_modes; /**< bit mask of modes supp. by this output */ + uint8_t timestr_ports; /**< bit mask of COM ports supported for POUT_TIMESTR */ + uint8_t reserved_0; /**< reserved for future use, currently 0 */ + uint16_t reserved_1; /**< reserved for future use, currently 0 */ + uint32_t flags; /**< reserved for future use, currently 0 */ +} POUT_INFO; + +#define _mbg_swab_pout_info( _p ) \ +{ \ + _mbg_swab_pout_settings( &(_p)->pout_settings ); \ + _mbg_swab32( &(_p)->supp_modes ); \ + _mbg_swab16( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->flags ); \ +} + + +/** The max number of COM ports that can be handled by POUT_INFO::timestr_ports */ +#define MAX_POUT_TIMESTR_PORTS 8 + +/** + The structure below adds an index number to the structure + above to allow addressing of several instances: + */ +typedef struct +{ + uint16_t idx; /**< 0..RECEIVER_INFO.n_prg_out-1 */ + POUT_INFO pout_info; +} POUT_INFO_IDX; + +#define _mbg_swab_pout_info_idx( _p ) \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_pout_info( &(_p)->pout_info ); \ +} + + +/* + * The codes below are used with devices which support multiple + * ref time sources at the same time. The priorities of the + * supported ref time sources is configurable. + */ + + +/* + * All possibly supported ref time sources + */ +enum +{ + MULTI_REF_NONE = -1, // nothing, undefined + MULTI_REF_GPS = 0, // standard GPS + MULTI_REF_10MHZ, // 10 MHz input frequency + MULTI_REF_PPS, // 1 PPS input signal + MULTI_REF_10MHZ_PPS, // combined 10 MHz plus PPS + MULTI_REF_IRIG, // IRIG input + MULTI_REF_NTP, // Network Time Protocol (NTP) + MULTI_REF_PTP, // Precision Time Protocol (PTP, IEEE1588) + MULTI_REF_PTP_E1, // PTP over E1 + MULTI_REF_FREQ, // fixed frequency + N_MULTI_REF // the number of defined sources +}; + + +/* + * Names of supported ref time sources + */ +#define DEFAULT_MULTI_REF_NAMES \ +{ \ + "GPS", \ + "10 MHz freq in", \ + "PPS in", \ + "10 MHz + PPS in", \ + "IRIG", \ + "NTP", \ + "PTP (IEEE1588)", \ + "PTP over E1", \ + "Fixed Freq. in" \ +} + + +/* + * Bit masks used to indicate supported reference sources + */ +#define HAS_MULTI_REF_GPS ( 1UL << MULTI_REF_GPS ) +#define HAS_MULTI_REF_10MHZ ( 1UL << MULTI_REF_10MHZ ) +#define HAS_MULTI_REF_PPS ( 1UL << MULTI_REF_PPS ) +#define HAS_MULTI_REF_10MHZ_PPS ( 1UL << MULTI_REF_10MHZ_PPS ) +#define HAS_MULTI_REF_IRIG ( 1UL << MULTI_REF_IRIG ) +#define HAS_MULTI_REF_NTP ( 1UL << MULTI_REF_NTP ) +#define HAS_MULTI_REF_PTP ( 1UL << MULTI_REF_PTP ) +#define HAS_MULTI_REF_PTP_E1 ( 1UL << MULTI_REF_PTP_E1 ) +#define HAS_MULTI_REF_FREQ ( 1UL << MULTI_REF_FREQ ) + + +/* + * There are 2 different ways to configure multi ref support + * provided by some devices. + * + * Newer devices which have the GPS_FEAT_XMULTI_REF flag set + * in RECEIVER_INFO::features support the newer XMULTI_REF_... + * structures which provide a more flexible interface. + * + * Older devices which have the GPS_FEAT_MULTI_REF flag set + * support these MULTI_REF_... structures below where + * the number of supported input sources and priorities + * is limited to N_MULTI_REF_PRIO. + */ + +#define N_MULTI_REF_PRIO 4 + + +/** + The structure below is used to configure the priority of + the supported ref sources. + + The number stored in prio[0] of the array indicates the ref time + source with highest priority. If that source fails, the device + falls back to the source indicated by prio[1]. Each field of + the prio[] array must be set to one of the values 0..N_MULTI_REF-1, + or to -1 (0xFF) if the value is not assigned. + */ +typedef struct +{ + uint8_t prio[N_MULTI_REF_PRIO]; +} MULTI_REF_SETTINGS; + + +/** + The structure below is used to query the MULTI_REF configuration, + plus the supported ref sources. + */ +typedef struct +{ + MULTI_REF_SETTINGS settings; /* current settings */ + uint32_t supp_ref; /* supp. HAS_MULTI_REF_... codes or'ed */ + uint16_t n_levels; /* supp. levels, 0..N_MULTI_REF_PRIO */ + uint16_t flags; /* reserved, currently 0 */ +} MULTI_REF_INFO; + + +/* + * The type below is used to query the MULTI_REF status information, + */ +typedef uint16_t MULTI_REF_STATUS; /* flag bits as defined below */ + + +/* + * The bits and associated bit masks below are used with the + * MULTI_REF_STATUS type. Each bit is set if the associated + * condition is true and is reset if the condition is not true: + */ +enum +{ + WRN_MODULE_MODE, /* selected input mode was invalid, set to default */ + WRN_COLD_BOOT, /* GPS is in cold boot mode */ + WRN_WARM_BOOT, /* GPS is in warm boot mode */ + WRN_ANT_DISCONN, /* antenna is disconnected */ + WRN_10MHZ_UNLOCK, /* impossible to lock to external 10MHz reference */ + WRN_1PPS_UNLOCK, /* impossible to lock to external 1PPS reference */ + WRN_GPS_UNLOCK, /* impossible to lock to GPS */ + WRN_10MHZ_MISSING, /* external 10MHz signal not available */ + WRN_1PPS_MISSING, /* external 1PPS signal not available */ + N_MULTI_REF_STATUS_BITS +}; + +#define MSK_WRN_COLD_BOOT ( 1UL << WRN_COLD_BOOT ) +#define MSK_WRN_WARM_BOOT ( 1UL << WRN_WARM_BOOT ) +#define MSK_WRN_ANT_DISCONN ( 1UL << WRN_ANT_DISCONN ) +#define MSK_WRN_10MHZ_UNLOCK ( 1UL << WRN_10MHZ_UNLOCK ) +#define MSK_WRN_1PPS_UNLOCK ( 1UL << WRN_1PPS_UNLOCK ) +#define MSK_WRN_GPS_UNLOCK ( 1UL << WRN_GPS_UNLOCK ) +#define MSK_WRN_10MHZ_MISSING ( 1UL << WRN_10MHZ_MISSING ) +#define MSK_WRN_1PPS_MISSING ( 1UL << WRN_1PPS_MISSING ) +#define MSK_WRN_MODULE_MODE ( 1UL << WRN_MODULE_MODE ) + + + +/* + * If the RECEIVER_INFO::features flag GPS_FEAT_XMULTI_REF is set + * then the following XMULTI_REF_... data structures must be used + * instead of the older MULTI_REF_... structures above. + * + * Those devices support a number of priority levels addressed by + * the priority index, starting at 0 for highest priority. A single + * reference time source from the set of supported sources can be + * assigned to each priority level. + * + * The structures below are used to configure the individual + * time source for each priority level, and retrieve the status + * of the time source at each priority level. + */ + +typedef struct +{ + uint8_t type; /* 0..N_MULTI_REF-1 from the enum above */ + uint8_t instance; /* reserved, currently always 0 */ +} XMULTI_REF_ID; + +typedef struct +{ + XMULTI_REF_ID id; /* time source identifier */ + uint16_t flags; /* reserved, currently always 0 */ + NANO_TIME bias; /* time bias, e.g. path delay */ + NANO_TIME precision; /* precision of the time source */ + uint32_t fine_limit; /* smooth control if below this limit */ +} XMULTI_REF_SETTINGS; + + +/* + * The structure below is used to retrieve or configure the time source + * for a specific priority level. + * After configuring, a structure with idx == 0xFFFF (-1) must be sent + * to let the changes become effective. + */ +typedef struct +{ + uint16_t idx; /* the priority level index, highest == 0 */ + XMULTI_REF_SETTINGS settings; /* the settings configured for this level */ + +} XMULTI_REF_SETTINGS_IDX; + + +/* + * The structure below contains the XMULTI_REF configuration + * for a single priority level, plus information on supported + * ref time sources, and the number of supported priority levels. + */ +typedef struct +{ + XMULTI_REF_SETTINGS settings; /* current settings */ + uint32_t supp_ref; /* supp. HAS_MULTI_REF_... codes or'ed */ + uint8_t n_supp_ref; /* number of supported ref time sources */ + uint8_t n_prio; /* number of supported priority levels */ + uint16_t flags; /* reserved, currently 0, e.g. multiple instance support */ + +} XMULTI_REF_INFO; + + +/* + * The structure below is used to retrieve the XMULTI_REF configuration + * information for a specific priority level. + */ +typedef struct +{ + uint16_t idx; /* the priority level index, highest == 0 */ + XMULTI_REF_INFO info; + +} XMULTI_REF_INFO_IDX; + + +/* + * The structure below contains status information on a single + * ref time source. + */ +typedef struct +{ + XMULTI_REF_ID id; /* time source identifier */ + uint16_t status; /* flag bits as defined below */ + NANO_TIME offset; /* time offset from main time base */ + uint32_t reserved; /* reserved, currently always 0 */ + +} XMULTI_REF_STATUS; + + +/* + * The structure below is used to retrieve the the status information + * of the time source at a specific priority level. + */ +typedef struct +{ + uint16_t idx; /* the priority level index, highest == 0 */ + XMULTI_REF_STATUS status; + +} XMULTI_REF_STATUS_IDX; + + +/* + * Bits used with XMULTI_REF_STATUS. + */ +enum +{ + XMRS_BIT_NOT_SUPP, /* ref type cfg'd for this level is not supported */ + XMRS_BIT_NO_CONN, /* input signal is disconnected */ + XMRS_BIT_NO_SIGNAL, /* no input signal */ + XMRS_BIT_IS_MASTER, /* reference is master source */ + XMRS_BIT_IS_LOCKED, /* locked to input signal */ + XMRS_BIT_IS_ACCURATE, /* oscillator control has reached full accuracy */ + XMRS_BIT_NOT_SETTLED, /* reference time signal not settled */ + N_XMRS_BITS +}; + + +/* bit masks corresponding to the flag bits above */ + +#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP ) +#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN ) +#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL ) +#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER ) +#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED ) +#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE ) +#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED ) + + + +/* + * An initializer for a XMULTI_REF_STATUS variable + * with status invalid / not used + */ +#define XMULTI_REF_STATUS_INVALID \ +{ \ + { (uint8_t) MULTI_REF_NONE, 0 }, /* id; instance 0 ? */ \ + XMRS_MSK_NO_CONN | XMRS_MSK_NO_SIGNAL, /* status */ \ + { 0 }, /* offset */ \ + 0 /* reserved */ \ +} + + + +/*------------------------------------------------------------------------*/ + +/* + * The types below are not used with all devices: + */ + +typedef uint16_t ROM_CSUM; /* The ROM checksum */ +typedef uint16_t RCV_TIMEOUT; /* [min] (only if HAS_RCV_TIMEOUT) */ +typedef uint16_t IGNORE_LOCK; /* (only if GPS_HAS_IGNORE_LOCK) */ + +/* + * Originally IGNORE_LOG above has been a boolean value (equal or + * not equal 0) which was evaluated the same way for all ports. + * + * Due to special firmware requirements it has been changed to a + * bit maskable property in order to be able to specify the behaviour + * for individual ports. + * + * In order to keep compatibility with older versions the LSB is used + * to specify ignore_lock for all ports. The next higher bits are used + * to specify ignore_lock for an individual port, where the bit position + * depends on the port number, e.g. 0x02 for COM0, 0x04 for COM1, etc. + * The macros below can be used to simplify the code: + */ + +/* return a bit mask depending on the port number */ +#define IGNORE_LOCK_FOR_ALL_PORTS 0x01 + +#define _ignore_lock_for_all_ports() ( IGNORE_LOCK_FOR_ALL_PORTS ) + +#define _ignore_lock_for_port( _n ) ( 0x02 << (_n) ) + +/* check if all ports are ignore_lock'ed */ +#define _is_ignore_lock_all_ports( _il ) ( (_il) & IGNORE_LOCK_FOR_ALL_PORTS ) + +/* check if a specific port is ignore_lock'ed */ +#define _is_ignore_lock_for_port( _il, _n ) \ + ( (_il) & ( _ignore_lock_for_port(_n) | IGNORE_LOCK_FOR_ALL_PORTS ) ) + + +/*------------------------------------------------------------------------*/ + +/* + * The structures below are used with the SCU multiplexer board + * in a redundant system: + */ + +typedef struct +{ + uint32_t hw_id; // hardware identification + uint32_t fw_id; // firmware identification + uint16_t flags; // reserved currently 0 + uint8_t clk0_info; // reference clock 0 type + uint8_t clk1_info; // reference clock 1 type + uint16_t epld_status; // epld status word, see defintions below + uint16_t epld_control; // epld control word, see defintions below +} SCU_STAT_INFO; + +typedef struct +{ + uint16_t epld_control_mask; // control mask, determines which bit is to be changed + uint16_t epld_control_value; // control value, determines value of bits to be changed + uint32_t flags; // reserved, currently 0 +} SCU_STAT_SETTINGS; + +// definitions for status word bit masks +#define MSK_EPLD_STAT_TS1 0x0001 // state of time sync signal clk_1 +#define MSK_EPLD_STAT_TS2 0x0002 // state of time sync signal clk_2 +#define MSK_EPLD_STAT_TL_ERROR 0x0004 // state of time limit error input +#define MSK_EPLD_STAT_PSU1_OK 0x0008 // state of power supply 1 monitoring input +#define MSK_EPLD_STAT_PSU2_OK 0x0010 // state of power supply 2 monitoring input +#define MSK_EPLD_STAT_AUTO 0x0020 // AUTOMATIC/REMOTE or MANUAL Mode +#define MSK_EPLD_STAT_SEL 0x0040 // select bit for output MUX, ( clk_1 = 0 ) +#define MSK_EPLD_STAT_ENA 0x0080 // enable Bit for output MUX, set if enabled +#define MSK_EPLD_STAT_ACO 0x4000 // Access control override bit +#define MSK_EPLD_STAT_WDOG_OK 0x8000 // WDT_OK set to zero if watchdog expired + + +#define MSK_EPLD_CNTL_SEL_REM 0x0800 // remote select for output MUX ( clk_1 = 0 ) +#define MSK_EPLD_CNTL_DIS_REM 0x1000 // remote disable for output MUX +#define MSK_EPLD_CNTL_REMOTE 0x2000 // must be set to enable remote operation +#define MSK_EPLD_CNTL_SEL_SNMP 0x4000 // connect COM0 channels to XPORT +#define MSK_EPLD_CNTL_ENA_SNMP 0x8000 // select clk for comm. ( clk1 = 0 ) + + +/* + * Definitions for clk0_info and clk1_info, can be used to determine + * the reference clock type connected to SCU input channel 0 and 1: + */ +enum +{ + SCU_CLK_INFO_GPS, // ref. clock is GPS receiver + SCU_CLK_INFO_DCF_PZF, // ref. clock is DCF77 PZF receiver + SCU_CLK_INFO_DCF_AM, // ref. clock is DCF77 AM receiver + SCU_CLK_INFO_TCR // ref. clock is IRIG time code receiver +}; + + + +/*------------------------------------------------------------------------*/ + +/* + * GPS receiver modes of operation. Some of the codes combinations + * are obsolete with recent GPS receivers. However, that doesn't + * matter since the mode is just read from the receiver: + */ +#define REMOTE 0x10 +#define BOOT 0x20 + +#define TRACK ( 0x01 ) +#define AUTO_166 ( 0x02 ) +#define WARM_166 ( 0x03 | BOOT ) +#define COLD_166 ( 0x04 | BOOT ) +#define AUTO_BC ( 0x05 | REMOTE ) +#define WARM_BC ( 0x06 | REMOTE | BOOT ) +#define COLD_BC ( 0x07 | REMOTE | BOOT ) +#define UPDA_166 ( 0x08 | BOOT ) +#define UPDA_BC ( 0x09 | REMOTE | BOOT ) + +typedef struct +{ + uint16_t mode; /**< Mode of operation. */ + uint16_t good_svs; /**< No. of satellites that are currently used by the receiver */ + uint16_t svs_in_view; /**< No. of satellites that are in view according to the almanac data */ + int16_t dac_val; /**< Oscillator fine DAC value */ + int16_t dac_cal; /**< Calibration DAC value of oscillator ( see #OSC_DAC_RANGE, #OSC_DAC_BIAS ) */ +} STAT_INFO; + +#define _mbg_swab_stat_info( _p ) \ +{ \ + _mbg_swab16( &(_p)->mode ); \ + _mbg_swab16( &(_p)->good_svs ); \ + _mbg_swab16( &(_p)->svs_in_view ); \ + _mbg_swab16( &(_p)->dac_val ); \ + _mbg_swab16( &(_p)->dac_cal ); \ +} + + +#define OSC_DAC_RANGE 4096UL +#define OSC_DAC_BIAS ( OSC_DAC_RANGE / 2 ) + + +#ifndef _IDENT_DEFINED + + typedef union + { + char c[16]; // as string which may NOT be terminated + int16_t wrd[8]; + uint32_t lw[4]; + } IDENT; + + #define _IDENT_DEFINED +#endif + +#define _mbg_swab_ident( _p ) \ +{ \ + int i; \ + for ( i = 0; i < 4; i++ ) \ + _mbg_swab32( &(_p)->lw[i] ); \ +} + +/** + * The type below is used to configure the length of the + * antenna cable in [m]: + */ +typedef uint16_t ANT_CABLE_LEN; + +#define _mbg_swab_ant_cable_len( _p ) _mbg_swab16( _p ) + + +/*------------------------------------------------------------------------*/ + +/* Ephemeris parameters of one specific SV. Needed to compute the position */ +/* of a satellite at a given time with high precision. Valid for an */ +/* interval of 4 to 6 hours from start of transmission. */ + +typedef struct +{ + CSUM csum; /* checksum of the remaining bytes */ + int16_t valid; /* flag data are valid */ + + HEALTH health; /* health indication of transmitting SV [---] */ + IOD IODC; /* Issue Of Data, Clock */ + IOD IODE2; /* Issue of Data, Ephemeris (Subframe 2) */ + IOD IODE3; /* Issue of Data, Ephemeris (Subframe 3) */ + T_GPS tt; /* time of transmission */ + T_GPS t0c; /* Reference Time Clock [---] */ + T_GPS t0e; /* Reference Time Ephemeris [---] */ + + double sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */ + double e; /* Eccentricity [---] */ + double M0; /* +- Mean Anomaly at Ref. Time [rad] */ + double omega; /* +- Argument of Perigee [rad] */ + double OMEGA0; /* +- Longit. of Asc. Node of orbit plane [rad] */ + double OMEGADOT; /* +- Rate of Right Ascension [rad/sec] */ + double deltan; /* +- Mean Motion Diff. from computed value [rad/sec] */ + double i0; /* +- Inclination Angle [rad] */ + double idot; /* +- Rate of Inclination Angle [rad/sec] */ + double crc; /* +- Cosine Corr. Term to Orbit Radius [m] */ + double crs; /* +- Sine Corr. Term to Orbit Radius [m] */ + double cuc; /* +- Cosine Corr. Term to Arg. of Latitude [rad] */ + double cus; /* +- Sine Corr. Term to Arg. of Latitude [rad] */ + double cic; /* +- Cosine Corr. Term to Inclination Angle [rad] */ + double cis; /* +- Sine Corr. Term to Inclination Angle [rad] */ + + double af0; /* +- Clock Correction Coefficient 0 [sec] */ + double af1; /* +- Clock Correction Coefficient 1 [sec/sec] */ + double af2; /* +- Clock Correction Coefficient 2 [sec/sec^2] */ + double tgd; /* +- estimated group delay differential [sec] */ + + uint16_t URA; /* predicted User Range Accuracy */ + + uint8_t L2code; /* code on L2 channel [---] */ + uint8_t L2flag; /* L2 P data flag [---] */ +} EPH; + + + +/* Almanac parameters of one specific SV. A reduced precision set of */ +/* parameters used to check if a satellite is in view at a given time. */ +/* Valid for an interval of more than 7 days from start of transmission. */ + +typedef struct +{ + CSUM csum; /* checksum of the remaining bytes */ + int16_t valid; /* flag data are valid */ + + HEALTH health; /* [---] */ + T_GPS t0a; /* Reference Time Almanac [sec] */ + + double sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */ + double e; /* Eccentricity [---] */ + + double M0; /* +- Mean Anomaly at Ref. Time [rad] */ + double omega; /* +- Argument of Perigee [rad] */ + double OMEGA0; /* +- Longit. of Asc. Node of orbit plane [rad] */ + double OMEGADOT; /* +- Rate of Right Ascension [rad/sec] */ + double deltai; /* +- [rad] */ + double af0; /* +- Clock Correction Coefficient 0 [sec] */ + double af1; /* +- Clock Correction Coefficient 1 [sec/sec] */ +} ALM; + + + +/* Summary of configuration and health data of all SVs. */ + +typedef struct +{ + CSUM csum; /* checksum of the remaining bytes */ + int16_t valid; /* flag data are valid */ + + T_GPS tot_51; /* time of transmission, page 51 */ + T_GPS tot_63; /* time of transmission, page 63 */ + T_GPS t0a; /* complete reference time almanac */ + + CFG cfg[N_SVNO]; /* SV configuration from page 63 */ + HEALTH health[N_SVNO]; /* SV health from pages 51, 63 */ +} CFGH; + + + +/* UTC correction parameters */ + +typedef struct +{ + CSUM csum; /* checksum of the remaining bytes */ + int16_t valid; /* flag data are valid */ + + T_GPS t0t; /* Reference Time UTC Parameters [sec] */ + double A0; /* +- Clock Correction Coefficient 0 [sec] */ + double A1; /* +- Clock Correction Coefficient 1 [sec/sec] */ + + uint16_t WNlsf; /* week number of nearest leap second */ + int16_t DNt; /* the day number at the end of which LS is inserted */ + int8_t delta_tls; /* */ + int8_t delta_tlsf; /* */ +} UTC; + + + +/* Ionospheric correction parameters */ + +typedef struct +{ + CSUM csum; /* checksum of the remaining bytes */ + int16_t valid; /* flag data are valid */ + + double alpha_0; /* Ionosph. Corr. Coeff. Alpha 0 [sec] */ + double alpha_1; /* Ionosph. Corr. Coeff. Alpha 1 [sec/deg] */ + double alpha_2; /* Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2] */ + double alpha_3; /* Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3] */ + + double beta_0; /* Ionosph. Corr. Coeff. Beta 0 [sec] */ + double beta_1; /* Ionosph. Corr. Coeff. Beta 1 [sec/deg] */ + double beta_2; /* Ionosph. Corr. Coeff. Beta 2 [sec/deg^2] */ + double beta_3; /* Ionosph. Corr. Coeff. Beta 3 [sec/deg^3] */ +} IONO; + + + +/* GPS ASCII message */ + +typedef struct +{ + CSUM csum; /* checksum of the remaining bytes */ + int16_t valid; /* flag data are valid */ + char s[23]; /* 22 chars GPS ASCII message plus trailing zero */ +} ASCII_MSG; + + +/* End of header body */ + + +#if defined( _USE_PACK ) // set default alignment + #pragma pack() +#endif + + +#endif /* _GPSDEFS_H */ |