summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2009-08-18 12:00:00 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2009-08-18 12:00:00 +0200
commit825eead41f318b3f01b2e7771396e685ef01e98d (patch)
tree31cf9fadfe17cb78da071256388be6ce2546790b
parente4359116d6fd6abe33fee37ab1df86d99c9900a1 (diff)
downloadmbgsdk-win-825eead41f318b3f01b2e7771396e685ef01e98d.tar.gz
mbgsdk-win-825eead41f318b3f01b2e7771396e685ef01e98d.zip
Update mbglib files for the C demo projects
-rw-r--r--c/mbglib/include/gpsdefs.h632
-rw-r--r--c/mbglib/include/mbg_arch.h2
-rw-r--r--c/mbglib/include/mbg_tgt.h49
-rw-r--r--c/mbglib/include/mbgdevio.h190
-rw-r--r--c/mbglib/include/mbgsvcio.h8
-rw-r--r--c/mbglib/include/mbgtime.h265
-rw-r--r--c/mbglib/include/mbgutil.h8
-rw-r--r--c/mbglib/include/pci_asic.h22
-rw-r--r--c/mbglib/include/pcpsdefs.h66
-rw-r--r--c/mbglib/include/pcpsdev.h32
-rw-r--r--c/mbglib/include/words.h61
-rw-r--r--c/mbglib/lib/bc/mbgdevio.libbin24576 -> 26112 bytes
-rw-r--r--c/mbglib/lib/msc/mbgdevio.libbin185640 -> 197556 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.libbin31332 -> 33774 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, 1250 insertions, 85 deletions
diff --git a/c/mbglib/include/gpsdefs.h b/c/mbglib/include/gpsdefs.h
index 81b375f..232f30b 100644
--- a/c/mbglib/include/gpsdefs.h
+++ b/c/mbglib/include/gpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: gpsdefs.h 1.75 2009/03/19 14:06:39Z martin REL_M $
+ * $Id: gpsdefs.h 1.79 2009/08/12 14:12:38Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -13,6 +13,28 @@
*
* -----------------------------------------------------------------------
* $Log: gpsdefs.h $
+ * Revision 1.79 2009/08/12 14:12:38Z daniel
+ * Added definitions to support new model MGR170.
+ * Added definitions and commands to support configuration
+ * of navigation engine (currently supported by u-blox
+ * receivers only).
+ * Renamed simulation values in PTP_SETTINGS to reserved.
+ * Added "UNINITIALIZED" to PTP port state.
+ * Removed obsolete braces in initializer.
+ * Revision 1.78 2009/06/25 15:49:05Z martin
+ * Added macro _nano_time_negative().
+ * Revision 1.77 2009/06/08 19:22:32Z daniel
+ * Added feature GPS_HAS_PTP.
+ * Added preliminary structures and definitions for PTP
+ * configuration and state.
+ * Added IP4_ADDR type.
+ * Added Bitmask IP4_MSK_DHCP.
+ * Added byte swapper macros for LAN and PTP structures.
+ * Moved LAN interface configuration definitions here.
+ * Moved DAC_VAL definition here.
+ * Changed type iof FPGA_INFO::start_addr for non-firmware applications.
+ * Revision 1.76 2009/04/08 08:26:56 daniel
+ * Added feature GPS_FEAT_IRIG_CTRL_BITS.
* 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
@@ -454,6 +476,7 @@ enum
GPS_MODEL_GEN170,
GPS_MODEL_TCR170PEX,
GPS_MODEL_WWVB511,
+ GPS_MODEL_MGR170,
N_GPS_MODEL
/* If new model codes are added then care must be taken
* to update the associated string initializers below
@@ -494,6 +517,7 @@ enum
#define GPS_MODEL_NAME_GEN170 "GEN170"
#define GPS_MODEL_NAME_TCR170PEX "TCR170PEX"
#define GPS_MODEL_NAME_WWVB511 "WWVB511"
+#define GPS_MODEL_NAME_MGR170 "MGR170"
/*
@@ -529,7 +553,8 @@ enum
GPS_MODEL_NAME_FRC511PEX, \
GPS_MODEL_NAME_GEN170, \
GPS_MODEL_NAME_TCR170PEX, \
- GPS_MODEL_NAME_WWVB511 \
+ GPS_MODEL_NAME_WWVB511, \
+ GPS_MODEL_NAME_MGR170 \
}
@@ -544,7 +569,11 @@ enum
( strstr( (_p_ri)->model_name, "PEX" ) )
#define _mbg_rcvr_is_gps( _p_ri ) \
- ( strstr( (_p_ri)->model_name, "GPS" ) )
+ ( strstr( (_p_ri)->model_name, "GPS" ) || \
+ ( strstr( (_p_ri)->model_name, "MGR" ) )
+
+#define _mbg_rcvr_is_mobile_gps( _p_ri ) \
+ ( strstr( (_p_ri)->model_name, "MGR" ) )
#define _mbg_rcvr_is_gps_plug_in( _p_ri ) \
( _mbg_rcvr_is_gps( _p_ri ) && \
@@ -693,6 +722,9 @@ enum
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, ...) */
+ GPS_FEAT_IRIG_CTRL_BITS, /**< supports IRIG control bits */
+ GPS_FEAT_PTP, /**< has PTP support */
+ GPS_FEAT_NAV_ENGINE_SETTINGS, /**< supports navigation engine configuration */
N_GPS_FEATURE /**< the number of valid features */
};
@@ -712,7 +744,10 @@ enum
"5 MHz Output", \
"Ext. Multiple Ref. Src. Cfg.", \
"Supp. Optional Settings", \
- "Configurable Time Scale" \
+ "Configurable Time Scale", \
+ "Irig Control Bits", \
+ "PTP/IEEE1588", \
+ "Supp. Nav. Engine Settings" \
}
@@ -734,6 +769,9 @@ enum
#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_IRIG_CTRL_BITS ( 1UL << GPS_FEAT_IRIG_CTRL_BITS )
+#define GPS_HAS_PTP ( 1UL << GPS_FEAT_PTP )
+#define GPS_HAS_NAV_ENGINE_SETTINGS ( 1UL << GPS_FEAT_NAV_ENGINE_SETTINGS )
#define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX
@@ -774,7 +812,11 @@ typedef union
{
CSUM csum;
uint32_t fsize;
- uint32_t start_addr;
+ #if _IS_MBG_FIRMWARE
+ uint32_t start_addr;
+ #else
+ uint8_t *start_addr;
+ #endif
char name[FPGA_NAME_SIZE];
} hdr;
@@ -951,6 +993,11 @@ typedef struct
_mbg_swab32( &(_p)->secs ); \
}
+// The macro below checks if a NANO_TIME value is negative.
+#define _nano_time_negative( _nt ) \
+ ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) )
+
+
/* Two types of variables used to store a position. Type XYZ is */
/* used with a position in earth centered, earth fixed (ECEF) */
@@ -3117,22 +3164,31 @@ enum
#define UPDA_166 ( 0x08 | BOOT )
#define UPDA_BC ( 0x09 | REMOTE | BOOT )
+
+
+typedef int16_t DAC_VAL;
+
+#define _mbg_swab_dac_val( _p ) \
+ _mbg_swab16( _p );
+
+
+
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 ) */
+ uint16_t mode; /**< Mode of operation */
+ uint16_t good_svs; /**< Numb. of satellites that can currently be received and used */
+ uint16_t svs_in_view; /**< Numb. of satellites that should be in view according to the almanac data */
+ DAC_VAL dac_val; /**< Oscillator fine DAC value */
+ DAC_VAL dac_cal; /**< Oscillator calibration DAC value ( 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 _mbg_swab_stat_info( _p ) \
+{ \
+ _mbg_swab16( &(_p)->mode ); \
+ _mbg_swab16( &(_p)->good_svs ); \
+ _mbg_swab16( &(_p)->svs_in_view ); \
+ _mbg_swab_dac_val( &(_p)->dac_val ); \
+ _mbg_swab_dac_val( &(_p)->dac_cal ); \
}
@@ -3168,6 +3224,476 @@ typedef uint16_t ANT_CABLE_LEN;
#define _mbg_swab_ant_cable_len( _p ) _mbg_swab16( _p )
+
+/* Configuration data for an optional LAN interface.
+ *
+ * This is only supported if the flag GPS_HAS_LAN_IP4
+ * is set in RECEIVER_INFO::features.
+ */
+
+
+/* Basic network settings */
+
+typedef uint32_t IP4_ADDR;
+
+#define _mbg_swab_ip4_addr( _p ) \
+ _mbg_swab32( _p );
+
+
+typedef struct
+{
+ IP4_ADDR ip_addr;
+ IP4_ADDR netmask;
+ IP4_ADDR broad_addr;
+ IP4_ADDR gateway;
+ uint32_t flags; /* see below */
+
+} IP4_SETTINGS;
+
+#define _mbg_swab_ip4_settings( _p ) \
+{ \
+ _mbg_swab_ip4_addr( &(_p)->ip_addr ); \
+ _mbg_swab_ip4_addr( &(_p)->netmask ); \
+ _mbg_swab_ip4_addr( &(_p)->broad_addr ); \
+ _mbg_swab_ip4_addr( &(_p)->gateway ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+#if 0 //##++ currently not used
+
+/* Misc configuration */
+
+typedef struct
+{
+ uint16_t id; /* service ID, see below */
+ uint16_t index; /* used if several same svcs must be cfg'd, e.g. DNS */
+ char host[50]; /* see below */
+
+} IP_CFG;
+
+
+
+/* Description of a service running on a device */
+
+typedef struct
+{
+ uint16_t id; /* service ID, see below */
+ uint16_t socket; /* the socket on which the service is listening */
+ uint32_t flags; /* see below */
+
+} IP_SERVICE;
+
+#endif // 0
+
+
+
+/* LAN interface information */
+
+typedef struct
+{
+ uint16_t type; /* codes see below */
+ uint8_t mac_addr[6]; /* MAC address */
+ uint16_t ver_code; /* high byte.low byte, in hex */
+ char ver_str[GPS_ID_STR_SIZE];
+ char sernum[GPS_ID_STR_SIZE];
+ uint32_t rsvd; /* reserved, currently always 0 */
+ uint32_t flags; /* reserved, currently always 0 */
+} LAN_IF_INFO;
+
+#define _mbg_swab_lan_if_info( _p ) \
+{ \
+ _mbg_swab16( &(_p)->type ); \
+ _mbg_swab16( &(_p)->ver_code ); \
+ _mbg_swab32( &(_p)->rsvd ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+/* codes used with LAN_IF_INFO::type: */
+
+enum
+{
+ LAN_IF_TYPE_XPORT,
+ LAN_IF_TYPE_PTP,
+ N_LAN_IF_TYPE
+};
+
+
+/* Flags used with IP4_SETTINGS::flags and LAN_IF_INFO::flags: */
+
+enum
+{
+ IP4_BIT_DHCP,
+ IP4_BIT_LINK, // used only to report state
+ N_IP4_BIT
+};
+
+#define IP4_MSK_DHCP ( 1UL << IP4_BIT_DHCP )
+#define IP4_MSK_LINK ( 1UL << IP4_BIT_LINK )
+
+
+enum
+{
+ PTP_NW_PROT_BIT_RESERVED,
+ PTP_NW_PROT_BIT_UDP_IPV4,
+ PTP_NW_PROT_BIT_UDP_IPV6,
+ PTP_NW_PROT_BIT_IEEE_802_3,
+ PTP_NW_PROT_BIT_DEVICE_NET,
+ PTP_NW_PROT_BIT_CONTROL_NET,
+ PTP_NW_PROT_BIT_PROFINET,
+ N_PTP_NW_PROT
+};
+
+#define PTP_NW_PROT_MSK_RESERVED ( 1UL << PTP_NW_PROT_BIT_RESERVED )
+#define PTP_NW_PROT_MSK_UDP_IPV4 ( 1UL << PTP_NW_PROT_BIT_UDP_IPV4 )
+#define PTP_NW_PROT_MSK_UDP_IPV6 ( 1UL << PTP_NW_PROT_BIT_UDP_IPV6 )
+#define PTP_NW_PROT_MSK_IEEE_802_3 ( 1UL << PTP_NW_PROT_BIT_IEEE_802_3 )
+#define PTP_NW_PROT_MSK_DEVICE_NET ( 1UL << PTP_NW_PROT_BIT_DEVICE_NET )
+#define PTP_NW_PROT_MSK_CONTROL_NET ( 1UL << PTP_NW_PROT_BIT_CONTROL_NET )
+#define PTP_NW_PROT_MSK_PROFINET ( 1UL << PTP_NW_PROT_BIT_PROFINET )
+
+#if !defined( DEFAULT_PTP_NW_PROT_MASK )
+ #define DEFAULT_PTP_NW_PROT_MASK ( PTP_NW_PROT_MSK_UDP_IPV4 | PTP_NW_PROT_MSK_IEEE_802_3 )
+#endif
+
+#define PTP_NW_PROT_STRS \
+{ \
+ "Reserved", \
+ "UDP/IPv4", \
+ "UDP/IPv6", \
+ "IEEE 802.3", \
+ "DeviceNet", \
+ "ControlNet", \
+ "PROFINET" \
+}
+
+
+
+enum
+{
+ PTP_PORT_STATE_UNINITIALIZED,
+ PTP_PORT_STATE_INITIALIZING,
+ PTP_PORT_STATE_FAULTY,
+ PTP_PORT_STATE_DISABLED,
+ PTP_PORT_STATE_LISTENING,
+ PTP_PORT_STATE_PRE_MASTER,
+ PTP_PORT_STATE_MASTER,
+ PTP_PORT_STATE_PASSIVE,
+ PTP_PORT_STATE_UNCALIBRATED,
+ PTP_PORT_STATE_SLAVE,
+ N_PTP_PORT_STATE
+};
+
+#define PTP_PORT_STATE_STRS \
+{ \
+ "UNINITIALIZED", \
+ "INITIALIZING", \
+ "FAULTY", \
+ "DISABLED", \
+ "LISTENING", \
+ "PRE_MASTER", \
+ "MASTER", \
+ "PASSIVE", \
+ "UNCALIBRATED", \
+ "SLAVE" \
+}
+
+
+typedef struct
+{
+ uint8_t value;
+ char *name;
+} PTP_TABLE;
+
+
+enum
+{
+ PTP_DELAY_MECH_BIT_E2E, // in PTP2 specs: 0x01
+ PTP_DELAY_MECH_BIT_P2P, // in PTP2 specs: 0x02
+ N_PTP_DELAY_MECH // additionally the specs define 0xFE for disabled
+};
+
+#define PTP_DELAY_MECH_MSK_E2E ( 1UL << PTP_DELAY_MECH_BIT_E2E )
+#define PTP_DELAY_MECH_MSK_P2P ( 1UL << PTP_DELAY_MECH_BIT_P2P )
+
+#if !defined( DEFAULT_PTP_DELAY_MECH_MASK )
+ #define DEFAULT_PTP_DELAY_MECH_MASK ( PTP_DELAY_MECH_MSK_E2E )
+#endif
+
+#define PTP_DELAY_MECH_NAMES \
+{ \
+ "E2E", \
+ "P2P" \
+}
+
+
+
+#define PTP_CLOCK_ACCURACY_RESERVED_OFFSET 0x20
+
+enum
+{
+ PTP_CLOCK_ACCURACY_25ns = PTP_CLOCK_ACCURACY_RESERVED_OFFSET,
+ PTP_CLOCK_ACCURACY_100ns,
+ PTP_CLOCK_ACCURACY_250ns,
+ PTP_CLOCK_ACCURACY_1us,
+ PTP_CLOCK_ACCURACY_2_5us,
+ PTP_CLOCK_ACCURACY_10us,
+ PTP_CLOCK_ACCURACY_25us,
+ PTP_CLOCK_ACCURACY_100us,
+ PTP_CLOCK_ACCURACY_250us,
+ PTP_CLOCK_ACCURACY_1ms,
+ PTP_CLOCK_ACCURACY_2_5ms,
+ PTP_CLOCK_ACCURACY_10ms,
+ PTP_CLOCK_ACCURACY_25ms,
+ PTP_CLOCK_ACCURACY_100ms,
+ PTP_CLOCK_ACCURACY_250ms,
+ PTP_CLOCK_ACCURACY_1s,
+ PTP_CLOCK_ACCURACY_10s,
+ PTP_CLOCK_ACCURACY_MORE_10s,
+ PTP_CLOCK_ACCURACY_RESERVED_1,
+ PTP_CLOCK_ACCURACY_RESERVED_2,
+ PTP_CLOCK_ACCURACY_RESERVED_3,
+ PTP_CLOCK_ACCURACY_RESERVED_4,
+ N_PTP_CLOCK_ACCURACY
+};
+
+
+// Attention: Substract offset of PTP_CLOCK_ACCURACY_RESERVED_OFFSET when
+// using the enum above as index for the initializer below!
+#define PTP_CLOCK_ACCURACY_STRS \
+{ \
+ "< 25 ns", \
+ "< 100 ns", \
+ "< 250 ns", \
+ "< 1 us", \
+ "< 2.5 us", \
+ "< 10 us", \
+ "< 25 us", \
+ "< 100 us", \
+ "< 250 us", \
+ "< 1 ms", \
+ "< 2.5 ms", \
+ "< 10 ms", \
+ "< 25 ms", \
+ "< 100 ms", \
+ "< 250 ms", \
+ "< 1 s", \
+ "< 10 s", \
+ "more than 10 s", \
+ "reserved_1", \
+ "reserved_2", \
+ "reserved_3", \
+ "reserved_4" \
+}
+
+
+
+#define PTP_TIME_SOURCE_ATOMIC_CLOCK 0x10
+#define PTP_TIME_SOURCE_GPS 0x20
+#define PTP_TIME_SOURCE_TERRESTRIAL_RADIO 0x30
+#define PTP_TIME_SOURCE_PTP 0x40
+#define PTP_TIME_SOURCE_NTP 0x50
+#define PTP_TIME_SOURCE_HAND_SET 0x60
+#define PTP_TIME_SOURCE_OTHER 0x90
+#define PTP_TIME_SOURCE_INTERNAL_OSCILLATOR 0xA0
+
+
+
+#define PTP_TIME_SOURCE_TABLE \
+{ \
+ { PTP_TIME_SOURCE_ATOMIC_CLOCK, "Atomic Clock" }, \
+ { PTP_TIME_SOURCE_GPS, "GPS" }, \
+ { PTP_TIME_SOURCE_TERRESTRIAL_RADIO, "Terrestrial Radio" }, \
+ { PTP_TIME_SOURCE_PTP, "PTP" }, \
+ { PTP_TIME_SOURCE_NTP, "NTP" }, \
+ { PTP_TIME_SOURCE_HAND_SET, "HAND SET" }, \
+ { PTP_TIME_SOURCE_OTHER, "OTHER" }, \
+ { PTP_TIME_SOURCE_INTERNAL_OSCILLATOR, "Internal Oscillator" }, \
+ { 0, NULL } \
+}
+
+
+
+
+/* PTP configuration stuff */
+
+typedef struct
+{
+ uint8_t b[8];
+} PTP_CLOCK_IDENTITY;
+
+
+
+typedef struct
+{
+ uint16_t network_protocol; // enum
+ uint8_t ptp_proto_version; // PTP v1 or v2
+ uint8_t port_state; // enum
+ uint32_t flags;
+ NANO_TIME offset;
+ NANO_TIME path_delay;
+ NANO_TIME mean_path_delay;
+ NANO_TIME delay_asymmetry;
+
+ PTP_CLOCK_IDENTITY gm_identity;
+
+ uint16_t clock_offset_scaled_log_variance;
+ uint8_t clock_class;
+ uint8_t clock_accuracy; // enum
+
+ uint32_t num_clients;
+ uint32_t num_masters;
+
+ uint8_t domain_number;
+ uint8_t time_source; // enum
+ uint8_t delay_mech;
+ int8_t log_delay_req_intv;
+
+ int16_t utc_offset;
+ DAC_VAL osc_dac_cal;
+
+ uint32_t reserved;
+} PTP_STATE;
+
+#define _mbg_swab_ptp_state( _p ) \
+{ \
+ _mbg_swab16( &(_p)->network_protocol ); \
+ _mbg_swab32( &(_p)->flags ); \
+ _mbg_swab_nano_time( &(_p)->offset ); \
+ _mbg_swab_nano_time( &(_p)->path_delay ); \
+ _mbg_swab_nano_time( &(_p)->mean_path_delay ); \
+ _mbg_swab_nano_time( &(_p)->delay_asymmetry ); \
+ _mbg_swab16( &(_p)->clock_offset_scaled_log_variance ); \
+ _mbg_swab32( &(_p)->num_clients ); \
+ _mbg_swab32( &(_p)->num_masters ); \
+ _mbg_swab32( &(_p)->utc_offset ); \
+ _mbg_swab_dac_val( &(_p)->osc_dac_cal ); \
+}
+
+
+enum
+{
+ PTP_FLAG_BIT_SLAVE_ONLY,
+ PTP_FLAG_BIT_IS_SLAVE,
+ PTP_FLAG_BIT_TIMESCALE_IS_PTP,
+ PTP_FLAG_BIT_LS_ANN,
+ PTP_FLAG_BIT_LS_ANN_NEG,
+ N_PTP_FLAG_BIT
+};
+
+#define PTP_FLAG_MSK_SLAVE_ONLY ( 1UL << PTP_FLAG_BIT_SLAVE_ONLY )
+#define PTP_FLAG_MSK_IS_SLAVE ( 1UL << PTP_FLAG_BIT_IS_SLAVE )
+#define PTP_FLAG_MSK_TIMESCALE_IS_PTP ( 1UL << PTP_FLAG_BIT_TIMESCALE_IS_PTP )
+#define PTP_FLAG_MSK_LS_ANN ( 1UL << PTP_FLAG_BIT_LS_ANN )
+#define PTP_FLAG_MSK_LS_ANN_NEG ( 1UL << PTP_FLAG_BIT_LS_ANN_NEG )
+
+
+#define PTP_SYNC_INTERVAL_MIN -6
+#define PTP_SYNC_INTERVAL_MAX 6
+
+#define PTP_DELAY_REQ_INTERVAL_MIN -6
+#define PTP_DELAY_REQ_INTERVAL_MAX 6
+
+
+typedef struct
+{
+ uint16_t network_protocol; // enum, only 1 or 3
+ uint8_t profile; // currently only 0 = default
+ uint8_t domain_number; // 0:3
+
+ uint8_t delay_mechanism; // 0 (E2E) or 1 (P2P), unless disabled
+ uint8_t reserved_0;
+ uint8_t priority_1;
+ uint8_t priority_2;
+
+ uint8_t dflt_clk_class_unsync_cold; // 6:255
+ uint8_t dflt_clk_class_unsync_warm; // 6:255
+ uint8_t dflt_clk_class_sync_cold; // 6:255
+ uint8_t dflt_clk_class_sync_warm; // 6:255
+
+ uint8_t reserved_1; // currently always 0
+ uint8_t reserved_2; // currently always 0
+ int16_t sync_interval; // log 2
+
+ int16_t announce_interval; // log 2
+ int16_t delay_request_interval; // log 2
+
+ uint32_t upper_bound; // [ns] sync state set to false if above this limit
+ uint32_t lower_bound; // [ns] sync state set to true if below this limit
+
+ uint32_t reserved_3; // currently always 0
+ uint32_t flags; // (see below)
+
+} PTP_CFG_SETTINGS;
+
+#define _mbg_swab_ptp_cfg_settings( _p ) \
+{ \
+ _mbg_swab16( &(_p)->network_protocol ); \
+ _mbg_swab16( &(_p)->sync_interval ); \
+ _mbg_swab16( &(_p)->announce_interval ); \
+ _mbg_swab16( &(_p)->delay_request_interval ); \
+ _mbg_swab32( &(_p)->upper_bound ); \
+ _mbg_swab32( &(_p)->lower_bound ); \
+ _mbg_swab32( &(_p)->reserved_1 ); \
+ _mbg_swab32( &(_p)->flags ); \
+}
+
+
+
+typedef struct
+{
+ PTP_CFG_SETTINGS settings;
+
+ uint8_t ptp_proto_version; // PTP v1 or v2
+ uint8_t reserved_1; // currently always 0
+ uint16_t reserved_2; // currently always 0
+
+ int16_t sync_interval_min; // log 2
+ int16_t sync_interval_max; // log 2
+ int16_t announce_interval_min; // log 2
+ int16_t announce_interval_max; // log 2
+ int16_t delay_request_interval_min; // log 2
+ int16_t delay_request_interval_max; // log 2
+
+ uint32_t supported_flags; // (see below)
+ uint32_t supported_network_protocols;
+ uint32_t supported_profiles;
+ uint32_t supported_delay_mechanisms;
+
+} PTP_CFG_INFO;
+
+#define _mbg_swab_ptp_cfg_info( _p ) \
+{ \
+ _mbg_swab_ptp_cfg_settings( &(_p)->settings ); \
+ _mbg_swab16( &(_p)->sync_interval_min ); \
+ _mbg_swab16( &(_p)->sync_interval_max ); \
+ _mbg_swab16( &(_p)->announce_interval_min ); \
+ _mbg_swab16( &(_p)->announce_interval_max ); \
+ _mbg_swab16( &(_p)->delay_request_interval_min ); \
+ _mbg_swab16( &(_p)->delay_request_interval_max ); \
+ _mbg_swab32( &(_p)->supported_flags ); \
+ _mbg_swab32( &(_p)->supported_profiles ); \
+ _mbg_swab32( &(_p)->supported_delay_mechanisms ); \
+}
+
+
+
+// flags used with PTP_CFG_SETTINGS::flags and PTP_CFG_INFO::supported_flags:
+// possibly also: can be master (i.e not slave only), v1 hw compat, ...
+enum
+{
+ PTP_CFG_BIT_TIME_SCALE_IS_PTP, // time scale is PTP/TAI, else arbitrary
+ PTP_CFG_BIT_V1_HW_COMPAT,
+ N_PTP_CFG_BIT
+};
+
+#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_BIT_TIME_SCALE_IS_PTP )
+#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_BIT_V1_HW_COMPAT )
+
+
+
/*------------------------------------------------------------------------*/
/* Ephemeris parameters of one specific SV. Needed to compute the position */
@@ -3320,6 +3846,78 @@ typedef struct
} ASCII_MSG;
+
+enum
+{
+ GPS_PLATFORM_PORTABLE,
+ GPS_PLATFORM_FIXED,
+ GPS_PLATFORM_STATIONARY,
+ GPS_PLATFORM_PEDESTRIAN,
+ GPS_PLATFORM_AUTOMOTIVE,
+ GPS_PLATFORM_SEA,
+ GPS_PLATFORM_AIRBORNE_1G,
+ GPS_PLATFORM_AIRBORNE_2G,
+ GPS_PLATFORM_AIRBORNE_4G,
+ N_GPS_PLATFORMS
+};
+
+
+#define GPS_PLATFORM_STRS \
+{ \
+ "Portable ", \
+ "Fixed ", \
+ "Stationary ", \
+ "Pedestrian ", \
+ "Automotive ", \
+ "Sea ", \
+ "Airborne <1G", \
+ "Airborne <2G", \
+ "Airborne <4G" \
+}
+
+
+
+enum
+{
+ TIME_MODE_DISABLED,
+ TIME_MODE_SURVEY_IN,
+ TIME_MODE_FIXED
+};
+
+
+
+typedef struct
+{
+ uint32_t time_mode;
+ uint32_t survey_in_duration;
+ uint32_t survey_in_pos_var;
+ int32_t fixedPosX; // cm
+ int32_t fixedPosY; // cm
+ int32_t fixedPosZ; // cm
+ uint32_t fixedPosVar; // cm
+ uint32_t flags; // currently 0
+ uint32_t reserved; // currently 0
+} NAV_TIME_MODE_SETTINGS;
+
+
+/**
+ Navigation Engine settings to set configuration
+ parameters of a dynamic platform model.
+*/
+typedef struct
+{
+ uint8_t dynamic_platform;
+ uint8_t fix_mode;
+ int8_t min_elevation;
+ uint8_t static_hold_threshold;
+ int32_t fixed_altitude;
+ uint32_t fixed_altitude_variance;
+ uint32_t flags; // currently 0
+ uint32_t reserved; // currently 0
+ NAV_TIME_MODE_SETTINGS nav_time_mode_settings;
+} NAV_ENGINE_SETTINGS;
+
+
/* End of header body */
diff --git a/c/mbglib/include/mbg_arch.h b/c/mbglib/include/mbg_arch.h
index 5b8d42a..dc97477 100644
--- a/c/mbglib/include/mbg_arch.h
+++ b/c/mbglib/include/mbg_arch.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_arch.h 1.2 2009/03/19 15:14:15Z martin REL_M $
+ * $Id: mbg_arch.h 1.2 2009/03/19 15:14:15Z martin REL_M martin $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
diff --git a/c/mbglib/include/mbg_tgt.h b/c/mbglib/include/mbg_tgt.h
index 15eca61..28aebf8 100644
--- a/c/mbglib/include/mbg_tgt.h
+++ b/c/mbglib/include/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.17 2009/03/19 15:21:07Z martin REL_M $
+ * $Id: mbg_tgt.h 1.19 2009/06/09 10:03:58Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,6 +11,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
+ * Revision 1.19 2009/06/09 10:03:58Z daniel
+ * Preliminary support for ARM architecture.
+ * Revision 1.18 2009/04/01 14:10:55 martin
+ * Cleanup for CVI.
* 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
@@ -80,8 +84,9 @@
/* Start of header body */
-#if defined( _CVI )
+#if defined( _CVI ) || defined( _CVI_ )
+ #define MBG_TGT_WIN32
#define MBG_TGT_CVI
#elif defined( _WIN32_WINNT )
@@ -187,7 +192,15 @@
#define MBG_TGT_HAS_WCHAR_T defined( MBG_TGT_WIN32 )
#if defined( __sparc__ )
+
#define MBG_ARCH_SPARC
+ #define _MBG_ARCH_DEFINED
+
+ #elif defined( __arm__ )
+
+ #define MBG_ARCH_ARM
+ #define _MBG_ARCH_DEFINED
+
#endif
#elif defined( _MSC_VER )
@@ -196,7 +209,7 @@
#define MBG_TGT_HAS_WCHAR_T 1
-#elif defined( _CVI )
+#elif defined( _CVI ) || defined( _CVI_ )
#define __mbg_inline //##++++
@@ -223,7 +236,7 @@
// Currently we support only Sparc and i386/x86_64 architectures,
// so unless we have explicitely found sparc we assume i386.
-#if !defined MBG_ARCH_SPARC
+#if !defined( _MBG_ARCH_DEFINED )
#define MBG_ARCH_I386
#endif
@@ -249,17 +262,7 @@
-#if defined( MBG_TGT_CVI )
-
- #include <windows.h>
- #include <utility.h>
-
- #define MBG_HANDLE HANDLE
- #define MBG_PORT_HANDLE int
-
- #define MBG_INVALID_HANDLE -1
-
-#elif defined( MBG_TGT_WIN32 )
+#if defined( MBG_TGT_WIN32 )
#if defined( _AMD64_ )
// This is used for AMD64 architecture and for
@@ -277,9 +280,17 @@
// This must not be used for kernel drivers.
#include <windows.h>
typedef HANDLE MBG_HANDLE;
- typedef HANDLE MBG_PORT_HANDLE;
#define MBG_INVALID_HANDLE INVALID_HANDLE_VALUE
+
+ #if defined( MBG_TGT_CVI )
+ // CVI uses an own set of functions to support serial ports
+ typedef int MBG_PORT_HANDLE;
+ #define MBG_INVALID_PORT_HANDLE -1
+ #else
+ typedef HANDLE MBG_PORT_HANDLE;
+ #define MBG_INVALID_PORT_HANDLE MBG_INVALID_HANDLE
+ #endif
// The DWORD_PTR type is not defined in the headers shipping
// with VC6. However, if the SDK is installed then the SDK's
@@ -326,7 +337,11 @@
#if !defined( MBG_USE_MM_IO_FOR_PCI )
- #define MBG_USE_MM_IO_FOR_PCI ( 0 || defined( MBG_ARCH_SPARC ) )
+ #if ( 0 || defined( MBG_ARCH_SPARC ) )
+ #define MBG_USE_MM_IO_FOR_PCI 1
+ #else
+ #define MBG_USE_MM_IO_FOR_PCI 0
+ #endif
#endif
diff --git a/c/mbglib/include/mbgdevio.h b/c/mbglib/include/mbgdevio.h
index 26a852b..ff44706 100644
--- a/c/mbglib/include/mbgdevio.h
+++ b/c/mbglib/include/mbgdevio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgdevio.h 1.33 2009/03/19 15:36:26Z martin REL_M $
+ * $Id: mbgdevio.h 1.37 2009/08/12 14:31:51Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,16 @@
*
* -----------------------------------------------------------------------
* $Log: mbgdevio.h $
- * Revision 1.33 2009/03/19 15:36:26Z martin
+ * Revision 1.37 2009/08/12 14:31:51Z daniel
+ * New version code 306, compatibility version still 210.
+ * Revision 1.36 2009/06/19 12:20:31Z martin
+ * Updated function prototypes.
+ * Revision 1.35 2009/06/09 08:57:09 daniel
+ * New version code 305, compatibility version still 210.
+ * Revision 1.34 2009/06/08 18:20:14Z daniel
+ * Updated function prototypes.
+ * Fixes for ARM target.
+ * Revision 1.33 2009/03/19 15:36:26 martin
* New version code 304, compatibility version still 210.
* Moved some inline functions dealing with MBG_PC_CYCLES
* from mbgdevio.h to pcpsdev.h.
@@ -141,7 +150,7 @@
#include <time.h>
-#define MBGDEVIO_VERSION 0x0304
+#define MBGDEVIO_VERSION 0x0306
#define MBGDEVIO_COMPAT_VERSION 0x0210
@@ -255,7 +264,7 @@
-#if defined( MBG_TGT_LINUX )
+#if defined( MBG_TGT_LINUX ) && !defined( MBG_ARCH_ARM )
#include <sched.h>
@@ -1118,6 +1127,35 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_irig_ctrl_bits( MBG_DEV_HANDLE dh, MBG_IRIG_CTRL_BITS *p ) ;
/**
+ Check if a specific device supports the mbg_get_irig_time() 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_time()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_irig_time( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read a ::PCPS_IRIG_TIME type which returns the raw IRIG day-of-year number
+ and time decoded from the latest IRIG input frame. If the configured IRIG code
+ also contains the year number then the year number is also returned, otherwise
+ the returned year number is 0xFF.
+ The macro _pcps_has_irig_time() or the API call mbg_dev_has_irig_time()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PCPS_IRIG_TIME type to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_irig_time()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_get_irig_time( MBG_DEV_HANDLE dh, PCPS_IRIG_TIME *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.
@@ -2484,6 +2522,150 @@ extern "C" {
_MBG_API_ATTR int _MBG_API mbg_get_irq_stat_info( MBG_DEV_HANDLE dh, PCPS_IRQ_STAT_INFO *p ) ;
/**
+ Check if a specific device provides simple LAN interface API calls.
+
+ @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_lan_if_info()
+ @see mbg_get_ip4_state()
+ @see mbg_get_ip4_settings()
+ @see mbg_set_ip4_settings()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_lan_intf( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read LAN interface information from a card which supports this.
+ The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::LAN_IF_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_lan_intf()
+ @see mbg_get_ip4_state()
+ @see mbg_get_ip4_settings()
+ @see mbg_set_ip4_settings()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_lan_if_info( MBG_DEV_HANDLE dh, LAN_IF_INFO *p ) ;
+
+ /**
+ Read LAN IPv4 state from a card which supports this.
+ The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::IP4_SETTINGS variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_lan_intf()
+ @see mbg_get_lan_if_info()
+ @see mbg_get_ip4_settings()
+ @see mbg_set_ip4_settings()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_ip4_state( MBG_DEV_HANDLE dh, IP4_SETTINGS *p ) ;
+
+ /**
+ Read LAN IPv4 settings from a card which supports this.
+ The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::IP4_SETTINGS variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_lan_intf()
+ @see mbg_get_lan_if_info()
+ @see mbg_get_ip4_state()
+ @see mbg_set_ip4_settings()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_ip4_settings( MBG_DEV_HANDLE dh, IP4_SETTINGS *p ) ;
+
+ /**
+ Write LAN IPv4 settings to a card which supports this.
+ The macro _pcps_has_lan_intf() or the API call mbg_dev_has_lan_intf()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p ::IP4_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_lan_intf()
+ @see mbg_get_lan_if_info()
+ @see mbg_get_ip4_settings()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_ip4_settings( MBG_DEV_HANDLE dh, const IP4_SETTINGS *p ) ;
+
+ /**
+ Check if a specific device provides PTP configuration/status calls.
+
+ @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_ptp_state()
+ @see mbg_get_ptp_cfg_info()
+ @see mbg_set_ptp_cfg_settings()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_dev_has_ptp( MBG_DEV_HANDLE dh, int *p ) ;
+
+ /**
+ Read PTP/IEEE1588 status from a card which supports this.
+ The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PTP_CFG_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp()
+ @see mbg_get_ptp_cfg_info()
+ @see mbg_set_ptp_cfg_settings()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_ptp_state( MBG_DEV_HANDLE dh, PTP_STATE *p ) ;
+
+ /**
+ Read PTP/IEEE1588 config info and current settings from a card which supports this.
+ The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device
+ @param *p Pointer to a ::PTP_CFG_INFO variable to be filled up
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp()
+ @see mbg_get_ptp_state()
+ @see mbg_set_ptp_cfg_settings()
+ */
+ _MBG_API_ATTR int _MBG_API mbg_get_ptp_cfg_info( MBG_DEV_HANDLE dh, PTP_CFG_INFO *p ) ;
+
+ /**
+ Write PTP/IEEE1588 configuration settings to a card which supports this.
+ The macro _pcps_ddev_has_ptp() or the API call mbg_dev_has_ptp()
+ check whether this call is supported by a specific card.
+
+ @param dh Valid handle to a Meinberg device.
+ @param *p ::PTP_CFG_SETTINGS structure to be written
+
+ @return ::MBG_SUCCESS or error code returned by device I/O control function.
+
+ @see mbg_dev_has_ptp()
+ @see mbg_get_ptp_state()
+ @see mbg_get_ptp_cfg_info()
+*/
+ _MBG_API_ATTR int _MBG_API mbg_set_ptp_cfg_settings( MBG_DEV_HANDLE dh, const PTP_CFG_SETTINGS *p ) ;
+
+ /**
Read the CPU affinity of a process, i.e. on which of the available
CPUs the process can be executed.
diff --git a/c/mbglib/include/mbgsvcio.h b/c/mbglib/include/mbgsvcio.h
index 6289a7b..83ec1ae 100644
--- a/c/mbglib/include/mbgsvcio.h
+++ b/c/mbglib/include/mbgsvcio.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgsvcio.h 1.14 2009/03/19 09:06:40Z daniel REL_M $
+ * $Id: mbgsvcio.h 1.16 2009/08/14 09:28:13Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgsvcio.h $
+ * Revision 1.16 2009/08/14 09:28:13Z daniel
+ * New version code 306, compatibility version code still 200.
+ * Revision 1.15 2009/06/09 08:57:47Z daniel
+ * Rev No. 305
* 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
@@ -65,7 +69,7 @@
#pragma pack( 1 )
#endif
-#define MBGSVCIO_VERSION 0x0304
+#define MBGSVCIO_VERSION 0x0306
#define MBGSVCIO_COMPAT_VERSION 0x0200
diff --git a/c/mbglib/include/mbgtime.h b/c/mbglib/include/mbgtime.h
new file mode 100644
index 0000000..774ee69
--- /dev/null
+++ b/c/mbglib/include/mbgtime.h
@@ -0,0 +1,265 @@
+
+/**************************************************************************
+ *
+ * $Id: mbgtime.h 1.12 2009/03/27 14:14:00Z martin TEST $
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Definitions and prototypes for mbgtime.c.
+ *
+ * -----------------------------------------------------------------------
+ * $Log: mbgtime.h $
+ * Revision 1.12 2009/03/27 14:14:00Z martin
+ * Cleanup for CVI.
+ * Revision 1.11 2009/03/13 09:30:06Z martin
+ * Include mystd.h in mbgtime.c rather than here. The bit type used
+ * here is now defined in words.h.
+ * Updated comments for GPS_SEC_BIAS.
+ * Revision 1.10 2008/12/11 10:45:41Z martin
+ * Added clock_t mask for gcc (GnuC).
+ * Revision 1.9 2006/08/25 09:33:46Z martin
+ * Updated function prototypes.
+ * Revision 1.8 2004/12/28 11:29:02Z martin
+ * Added macro _n_days.
+ * Updated function prototypes.
+ * Revision 1.7 2002/09/06 07:15:48Z martin
+ * Added MASK_CLOCK_T for Linux.
+ * Revision 1.6 2002/02/25 08:37:44 Andre
+ * definition MASK_CLOCK_T for ARM added
+ * Revision 1.5 2001/03/02 10:18:10Z MARTIN
+ * Added MASK_CLOCK_T for Watcom C.
+ * Revision 1.4 2000/09/15 07:57:53 MARTIN
+ * Removed outdated function prototypes.
+ * Revision 1.3 2000/07/21 14:05:18 MARTIN
+ * Defined some new constants.
+ *
+ **************************************************************************/
+
+#ifndef _MBGTIME_H
+#define _MBGTIME_H
+
+
+/* Other headers to be included */
+
+#include <gpsdefs.h>
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _MBGTIME
+ #define _ext
+#else
+ #define _ext extern
+#endif
+
+
+/* Start of header body */
+
+#ifdef _166
+ #define _const const
+#else
+ #define _const
+#endif
+
+
+// The Unix time_t epoche is usually 1970-01-01 00:00 whereas
+// the GPS epoche is 1980-01-06 00:00, so the difference is 10 years,
+// plus 2 days due to leap years (1972 and 1976), plus the difference
+// of the day-of-month (6 - 1).
+#define GPS_SEC_BIAS 315964800UL // ( ( ( 10UL * 365UL ) + 2 + 5 ) * SECS_PER_DAY )
+
+// time_t t = ( gps_week * SECS_PER_WEEK ) + sec_of_week + GPS_SEC_BIAS
+
+
+#if defined( _C166 )
+ #if _C166 >= 50
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+ #else
+ #define MASK_CLOCK_T 0x7FFF /* time.h not shipped with compiler */
+ #endif
+#endif
+
+#if defined( __WATCOMC__ )
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+#endif
+
+#if defined( _CVI ) || defined( _CVI_ )
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+#endif
+
+#if defined( _MSC_VER )
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+#endif
+
+#if defined( __NETWARE_386__ )
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+#endif
+
+#if defined( __ARM )
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+#endif
+
+#if defined( __GNUC__ )
+ #if defined( __linux )
+ #define MASK_CLOCK_T ( ( (ulong) (clock_t) -1 ) >> 1 )
+ #else // Windows / MinGW
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+ #endif
+#endif
+
+
+#if !defined( MASK_CLOCK_T )
+ #if sizeof( clock_t ) == sizeof( short )
+ #define MASK_CLOCK_T 0x7FFF
+ #elif sizeof( clock_t ) == sizeof( long )
+ #define MASK_CLOCK_T 0x7FFFFFFFL
+ #endif
+#endif
+
+typedef struct
+{
+ clock_t start;
+ clock_t stop;
+ short is_set;
+} TIMEOUT;
+
+
+#define DAYS_PER_WEEK 7
+
+#define SECS_PER_MIN 60
+#define MINS_PER_HOUR 60
+#define HOURS_PER_DAY 24
+#define DAYS_PER_WEEK 7
+
+#define MINS_PER_DAY ( MINS_PER_HOUR * HOURS_PER_DAY )
+
+#define SECS_PER_HOUR 3600
+#define SECS_PER_DAY 86400L
+#define SECS_PER_WEEK 604800L
+
+#define SEC100S_PER_SEC 100L
+#define SEC100S_PER_MIN ( SEC100S_PER_SEC * SECS_PER_MIN )
+#define SEC100S_PER_HOUR ( SEC100S_PER_SEC * SECS_PER_HOUR )
+#define SEC100S_PER_DAY ( SEC100S_PER_SEC * SECS_PER_DAY )
+
+#define MSEC_PER_SEC 1000L
+#define MSEC_PER_MIN ( MSEC_PER_SEC * SECS_PER_MIN )
+#define MSEC_PER_HOUR ( MSEC_PER_SEC * SECS_PER_HOUR )
+#define MSEC_PER_DAY ( MSEC_PER_SEC * SECS_PER_DAY )
+
+
+
+_ext TM_GPS dhms;
+_ext TM_GPS datum;
+
+
+_ext const char *short_time_fmt
+#ifdef _MBGTIME
+ = "%2i:%02i"
+#endif
+;
+
+_ext const char *time_fmt
+#ifdef _MBGTIME
+ = "%2i:%02i:%02i"
+#endif
+;
+
+_ext const char *long_time_fmt
+#ifdef _MBGTIME
+ = "%2i:%02i:%02i.%02i"
+#endif
+;
+
+_ext const char *date_fmt
+#ifdef _MBGTIME
+ = "%2i.%02i.%04i"
+#endif
+;
+
+_ext const char *day_date_fmt
+#ifdef _MBGTIME
+ = "%s, %2i.%02i.%04i"
+#endif
+;
+
+_ext const char *day_name_eng[]
+#ifdef _MBGTIME
+ = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }
+#endif
+;
+
+_ext const char *day_name_ger[]
+#ifdef _MBGTIME
+ = { "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa" }
+#endif
+;
+
+_ext _const TM_GPS init_tm
+#ifdef _MBGTIME
+ = { 1980, 1, 1, 0, 0, 0, 0, 0, 0, 0 }
+#endif
+;
+
+
+_ext char days_of_month[2][12]
+#ifdef _MBGTIME
+ = {
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+ }
+#endif
+;
+
+
+// simplify call to n_days with structures
+#define _n_days( _s ) \
+ n_days( (_s)->mday, (_s)->month, (_s)->year )
+
+
+/* ----- function prototypes begin ----- */
+
+/* This section was generated automatically */
+/* by MAKEHDR, do not remove the comments. */
+
+ void set_timeout( TIMEOUT *t, clock_t clk, clock_t interval ) ;
+ void stretch_timeout( TIMEOUT *t, clock_t interval ) ;
+ bit check_timeout( TIMEOUT *t, clock_t clk ) ;
+ int err_tm( TM_GPS *tm ) ;
+ TM_GPS *clear_time( TM_GPS *tm ) ;
+ TM_GPS *wsec_to_tm( long wsec, TM_GPS *tm ) ;
+ long tm_to_wsec( TM_GPS *tm ) ;
+ int is_leap_year( int y ) ;
+ int day_of_year( int day, int month, int year ) ;
+ void date_of_year ( int year, int day_num, TM_GPS *tm ) ;
+ int day_of_week( int day, int month, int year ) ;
+ int days_to_years( long *day_num, int year ) ;
+ long n_days( ushort mday, ushort month, ushort year ) ;
+ double nano_time_to_double( const NANO_TIME *p ) ;
+ void double_to_nano_time( NANO_TIME *p, double d ) ;
+ int sprint_time( char *s, const TM_GPS *tm ) ;
+ int sprint_short_time( char *s, TM_GPS *time ) ;
+ int sprint_date( char *s, const TM_GPS *tm ) ;
+ int sprint_day_date( char *s, const TM_GPS *tm ) ;
+ int sprint_tm( char *s, const TM_GPS *tm ) ;
+ void sscan_time( char *s, TM_GPS *tm ) ;
+ void sscan_date( char *s, TM_GPS *tm ) ;
+
+/* ----- function prototypes end ----- */
+
+
+/* End of header body */
+
+
+#undef _ext
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _MBGTIME_H */
diff --git a/c/mbglib/include/mbgutil.h b/c/mbglib/include/mbgutil.h
index 4ad6239..7de28ae 100644
--- a/c/mbglib/include/mbgutil.h
+++ b/c/mbglib/include/mbgutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgutil.h 1.14 2009/03/19 09:06:00Z daniel REL_M $
+ * $Id: mbgutil.h 1.16 2009/08/14 10:11:53Z daniel REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: mbgutil.h $
+ * Revision 1.16 2009/08/14 10:11:53Z daniel
+ * New version code 306, compatibility version still 110.
+ * Revision 1.15 2009/06/09 08:57:47Z daniel
+ * Rev No. 305
* 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
@@ -54,7 +58,7 @@
#include <pci_asic.h>
-#define MBGUTIL_VERSION 0x0304
+#define MBGUTIL_VERSION 0x0306
#define MBGUTIL_COMPAT_VERSION 0x0110
diff --git a/c/mbglib/include/pci_asic.h b/c/mbglib/include/pci_asic.h
index 7e6ae60..a0f505c 100644
--- a/c/mbglib/include/pci_asic.h
+++ b/c/mbglib/include/pci_asic.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pci_asic.h 1.14 2009/03/11 16:54:10Z martin REL_M $
+ * $Id: pci_asic.h 1.15 2009/03/27 09:39:15Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,8 +10,11 @@
*
* -----------------------------------------------------------------------
* $Log: pci_asic.h $
+ * Revision 1.15 2009/03/27 09:39:15Z martin
+ * Increased current ASIC minor number for TCR170PEX to 0x02.
+ * Renamed some symbols.
* Revision 1.14 2009/03/11 16:54:10Z martin
- * Increase current ASIC minor number for TCR511PEX to 0x04.
+ * Increased 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().
@@ -269,19 +272,19 @@ enum
*/
#define PCI_ASIC_CURRENT_MINOR_PEX511 0x04
#define PCI_ASIC_REQUIRED_MINOR_PEX511 0x03
-#define PCI_ASIC_HRT_FIX_MINOR_PEX511 0x04 // increases HRT accuracy
-#define PCI_ASIC_IRQ_FIX_MINOR_PEX511 0x03 // fixes IRQ problem
+#define PCI_ASIC_FIX_HRT_MINOR_PEX511 0x04 // increases HRT accuracy
+#define PCI_ASIC_FIX_IRQ_MINOR_PEX511 0x03 // fixes IRQ problem
#define PCI_ASIC_HR_TIME_MINOR_PEX511 0x02 // supports HR time with PEX511
#define PCI_ASIC_CURRENT_MINOR_GPS170PEX 0x04
#define PCI_ASIC_REQUIRED_MINOR_GPS170PEX 0x03
-#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_FIX_HRT_MINOR_GPS170PEX 0x04 // increases MM HRT accuracy
+#define PCI_ASIC_FIX_IRQ_MINOR_GPS170PEX 0x03 // fixes IRQ problem
#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_FIX_IRQ_MINOR_TCR511PEX 0x03 // fixes IRQ problem, increases HRT accuracy
#define PCI_ASIC_CURRENT_MINOR_PTP270PEX 0x01
#define PCI_ASIC_REQUIRED_MINOR_PTP270PEX 0x01
@@ -289,8 +292,9 @@ enum
#define PCI_ASIC_CURRENT_MINOR_FRC511PEX 0x01
#define PCI_ASIC_REQUIRED_MINOR_FRC511PEX 0x01
-#define PCI_ASIC_CURRENT_MINOR_TCR170PEX 0x01
-#define PCI_ASIC_REQUIRED_MINOR_TCR170PEX 0x01
+#define PCI_ASIC_CURRENT_MINOR_TCR170PEX 0x02
+#define PCI_ASIC_REQUIRED_MINOR_TCR170PEX 0x02
+#define PCI_ASIC_FIX_EE_ACCESS_TCR170PEX 0x02 // fixes EE access problem after reset
/* function prototypes: */
diff --git a/c/mbglib/include/pcpsdefs.h b/c/mbglib/include/pcpsdefs.h
index a4a4021..c1db2f5 100644
--- a/c/mbglib/include/pcpsdefs.h
+++ b/c/mbglib/include/pcpsdefs.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdefs.h 1.39 2009/03/19 08:58:09Z martin REL_M $
+ * $Id: pcpsdefs.h 1.41 2009/06/19 12:16:42Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,13 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdefs.h $
- * Revision 1.39 2009/03/19 08:58:09Z martin
+ * Revision 1.41 2009/06/19 12:16:42Z martin
+ * Added PCPS_GIVE_IRIG_TIME command and associated definitions.
+ * Revision 1.40 2009/06/08 19:29:11 daniel
+ * Support PTP configuration.
+ * Support LAN_IF configuration
+ * Added definition of PCPS_CMD_INFO.
+ * Revision 1.39 2009/03/19 08:58:09 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.
@@ -332,6 +338,11 @@ enum
used to read the clock with higher resolution.
_pcps_has_hr_time() checks whether supported.
+ - #PCPS_GIVE_IRIG_TIME<br>
+ Return a PCPS_IRIG_TIME structure with day-of-year,
+ time and status as decoded from the IRIG signal.
+ _pcps_has_irig_time() checks whether supported.
+
- #PCPS_SET_TIME<br>
Set the board date, time and status. This
command expects sizeof( ::PCPS_STIME ) parameter
@@ -525,8 +536,9 @@ enum
/* PCPS_GIVE_TIME_GROUP */
#define PCPS_GIVE_TIME ( PCPS_GIVE_TIME_GROUP | 0x0 )
#define PCPS_GIVE_TIME_NOCLEAR ( PCPS_GIVE_TIME_GROUP | 0x1 )
-#define PCPS_GIVE_SYNC_TIME ( PCPS_GIVE_TIME_GROUP | 0x2 )
-#define PCPS_GIVE_HR_TIME ( PCPS_GIVE_TIME_GROUP | 0x3 )
+#define PCPS_GIVE_SYNC_TIME ( PCPS_GIVE_TIME_GROUP | 0x2 ) // only supported if _pcps_has_sync_time()
+#define PCPS_GIVE_HR_TIME ( PCPS_GIVE_TIME_GROUP | 0x3 ) // only supported if _pcps_has_hr_time()
+#define PCPS_GIVE_IRIG_TIME ( PCPS_GIVE_TIME_GROUP | 0x4 ) // only supported if _pcps_has_irig_time()
/* PCPS_SET_TIME_GROUP */
@@ -894,6 +906,40 @@ typedef union
+/**
+ The structure below can be used to read the raw IRIG time
+ from an IRIG receiver card, if the card supports this.
+ See the #PCPS_GIVE_IRIG_TIME command.
+
+ The granularity of the value in the .frac field depends on
+ the update interval of the structure as implementation
+ in the firmware. I.e. if the raw IRIG time is updated
+ only once per second, the .frac value can always be 0.
+*/
+typedef struct PCPS_IRIG_TIME_s
+{
+ PCPS_TIME_STATUS_X status; /**< status bits, see below */
+ int16_t offs_utc; /**< [minutes] */
+ uint16_t yday; /**< day of year, 1..365/366 */
+ uint16_t frac; /**< fractions of seconds, 0.1 ms units */
+ uint8_t sec; /**< seconds, 0..59, or 60 if leap second */
+ uint8_t min; /**< minutes, 0..59 */
+ uint8_t hour; /**< hours, 0..23 */
+ uint8_t year; /**< 2 digit year number, 0xFF if year not supp. by the IRIG code */
+ uint8_t signal; /**< relative signal strength, range depends on device type */
+ uint8_t reserved; /**< currently not used, always 0 */
+} PCPS_IRIG_TIME;
+
+#define _mbg_swab_pcps_irig_time( _p ) \
+{ \
+ _mbg_swab_pcps_time_status_x( &(_p)->status ); \
+ _mbg_swab16( &(_p)->offs_utc ); \
+ _mbg_swab16( &(_p)->yday ); \
+ _mbg_swab16( &(_p)->frac ); \
+}
+
+
+
/* Bit masks used with both PCPS_TIME_STATUS and PCPS_TIME_STATUS_X */
#define PCPS_FREER 0x01 /**< DCF77 clock running on xtal */
@@ -1132,6 +1178,11 @@ enum
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
+ PC_GPS_LAN_IF_INFO, // R/- LAN_IF_INFO LAN interface info, only if PCPS_HAS_LAN_INTF
+ PC_GPS_IP4_STATE, // R/- IP4_SETTINGS LAN interface state, only if PCPS_HAS_LAN_INTF
+ PC_GPS_IP4_SETTINGS, // R/W IP4_SETTINGS LAN interface configuration, only if PCPS_HAS_LAN_INTF
+ PC_GPS_PTP_STATE, // R/- PTP_STATE, only if PCPS_HAS_PTP
+ PC_GPS_PTP_CFG, // R/W PTP_CFG_{SETTINGS|INFO}, only if PCPS_HAS_PTP
// GPS data
PC_GPS_CFGH = 0x80, // -/- CFGH SVs' config. and health codes
@@ -1153,6 +1204,13 @@ enum
N_PC_GPS_CMD /**< no command, just the number of known commands */
};
+// The type below can be used to store an unambiguous command code.
+// In case of the standard PCPS_... commands the lower byte contains
+// the command code and the upper byte is 0.
+// In case of a GPS command the lower byte contains PCPS_READ_GPS_DATA
+// or PCPS_WRITE_GPS_DATA, as appropriate, and the upper byte contains
+// the associated PC_GPS_... type code.
+typedef uint16_t PCPS_CMD_INFO;
#if defined( _USE_PACK ) // set default alignment
#pragma pack()
diff --git a/c/mbglib/include/pcpsdev.h b/c/mbglib/include/pcpsdev.h
index 00a32ad..30015b6 100644
--- a/c/mbglib/include/pcpsdev.h
+++ b/c/mbglib/include/pcpsdev.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: pcpsdev.h 1.42 2009/03/19 14:58:47Z martin REL_M $
+ * $Id: pcpsdev.h 1.45 2009/06/19 12:15:18Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -17,6 +17,14 @@
*
* -----------------------------------------------------------------------
* $Log: pcpsdev.h $
+ * Revision 1.45 2009/06/19 12:15:18Z martin
+ * Added has_irig_time feature and associated macros.
+ * Revision 1.44 2009/06/08 19:30:48 daniel
+ * Account for new features PCPS_HAS_LAN_INTF and
+ * PCPS_HAS_PTP.
+ * Revision 1.43 2009/04/08 08:26:20 daniel
+ * Define firmware version at which the TCR511PCI starts
+ * to support Irig control bits.
* 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.
@@ -603,6 +611,9 @@ typedef struct
#define PCPS_HAS_TIME_SCALE 0x00080000UL
#define PCPS_HAS_UTC_PARM 0x00100000UL
#define PCPS_HAS_IRIG_CTRL_BITS 0x00200000UL
+#define PCPS_HAS_LAN_INTF 0x00400000UL
+#define PCPS_HAS_PTP 0x00800000UL
+#define PCPS_HAS_IRIG_TIME 0x01000000UL
/** @} */
// The constants below define those features which are available
@@ -743,6 +754,13 @@ typedef struct
)
+/* command PCPS_GIVE_IRIG_TIME: */
+#define REV_HAS_IRIG_TIME_TCR511PEX 0x0109
+#define REV_HAS_IRIG_TIME_TCR511PCI 0x0109
+
+/* command PCPS_GET_IRIG_CTRL_BITS: */
+#define REV_HAS_IRIG_CTRL_BITS_TCR511PEX 0x0107
+#define REV_HAS_IRIG_CTRL_BITS_TCR511PCI 0x0107
/* This board uses the GPS_DATA interface with 16 bit buffer sizes
instead of the original 8 bit sizes, thus allowing to transfer
@@ -771,9 +789,6 @@ typedef struct
#define REV_HAS_HR_TIME_PEX511 0x0105 // This also requires a certain ASIC version.
#define REV_HAS_HR_TIME_PCI511 0x0103
-/* 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
@@ -926,7 +941,11 @@ 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_irig_ctrl_bits( _d ) \
+ _pcps_has_feature( (_d), PCPS_HAS_IRIG_CTRL_BITS )
+
+#define _pcps_has_irig_time( _d ) \
+ _pcps_has_feature( (_d), PCPS_HAS_IRIG_TIME )
#define _pcps_has_ref_offs( _d ) \
_pcps_is_irig_rx( _d )
@@ -950,6 +969,9 @@ typedef struct
#define _pcps_has_utc_parm( _d ) _pcps_has_feature( (_d), PCPS_HAS_UTC_PARM )
+#define _pcps_has_lan_intf( _d ) _pcps_has_feature( (_d), PCPS_HAS_LAN_INTF )
+
+#define _pcps_has_ptp( _d ) _pcps_has_feature( (_d), PCPS_HAS_PTP )
#define _pcps_has_asic_version( _d ) ( _pcps_is_pci_asic( _d ) || _pcps_is_pci_pex8311( _d ) )
diff --git a/c/mbglib/include/words.h b/c/mbglib/include/words.h
index adfb21f..a4337f6 100644
--- a/c/mbglib/include/words.h
+++ b/c/mbglib/include/words.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: words.h 1.17 2009/03/13 09:06:03Z martin REL_M $
+ * $Id: words.h 1.20 2009/07/02 15:38:12Z martin REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,12 @@
*
* -----------------------------------------------------------------------
* $Log: words.h $
+ * Revision 1.20 2009/07/02 15:38:12Z martin
+ * Added new macro _wswap32().
+ * Revision 1.19 2009/04/14 14:45:45Z martin
+ * Added BYTE_OF_P() and WORD_OF_P() macros.
+ * Revision 1.18 2009/03/27 14:05:18 martin
+ * Cleanup for CVI.
* 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
@@ -59,20 +65,15 @@
/* Other headers to be included */
-#if defined( _CVI )
- // This is a hack for CVI which seems to be unable
- // to handle recursive preprocessor symbols.
- #define _IS_MBG_FIRMWARE 0
-#endif
-
#if !defined( _IS_MBG_FIRMWARE )
- #define _IS_MBG_FIRMWARE \
- ( \
- defined( _C166 ) || \
+#if defined( _C166 ) || \
defined( _CC51 ) || \
- defined( __ARM ) \
- )
+ defined( __ARM )
+ #define _IS_MBG_FIRMWARE 1
+#else
+ #define _IS_MBG_FIRMWARE 0
+#endif
#endif
@@ -232,24 +233,36 @@ typedef unsigned long dword;
#define LO_WORD( _x ) ( (_x) & 0xFFFF )
// the macros below assume little endianess
-#define BYTE_OF( _x, _n ) *( ( (uint8_t *) &(_x) ) + (_n) )
-#define WORD_OF( _x, _n ) *( ( (uint16_t *) &(_x) ) + (_n) )
+// these macros expect the name of a variable
+#define BYTE_OF( _v, _n ) *( ( (uint8_t *) &(_v) ) + (_n) )
+#define WORD_OF( _v, _n ) *( ( (uint16_t *) &(_v) ) + (_n) )
+
+// same as above, but taking pointers
+#define BYTE_OF_P( _p, _n ) *( ( (uint8_t *) (_p) ) + (_n) )
+#define WORD_OF_P( _p, _n ) *( ( (uint16_t *) (_p) ) + (_n) )
// a macro to swap the byte order of a 16 bit value
-#define _bswap16( _x ) \
-( \
- ( ( ( (ushort) (_x) ) & 0x00FF ) << 8 ) | \
- ( ( ( (ushort) (_x) ) & 0xFF00 ) >> 8 ) \
+#define _bswap16( _x ) \
+( \
+ ( ( ( (uint16_t) (_x) ) & 0x00FF ) << 8 ) | \
+ ( ( ( (uint16_t) (_x) ) & 0xFF00 ) >> 8 ) \
)
// a macro to swap the byte order of a 32 bit value
-#define _bswap32( _x ) \
-( \
- ( ( ( (ulong) (_x) ) & 0x000000FFUL ) << 24 ) | \
- ( ( ( (ulong) (_x) ) & 0x0000FF00UL ) << 8 ) | \
- ( ( ( (ulong) (_x) ) & 0x00FF0000UL ) >> 8 ) | \
- ( ( ( (ulong) (_x) ) & 0xFF000000UL ) >> 24 ) \
+#define _bswap32( _x ) \
+( \
+ ( ( ( (uint32_t) (_x) ) & 0x000000FFUL ) << 24 ) | \
+ ( ( ( (uint32_t) (_x) ) & 0x0000FF00UL ) << 8 ) | \
+ ( ( ( (uint32_t) (_x) ) & 0x00FF0000UL ) >> 8 ) | \
+ ( ( ( (uint32_t) (_x) ) & 0xFF000000UL ) >> 24 ) \
+)
+
+// a macro to swap the word order of a 32 bit value
+#define _wswap32( _x ) \
+( \
+ ( ( ( (uint32_t) (_x) ) & 0x0000FFFFUL ) << 16 ) | \
+ ( ( ( (uint32_t) (_x) ) >> 16 ) & 0x0000FFFFUL ) \
)
#define _var_bswap16( _v ) (_v) = _bswap16( _v )
diff --git a/c/mbglib/lib/bc/mbgdevio.lib b/c/mbglib/lib/bc/mbgdevio.lib
index 614bea8..5264f83 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 4c01edd..6078f97 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 e154382..1c9d738 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 a6d0b5a..ed87b0f 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 ed341af..dd857a7 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 64e66ab..38971aa 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 9c6458a..32c2e23 100644
--- a/c/mbglib/lib64/msc/mbgutil.lib
+++ b/c/mbglib/lib64/msc/mbgutil.lib
Binary files differ