summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2009-03-26 12:00:00 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2009-03-26 12:00:00 +0100
commitb80090737e4148916dcf7c05c8bad4aaaa2748f4 (patch)
treedf33d78ec5e6978f51272124b575e08373c78671
parent61903ec22aafe32fa365f16de5a9c5ba5536b52e (diff)
downloadmbgsdk-win-b80090737e4148916dcf7c05c8bad4aaaa2748f4.tar.gz
mbgsdk-win-b80090737e4148916dcf7c05c8bad4aaaa2748f4.zip
Update mbglib files for the C demo projects
-rw-r--r--c/mbglib/include/gpsdefs.h242
-rw-r--r--c/mbglib/include/mbg_arch.h157
-rw-r--r--c/mbglib/include/mbg_tgt.h14
-rw-r--r--c/mbglib/include/mbgdevio.h265
-rw-r--r--c/mbglib/include/mbgsvcio.h6
-rw-r--r--c/mbglib/include/mbgutil.h6
-rw-r--r--c/mbglib/include/pci_asic.h12
-rw-r--r--c/mbglib/include/pcpsdefs.h40
-rw-r--r--c/mbglib/include/pcpsdev.h190
-rw-r--r--c/mbglib/include/usbdefs.h25
-rw-r--r--c/mbglib/include/words.h6
-rw-r--r--c/mbglib/lib/bc/mbgdevio.libbin23040 -> 24576 bytes
-rw-r--r--c/mbglib/lib/msc/mbgdevio.libbin172746 -> 185640 bytes
-rw-r--r--c/mbglib/lib/msc/mbgsvcio.libbin4248 -> 4248 bytes
-rw-r--r--c/mbglib/lib/msc/mbgutil.libbin45034 -> 45034 bytes
-rw-r--r--c/mbglib/lib64/msc/mbgdevio.libbin29210 -> 31332 bytes
-rw-r--r--c/mbglib/lib64/msc/mbgsvcio.libbin2754 -> 2754 bytes
-rw-r--r--c/mbglib/lib64/msc/mbgutil.libbin8630 -> 8630 bytes
18 files changed, 767 insertions, 196 deletions
diff --git a/c/mbglib/include/gpsdefs.h b/c/mbglib/include/gpsdefs.h
index c638841..81b375f 100644
--- a/c/mbglib/include/gpsdefs.h
+++ b/c/mbglib/include/gpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: gpsdefs.h 1.72 2008/11/28 09:26:21Z daniel REL_M $
+ * $Id: gpsdefs.h 1.75 2009/03/19 14:06:39Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -13,6 +13,17 @@
*
* -----------------------------------------------------------------------
* $Log: gpsdefs.h $
+ * Revision 1.75 2009/03/19 14:06:39Z martin
+ * Modified string initializer for unknown oscillator type.
+ * Revision 1.74 2009/03/18 13:45:53 daniel
+ * Added missing commas in
+ * MBG_DEBUG_STATUS_STRS initializer.
+ * Adjusted some comments for doxygen parser.
+ * Revision 1.73 2009/03/10 16:55:33Z martin
+ * Support configurable time scales GPS and TAI.
+ * Defined extended TM status type and associated flags.
+ * Added definition TM_MSK_TIME_VALID.
+ * Added some macros to swap endianess of structures.
* 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
@@ -293,6 +304,8 @@ typedef uint16_t IOD; /* Issue-Of-Data code */
#ifndef _CSUM_DEFINED
typedef uint16_t CSUM;
#define _CSUM_DEFINED
+
+ #define _mbg_swab_csum( _p ) _mbg_swab16( _p )
#endif
@@ -617,7 +630,7 @@ enum
*/
#define DEFAULT_GPS_OSC_NAMES \
{ \
- "- unknown -", \
+ "[unknown]", \
"TCXO LQ", \
"TCXO HQ", \
"OCXO LQ", \
@@ -665,21 +678,22 @@ enum
*/
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 */
+ 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 */
+ GPS_FEAT_TIME_SCALE, /**< supports configurable time scale (UTC, TAI, GPS, ...) */
+ N_GPS_FEATURE /**< the number of valid features */
};
@@ -697,7 +711,8 @@ enum
"Ignore Lock", \
"5 MHz Output", \
"Ext. Multiple Ref. Src. Cfg.", \
- "Supp. Optional Settings" \
+ "Supp. Optional Settings", \
+ "Configurable Time Scale" \
}
@@ -718,8 +733,9 @@ enum
#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_TIME_SCALE ( 1UL << GPS_FEAT_TIME_SCALE )
-#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX
+#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX
/*
@@ -747,7 +763,7 @@ enum
* 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_LEN 31 // max name length
#define FPGA_NAME_SIZE ( FPGA_NAME_LEN + 1 ) // size including trailing 0
#define FPGA_INFO_SIZE 128
@@ -788,18 +804,19 @@ typedef struct
-/* 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. */
-
+/**
+ 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 */
+ 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 ) \
@@ -865,26 +882,43 @@ enum
TM_BIT_NO_POS /* position actually not verified, LOCK LED off */
};
+// Type of an extended TM status which is mainly used by the firmware.
+typedef uint32_t TM_STATUS_EXT; // extended status, mainly used by the firmware
-/* bit masks corresponding to the flag bits above */
+// The lower 16 bits of the TM_STATUS_X type correspond to those defined above,
+// and the upper bits are defined below:
+enum
+{
+ TM_BIT_SCALE_GPS = 16,
+ TM_BIT_SCALE_TAI
+ // the remaining bits are reserved
+};
-#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 )
+/* bit masks corresponding to the flag bits above */
+#define TM_UTC ( 1UL << TM_BIT_UTC )
+#define TM_LOCAL ( 1UL << TM_BIT_LOCAL )
+#define TM_DL_ANN ( 1UL << TM_BIT_DL_ANN )
+#define TM_DL_ENB ( 1UL << TM_BIT_DL_ENB )
+#define TM_LS_ANN ( 1UL << TM_BIT_LS_ANN )
+#define TM_LS_ENB ( 1UL << TM_BIT_LS_ENB )
+#define TM_LS_ANN_NEG ( 1UL << TM_BIT_LS_ANN_NEG )
+
+#define TM_EXT_SYNC ( 1UL << TM_BIT_EXT_SYNC )
+#define TM_HOLDOVER ( 1UL << TM_BIT_HOLDOVER )
+#define TM_ANT_SHORT ( 1UL << TM_BIT_ANT_SHORT )
+#define TM_NO_WARM ( 1UL << TM_BIT_NO_WARM )
+#define TM_ANT_DISCONN ( 1UL << TM_BIT_ANT_DISCONN )
+#define TM_SYN_FLAG ( 1UL << TM_BIT_SYN_FLAG )
+#define TM_NO_SYNC ( 1UL << TM_BIT_NO_SYNC )
+#define TM_NO_POS ( 1UL << TM_BIT_NO_POS )
+
+// The following bits are only used with the TM_STATUS_X type:
+#define TM_SCALE_GPS ( 1UL << TM_BIT_SCALE_GPS )
+#define TM_SCALE_TAI ( 1UL << TM_BIT_SCALE_TAI )
+
+#define TM_MSK_TIME_VALID ( TM_UTC | TM_SCALE_GPS | TM_SCALE_TAI )
/**
This structure is used to transmit information on date and time
@@ -951,7 +985,7 @@ typedef struct
/**
- @defgroup group_synth Synthesizer parameters.
+ @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
@@ -1066,7 +1100,7 @@ typedef struct
/** @} */ // endgroup
/**
- @defgroup group_tzdl Time zone/daylight saving parameters.
+ @defgroup group_tzdl Time zone/daylight saving parameters
Example: <br>
For automatic daylight saving enable/disable in Central Europe,
@@ -2234,11 +2268,11 @@ enum
"IRIG msg not consistent", \
"Decoder control loop locked", \
"Phase jitter too large", \
- "Invalid ref offset" \
+ "Invalid ref offset", \
\
- "Internal time not valid" \
- "On board time set via API" \
- "On board RTC invalid" \
+ "Internal time not valid", \
+ "On board time set via API", \
+ "On board RTC invalid", \
"CPU PLL failure, needs restart" \
}
@@ -2314,6 +2348,76 @@ enum
#define MBG_OPT_FLAG_EMU_SYNC ( 1UL << MBG_OPT_BIT_EMU_SYNC )
+/**
+ @defgroup group_scale Time Scale Configuration
+
+ The structures and defines can be used to configure the GPS receiver's
+ basic time scale. By default this is UTC which can optionally
+ be converted to some local time. However, some applications
+ prefer TAI or pure GPS time. This can be configured using the
+ structures below if the GPS_HAS_TIME_SCALE flag is set in
+ RECEIVER_INFO::features.
+ @{
+*/
+
+enum
+{
+ MBG_TIME_SCALE_DEFAULT, /**< UTC or local time, t_gps - deltat_ls */
+ MBG_TIME_SCALE_GPS, /**< GPS time, monotonical */
+ MBG_TIME_SCALE_TAI, /**< TAI, t_gps + GPS_TAI_OFFSET seconds */
+ N_MBG_TIME_SCALE
+};
+
+#define MBG_TIME_SCALE_MSK_DEFAULT ( 1UL << MBG_TIME_SCALE_DEFAULT )
+#define MBG_TIME_SCALE_MSK_GPS ( 1UL << MBG_TIME_SCALE_GPS )
+#define MBG_TIME_SCALE_MSK_TAI ( 1UL << MBG_TIME_SCALE_TAI )
+
+// See also the extended status bits TM_SCALE_GPS and TM_SCALE_TAI
+// indicating the active time scale setting.
+
+
+#define MBG_TIME_SCALE_STRS \
+{ \
+ "UTC/local", \
+ "GPS", \
+ "TAI" \
+}
+
+
+
+/**
+ The fixed time offset between the GPS and TAI time scales, in seconds
+*/
+#define GPS_TAI_OFFSET 19 /**< [s], TAI = GPS + GPS_TAI_OFFSET */
+
+
+typedef struct
+{
+ uint8_t scale; /**< current time scale code from the enum above */
+ uint8_t flags; /**< reserved, currently always 0 */
+} MBG_TIME_SCALE_SETTINGS;
+
+#define _mbg_swab_mbg_time_scale_settings( _p ) \
+ _nop_macro_fnc()
+
+
+typedef struct
+{
+ MBG_TIME_SCALE_SETTINGS settings; /**< current settings */
+ MBG_TIME_SCALE_SETTINGS max_settings; /**< numb. of scales, all supported flags */
+ uint32_t supp_scales; /**< bit masks of supported scales */
+} MBG_TIME_SCALE_INFO;
+
+#define _mbg_swab_mbg_time_scale_info( _p ) \
+{ \
+ _mbg_swab_mbg_time_scale_settings( &(_p)->settings ); \
+ _mbg_swab_mbg_time_scale_settings( &(_p)->max_settings ); \
+ _mbg_swab32( &(_p)->supp_scales ); \
+}
+
+/** @} */ // endgroup
+
+
/*
* The structures below are required to setup the programmable
* pulse outputs which are provided by some GPS receivers.
@@ -3155,23 +3259,35 @@ typedef struct
-/* UTC correction parameters */
-
+/**
+ UTC correction parameters
+*/
typedef struct
{
- CSUM csum; /* checksum of the remaining bytes */
- int16_t valid; /* flag data are valid */
+ CSUM csum; /**< Checksum of the remaining bytes */
+ int16_t valid; /**< Flag indicating UTC parameters 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] */
+ 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; /* */
+ uint16_t WNlsf; /**< Week number of nearest leap second */
+ int16_t DNt; /**< The day number at the end of which leap second is inserted */
+ int8_t delta_tls; /**< Current UTC offset to GPS system time [sec] */
+ int8_t delta_tlsf; /**< Future UTC offset to GPS system time after next leap second transition [sec] */
} UTC;
+#define _mbg_swab_utc_parm( _p ) \
+{ \
+ _mbg_swab_csum( &(_p)->csum ); \
+ _mbg_swab16( &(_p)->valid ); \
+ _mbg_swab_t_gps( &(_p)->t0t ); \
+ _mbg_swab_double( &(_p)->A0 ); \
+ _mbg_swab_double( &(_p)->A1 ); \
+ _mbg_swab16( &(_p)->WNlsf ); \
+ _mbg_swab16( &(_p)->DNt ); \
+}
+
/* Ionospheric correction parameters */
diff --git a/c/mbglib/include/mbg_arch.h b/c/mbglib/include/mbg_arch.h
new file mode 100644
index 0000000..5b8d42a
--- /dev/null
+++ b/c/mbglib/include/mbg_arch.h
@@ -0,0 +1,157 @@
+
+/**************************************************************************
+ *
+ * $Id: mbg_arch.h 1.2 2009/03/19 15:14:15Z martin REL_M $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions to support different computer hardware architectures.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbg_arch.h $
+ * Revision 1.2 2009/03/19 15:14:15Z martin
+ * Fixed byte swapping of doubles for SPARC architecture.
+ * Revision 1.1 2008/12/05 13:47:42 martin
+ * Initial revision.
+ *
+ **************************************************************************/
+
+#ifndef _MBG_ARCH_H
+#define _MBG_ARCH_H
+
+#include <mbg_tgt.h>
+
+
+#if defined( MBG_ARCH_SPARC )
+ #define MBG_ARCH_BIG_ENDIAN 1
+#endif
+
+
+#if !defined( MBG_ARCH_BIG_ENDIAN )
+ #define MBG_ARCH_LITTLE_ENDIAN 1
+#endif
+
+
+
+#if defined( MBG_TGT_LINUX )
+
+ #include <asm/byteorder.h>
+
+ #if defined( __KERNEL__ )
+ #include <asm/unaligned.h>
+
+ #define _mbg_put_unaligned( _v, _p ) put_unaligned( _v, _p )
+ #define _mbg_get_unaligned( _p ) get_unaligned( _p )
+ #endif
+
+#endif
+
+
+
+// If no macros required to access unaligned data have yet been defined,
+// define some default macros assuming no special handling is required
+// to access unaligned data.
+
+#if !defined( _pcps_put_unaligned )
+ #define _pcps_put_unaligned( _v, _p ) ((void)( *(_p) = (_v) ))
+#endif
+
+#if !defined( _pcps_get_unaligned )
+ #define _pcps_get_unaligned( _p ) (*(_p))
+#endif
+
+
+
+// If no macros to convert endianess have yet been defined, define
+// some default macros assuming endianess conversion is not required.
+
+#if !defined( __le16_to_cpu )
+ #define __le16_to_cpu( _x ) (_x)
+#endif
+
+#if !defined( __le32_to_cpu )
+ #define __le32_to_cpu( _x ) (_x)
+#endif
+
+#if !defined( __le64_to_cpu )
+ #define __le64_to_cpu( _x ) (_x)
+#endif
+
+#if !defined( __cpu_to_le16 )
+ #define __cpu_to_le16( _x ) (_x)
+#endif
+
+#if !defined( __cpu_to_le32 )
+ #define __cpu_to_le32( _x ) (_x)
+#endif
+
+#if !defined( __cpu_to_le64 )
+ #define __cpu_to_le64( _x ) (_x)
+#endif
+
+
+
+// The macros below are used to convert the endianess
+// of the plug-in cards to the endianess of the host CPU
+
+#define _mbg8_to_cpu( _x ) ( _x )
+#define _mbg16_to_cpu( _x ) __le16_to_cpu( _x )
+#define _mbg32_to_cpu( _x ) __le32_to_cpu( _x )
+#define _mbg64_to_cpu( _x ) __le64_to_cpu( _x )
+
+#define _cpu_to_mbg8( _x ) ( _x )
+#define _cpu_to_mbg16( _x ) __cpu_to_le16( _x )
+#define _cpu_to_mbg32( _x ) __cpu_to_le32( _x )
+#define _cpu_to_mbg64( _x ) __cpu_to_le64( _x )
+
+
+
+// swap a double type variable bytewise e.g. to convert the endianess
+
+static __mbg_inline
+void mbg_swab_double( double *p )
+{
+#if 0 // The __swab64() may not work correctly for whatever reason ...
+ __swab64p( p );
+#else // ... so we do the swapping manually
+ double d = 0;
+ int i;
+
+ for ( i = 0; i < sizeof( double); i++ )
+ BYTE_OF( d, i ) = BYTE_OF( *p, ( sizeof( double) - 1 - i ) );
+
+ for ( i = 0; i < sizeof( double); i++ )
+ BYTE_OF( *p, i ) = BYTE_OF( d, i );
+#endif
+
+} // mbg_swab_double
+
+
+
+#if defined( MBG_ARCH_BIG_ENDIAN )
+
+ #define _mbg_swab16( _p ) *(_p) = __swab16( *(_p) )
+ #define _mbg_swab32( _p ) *(_p) = __swab32( *(_p) )
+
+ #define _mbg_swab_double( _p ) mbg_swab_double( _p )
+
+ #define _mbg_swab_doubles( _p, _n ) \
+ { \
+ int i; \
+ for ( i = 0; i < (_n); i++ ) \
+ _mbg_swab_double( &_p[i] ); \
+ }
+
+#else
+
+ #define _mbg_swab16( _p ) _nop_macro_fnc()
+ #define _mbg_swab32( _p ) _nop_macro_fnc()
+
+ #define _mbg_swab_double( _p ) _nop_macro_fnc()
+
+ #define _mbg_swab_doubles( _p, _n ) _nop_macro_fnc()
+
+#endif
+
+#endif /* _MBG_ARCH_H */
diff --git a/c/mbglib/include/mbg_tgt.h b/c/mbglib/include/mbg_tgt.h
index 6bd9919..15eca61 100644
--- a/c/mbglib/include/mbg_tgt.h
+++ b/c/mbglib/include/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.16 2008/12/08 16:42:30Z martin REL_M $
+ * $Id: mbg_tgt.h 1.17 2009/03/19 15:21:07Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
- * Revision 1.16 2008/12/08 16:42:30Z martin
+ * Revision 1.17 2009/03/19 15:21:07Z martin
+ * Conditionally define DWORD_PTR type for old MS C compilers.
+ * Revision 1.16 2008/12/08 16:42:30 martin
* Defined _GNU_SOURCE for Linux.
* Revision 1.15 2008/11/19 15:31:49 martin
* Added symbol MBG_ARCH_I386.
@@ -279,6 +281,14 @@
#define MBG_INVALID_HANDLE INVALID_HANDLE_VALUE
+ // The DWORD_PTR type is not defined in the headers shipping
+ // with VC6. However, if the SDK is installed then the SDK's
+ // headers may declare this type. This is at least the case
+ // in the Oct 2001 SDK which also defines the symbol _W64.
+ #if !defined( _W64 )
+ typedef DWORD DWORD_PTR;
+ #endif
+
#endif
#define _MBG_API WINAPI
diff --git a/c/mbglib/include/mbgdevio.h b/c/mbglib/include/mbgdevio.h
index e75e2c7..26a852b 100644
--- a/c/mbglib/include/mbgdevio.h
+++ b/c/mbglib/include/mbgdevio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.h 1.32 2008/12/17 10:43:30Z martin REL_M $
+ * $Id: mbgdevio.h 1.33 2009/03/19 15:36:26Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,13 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.h $
+ * Revision 1.33 2009/03/19 15:36:26Z martin
+ * New version code 304, compatibility version still 210.
+ * Moved some inline functions dealing with MBG_PC_CYCLES
+ * from mbgdevio.h to pcpsdev.h.
+ * Include mbg_arch.h here.
+ * Removed unused doxygen comment.
+ * Updated function prototypes.
* Revision 1.32 2008/12/17 10:43:30Z martin
* New version code 303, compatibility version still 210.
* Increased MBG_MAX_DEVICES from 5 to 8.
@@ -126,6 +133,7 @@
#include <mbggeo.h>
#include <mbg_tgt.h>
+#include <mbg_arch.h>
#include <mbgerror.h>
#include <pcpsdev.h>
#include <pci_asic.h>
@@ -133,7 +141,7 @@
#include <time.h>
-#define MBGDEVIO_VERSION 0x0303
+#define MBGDEVIO_VERSION 0x0304
#define MBGDEVIO_COMPAT_VERSION 0x0210
@@ -1079,6 +1087,37 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_set_irig_rx_settings( MBG_DEV_HANDLE dh, const IRIG_SETTINGS *p ) ;
/**
+ Check if a specific device supports the mbg_get_irig_ctrl_bits() call.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_irig_ctrl_bits()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_irig_ctrl_bits( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read a ::MBG_IRIG_CTRL_BITS type which contains the control function
+ bits of the latest IRIG input frame. Those bits may carry some
+ well-known information, as in the IEEE1344 code, but may also contain
+ some customized information, depending on the IRIG frame type and
+ the configuration of the IRIG generator. So these bits are returned
+ as-is and must be interpreted by the application.
+ The macro _pcps_has_irig_ctrl_bits() or the API call mbg_dev_has_irig_ctrl_bits()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_IRIG_CTRL_BITS type to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_irig_ctrl_bits()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_irig_ctrl_bits( MBG_DEV_HANDLE dh, MBG_IRIG_CTRL_BITS *p ) ;
+
+ /**
Clear the card's on-board time capture FIFO buffer.
The macro _pcps_can_clr_ucap_buff() or the API call mbg_dev_can_clr_ucap_buff()
check whether this call is supported by a specific card.
@@ -1628,6 +1667,122 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_asic_features( MBG_DEV_HANDLE dh, PCI_ASIC_FEATURES *p ) ;
/**
+ Check if a specific device supports configurable time scales.
+
+ By default the cards return UTC and/or local time. However, some cards
+ can be configured to return pure GPS time or TAI instead.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_time_scale_info()
+ @see mbg_set_time_scale_settings()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_time_scale( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read a ::MBG_TIME_SCALE_INFO structure from a card telling which time scales
+ are supported by a card, and the current settings of the card.
+
+ The macro _pcps_has_time_scale() or the API call mbg_dev_has_time_scale()
+ check whether this call is supported by a specific card.
+ See also the notes for mbg_dev_has_time_scale().
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_TIME_SCALE_INFO structure to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_set_time_scale_settings()
+ @see mbg_dev_has_time_scale()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_time_scale_info( MBG_DEV_HANDLE dh, MBG_TIME_SCALE_INFO *p ) ;
+
+ /**
+ Write a ::MBG_TIME_SCALE_SETTINGS structure to a card which determines
+ which time scale shall be represented by time stamps read from the card.
+
+ The macro _pcps_has_time_scale() or the API call mbg_dev_has_time_scale()
+ check whether this call is supported by a specific card.
+ See also the notes for mbg_dev_has_time_scale().
+
+ The function mbg_get_time_scale_info() should have been called before
+ in order to determine which time scales are supported by the card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::MBG_TIME_SCALE_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_time_scale_info()
+ @see mbg_dev_has_time_scale()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_time_scale_settings( MBG_DEV_HANDLE dh, MBG_TIME_SCALE_SETTINGS *p ) ;
+
+ /**
+ Check if a specific device supports reading/writing a GPS UTC parameter
+ set via the PC bus (reading/writing these parameters via the serial port
+ is supported by all GPS devices).
+
+ The UTC parameters are normally received from the satellites' broadcasts
+ and contain the current time offset between GPT time and UTC, plus information
+ on a pending leap second.
+
+ It may be useful to overwrite them to do some tests, or for applications
+ where a card is freewheeling.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to an int which is set 0 or != 0 unless the call fails.
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_get_utc_parm()
+ @see mbg_set_utc_parm()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_utc_parm( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read a ::UTC structure from a card.
+
+ The macro _pcps_has_utc_parm() or the API call mbg_dev_has_utc_parm()
+ check whether this call is supported by a specific card.
+ See also the notes for mbg_dev_has_utc_parm().
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::UTC structure to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_utc_parm()
+ @see mbg_set_utc_parm()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_utc_parm( MBG_DEV_HANDLE dh, UTC *p ) ;
+
+ /**
+ Write a ::UTC structure to a card.
+
+ This should only be done for testing, or if a card is operated in
+ freewheeling mode. If the card receives any satellites the settings
+ written to the board are overwritten by the parameters broadcasted
+ by the satellites.
+
+ The macro _pcps_has_utc_parm() or the API call mbg_dev_has_utc_parm()
+ check whether this call is supported by a specific card.
+ See also the notes for mbg_dev_has_utc_parm().
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a valid ::UTC structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_utc_parm()
+ @see mbg_get_utc_parm()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_utc_parm( MBG_DEV_HANDLE dh, UTC *p ) ;
+
+ /**
Read a ::PCPS_TIME_CYCLES structure that contains a ::PCPS_TIME structure
and a PC cycle counter value which can be used to compensate the latency
of the call, i.e. the program execution time until the time stamp has actually
@@ -1820,6 +1975,7 @@ extern "C" {
@see mbg_get_fast_hr_timestamp_cycles()
@see mbg_get_fast_hr_timestamp_comp()
+ @see mbg_get_fast_hr_timestamp()
*/
_MBG_API_ATTR int _MBG_API mbg_dev_has_fast_hr_timestamp( MBG_DEV_HANDLE dh, int *p ) ;
@@ -1833,6 +1989,7 @@ extern "C" {
@see mbg_dev_has_fast_hr_timestamp()
@see mbg_get_fast_hr_timestamp_comp()
+ @see mbg_get_fast_hr_timestamp()
*/
_MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_cycles( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP_CYCLES *p ) ;
@@ -1847,11 +2004,32 @@ extern "C" {
@return ::MBG_SUCCESS or error code returned by device I/O control function.
@see mbg_dev_has_fast_hr_timestamp()
- @see mbg_get_fast_hr_timestamp_comp()
+ @see mbg_get_fast_hr_timestamp_cycles()
+ @see mbg_get_fast_hr_timestamp()
*/
_MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp_comp( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p, int32_t *hns_latency ) ;
/**
+ Read a high resolution ::PCPS_TIME_STAMP structure via memory mapped access.
+
+ This function does not return or evaluate a cycles count, so the latency
+ of the call can not be determined. However, depending on the timer hardware
+ used as cycles counter it may take quite some time to read the cycles count
+ on some hardware architectures, so this call can be used to yield lower
+ latencies, under the restriction to be unable to determine the exact latency.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PCPS_TIME_STAMP structure to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_fast_hr_timestamp()
+ @see mbg_get_fast_hr_timestamp_comp()
+ @see mbg_get_fast_hr_timestamp_cycles()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_fast_hr_timestamp( MBG_DEV_HANDLE dh, PCPS_TIME_STAMP *p ) ;
+
+ /**
Check if a specific device is a GPS receiver.
@param dh Valid handle to a Meinberg device
@@ -2545,64 +2723,6 @@ extern "C" {
-#if defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_I386 )
-
- static __mbg_inline unsigned long long int mbg_rdtscll( void )
- {
- // The code below is a hack to get around issues with
- // different versions of gcc.
- //
- // Normally the inline asm code could look similar to:
- //
- // __asm__ volatile ( "rdtsc" : "=A" (x) )
- //
- // which would copy the output regs edx:eax as a 64 bit
- // number to a variable x.
- //
- // The "=A" expression should implicitely tell the compiler
- // the edx and eax registers have been clobbered. However,
- // this does not seem to work properly at least with gcc 4.1.2
- // shipped with Centos 5.
- //
- // If optimization level 1 or higher is used then function
- // parameters are also passed in registers. If the inline
- // code above is used inside a function then the edx register
- // is clobbered but the gcc 4.1.2 is not aware of this and
- // assumes edx is unchanged, which may yield faulty results
- // or even lead to segmentation faults.
- //
- // A possible workaround could be to mark edx explicitely as
- // being clobbered in the asm inline code, but unfortunately
- // other gcc versions report an error if a register which is
- // implicitely (by "=A") known to be clobbered is also listed
- // explicitely to be clobbered.
- //
- // So the code below is a workaround which tells the compiler
- // implicitely that the eax ("=a") and edx ("=d") registers
- // are being used and thus clobbered.
-
- union
- {
- struct
- {
- uint32_t lo;
- uint32_t hi;
- } u32;
-
- uint64_t u64;
-
- } tsc_val;
-
- __asm__ __volatile__( "rdtsc" : "=a" (tsc_val.u32.lo), "=d" (tsc_val.u32.hi) );
-
- return tsc_val.u64;
-
- }
-
-#endif
-
-
-
static __mbg_inline
void mbg_init_pc_cycles_frequency( MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p )
{
@@ -2613,29 +2733,6 @@ void mbg_init_pc_cycles_frequency( MBG_DEV_HANDLE dh, MBG_PC_CYCLES_FREQUENCY *p
-static __mbg_inline
-void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
-{
- #if defined( MBG_TGT_WIN32 )
- QueryPerformanceCounter( (LARGE_INTEGER *) p );
- #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_I386 )
- *p = mbg_rdtscll();
- #else
- *p = 0;
- #endif
-} // mbg_get_pc_cycles
-
-
-
-static __mbg_inline
-MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2 )
-{
- return *p1 - *p2;
-
-} // mbg_delta_pc_cycles
-
-
-
#if MBG_TGT_HAS_64BIT_TYPES
static __mbg_inline
diff --git a/c/mbglib/include/mbgsvcio.h b/c/mbglib/include/mbgsvcio.h
index c22ba5d..6289a7b 100644
--- a/c/mbglib/include/mbgsvcio.h
+++ b/c/mbglib/include/mbgsvcio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsvcio.h 1.13 2009/01/12 09:40:18Z daniel REL_M $
+ * $Id: mbgsvcio.h 1.14 2009/03/19 09:06:40Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsvcio.h $
+ * Revision 1.14 2009/03/19 09:06:40Z daniel
+ * New version code 304, compatibility version code still 200.
* Revision 1.13 2009/01/12 09:40:18Z daniel
* New version code 303, compatibility version code still 200.
* Added comments in doxygen format.
@@ -63,7 +65,7 @@
#pragma pack( 1 )
#endif
-#define MBGSVCIO_VERSION 0x0303
+#define MBGSVCIO_VERSION 0x0304
#define MBGSVCIO_COMPAT_VERSION 0x0200
diff --git a/c/mbglib/include/mbgutil.h b/c/mbglib/include/mbgutil.h
index b821f1b..4ad6239 100644
--- a/c/mbglib/include/mbgutil.h
+++ b/c/mbglib/include/mbgutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgutil.h 1.13 2009/01/12 09:35:41Z daniel REL_M $
+ * $Id: mbgutil.h 1.14 2009/03/19 09:06:00Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbgutil.h $
+ * Revision 1.14 2009/03/19 09:06:00Z daniel
+ * New version code 304, compatibility version still 110.
* Revision 1.13 2009/01/12 09:35:41Z daniel
* New version code 303, compatibility version still 110.
* Updated function prototypes.
@@ -52,7 +54,7 @@
#include <pci_asic.h>
-#define MBGUTIL_VERSION 0x0303
+#define MBGUTIL_VERSION 0x0304
#define MBGUTIL_COMPAT_VERSION 0x0110
diff --git a/c/mbglib/include/pci_asic.h b/c/mbglib/include/pci_asic.h
index b7bf3a7..7e6ae60 100644
--- a/c/mbglib/include/pci_asic.h
+++ b/c/mbglib/include/pci_asic.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pci_asic.h 1.13 2008/12/05 12:28:18Z martin REL_M $
+ * $Id: pci_asic.h 1.14 2009/03/11 16:54:10Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: pci_asic.h $
+ * Revision 1.14 2009/03/11 16:54:10Z martin
+ * Increase current ASIC minor number for TCR511PEX to 0x04.
+ * Fixed a typo.
* Revision 1.13 2008/12/05 12:28:18Z martin
* Modified syntax of macro _convert_asic_version_number().
* Added macros to deal with the ASIC version number.
@@ -249,7 +252,7 @@ enum
{
PCI_ASIC_MAJOR_PCI_0, // PCI ASIC with CRC bug
PCI_ASIC_MAJOR_PCI_1, // fixed version of PCI ASIC
- PCI_ASIC_MAJOR_PEX511, // PEX EPLD for PEX_511
+ PCI_ASIC_MAJOR_PEX511, // PEX EPLD for PEX511
PCI_ASIC_MAJOR_GPS170PEX, // PEX EPLD for GPS170PEX
PCI_ASIC_MAJOR_TCR511PEX, // PEX EPLD for TCR511PEX
PCI_ASIC_MAJOR_PTP270PEX, // PEX EPLD for PTP270PEX
@@ -272,11 +275,12 @@ enum
#define PCI_ASIC_CURRENT_MINOR_GPS170PEX 0x04
#define PCI_ASIC_REQUIRED_MINOR_GPS170PEX 0x03
-#define PCI_ASIC_HRT_FIX_MINOR_PEX511 0x04 // increases MM HRT accuracy
+#define PCI_ASIC_HRT_FIX_MINOR_GPS170PEX 0x04 // increases MM HRT accuracy
#define PCI_ASIC_IRQ_FIX_MINOR_GPS170PEX 0x03 // fixes IRQ problem
-#define PCI_ASIC_CURRENT_MINOR_TCR511PEX 0x03
+#define PCI_ASIC_CURRENT_MINOR_TCR511PEX 0x04
#define PCI_ASIC_REQUIRED_MINOR_TCR511PEX 0x03
+// 0x04 // EPLD sources shared with PEX511 0x04
#define PCI_ASIC_IRQ_FIX_MINOR_TCR511PEX 0x03 // fixes IRQ problem, increases HRT accuracy
#define PCI_ASIC_CURRENT_MINOR_PTP270PEX 0x01
diff --git a/c/mbglib/include/pcpsdefs.h b/c/mbglib/include/pcpsdefs.h
index bff5eef..a4a4021 100644
--- a/c/mbglib/include/pcpsdefs.h
+++ b/c/mbglib/include/pcpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdefs.h 1.37 2008/12/05 16:01:37Z martin REL_M $
+ * $Id: pcpsdefs.h 1.39 2009/03/19 08:58:09Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,12 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdefs.h $
+ * Revision 1.39 2009/03/19 08:58:09Z martin
+ * Added PCPS_GET_IRIG_CTRL_BITS cmd and associated data type.
+ * Revision 1.38 2009/03/10 17:07:09 martin
+ * Support configurable time scales and GPS UTC parameters.
+ * Added ext. status flag for time scales, and PCPS_LS_ANN_NEG.
+ * Added bit mask PCPS_SCALE_MASK.
* Revision 1.37 2008/12/05 16:01:37Z martin
* Added ref types PTP, FRC, and WWVB.
* Added ref names MSF, PTP, FRC, and WWVB.
@@ -424,6 +430,16 @@ enum
only. _pcps_is_irig_rx() and _pcps_is_irig_tx()
check whether supported.
+ - #PCPS_GET_IRIG_CTRL_BITS<br>
+ This command can be used to retrieve the control function
+ bits of the latest IRIG input frame. Those bits may carry
+ some well-known information as in the IEEE1344 code, but
+ may also contain some customized information, depending on
+ the IRIG frame type and the configuration of the IRIG generator.
+ So these bits are returned as-is and must be interpreted
+ by the application.
+ _pcps_has_irig_ctrl_bits() checks whether supported.
+
- #PCPS_GET_SYNTH<br>
#PCPS_SET_SYNTH<br>
#PCPS_GET_SYNTH_STATE<br>
@@ -657,12 +673,19 @@ typedef struct
#define PCPS_GIVE_SERNUM ( PCPS_GIVE_DATA_GROUP | 0x2 )
#define PCPS_GENERIC_IO ( PCPS_GIVE_DATA_GROUP | 0x3 )
#define PCPS_GET_SYNTH_STATE ( PCPS_GIVE_DATA_GROUP | 0x4 )
+#define PCPS_GET_IRIG_CTRL_BITS ( PCPS_GIVE_DATA_GROUP | 0x5 )
+
+// bit coded return type for PCPS_GET_IRIG_CTRL_BITS
+typedef uint32_t MBG_IRIG_CTRL_BITS;
+
+#define _mbg_swab_irig_ctrl_bits( _p ) _mbg_swab32( _p )
+
#define PCPS_GET_STATUS_PORT ( PCPS_GIVE_DATA_GROUP | 0xB )
#define PCPS_GET_DEBUG_STATUS ( PCPS_GIVE_DATA_GROUP | 0xC )
// expects sizeof( MBG_DEBUG_STATUS ) chars
-
+// PCPS_GIVE_DATA_GROUP codes 0x0D, 0x0E, and 0x0F are reserved.
/* PCPS_GPS_DATA_GROUP */
@@ -897,6 +920,9 @@ typedef union
#define PCPS_LS_ENB 0x0100 /**< current second is leap second */
#define PCPS_ANT_FAIL 0x0200 /**< antenna failure */
+#define PCPS_LS_ANN_NEG 0x0400 /**< announced leap second is negative */
+#define PCPS_SCALE_GPS 0x0800 /**< time stamp is GPS scale */
+#define PCPS_SCALE_TAI 0x1000 /**< time stamp is TAI scale */
/* The next two bits are used only if the structure */
/* PCPS_HR_TIME contains a user capture event */
@@ -915,6 +941,13 @@ typedef union
*/
#define PCPS_IO_BLOCKED 0x8000
+/**
+ This bit mask can be used to extract the time scale information out
+ of a PCPS_TIME_STATUS_X value.
+*/
+#define PCPS_SCALE_MASK ( PCPS_SCALE_TAI | PCPS_SCALE_GPS )
+
+
/**
* Some DCF77 clocks have a serial interface that can be controlled
* using the commands PCPS_SET_SERIAL and PCPS_GET_SERIAL. Both commands
@@ -1098,12 +1131,13 @@ enum
PC_GPS_PORT_SETTINGS_IDX, // -/W PORT_SETTINGS_IDX port settings only
PC_GPS_ALL_POUT_INFO, // R/- n*POUT_INFO_IDX all pout info
PC_GPS_POUT_SETTINGS_IDX, // -/W POUT_SETTINGS_IDX pout settings only
+ PC_GPS_TIME_SCALE, // R/W MBG_TIME_SCALE_{SETTINGS|INFO}, only if PCPS_HAS_TIME_SCALE
// GPS data
PC_GPS_CFGH = 0x80, // -/- CFGH SVs' config. and health codes
PC_GPS_ALM, // -/- SV_ALM one SV's num and almanac
PC_GPS_EPH, // -/- SV_EPH one SV's num and ephemeris
- PC_GPS_UTC, // -/- UTC UTC corr. param.
+ PC_GPS_UTC, // R/W UTC UTC corr. param., only if PCPS_HAS_UTC_PARM
PC_GPS_IONO, // -/- IONO ionospheric corr. param.
PC_GPS_ASCII_MSG // -/- ASCII_MSG the GPS ASCII message
};
diff --git a/c/mbglib/include/pcpsdev.h b/c/mbglib/include/pcpsdev.h
index b065d46..00a32ad 100644
--- a/c/mbglib/include/pcpsdev.h
+++ b/c/mbglib/include/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.39 2008/12/05 16:24:24Z martin REL_M $
+ * $Id: pcpsdev.h 1.42 2009/03/19 14:58:47Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,6 +17,19 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
+ * Revision 1.42 2009/03/19 14:58:47Z martin
+ * Tmp. workaround in mbg_delta_pc_cycles() under SPARC which might
+ * generate bus errors due to unaligned access.
+ * Revision 1.41 2009/03/16 16:01:22 martin
+ * Support reading IRIG control function bits.
+ * Revision 1.40 2009/03/13 09:13:39 martin
+ * Support new features .._has_time_scale() and .._has_utc_parm().
+ * Moved some inline functions dealing with MBG_PC_CYCLES
+ * from mbgdevio.h here.
+ * Merged the code from _pcps_get_cycles() and _pcps_get_cycles_frequency()
+ * to the mbg_get_pc_cycles...() inline functions which now replace the
+ * _pcps_get_cycles...() macros.
+ * Fixed cycles code for non-x86 architectures.
* Revision 1.39 2008/12/05 16:24:24Z martin
* Changed MAX_PARM_STR_TYPE from 10 to 20.
* Added support for WWVB signal source.
@@ -175,20 +188,6 @@
#include <mbg_tgt.h>
#include <use_pack.h>
-#if defined( MBG_TGT_WIN32 )
-
- //##++ ntddk.h or windows.h is now already included from mbg_tgt.h.
-
-#elif defined( MBG_TGT_LINUX )
-
- //##++ #include <asm/timex.h>
-
-#elif defined( MBG_TGT_BSD )
-
- //##++ #include <machine/bus.h>
-
-#endif
-
/* Start of header body */
@@ -198,6 +197,7 @@
#endif
+
#if defined( MBG_TGT_WIN32 )
// used with QueryPerformanceCounter()
@@ -228,11 +228,149 @@
#endif
-// MBG_PC_CYCLES is always read in native machine endianess,
-// so no endianess conversion is required.
+// MBG_PC_CYCLES and MBG_PC_CYCLES_FREQUENCY are always read in native
+// machine endianess, so no endianess conversion is required.
#define _mbg_swab_mbg_pc_cycles( _p ) \
_nop_macro_fnc()
+#define _mbg_swab_mbg_pc_cycles_frequency( _p ) \
+ _nop_macro_fnc()
+
+
+
+#if defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_I386 )
+
+ static __mbg_inline unsigned long long int mbg_rdtscll( void )
+ {
+ // The code below is a hack to get around issues with
+ // different versions of gcc.
+ //
+ // Normally the inline asm code could look similar to:
+ //
+ // __asm__ volatile ( "rdtsc" : "=A" (x) )
+ //
+ // which would copy the output regs edx:eax as a 64 bit
+ // number to a variable x.
+ //
+ // The "=A" expression should implicitely tell the compiler
+ // the edx and eax registers have been clobbered. However,
+ // this does not seem to work properly at least with gcc 4.1.2
+ // shipped with Centos 5.
+ //
+ // If optimization level 1 or higher is used then function
+ // parameters are also passed in registers. If the inline
+ // code above is used inside a function then the edx register
+ // is clobbered but the gcc 4.1.2 is not aware of this and
+ // assumes edx is unchanged, which may yield faulty results
+ // or even lead to segmentation faults.
+ //
+ // A possible workaround could be to mark edx explicitely as
+ // being clobbered in the asm inline code, but unfortunately
+ // other gcc versions report an error if a register which is
+ // implicitely (by "=A") known to be clobbered is also listed
+ // explicitely to be clobbered.
+ //
+ // So the code below is a workaround which tells the compiler
+ // implicitely that the eax ("=a") and edx ("=d") registers
+ // are being used and thus clobbered.
+
+ union
+ {
+ struct
+ {
+ uint32_t lo;
+ uint32_t hi;
+ } u32;
+
+ uint64_t u64;
+
+ } tsc_val;
+
+ __asm__ __volatile__( "rdtsc" : "=a" (tsc_val.u32.lo), "=d" (tsc_val.u32.hi) );
+
+ return tsc_val.u64;
+
+ } // mbg_rdtscll
+
+#endif
+
+
+
+static __mbg_inline
+void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
+{
+ #if defined( MBG_TGT_WIN32 )
+
+ #if defined( _KDD_ ) // kernel space
+ *p = (MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
+ #else // user space
+ QueryPerformanceCounter( (LARGE_INTEGER *) p );
+ #endif
+
+ #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_I386 )
+
+ #if 0 && ( defined( CONFIG_X86_TSC ) || defined( CONFIG_M586TSC ) ) //##++++
+ #define _pcps_get_cycles( _c ) \
+ _c = get_cycles()
+ #else
+ *p = mbg_rdtscll();
+ #endif
+
+ #else
+
+ *p = 0;
+
+ #endif
+
+} // mbg_get_pc_cycles
+
+
+
+static __mbg_inline
+void mbg_get_pc_cycles_frequency( MBG_PC_CYCLES_FREQUENCY *p )
+{
+ #if defined( MBG_TGT_WIN32 )
+ LARGE_INTEGER li;
+
+ #if defined( _KDD_ ) // kernel space
+ KeQueryPerformanceCounter( &li );
+ #else // user space
+ QueryPerformanceFrequency( &li );
+ #endif
+
+ *p = li.QuadPart;
+
+ #elif defined( MBG_TGT_LINUX )
+
+ #if defined( __KERNEL__ ) && defined( MBG_ARCH_I386 )
+ *p = ( cpu_khz * 1000 );
+ #else
+ *p = 0;
+ #endif
+
+ #else
+
+ *p = 0;
+
+ #endif
+
+} // mbg_get_pc_cycles_frequency
+
+
+
+static __mbg_inline
+MBG_PC_CYCLES mbg_delta_pc_cycles( const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2 )
+{
+#if defined( MBG_ARCH_SPARC )
+ // cycle counts are currently not supported under SPARC, so we always return 0.
+ return 0;
+#else
+ return *p1 - *p2;
+#endif
+
+} // mbg_delta_pc_cycles
+
+
#if !defined( MBG_MEM_ADDR )
// By default a memory address is stored
@@ -462,6 +600,9 @@ typedef struct
#define PCPS_HAS_GPS_DATA_16 0x00010000UL // use 16 bit size specifiers
#define PCPS_HAS_SYNTH 0x00020000UL
#define PCPS_HAS_GENERIC_IO 0x00040000UL
+#define PCPS_HAS_TIME_SCALE 0x00080000UL
+#define PCPS_HAS_UTC_PARM 0x00100000UL
+#define PCPS_HAS_IRIG_CTRL_BITS 0x00200000UL
/** @} */
// The constants below define those features which are available
@@ -624,13 +765,16 @@ typedef struct
#define REV_HAS_CABLE_LEN_GPS167PCI 0x0411
#define REV_HAS_CABLE_LEN_GPS167PC 0x0411
-/* command PCPS_GIVE_HR_TIME, structure PCPS_HR_TIME */
+/* command PCPS_GIVE_HR_TIME, structure PCPS_HR_TIME: */
#define REV_HAS_HR_TIME_GPS167PC 0x0305
#define REV_HAS_HR_TIME_TCR510PCI 0x0200
#define REV_HAS_HR_TIME_PEX511 0x0105 // This also requires a certain ASIC version.
#define REV_HAS_HR_TIME_PCI511 0x0103
-/* field offs_utc in structure PCPS_TIME */
+/* command PCPS_GET_IRIG_CTRL_BITS: */
+#define REV_HAS_IRIG_CTRL_BITS_TCR511PEX 0x0107
+
+/* field offs_utc in structure PCPS_TIME: */
#define REV_HAS_UTC_OFFS_PC31PS31 0x0300
/* command PCPS_GIVE_SYNC_TIME: */
@@ -782,6 +926,8 @@ typedef struct
#define _pcps_has_irig( _d ) \
( _pcps_is_irig_rx( _d ) || _pcps_has_irig_tx( _d ) )
+#define _pcps_has_irig_ctrl_bits( _d ) _pcps_has_feature( (_d), PCPS_HAS_IRIG_CTRL_BITS )
+
#define _pcps_has_ref_offs( _d ) \
_pcps_is_irig_rx( _d )
@@ -800,6 +946,12 @@ typedef struct
#define _pcps_has_generic_io( _d ) _pcps_has_feature( (_d), PCPS_HAS_GENERIC_IO )
+#define _pcps_has_time_scale( _d ) _pcps_has_feature( (_d), PCPS_HAS_TIME_SCALE )
+
+#define _pcps_has_utc_parm( _d ) _pcps_has_feature( (_d), PCPS_HAS_UTC_PARM )
+
+
+
#define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) || _pcps_is_pci_pex8311( _d ) )
#define _pcps_has_asic_features( _d ) _pcps_has_asic_version( _d )
diff --git a/c/mbglib/include/usbdefs.h b/c/mbglib/include/usbdefs.h
index 921b514..ebb5e4d 100644
--- a/c/mbglib/include/usbdefs.h
+++ b/c/mbglib/include/usbdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: usbdefs.h 1.7 2008/11/28 07:45:30Z daniel REL_M $
+ * $Id: usbdefs.h 1.9 2009/03/13 09:02:24Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: usbdefs.h $
+ * Revision 1.9 2009/03/13 09:02:24Z martin
+ * Removed definitions for timeout intervals.
+ * Revision 1.8 2009/02/18 11:08:44 daniel
+ * Added new class code and device ID for SCU_USB
* Revision 1.7 2008/11/28 07:45:30Z daniel
* Added new class code and device ID for WWVB51USB
* Revision 1.6 2008/01/09 10:39:18Z daniel
@@ -59,6 +63,7 @@ enum
MBG_USB_CLASS_TCR, // IRIG Time Code Receiver
MBG_USB_CLASS_MSF, // MSF Radio Clock
MBG_USB_CLASS_WWVB, // WWVB Radio Clock
+ MBG_USB_CLASS_SCU, // Meinberg Signal Changeover Unit
N_MBG_USB_CLASS // number of known device class codes
};
@@ -80,7 +85,9 @@ enum
#define USB_DEV_MSF51USB ( ( MBG_USB_CLASS_MSF << 8 ) | 0x01 )
-#define USB_DEV_WWVB51USB ( ( MBG_USB_CLASS_WWVB << 8 ) | 0x01 )
+#define USB_DEV_WWVB51USB ( ( MBG_USB_CLASS_WWVB << 8 ) | 0x01 )
+
+#define USB_DEV_SCU_USB ( ( MBG_USB_CLASS_SCU << 8 ) | 0x01 )
enum
{
@@ -91,20 +98,6 @@ enum
};
-#ifndef MBGUSB_TIMEOUT_SEND_MS
- #define MBGUSB_TIMEOUT_SEND_MS 500 // [ms]
-#endif
-
-#ifndef MBGUSB_TIMEOUT_RECEIVE_MS
- #define MBGUSB_TIMEOUT_RECEIVE_MS 500 // [ms]
-#endif
-
-#ifndef MBGUSB_TIMEOUT_RECEIVE_CYCLIC_MS
- #define MBGUSB_TIMEOUT_RECEIVE_CYCLIC_MS 2000 // [ms]
-#endif
-
-
-
#ifdef __cplusplus
}
#endif
diff --git a/c/mbglib/include/words.h b/c/mbglib/include/words.h
index ab77508..adfb21f 100644
--- a/c/mbglib/include/words.h
+++ b/c/mbglib/include/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.16 2008/12/05 12:05:41Z martin REL_M $
+ * $Id: words.h 1.17 2009/03/13 09:06:03Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
+ * Revision 1.17 2009/03/13 09:06:03Z martin
+ * Declared bit type for non-firmware environments.
* Revision 1.16 2008/12/05 12:05:41Z martin
* Define dummy int64_t/uint64_t types for targets
* which don't support 64 bit data types.
@@ -77,6 +79,8 @@
#if !_IS_MBG_FIRMWARE
#include <mbg_tgt.h>
+
+ typedef unsigned char bit;
#endif
diff --git a/c/mbglib/lib/bc/mbgdevio.lib b/c/mbglib/lib/bc/mbgdevio.lib
index 9a7b010..614bea8 100644
--- a/c/mbglib/lib/bc/mbgdevio.lib
+++ b/c/mbglib/lib/bc/mbgdevio.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgdevio.lib b/c/mbglib/lib/msc/mbgdevio.lib
index 218352b..4c01edd 100644
--- a/c/mbglib/lib/msc/mbgdevio.lib
+++ b/c/mbglib/lib/msc/mbgdevio.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgsvcio.lib b/c/mbglib/lib/msc/mbgsvcio.lib
index 990342b..e154382 100644
--- a/c/mbglib/lib/msc/mbgsvcio.lib
+++ b/c/mbglib/lib/msc/mbgsvcio.lib
Binary files differ
diff --git a/c/mbglib/lib/msc/mbgutil.lib b/c/mbglib/lib/msc/mbgutil.lib
index 6070da5..a6d0b5a 100644
--- a/c/mbglib/lib/msc/mbgutil.lib
+++ b/c/mbglib/lib/msc/mbgutil.lib
Binary files differ
diff --git a/c/mbglib/lib64/msc/mbgdevio.lib b/c/mbglib/lib64/msc/mbgdevio.lib
index 23391bb..ed341af 100644
--- a/c/mbglib/lib64/msc/mbgdevio.lib
+++ b/c/mbglib/lib64/msc/mbgdevio.lib
Binary files differ
diff --git a/c/mbglib/lib64/msc/mbgsvcio.lib b/c/mbglib/lib64/msc/mbgsvcio.lib
index 04bafa2..64e66ab 100644
--- a/c/mbglib/lib64/msc/mbgsvcio.lib
+++ b/c/mbglib/lib64/msc/mbgsvcio.lib
Binary files differ
diff --git a/c/mbglib/lib64/msc/mbgutil.lib b/c/mbglib/lib64/msc/mbgutil.lib
index 54b478e..9c6458a 100644
--- a/c/mbglib/lib64/msc/mbgutil.lib
+++ b/c/mbglib/lib64/msc/mbgutil.lib
Binary files differ