diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2021-11-19 09:47:20 +0100 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2021-11-19 09:47:20 +0100 |
commit | a1e5c7a702168a5457728bf7de2a400a0aec1bc7 (patch) | |
tree | a9b0ab8b031fd35e9f63c7304e0dcb59d7cb27da | |
parent | bb0ce1a72f4a3ba23af9dc15249729309adc93c1 (diff) | |
download | ntptest-a1e5c7a702168a5457728bf7de2a400a0aec1bc7.tar.gz ntptest-a1e5c7a702168a5457728bf7de2a400a0aec1bc7.zip |
Update some mbglib files
-rwxr-xr-x | mbglib/common/gpsdefs.h | 7169 | ||||
-rwxr-xr-x | mbglib/common/mbg_tgt.h | 99 | ||||
-rwxr-xr-x | mbglib/common/mbgerror.c | 204 | ||||
-rwxr-xr-x | mbglib/common/mbgerror.h | 296 | ||||
-rwxr-xr-x | mbglib/common/mbgtime.h | 839 | ||||
-rwxr-xr-x | mbglib/common/str_util.c | 181 | ||||
-rwxr-xr-x | mbglib/common/str_util.h | 166 | ||||
-rwxr-xr-x | mbglib/common/timeutil.c | 57 | ||||
-rwxr-xr-x | mbglib/common/timeutil.h | 217 | ||||
-rwxr-xr-x | mbglib/common/words.h | 94 |
10 files changed, 7141 insertions, 2181 deletions
diff --git a/mbglib/common/gpsdefs.h b/mbglib/common/gpsdefs.h index 6dacbc8..2d6fc5a 100755 --- a/mbglib/common/gpsdefs.h +++ b/mbglib/common/gpsdefs.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: gpsdefs.h 1.126 2018/07/05 10:18:34 martin REL_M $ + * $Id: gpsdefs.h 1.127 2019/09/27 13:10:17 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -13,6 +13,36 @@ * * ----------------------------------------------------------------------- * $Log: gpsdefs.h $ + * Revision 1.127 2019/09/27 13:10:17 martin + * New model codes MSHPS100, BPE_STM, VSI180, + * GNM181, RSCRDU_TTL, RSC2000, FCU200, REL1000_RC. + * Replaced old model CSM100 by MSSB100. + * Replaced old model USYNCPWR by CPC200. + * New PTP configuration structures. + * New PTP SMPTE stuff. + * Some extension of NTP configuration. + * XMR_QL_INFO was added to XMR API. + * Port types SPST and SPDT and some other IO stuff was added. + * New XBP device state 'outdated'. + * New MBG_EXT_SYS_STATUS stuff. + * New MBG_EVENTS stuff. + * New FCU stuff. + * New sysinfo definitions. + * New bit mask GNSS_SV_STAT_DUAL_FREQ_MSK. + * Updated some SyncE definitions. + * New string table initializers. + * New types GPS_WNUM, GPS_WSEC, and GPS_TICK. + * New types MBG_MSG_IDX and MBG_MSG_IDX_32. + * Struct names were added by thomas-b to support forward declarations. + * Added an enumeration MBG_DEV_CPU_TYPES and as well as an + * initializer MBG_DEV_CPU_TYPE_TABLE_INIT for a table indicating + * which CPU type is used on which hardware device. + * Renamed type TM_STATUS_EXT to TM_GPS_STATUS_EXT, which is + * more similar to the name TM_GPS_STATUS, but provided a #define + * to avoid build problems with existing code. + * Moved some structures here that were previously private. + * Moved definitions of ANN_LIMIT and ANN_LIMIT_DCF here. + * Lots of doxygen updates. * Revision 1.126 2018/07/05 10:18:34 martin * New models GPS_MODEL_PIO180, GPS_MODEL_FCM180, GPS_MODEL_TCR180USB, * GPS_MODEL_SSP100, GPS_MODEL_GNS165, GPS_MODEL_RSC180RDMP, @@ -614,7 +644,6 @@ #ifndef _GPSDEFS_H #define _GPSDEFS_H - /* Other headers to be included */ #if defined( HAVE_CONFIG_H ) @@ -622,10 +651,10 @@ #include <config.h> #endif -// CLOCK_MEINBERG is defined in NTP's config.h if configured -// to support Meinberg clocks. +// CLOCK_MEINBERG is defined in the config.h file provided +// by the NTP project to support Meinberg clocks. #if !defined( CLOCK_MEINBERG ) - // avoid having to use these headers in non-Meinberg projects + // Avoid having to use these headers in non-Meinberg projects. #include <words.h> #include <use_pack.h> #endif @@ -647,8 +676,8 @@ /** * @brief GNSS satellite numbers * - * @todo: Check if MAX_SVNO_GLN is 94 instead of 95, and thus - * N_SVNO_GLN is 30 instead of 31, as reported by Wikipedia. + * @todo Check if ::MAX_SVNO_GLONASS is 94 instead of 95, and thus + * ::N_SVNO_GLONASS is 30 instead of 31, as reported by Wikipedia. */ enum GNSS_SVNOS { @@ -688,21 +717,31 @@ enum GNSS_SVNOS * model support the ::RECEIVER_INFO structure which contains * the actual value. */ - #define GPS_TICKS_PER_SEC DEFAULT_GPS_TICKS_PER_SEC ///< see ::DEFAULT_GPS_TICKS_PER_SEC + #define GPS_TICKS_PER_SEC DEFAULT_GPS_TICKS_PER_SEC ///< See ::DEFAULT_GPS_TICKS_PER_SEC #endif -typedef uint16_t SVNO; ///< the number of an SV (Space Vehicle, i.e. satellite) -typedef uint16_t HEALTH; ///< an SV's 6 bit health code -typedef uint16_t CFG; ///< an SV's 4 bit configuration code -typedef uint16_t IOD; ///< Issue-Of-Data code +typedef uint16_t SVNO; ///< The number of an SV (Space Vehicle, i.e. satellite). +typedef uint16_t HEALTH; ///< The 6 bit health code for an SV. +typedef uint16_t CFG; ///< The 4 bit configuration code for an SV. +typedef uint16_t IOD; ///< Issue-Of-Data code. + +typedef int16_t GPS_WNUM; ///< Type of a signed extended GPS week number. +typedef int16_t GPS_DNUM; ///< Type of a signed GPS day number as used with ::UTC. +typedef int32_t GPS_WSEC; ///< Type of a signed GPS second-of-week number. +typedef int32_t GPS_TICK; ///< Type of a signed tick-of-second number, see + ///< ::GPS_TICKS_PER_SEC and ::RECEIVER_INFO::ticks_per_sec. + + +typedef uint16_t MBG_MSG_IDX; ///< Standard type of an index number used with binary messages. +typedef uint32_t MBG_MSG_IDX_32; ///< Type of a 32 bit index number used with binary messages in some cases. /* the type of various checksums */ #ifndef _CSUM_DEFINED - typedef uint16_t CSUM; ///< checksum used by some structures stored in non-volatile memory + typedef uint16_t CSUM; ///< Checksum used by some structures stored in non-volatile memory. #define _CSUM_DEFINED #endif @@ -766,6 +805,9 @@ do \ * the associated type of GPS data is not available. * * @see ::BVAR_FLAGS + * @see ::BVAR_FLAG_BITS + * @see ::BVAR_FLAG_NAMES + * @see ::BVAR_FLAG_NAMES_SHORT */ typedef uint16_t BVAR_STAT; @@ -785,15 +827,16 @@ typedef uint16_t BVAR_STAT; * @see ::BVAR_STAT * @see ::BVAR_FLAGS * @see ::BVAR_FLAG_NAMES + * @see ::BVAR_FLAG_NAMES_SHORT */ enum BVAR_FLAG_BITS { - BVAR_BIT_CFGH_INVALID, ///< Satellite configuration and health parameters incomplete - BVAR_BIT_ALM_NOT_COMPLETE, ///< Almanac parameters incomplete - BVAR_BIT_UTC_INVALID, ///< %UTC offset parameters incomplete - BVAR_BIT_IONO_INVALID, ///< Ionospheric correction parameters incomplete - BVAR_BIT_RCVR_POS_INVALID, ///< No valid receiver position available - N_BVAR_BIT ///< number of defined ::BVAR_STAT bits + BVAR_BIT_CFGH_INVALID, ///< Satellite configuration and health parameters incomplete. + BVAR_BIT_ALM_NOT_COMPLETE, ///< Almanac parameters incomplete. + BVAR_BIT_UTC_INVALID, ///< %UTC offset parameters incomplete. + BVAR_BIT_IONO_INVALID, ///< Ionospheric correction parameters incomplete. + BVAR_BIT_RCVR_POS_INVALID, ///< No valid receiver position available. + N_BVAR_BIT ///< number of defined ::BVAR_STAT bits. }; @@ -805,25 +848,27 @@ enum BVAR_FLAG_BITS * @see ::BVAR_STAT * @see ::BVAR_FLAG_BITS * @see ::BVAR_FLAG_NAMES + * @see ::BVAR_FLAG_NAMES_SHORT */ enum BVAR_FLAGS { - BVAR_CFGH_INVALID = ( 1UL << BVAR_BIT_CFGH_INVALID ), ///< see ::BVAR_BIT_CFGH_INVALID - BVAR_ALM_NOT_COMPLETE = ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ), ///< see ::BVAR_BIT_ALM_NOT_COMPLETE - BVAR_UTC_INVALID = ( 1UL << BVAR_BIT_UTC_INVALID ), ///< see ::BVAR_BIT_UTC_INVALID - BVAR_IONO_INVALID = ( 1UL << BVAR_BIT_IONO_INVALID ), ///< see ::BVAR_BIT_IONO_INVALID - BVAR_RCVR_POS_INVALID = ( 1UL << BVAR_BIT_RCVR_POS_INVALID ), ///< see ::BVAR_BIT_RCVR_POS_INVALID + BVAR_CFGH_INVALID = ( 1UL << BVAR_BIT_CFGH_INVALID ), ///< See ::BVAR_BIT_CFGH_INVALID + BVAR_ALM_NOT_COMPLETE = ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ), ///< See ::BVAR_BIT_ALM_NOT_COMPLETE + BVAR_UTC_INVALID = ( 1UL << BVAR_BIT_UTC_INVALID ), ///< See ::BVAR_BIT_UTC_INVALID + BVAR_IONO_INVALID = ( 1UL << BVAR_BIT_IONO_INVALID ), ///< See ::BVAR_BIT_IONO_INVALID + BVAR_RCVR_POS_INVALID = ( 1UL << BVAR_BIT_RCVR_POS_INVALID ), ///< See ::BVAR_BIT_RCVR_POS_INVALID }; #define BVAR_MASK ( ( 1UL << N_BVAR_BIT ) - 1 ) ///< Bit mask for all defined bits /** - * @brief String initializer for ::BVAR_STAT flag names + * @brief String initializer for long ::BVAR_STAT flag names. * - * @see ::BVAR_STAT + * @see ::BVAR_FLAG_NAMES_SHORT * @see ::BVAR_FLAG_BITS * @see ::BVAR_FLAGS + * @see ::BVAR_STAT */ #define BVAR_FLAG_NAMES \ { \ @@ -834,6 +879,25 @@ enum BVAR_FLAGS "Receiver position" \ } + + +/** + * @brief String initializer for short ::BVAR_STAT flag names. + * + * @see ::BVAR_FLAG_NAMES + * @see ::BVAR_FLAG_BITS + * @see ::BVAR_FLAGS + * @see ::BVAR_STAT + */ +#define BVAR_FLAG_NAMES_SHORT \ +{ \ + "CFGH", \ + "Alm.", \ + "UTC", \ + "IONO", \ + "Rcvr. pos." \ +} + /** @} defgroup group_bvar_stat */ @@ -870,7 +934,7 @@ typedef uint32_t RI_FEATURES; ///< see @ref GPS_FEATURE_MASKS * * @note This may not be supported by some very old devices. */ -typedef struct +typedef struct receiver_info_s { uint16_t model_code; ///< identifier for receiver model, see ::GPS_MODEL_CODES SW_REV sw_rev; ///< software revision and ID @@ -986,7 +1050,7 @@ enum GPS_MODEL_CODES GPS_MODEL_CMC_01, GPS_MODEL_SCU_01, GPS_MODEL_FCU_01, - GPS_MODEL_CSM100, + GPS_MODEL_MSSB100, GPS_MODEL_LNE180SFP, GPS_MODEL_GTS180, GPS_MODEL_GPS180CSM, @@ -999,7 +1063,8 @@ enum GPS_MODEL_CODES GPS_MODEL_GNS181_UC, GPS_MODEL_PSX_4GE, GPS_MODEL_RSC180RDU, - GPS_MODEL_USYNCPWR, + GPS_MODEL_CPC200, // FIXME Try if this works. This entry was originally defined as GPS_MODEL_USYNCPWR + // in 1.124.1.303, which was already obsolete right from the beginning. GPS_MODEL_FDM180M, GPS_MODEL_LSG180, // Line Signal Generator GPS_MODEL_GPS190, @@ -1011,7 +1076,14 @@ enum GPS_MODEL_CODES GPS_MODEL_GNS165, GPS_MODEL_RSC180RDMP, GPS_MODEL_GPS16X, // Some legacy GPS receiver - GPS_MODEL_MSHPS100, // microSYNC based on HPS100 hardware (but) as USB host + GPS_MODEL_MSHPS100, // microSync based on HPS100 hardware (but) as USB host + GPS_MODEL_BPE_STM, // BPE with STM M0 + GPS_MODEL_VSI180, + GPS_MODEL_GNM181, + GPS_MODEL_RSCRDU_TTL, // TTL version of ::GPS_MODEL_RSC180RDU + GPS_MODEL_RSC2000, // Variant of ::GPS_MODEL_RSC180 for LANTIME M2000 + GPS_MODEL_FCU200, // Fan (and power supply) Control Unit + GPS_MODEL_REL1000_RC, N_GPS_MODEL /* If new model codes are added then care must be taken * to update the associated string initializers GPS_MODEL_NAMES @@ -1112,7 +1184,7 @@ enum GPS_MODEL_CODES #define GPS_MODEL_NAME_CMC_01 "CMC_01" #define GPS_MODEL_NAME_SCU_01 "SCU_01" #define GPS_MODEL_NAME_FCU_01 "FCU_01" -#define GPS_MODEL_NAME_CSM100 "CSM100" +#define GPS_MODEL_NAME_MSSB100 "MSSB100" #define GPS_MODEL_NAME_LNE180SFP "LNE180SFP" #define GPS_MODEL_NAME_GTS180 "GTS180" #define GPS_MODEL_NAME_GPS180CSM "GPS180CSM" @@ -1125,7 +1197,7 @@ enum GPS_MODEL_CODES #define GPS_MODEL_NAME_GNS181_UC "GNS181_UC" #define GPS_MODEL_NAME_PSX_4GE "PSX_4GE" #define GPS_MODEL_NAME_RSC180RDU "RSC180RDU" -#define GPS_MODEL_NAME_USYNCPWR "MICROSYNC-PWR" +#define GPS_MODEL_NAME_CPC200 "CPC200" #define GPS_MODEL_NAME_FDM180M "FDM180M" #define GPS_MODEL_NAME_LSG180 "LSG180" #define GPS_MODEL_NAME_GPS190 "GPS190" @@ -1138,6 +1210,13 @@ enum GPS_MODEL_CODES #define GPS_MODEL_NAME_RSC180RDMP "RSC180RDMP" #define GPS_MODEL_NAME_GPS16X "GPS16x" #define GPS_MODEL_NAME_MSHPS100 "MSHPS100" +#define GPS_MODEL_NAME_BPE_STM "BPE" +#define GPS_MODEL_NAME_VSI180 "VSI180" +#define GPS_MODEL_NAME_GNM181 "GNM181" +#define GPS_MODEL_NAME_RSCRDU_TTL "RSC180RDU_TTL" +#define GPS_MODEL_NAME_RSC2000 "RSC2000" +#define GPS_MODEL_NAME_FCU200 "FCU200" +#define GPS_MODEL_NAME_REL1000_RC "REL1000_RC" /* * CARE MUST BE TAKEN that the name string of bus level devices * is limited to 9 characters. Longer strings will not fit into @@ -1237,7 +1316,7 @@ enum GPS_MODEL_CODES GPS_MODEL_NAME_CMC_01, \ GPS_MODEL_NAME_SCU_01, \ GPS_MODEL_NAME_FCU_01, \ - GPS_MODEL_NAME_CSM100, \ + GPS_MODEL_NAME_MSSB100, \ GPS_MODEL_NAME_LNE180SFP, \ GPS_MODEL_NAME_GTS180, \ GPS_MODEL_NAME_GPS180CSM, \ @@ -1250,7 +1329,7 @@ enum GPS_MODEL_CODES GPS_MODEL_NAME_GNS181_UC, \ GPS_MODEL_NAME_PSX_4GE, \ GPS_MODEL_NAME_RSC180RDU, \ - GPS_MODEL_NAME_USYNCPWR, \ + GPS_MODEL_NAME_CPC200, \ GPS_MODEL_NAME_FDM180M, \ GPS_MODEL_NAME_LSG180, \ GPS_MODEL_NAME_GPS190, \ @@ -1262,7 +1341,14 @@ enum GPS_MODEL_CODES GPS_MODEL_NAME_GNS165, \ GPS_MODEL_NAME_RSC180RDMP, \ GPS_MODEL_NAME_GPS16X, \ - GPS_MODEL_NAME_MSHPS100 \ + GPS_MODEL_NAME_MSHPS100, \ + GPS_MODEL_NAME_BPE_STM, \ + GPS_MODEL_NAME_VSI180, \ + GPS_MODEL_NAME_GNM181, \ + GPS_MODEL_NAME_RSCRDU_TTL, \ + GPS_MODEL_NAME_RSC2000, \ + GPS_MODEL_NAME_FCU200, \ + GPS_MODEL_NAME_REL1000_RC \ } @@ -1340,39 +1426,39 @@ enum GPS_BUILTIN_FEATURE_BITS * * @anchor GPS_BUILTIN_FEATURE_MASKS @{ */ -#define GPS_MODEL_IS_GPS ( 1UL << GPS_BIT_MODEL_IS_GPS ) ///< see ::GPS_BIT_MODEL_IS_GPS -#define GPS_MODEL_IS_GNSS ( 1UL << GPS_BIT_MODEL_IS_GNSS ) ///< see ::GPS_BIT_MODEL_IS_GNSS -#define GPS_MODEL_IS_TCR ( 1UL << GPS_BIT_MODEL_IS_TCR ) ///< see ::GPS_BIT_MODEL_IS_TCR -#define GPS_MODEL_IS_DCF_AM ( 1UL << GPS_BIT_MODEL_IS_DCF_AM ) ///< see ::GPS_BIT_MODEL_IS_DCF_AM -#define GPS_MODEL_IS_DCF_PZF ( 1UL << GPS_BIT_MODEL_IS_DCF_PZF ) ///< see ::GPS_BIT_MODEL_IS_DCF_PZF -#define GPS_MODEL_IS_MSF ( 1UL << GPS_BIT_MODEL_IS_MSF ) ///< see ::GPS_BIT_MODEL_IS_MSF -#define GPS_MODEL_IS_JJY ( 1UL << GPS_BIT_MODEL_IS_JJY ) ///< see ::GPS_BIT_MODEL_IS_JJY -#define GPS_MODEL_IS_WWVB ( 1UL << GPS_BIT_MODEL_IS_WWVB ) ///< see ::GPS_BIT_MODEL_IS_WWVB - -#define GPS_MODEL_IS_BUS_LVL_DEV ( 1UL << GPS_BIT_MODEL_IS_BUS_LVL_DEV ) ///< see ::GPS_BIT_MODEL_IS_BUS_LVL_DEV -#define GPS_MODEL_HAS_BVAR_STAT ( 1UL << GPS_BIT_MODEL_HAS_BVAR_STAT ) ///< see ::GPS_BIT_MODEL_HAS_BVAR_STAT -#define GPS_MODEL_HAS_POS_XYZ ( 1UL << GPS_BIT_MODEL_HAS_POS_XYZ ) ///< see ::GPS_BIT_MODEL_HAS_POS_XYZ -#define GPS_MODEL_HAS_POS_LLA ( 1UL << GPS_BIT_MODEL_HAS_POS_LLA ) ///< see ::GPS_BIT_MODEL_HAS_POS_LLA -#define GPS_MODEL_HAS_TIME_TTM ( 1UL << GPS_BIT_MODEL_HAS_TIME_TTM ) ///< see ::GPS_BIT_MODEL_HAS_TIME_TTM -#define GPS_MODEL_HAS_TZDL ( 1UL << GPS_BIT_MODEL_HAS_TZDL ) ///< see ::GPS_BIT_MODEL_HAS_TZDL -#define GPS_MODEL_HAS_TZCODE ( 1UL << GPS_BIT_MODEL_HAS_TZCODE ) ///< see ::GPS_BIT_MODEL_HAS_TZCODE -#define GPS_MODEL_HAS_ANT_INFO ( 1UL << GPS_BIT_MODEL_HAS_ANT_INFO ) ///< see ::GPS_BIT_MODEL_HAS_ANT_INFO - -#define GPS_MODEL_HAS_ENABLE_FLAGS ( 1UL << GPS_BIT_MODEL_HAS_ENABLE_FLAGS ) ///< see ::GPS_BIT_MODEL_HAS_ENABLE_FLAGS -#define GPS_MODEL_HAS_STAT_INFO ( 1UL << GPS_BIT_MODEL_HAS_STAT_INFO ) ///< see ::GPS_BIT_MODEL_HAS_STAT_INFO -#define GPS_MODEL_HAS_ANT_CABLE_LEN ( 1UL << GPS_BIT_MODEL_HAS_ANT_CABLE_LEN ) ///< see ::GPS_BIT_MODEL_HAS_ANT_CABLE_LEN -#define GPS_MODEL_HAS_SCU_STAT ( 1UL << GPS_BIT_MODEL_HAS_SCU_STAT ) ///< see ::GPS_BIT_MODEL_HAS_SCU_STAT -#define GPS_MODEL_HAS_SV_INFO ( 1UL << GPS_BIT_MODEL_HAS_SV_INFO ) ///< see ::GPS_BIT_MODEL_HAS_SV_INFO -#define GPS_MODEL_HAS_UP_CONV ( 1UL << GPS_BIT_MODEL_HAS_UP_CONV ) ///< see ::GPS_BIT_MODEL_HAS_UP_CONV -#define GPS_MODEL_HAS_MBG_OS ( 1UL << GPS_BIT_MODEL_HAS_MBG_OS ) ///< see ::GPS_BIT_MODEL_HAS_MBG_OS +#define GPS_MODEL_IS_GPS ( 1UL << GPS_BIT_MODEL_IS_GPS ) ///< See ::GPS_BIT_MODEL_IS_GPS +#define GPS_MODEL_IS_GNSS ( 1UL << GPS_BIT_MODEL_IS_GNSS ) ///< See ::GPS_BIT_MODEL_IS_GNSS +#define GPS_MODEL_IS_TCR ( 1UL << GPS_BIT_MODEL_IS_TCR ) ///< See ::GPS_BIT_MODEL_IS_TCR +#define GPS_MODEL_IS_DCF_AM ( 1UL << GPS_BIT_MODEL_IS_DCF_AM ) ///< See ::GPS_BIT_MODEL_IS_DCF_AM +#define GPS_MODEL_IS_DCF_PZF ( 1UL << GPS_BIT_MODEL_IS_DCF_PZF ) ///< See ::GPS_BIT_MODEL_IS_DCF_PZF +#define GPS_MODEL_IS_MSF ( 1UL << GPS_BIT_MODEL_IS_MSF ) ///< See ::GPS_BIT_MODEL_IS_MSF +#define GPS_MODEL_IS_JJY ( 1UL << GPS_BIT_MODEL_IS_JJY ) ///< See ::GPS_BIT_MODEL_IS_JJY +#define GPS_MODEL_IS_WWVB ( 1UL << GPS_BIT_MODEL_IS_WWVB ) ///< See ::GPS_BIT_MODEL_IS_WWVB + +#define GPS_MODEL_IS_BUS_LVL_DEV ( 1UL << GPS_BIT_MODEL_IS_BUS_LVL_DEV ) ///< See ::GPS_BIT_MODEL_IS_BUS_LVL_DEV +#define GPS_MODEL_HAS_BVAR_STAT ( 1UL << GPS_BIT_MODEL_HAS_BVAR_STAT ) ///< See ::GPS_BIT_MODEL_HAS_BVAR_STAT +#define GPS_MODEL_HAS_POS_XYZ ( 1UL << GPS_BIT_MODEL_HAS_POS_XYZ ) ///< See ::GPS_BIT_MODEL_HAS_POS_XYZ +#define GPS_MODEL_HAS_POS_LLA ( 1UL << GPS_BIT_MODEL_HAS_POS_LLA ) ///< See ::GPS_BIT_MODEL_HAS_POS_LLA +#define GPS_MODEL_HAS_TIME_TTM ( 1UL << GPS_BIT_MODEL_HAS_TIME_TTM ) ///< See ::GPS_BIT_MODEL_HAS_TIME_TTM +#define GPS_MODEL_HAS_TZDL ( 1UL << GPS_BIT_MODEL_HAS_TZDL ) ///< See ::GPS_BIT_MODEL_HAS_TZDL +#define GPS_MODEL_HAS_TZCODE ( 1UL << GPS_BIT_MODEL_HAS_TZCODE ) ///< See ::GPS_BIT_MODEL_HAS_TZCODE +#define GPS_MODEL_HAS_ANT_INFO ( 1UL << GPS_BIT_MODEL_HAS_ANT_INFO ) ///< See ::GPS_BIT_MODEL_HAS_ANT_INFO + +#define GPS_MODEL_HAS_ENABLE_FLAGS ( 1UL << GPS_BIT_MODEL_HAS_ENABLE_FLAGS ) ///< See ::GPS_BIT_MODEL_HAS_ENABLE_FLAGS +#define GPS_MODEL_HAS_STAT_INFO ( 1UL << GPS_BIT_MODEL_HAS_STAT_INFO ) ///< See ::GPS_BIT_MODEL_HAS_STAT_INFO +#define GPS_MODEL_HAS_ANT_CABLE_LEN ( 1UL << GPS_BIT_MODEL_HAS_ANT_CABLE_LEN ) ///< See ::GPS_BIT_MODEL_HAS_ANT_CABLE_LEN +#define GPS_MODEL_HAS_SCU_STAT ( 1UL << GPS_BIT_MODEL_HAS_SCU_STAT ) ///< See ::GPS_BIT_MODEL_HAS_SCU_STAT +#define GPS_MODEL_HAS_SV_INFO ( 1UL << GPS_BIT_MODEL_HAS_SV_INFO ) ///< See ::GPS_BIT_MODEL_HAS_SV_INFO +#define GPS_MODEL_HAS_UP_CONV ( 1UL << GPS_BIT_MODEL_HAS_UP_CONV ) ///< See ::GPS_BIT_MODEL_HAS_UP_CONV +#define GPS_MODEL_HAS_MBG_OS ( 1UL << GPS_BIT_MODEL_HAS_MBG_OS ) ///< See ::GPS_BIT_MODEL_HAS_MBG_OS #if 0 // ### TODO This has to be discussed - #define GPS_MODEL_IS_LNO ( 1UL << GPS_BIT_MODEL_IS_LNO ) ///< see ::GPS_BIT_MODEL_IS_LNO - #define GPS_MODEL_IS_SCU ( 1UL << GPS_BIT_MODEL_IS_SCU ) ///< see ::GPS_BIT_MODEL_IS_SCU + #define GPS_MODEL_IS_LNO ( 1UL << GPS_BIT_MODEL_IS_LNO ) ///< See ::GPS_BIT_MODEL_IS_LNO + #define GPS_MODEL_IS_SCU ( 1UL << GPS_BIT_MODEL_IS_SCU ) ///< See ::GPS_BIT_MODEL_IS_SCU #endif // ### TODO FIXME do we need the next one? Should be obsolete -// #define GPS_MODEL_HAS_XMR_HOLDOVER_INTV ( 1UL << GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV ) ///< see ::GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV +// #define GPS_MODEL_HAS_XMR_HOLDOVER_INTV ( 1UL << GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV ) ///< See ::GPS_BIT_MODEL_HAS_XMR_HOLDOVER_INTV //### TODO: should we use an extra flag? #define GPS_MODEL_HAS_POS ( GPS_MODEL_HAS_POS_XYZ | GPS_MODEL_HAS_POS_LLA ) @@ -1742,7 +1828,7 @@ enum GPS_BUILTIN_FEATURE_BITS #define BUILTIN_FEAT_GPS162 ( BUILTIN_FEAT_GPS ) #define BUILTIN_FEAT_PTP270PEX ( GPS_MODEL_IS_BUS_LVL_DEV ) #define BUILTIN_FEAT_FRC511PEX ( GPS_MODEL_IS_BUS_LVL_DEV ) -#define BUILTIN_FEAT_GEN170 ( 0 ) +#define BUILTIN_FEAT_GEN170 ( GPS_MODEL_HAS_TIME_TTM ) #define BUILTIN_FEAT_TCR170PEX ( BUILTIN_FEAT_TCR_2_BUS_LVL ) #define BUILTIN_FEAT_WWVB511 ( BUILTIN_FEAT_WVB_1 ) #define BUILTIN_FEAT_MGR170 ( 0 ) @@ -1794,7 +1880,7 @@ enum GPS_BUILTIN_FEATURE_BITS #define BUILTIN_FEAT_CMC_01 ( 0 ) #define BUILTIN_FEAT_SCU_01 ( 0 ) #define BUILTIN_FEAT_FCU_01 ( 0 ) -#define BUILTIN_FEAT_CSM100 ( GPS_MODEL_HAS_MBG_OS ) +#define BUILTIN_FEAT_MSSB100 ( GPS_MODEL_HAS_MBG_OS ) #define BUILTIN_FEAT_LNE180SFP ( 0 ) #define BUILTIN_FEAT_GTS180 ( 0 ) #define BUILTIN_FEAT_GPS180CSM ( BUILTIN_FEAT_GPS ) @@ -1807,7 +1893,7 @@ enum GPS_BUILTIN_FEATURE_BITS #define BUILTIN_FEAT_GNS181_UC ( BUILTIN_FEAT_GNSS | GPS_MODEL_HAS_UP_CONV ) #define BUILTIN_FEAT_PSX_4GE ( GPS_MODEL_HAS_MBG_OS ) #define BUILTIN_FEAT_RSC180RDU ( GPS_MODEL_HAS_SCU_STAT ) -#define BUILTIN_FEAT_USYNCPWR ( 0 ) +#define BUILTIN_FEAT_CPC200 ( 0 ) #define BUILTIN_FEAT_FDM180M ( GPS_MODEL_HAS_TZDL | GPS_MODEL_HAS_ENABLE_FLAGS ) #define BUILTIN_FEAT_LSG180 ( 0 ) #define BUILTIN_FEAT_GPS190 ( BUILTIN_FEAT_GPS ) @@ -1820,6 +1906,13 @@ enum GPS_BUILTIN_FEATURE_BITS #define BUILTIN_FEAT_RSC180RDMP ( GPS_MODEL_HAS_SCU_STAT ) #define BUILTIN_FEAT_GPS16X ( BUILTIN_FEAT_GPS ) #define BUILTIN_FEAT_MSHPS100 ( GPS_MODEL_HAS_MBG_OS ) +#define BUILTIN_FEAT_BPE_STM ( 0 ) +#define BUILTIN_FEAT_VSI180 ( 0 ) +#define BUILTIN_FEAT_GNM181 ( BUILTIN_FEAT_GNSS ) +#define BUILTIN_FEAT_RSCRDU_TTL ( GPS_MODEL_HAS_SCU_STAT ) +#define BUILTIN_FEAT_RSC2000 ( GPS_MODEL_HAS_SCU_STAT ) +#define BUILTIN_FEAT_FCU200 ( 0 ) +#define BUILTIN_FEAT_REL1000_RC ( BUILTIN_FEAT_REL1000 ) /** * @brief Feature mask used for legacy devices @@ -1921,7 +2014,7 @@ enum GPS_BUILTIN_FEATURE_BITS { GPS_MODEL_CMC_01, BUILTIN_FEAT_CMC_01 }, \ { GPS_MODEL_SCU_01, BUILTIN_FEAT_SCU_01 }, \ { GPS_MODEL_FCU_01, BUILTIN_FEAT_FCU_01 }, \ - { GPS_MODEL_CSM100, BUILTIN_FEAT_CSM100 }, \ + { GPS_MODEL_MSSB100, BUILTIN_FEAT_MSSB100 }, \ { GPS_MODEL_LNE180SFP, BUILTIN_FEAT_LNE180SFP }, \ { GPS_MODEL_GTS180, BUILTIN_FEAT_GTS180 }, \ { GPS_MODEL_GPS180CSM, BUILTIN_FEAT_GPS180CSM }, \ @@ -1934,7 +2027,7 @@ enum GPS_BUILTIN_FEATURE_BITS { GPS_MODEL_GNS181_UC, BUILTIN_FEAT_GNS181_UC }, \ { GPS_MODEL_PSX_4GE, BUILTIN_FEAT_PSX_4GE }, \ { GPS_MODEL_RSC180RDU, BUILTIN_FEAT_RSC180RDU }, \ - { GPS_MODEL_USYNCPWR, BUILTIN_FEAT_USYNCPWR }, \ + { GPS_MODEL_CPC200, BUILTIN_FEAT_CPC200 }, \ { GPS_MODEL_FDM180M, BUILTIN_FEAT_FDM180M }, \ { GPS_MODEL_LSG180, BUILTIN_FEAT_LSG180 }, \ { GPS_MODEL_GPS190, BUILTIN_FEAT_GPS190 }, \ @@ -1947,9 +2040,219 @@ enum GPS_BUILTIN_FEATURE_BITS { GPS_MODEL_RSC180RDMP, BUILTIN_FEAT_RSC180RDMP }, \ { GPS_MODEL_GPS16X, BUILTIN_FEAT_GPS16X }, \ { GPS_MODEL_MSHPS100, BUILTIN_FEAT_MSHPS100 }, \ + { GPS_MODEL_BPE_STM, BUILTIN_FEAT_BPE_STM }, \ + { GPS_MODEL_VSI180, BUILTIN_FEAT_VSI180 }, \ + { GPS_MODEL_GNM181, BUILTIN_FEAT_GNM181 }, \ + { GPS_MODEL_RSCRDU_TTL, BUILTIN_FEAT_RSCRDU_TTL }, \ + { GPS_MODEL_RSC2000, BUILTIN_FEAT_RSC2000 }, \ + { GPS_MODEL_FCU200, BUILTIN_FEAT_FCU200 }, \ + { GPS_MODEL_REL1000_RC, BUILTIN_FEAT_REL1000_RC }, \ { 0, 0 } \ } + + +/** + * @brief Enumeration of CPU types used in Meinberg products. + * + * @see @ref group_dev_cpu_type_names + * @see ::MBG_DEV_CPU_TYPE_NAMES + */ +enum MBG_DEV_CPU_TYPES +{ + MBG_DEV_CPU_TYPE_UNSPEC, ///< Unspecified, unknown, or special (e.g. embedded system) + MBG_DEV_CPU_TYPE_C509, + MBG_DEV_CPU_TYPE_C166_C167, + MBG_DEV_CPU_TYPE_C163, + MBG_DEV_CPU_TYPE_GP4020, + MBG_DEV_CPU_TYPE_XC164_XC167, + MBG_DEV_CPU_TYPE_T89C5XACX, + MBG_DEV_CPU_TYPE_XE167, + MBG_DEV_CPU_TYPE_SAM3U, + MBG_DEV_CPU_TYPE_SAM3S, + MBG_DEV_CPU_TYPE_STM32F0, + MBG_DEV_CPU_TYPE_STM32F4, + MBG_DEV_CPU_TYPE_STM32F7, + N_MBG_DEV_CPU_TYPES +}; + + + +/** + * @defgroup group_dev_cpu_type_names Name strings of CPU types used with Meinberg devices. + * + * Name strings for the CPU types enumerated in ::MBG_DEV_CPU_TYPES. + * + * @see ::MBG_DEV_CPU_TYPES + * @see ::MBG_DEV_CPU_TYPE_NAMES + * + * @{ */ + +#define MBG_DEV_CPU_NAME_UNSPEC "(unspecified)" +#define MBG_DEV_CPU_NAME_C509 "C509" +#define MBG_DEV_CPU_NAME_C166_C167 "C166/C167" +#define MBG_DEV_CPU_NAME_C163 "C163" +#define MBG_DEV_CPU_NAME_GP4020 "GP4020" +#define MBG_DEV_CPU_NAME_XC164_XC167 "XC164/XC167" +#define MBG_DEV_CPU_NAME_T89C5XACX "T89C5xACx" +#define MBG_DEV_CPU_NAME_XE167 "XE167" +#define MBG_DEV_CPU_NAME_SAM3U "SAM3U" +#define MBG_DEV_CPU_NAME_SAM3S "SAM3S" +#define MBG_DEV_CPU_NAME_STM32F0 "STM32F0" +#define MBG_DEV_CPU_NAME_STM32F4 "STM32F4" +#define MBG_DEV_CPU_NAME_STM32F7 "STM32F7" + +/** @} defgroup group_dev_cpu_type_names */ + + + +/** + * @brief Initializer for an array of CPU type name strings + * + * The array should have ::N_MBG_DEV_CPU_TYPES entries. + * + * @see ::MBG_DEV_CPU_TYPES + * @see @ref MBG_DEV_CPU_TYPE_NAMES + */ +#define MBG_DEV_CPU_TYPE_NAMES \ +{ \ + MBG_DEV_CPU_NAME_UNSPEC, \ + MBG_DEV_CPU_NAME_C509, \ + MBG_DEV_CPU_NAME_C166_C167, \ + MBG_DEV_CPU_NAME_C163, \ + MBG_DEV_CPU_NAME_GP4020, \ + MBG_DEV_CPU_NAME_XC164_XC167, \ + MBG_DEV_CPU_NAME_T89C5XACX, \ + MBG_DEV_CPU_NAME_XE167, \ + MBG_DEV_CPU_NAME_SAM3U, \ + MBG_DEV_CPU_NAME_SAM3S, \ + MBG_DEV_CPU_NAME_STM32F0 \ + MBG_DEV_CPU_NAME_STM32F4 \ + MBG_DEV_CPU_NAME_STM32F7 \ +} + + + +/** + * @brief Initializer for a table of CPU type per device. + * + * Last entry is all zero to indicated end of table. + * + * @see ::GPS_MODEL_CODES + * @see ::MBG_DEV_CPU_TYPES + */ +#define MBG_DEV_CPU_TYPE_TABLE_INIT \ +{ \ + { GPS_MODEL_GPS166, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS167, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS167SV, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS167PC, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS167PCI, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS163, MBG_DEV_CPU_TYPE_C163 }, \ + { GPS_MODEL_GPS168PCI, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS161, MBG_DEV_CPU_TYPE_GP4020 }, \ + { GPS_MODEL_GPS169PCI, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_TCR167PCI, MBG_DEV_CPU_TYPE_C166_C167 }, \ + { GPS_MODEL_GPS164, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_GPS170PCI, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_PZF511, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_GPS170, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_TCR511, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_AM511, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_MSF511, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_GRC170, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_GPS170PEX, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_GPS162, MBG_DEV_CPU_TYPE_XE167 }, \ + { GPS_MODEL_PTP270PEX, 0 /* Toradex */ }, \ + { GPS_MODEL_FRC511PEX, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_GEN170, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_TCR170PEX, MBG_DEV_CPU_TYPE_XE167 }, \ + { GPS_MODEL_WWVB511, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_MGR170, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_JJY511, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_PZF600, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_TCR600, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GPS180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GLN170, MBG_DEV_CPU_TYPE_XC164_XC167 }, \ + { GPS_MODEL_GPS180PEX, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_TCR180PEX, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_PZF180PEX, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_MGR180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_MSF600, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_WWVB600, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_JJY600, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GPS180HS, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GPS180AMC, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_ESI180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_CPE180, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_LNO180, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_GRC180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_LIU, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_DCF600HS, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_DCF600RS, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_MRI, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_BPE, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_GLN180PEX, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_N2X, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_RSC180, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_LNE_GB, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_PPG180, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_SCG, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_MDU300, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_SDI, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_FDM180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_SPT, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_PZF180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_REL1000, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_HPS100, 0 }, \ + { GPS_MODEL_VSG180, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_MSF180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_WWVB180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_CPC180, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_CTC100, 0 }, \ + { GPS_MODEL_TCR180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_LUE180, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_CPC_01, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_TSU_01, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_CMC_01, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_SCU_01, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_FCU_01, MBG_DEV_CPU_TYPE_T89C5XACX }, \ + { GPS_MODEL_MSSB100, 0 }, \ + { GPS_MODEL_LNE180SFP, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_GTS180, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_GPS180CSM, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GRC181, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_N2X180, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_GNS181PEX, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_MDU180, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_MDU312, MBG_DEV_CPU_TYPE_SAM3S }, \ + { GPS_MODEL_GPS165, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GNS181_UC, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_PSX_4GE, 0 }, \ + { GPS_MODEL_RSC180RDU, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_CPC200, MBG_DEV_CPU_TYPE_STM32F0 }, \ + { GPS_MODEL_FDM180M, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_LSG180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GPS190, MBG_DEV_CPU_TYPE_STM32F7 }, \ + { GPS_MODEL_GNS181, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_PIO180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_FCM180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_TCR180USB, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_SSP100, 0 }, \ + { GPS_MODEL_GNS165, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_RSC180RDMP, MBG_DEV_CPU_TYPE_STM32F4 }, \ + { GPS_MODEL_GPS16X, MBG_DEV_CPU_TYPE_UNSPEC }, \ + { GPS_MODEL_MSHPS100, 0 }, \ + { GPS_MODEL_BPE_STM, MBG_DEV_CPU_TYPE_STM32F0 }, \ + { GPS_MODEL_VSI180, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_GNM181, MBG_DEV_CPU_TYPE_SAM3U }, \ + { GPS_MODEL_RSCRDU_TTL, 0 }, \ + { GPS_MODEL_RSC2000, 0 }, \ + { GPS_MODEL_FCU200, 0 }, \ + { GPS_MODEL_REL1000_RC, 0 }, \ + { 0, 0 } \ +} + #endif // !defined( MBG_TGT_DOS ) /** @} anchor GPS_BUILTIN_FEATURE_DEFS */ @@ -2271,41 +2574,41 @@ enum GPS_FEATURE_BITS * * @anchor GPS_FEATURE_MASKS @{ */ -#define GPS_HAS_PPS ( 1UL << GPS_FEAT_PPS ) ///< see ::GPS_FEAT_PPS -#define GPS_HAS_PPM ( 1UL << GPS_FEAT_PPM ) ///< see ::GPS_FEAT_PPM -#define GPS_HAS_SYNTH ( 1UL << GPS_FEAT_SYNTH ) ///< see ::GPS_FEAT_SYNTH -#define GPS_HAS_DCFMARKS ( 1UL << GPS_FEAT_DCFMARKS ) ///< see ::GPS_FEAT_DCFMARKS -#define GPS_HAS_IRIG_TX ( 1UL << GPS_FEAT_IRIG_TX ) ///< see ::GPS_FEAT_IRIG_TX -#define GPS_HAS_IRIG_RX ( 1UL << GPS_FEAT_IRIG_RX ) ///< see ::GPS_FEAT_IRIG_RX -#define GPS_HAS_LAN_IP4 ( 1UL << GPS_FEAT_LAN_IP4 ) ///< see ::GPS_FEAT_LAN_IP4 -#define GPS_HAS_MULTI_REF ( 1UL << GPS_FEAT_MULTI_REF ) ///< see ::GPS_FEAT_MULTI_REF - -#define GPS_HAS_RCV_TIMEOUT ( 1UL << GPS_FEAT_RCV_TIMEOUT ) ///< see ::GPS_FEAT_RCV_TIMEOUT -#define GPS_HAS_IGNORE_LOCK ( 1UL << GPS_FEAT_IGNORE_LOCK ) ///< see ::GPS_FEAT_IGNORE_LOCK -#define GPS_HAS_5_MHZ ( 1UL << GPS_FEAT_5_MHZ ) ///< see ::GPS_FEAT_5_MHZ -#define GPS_HAS_XMULTI_REF ( 1UL << GPS_FEAT_XMULTI_REF ) ///< see ::GPS_FEAT_XMULTI_REF -#define GPS_HAS_OPT_SETTINGS ( 1UL << GPS_FEAT_OPT_SETTINGS ) ///< see ::GPS_FEAT_OPT_SETTINGS -#define GPS_HAS_TIME_SCALE ( 1UL << GPS_FEAT_TIME_SCALE ) ///< see ::GPS_FEAT_TIME_SCALE -#define GPS_HAS_IRIG_CTRL_BITS ( 1UL << GPS_FEAT_IRIG_CTRL_BITS ) ///< see ::GPS_FEAT_IRIG_CTRL_BITS -#define GPS_HAS_PTP ( 1UL << GPS_FEAT_PTP ) ///< see ::GPS_FEAT_PTP - -#define GPS_HAS_NAV_ENGINE_SETTINGS ( 1UL << GPS_FEAT_NAV_ENGINE_SETTINGS ) ///< see ::GPS_FEAT_NAV_ENGINE_SETTINGS -#define GPS_HAS_RAW_IRIG_DATA ( 1UL << GPS_FEAT_RAW_IRIG_DATA ) ///< see ::GPS_FEAT_RAW_IRIG_DATA -#define GPS_HAS_RAW_IRIG_TIME ( 1UL << GPS_FEAT_RAW_IRIG_TIME ) ///< see ::GPS_FEAT_RAW_IRIG_TIME -#define GPS_HAS_PTP_UNICAST ( 1UL << GPS_FEAT_PTP_UNICAST ) ///< see ::GPS_FEAT_PTP_UNICAST -#define GPS_HAS_GPIO ( 1UL << GPS_FEAT_GPIO ) ///< see ::GPS_FEAT_GPIO -#define GPS_HAS_XMRS_MULT_INSTC ( 1UL << GPS_FEAT_XMRS_MULT_INSTC ) ///< see ::GPS_FEAT_XMRS_MULT_INSTC -#define GPS_HAS_10MHZ_DISBD ( 1UL << GPS_FEAT_10MHZ_DISBD ) ///< see ::GPS_FEAT_10MHZ_DISBD -#define GPS_HAS_EVT_LOG ( 1UL << GPS_FEAT_EVT_LOG ) ///< see ::GPS_FEAT_EVT_LOG - -#define GPS_HAS_IMS ( 1UL << GPS_FEAT_IMS ) ///< see ::GPS_FEAT_IMS -#define GPS_HAS_HAVEQUICK ( 1UL << GPS_FEAT_HAVEQUICK ) ///< see ::GPS_FEAT_HAVEQUICK -#define GPS_HAS_NTP ( 1UL << GPS_FEAT_NTP ) ///< see ::GPS_FEAT_NTP -#define GPS_HAS_NET_CFG ( 1UL << GPS_FEAT_NET_CFG ) ///< see ::GPS_FEAT_NET_CFG -#define GPS_HAS_VST ( 1UL << GPS_FEAT_VST ) ///< see ::GPS_FEAT_VST -#define GPS_HAS_SHS ( 1UL << GPS_FEAT_SHS ) ///< see ::GPS_FEAT_SHS -#define GPS_HAS_XBP ( 1UL << GPS_FEAT_XBP ) ///< see ::GPS_FEAT_XBP -#define GPS_HAS_XFEATURE ( 1UL << GPS_FEAT_XFEATURE ) ///< see ::GPS_FEAT_XFEATURE +#define GPS_HAS_PPS ( 1UL << GPS_FEAT_PPS ) ///< See ::GPS_FEAT_PPS +#define GPS_HAS_PPM ( 1UL << GPS_FEAT_PPM ) ///< See ::GPS_FEAT_PPM +#define GPS_HAS_SYNTH ( 1UL << GPS_FEAT_SYNTH ) ///< See ::GPS_FEAT_SYNTH +#define GPS_HAS_DCFMARKS ( 1UL << GPS_FEAT_DCFMARKS ) ///< See ::GPS_FEAT_DCFMARKS +#define GPS_HAS_IRIG_TX ( 1UL << GPS_FEAT_IRIG_TX ) ///< See ::GPS_FEAT_IRIG_TX +#define GPS_HAS_IRIG_RX ( 1UL << GPS_FEAT_IRIG_RX ) ///< See ::GPS_FEAT_IRIG_RX +#define GPS_HAS_LAN_IP4 ( 1UL << GPS_FEAT_LAN_IP4 ) ///< See ::GPS_FEAT_LAN_IP4 +#define GPS_HAS_MULTI_REF ( 1UL << GPS_FEAT_MULTI_REF ) ///< See ::GPS_FEAT_MULTI_REF + +#define GPS_HAS_RCV_TIMEOUT ( 1UL << GPS_FEAT_RCV_TIMEOUT ) ///< See ::GPS_FEAT_RCV_TIMEOUT +#define GPS_HAS_IGNORE_LOCK ( 1UL << GPS_FEAT_IGNORE_LOCK ) ///< See ::GPS_FEAT_IGNORE_LOCK +#define GPS_HAS_5_MHZ ( 1UL << GPS_FEAT_5_MHZ ) ///< See ::GPS_FEAT_5_MHZ +#define GPS_HAS_XMULTI_REF ( 1UL << GPS_FEAT_XMULTI_REF ) ///< See ::GPS_FEAT_XMULTI_REF +#define GPS_HAS_OPT_SETTINGS ( 1UL << GPS_FEAT_OPT_SETTINGS ) ///< See ::GPS_FEAT_OPT_SETTINGS +#define GPS_HAS_TIME_SCALE ( 1UL << GPS_FEAT_TIME_SCALE ) ///< See ::GPS_FEAT_TIME_SCALE +#define GPS_HAS_IRIG_CTRL_BITS ( 1UL << GPS_FEAT_IRIG_CTRL_BITS ) ///< See ::GPS_FEAT_IRIG_CTRL_BITS +#define GPS_HAS_PTP ( 1UL << GPS_FEAT_PTP ) ///< See ::GPS_FEAT_PTP + +#define GPS_HAS_NAV_ENGINE_SETTINGS ( 1UL << GPS_FEAT_NAV_ENGINE_SETTINGS ) ///< See ::GPS_FEAT_NAV_ENGINE_SETTINGS +#define GPS_HAS_RAW_IRIG_DATA ( 1UL << GPS_FEAT_RAW_IRIG_DATA ) ///< See ::GPS_FEAT_RAW_IRIG_DATA +#define GPS_HAS_RAW_IRIG_TIME ( 1UL << GPS_FEAT_RAW_IRIG_TIME ) ///< See ::GPS_FEAT_RAW_IRIG_TIME +#define GPS_HAS_PTP_UNICAST ( 1UL << GPS_FEAT_PTP_UNICAST ) ///< See ::GPS_FEAT_PTP_UNICAST +#define GPS_HAS_GPIO ( 1UL << GPS_FEAT_GPIO ) ///< See ::GPS_FEAT_GPIO +#define GPS_HAS_XMRS_MULT_INSTC ( 1UL << GPS_FEAT_XMRS_MULT_INSTC ) ///< See ::GPS_FEAT_XMRS_MULT_INSTC +#define GPS_HAS_10MHZ_DISBD ( 1UL << GPS_FEAT_10MHZ_DISBD ) ///< See ::GPS_FEAT_10MHZ_DISBD +#define GPS_HAS_EVT_LOG ( 1UL << GPS_FEAT_EVT_LOG ) ///< See ::GPS_FEAT_EVT_LOG + +#define GPS_HAS_IMS ( 1UL << GPS_FEAT_IMS ) ///< See ::GPS_FEAT_IMS +#define GPS_HAS_HAVEQUICK ( 1UL << GPS_FEAT_HAVEQUICK ) ///< See ::GPS_FEAT_HAVEQUICK +#define GPS_HAS_NTP ( 1UL << GPS_FEAT_NTP ) ///< See ::GPS_FEAT_NTP +#define GPS_HAS_NET_CFG ( 1UL << GPS_FEAT_NET_CFG ) ///< See ::GPS_FEAT_NET_CFG +#define GPS_HAS_VST ( 1UL << GPS_FEAT_VST ) ///< See ::GPS_FEAT_VST +#define GPS_HAS_SHS ( 1UL << GPS_FEAT_SHS ) ///< See ::GPS_FEAT_SHS +#define GPS_HAS_XBP ( 1UL << GPS_FEAT_XBP ) ///< See ::GPS_FEAT_XBP +#define GPS_HAS_XFEATURE ( 1UL << GPS_FEAT_XFEATURE ) ///< See ::GPS_FEAT_XFEATURE // the next ones are special since they just shadow another flag: #define GPS_HAS_REF_OFFS GPS_HAS_IRIG_RX ///< always supported with IRIG inputs, see ::GPS_HAS_IRIG_RX @@ -2352,7 +2655,7 @@ enum MBG_XFEATURE_BITS MBG_XFEATURE_REBOOT, ///< Supports the ::GPS_REBOOT command MBG_XFEATURE_CLK_RES_INFO, ///< Supports the ::GPS_CLK_RES_INFO command, see @ref group_clk_res_info MBG_XFEATURE_UCAP_NET, ///< Supports the ::GPS_UCAP_NET_GLB_INFO and ::GPS_UCAP_NET_RECV_INFO_IDX commands, see @ref group_ucap_net - MBG_XFEATURE_REQ_TTM, ///< Supports TTM requests via GPS_TIME command + MBG_XFEATURE_REQ_TTM, ///< Supports requesting ::TTM via the ::GPS_TIME command MBG_XFEATURE_IO_PORTS, ///< Supports I/O port structures, see @ref group_io_ports MBG_XFEATURE_MONITORING, ///< Supports monitoring / notifications, see @ref group_monitoring MBG_XFEATURE_XHE, ///< Supports XHE external rubidium unit I/O commands @@ -2366,6 +2669,9 @@ enum MBG_XFEATURE_BITS MBG_XFEATURE_DAC_CTRL_PCI, ///< Supports DAC control via PCI or USB bus API. MBG_XFEATURE_DATABASE, ///< Supports database(s), see @ref group_database MBG_XFEATURE_GNSS_MODE, ///< Supports GPS_GNSS_MODE + MBG_XFEATURE_PTP_NG, ///< Supports PTP next gen API, see @ref group_ptp_ng + MBG_XFEATURE_SYS_REF, ///< Supports new system reference API, see @ref group_sys_ref + MBG_XFEATURE_FCU_API, ///< Supports FCU features, see @ref group_fcu_api N_MBG_XFEATURE ///< Number of defined extended features // NOTE If new features are appended here then an appropriate feature // name string has to be appended to ::MBG_XFEATURE_NAMES, and care must @@ -2407,7 +2713,9 @@ enum MBG_XFEATURE_BITS "Firmware Management", \ "DAC control via bus", \ "Database", \ - "GNSS Messages" \ + "GNSS Messages", \ + "PTP Next Gen.", \ + "System Reference" \ } @@ -2435,7 +2743,7 @@ enum MBG_XFEATURE_BITS * @see ::_set_xfeature_bit * @see ::check_xfeature */ -typedef struct +typedef struct mbg_xfeature_buffer_s { uint8_t b[MAX_XFEATURE_BYTES]; @@ -2490,9 +2798,9 @@ enum RECEIVER_INFO_FLAG_BITS */ enum RECEIVER_INFO_FLAG_MASKS { - GPS_OSC_CFG_SUPP = ( 1UL << GPS_BIT_OSC_CFG_SUPP ), ///< see ::GPS_BIT_OSC_CFG_SUPP - GPS_IRIG_FO_IN = ( 1UL << GPS_BIT_IRIG_FO_IN ), ///< see ::GPS_BIT_IRIG_FO_IN - GPS_HAS_FPGA = ( 1UL << GPS_BIT_HAS_FPGA ) ///< see ::GPS_BIT_HAS_FPGA + GPS_OSC_CFG_SUPP = ( 1UL << GPS_BIT_OSC_CFG_SUPP ), ///< See ::GPS_BIT_OSC_CFG_SUPP + GPS_IRIG_FO_IN = ( 1UL << GPS_BIT_IRIG_FO_IN ), ///< See ::GPS_BIT_IRIG_FO_IN + GPS_HAS_FPGA = ( 1UL << GPS_BIT_HAS_FPGA ) ///< See ::GPS_BIT_HAS_FPGA }; @@ -2552,7 +2860,7 @@ typedef struct * GPS time is counted by the week numbers since the epoch, plus second * of the week, plus fraction of the second. The week number transmitted * by the satellites rolls over from 1023 to 0, but Meinberg devices - * just continue to count the weeks beyond the 1024 week limit to keep + * simply continue counting weeks beyond the 1024-week limit to maintain * the receiver's internal time. * * %UTC time differs from GPS time since a number of leap seconds have @@ -2562,9 +2870,9 @@ typedef struct */ typedef struct { - uint16_t wn; ///< the week number since the GPS system has been put into operation - uint32_t sec; ///< the second of that week - uint32_t tick; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units + GPS_WNUM wn; ///< The week number since the GPS system has been put into operation. + GPS_WSEC sec; ///< The second of a week. + GPS_TICK tick; ///< Fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units. } T_GPS; @@ -2577,6 +2885,39 @@ do \ } while ( 0 ) + +/** + * @brief A type of status variable to be used with ::TM_GPS, etc. + * + * @see ::TM_GPS_STATUS_BIT_MASKS + */ +typedef uint16_t TM_GPS_STATUS; + +#define _mbg_swab_tm_gps_status( _p ) _mbg_swab16( _p ) + + + + +/** + * @brief Type of an extended TM status which is mainly used inside the firmware. + * + * @see ::TM_GPS_STATUS_BIT_MASKS + * @see @ref TM_GPS_STATUS_EXT_BIT_MASKS + */ +typedef uint32_t TM_GPS_STATUS_EXT; + +#define _mbg_swab_tm_gps_status_ext( _p ) _mbg_swab32( _p ) + + +/** + * @brief An alias for ::TM_GPS_STATUS_EXT + * + * This has been used in existing source code. + */ +#define TM_STATUS_EXT TM_GPS_STATUS_EXT + + + /** * @brief Local date and time computed from GPS time * @@ -2602,18 +2943,18 @@ typedef struct int8_t sec; ///< seconds, 0..59, or 60 in case of inserted leap second int32_t frac; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units int32_t offs_from_utc; ///< local time offset from %UTC [sec] - uint16_t status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS + TM_GPS_STATUS status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS } TM_GPS; -#define _mbg_swab_tm_gps( _p ) \ -do \ -{ \ - _mbg_swab16( &(_p)->year ); \ - _mbg_swab16( &(_p)->yday ); \ - _mbg_swab32( &(_p)->frac ); \ - _mbg_swab32( &(_p)->offs_from_utc ); \ - _mbg_swab16( &(_p)->status ); \ +#define _mbg_swab_tm_gps( _p ) \ +do \ +{ \ + _mbg_swab16( &(_p)->year ); \ + _mbg_swab16( &(_p)->yday ); \ + _mbg_swab32( &(_p)->frac ); \ + _mbg_swab32( &(_p)->offs_from_utc ); \ + _mbg_swab_tm_gps_status( &(_p)->status ); \ } while ( 0 ) @@ -2657,51 +2998,68 @@ enum TM_GPS_STATUS_BITS */ enum TM_GPS_STATUS_BIT_MASKS { - TM_UTC = ( 1UL << TM_BIT_UTC ), ///< see ::TM_BIT_UTC - TM_LOCAL = ( 1UL << TM_BIT_LOCAL ), ///< see ::TM_BIT_LOCAL - TM_DL_ANN = ( 1UL << TM_BIT_DL_ANN ), ///< see ::TM_BIT_DL_ANN - TM_DL_ENB = ( 1UL << TM_BIT_DL_ENB ), ///< see ::TM_BIT_DL_ENB - TM_LS_ANN = ( 1UL << TM_BIT_LS_ANN ), ///< see ::TM_BIT_LS_ANN - TM_LS_ENB = ( 1UL << TM_BIT_LS_ENB ), ///< see ::TM_BIT_LS_ENB - TM_LS_ANN_NEG = ( 1UL << TM_BIT_LS_ANN_NEG ), ///< see ::TM_BIT_LS_ANN_NEG - TM_INVT = ( 1UL << TM_BIT_INVT ), ///< see ::TM_BIT_INVT + TM_UTC = ( 1UL << TM_BIT_UTC ), ///< See ::TM_BIT_UTC + TM_LOCAL = ( 1UL << TM_BIT_LOCAL ), ///< See ::TM_BIT_LOCAL + TM_DL_ANN = ( 1UL << TM_BIT_DL_ANN ), ///< See ::TM_BIT_DL_ANN + TM_DL_ENB = ( 1UL << TM_BIT_DL_ENB ), ///< See ::TM_BIT_DL_ENB + TM_LS_ANN = ( 1UL << TM_BIT_LS_ANN ), ///< See ::TM_BIT_LS_ANN + TM_LS_ENB = ( 1UL << TM_BIT_LS_ENB ), ///< See ::TM_BIT_LS_ENB + TM_LS_ANN_NEG = ( 1UL << TM_BIT_LS_ANN_NEG ), ///< See ::TM_BIT_LS_ANN_NEG + TM_INVT = ( 1UL << TM_BIT_INVT ), ///< See ::TM_BIT_INVT - TM_EXT_SYNC = ( 1UL << TM_BIT_EXT_SYNC ), ///< see ::TM_BIT_EXT_SYNC - TM_HOLDOVER = ( 1UL << TM_BIT_HOLDOVER ), ///< see ::TM_BIT_HOLDOVER - TM_ANT_SHORT = ( 1UL << TM_BIT_ANT_SHORT ), ///< see ::TM_BIT_ANT_SHORT - TM_NO_WARM = ( 1UL << TM_BIT_NO_WARM ), ///< see ::TM_BIT_NO_WARM - TM_ANT_DISCONN = ( 1UL << TM_BIT_ANT_DISCONN ), ///< see ::TM_BIT_ANT_DISCONN - TM_SYN_FLAG = ( 1UL << TM_BIT_SYN_FLAG ), ///< see ::TM_BIT_SYN_FLAG - TM_NO_SYNC = ( 1UL << TM_BIT_NO_SYNC ), ///< see ::TM_BIT_NO_SYNC - TM_NO_POS = ( 1UL << TM_BIT_NO_POS ) ///< see ::TM_BIT_NO_POS + TM_EXT_SYNC = ( 1UL << TM_BIT_EXT_SYNC ), ///< See ::TM_BIT_EXT_SYNC + TM_HOLDOVER = ( 1UL << TM_BIT_HOLDOVER ), ///< See ::TM_BIT_HOLDOVER + TM_ANT_SHORT = ( 1UL << TM_BIT_ANT_SHORT ), ///< See ::TM_BIT_ANT_SHORT + TM_NO_WARM = ( 1UL << TM_BIT_NO_WARM ), ///< See ::TM_BIT_NO_WARM + TM_ANT_DISCONN = ( 1UL << TM_BIT_ANT_DISCONN ), ///< See ::TM_BIT_ANT_DISCONN + TM_SYN_FLAG = ( 1UL << TM_BIT_SYN_FLAG ), ///< See ::TM_BIT_SYN_FLAG + TM_NO_SYNC = ( 1UL << TM_BIT_NO_SYNC ), ///< See ::TM_BIT_NO_SYNC + TM_NO_POS = ( 1UL << TM_BIT_NO_POS ) ///< See ::TM_BIT_NO_POS }; /** - * @brief Type of an extended TM status which is mainly used inside the firmware - */ -typedef uint32_t TM_STATUS_EXT; - -/** - * @brief Enumeration of extended status bits used with ::TM_STATUS_EXT + * @brief Extended status flag bits used to define @ref TM_GPS_STATUS_EXT_BIT_MASKS * * @note The lower 16 bits correspond to ::TM_GPS_STATUS_BITS + * + * @see ::TM_GPS_STATUS_BITS + * @see @ref TM_GPS_STATUS_EXT_BIT_MASKS */ -enum TM_GPS_STATUS_BITS_EX +enum TM_GPS_STATUS_EXT_BITS { TM_BIT_SCALE_GPS = 16, ///< time scale configured to return GPS time TM_BIT_SCALE_TAI ///< time scale configured to return TAI - // the remaining bits are reserved + // The remaining bits are reserved. }; -// 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 ) + +/** + * @brief Bit masks to be only used with ::TM_GPS_STATUS_EXT. + * + * @note The lower 16 bits correspond to ::TM_GPS_STATUS_BIT_MASKS + * + * @see ::TM_GPS_STATUS_EXT + * @see ::TM_GPS_STATUS_BIT_MASKS + * @see ::TM_GPS_STATUS_EXT_BITS + * + * @anchor TM_GPS_STATUS_EXT_BIT_MASKS @{ */ + +#define TM_SCALE_GPS ( 1UL << TM_BIT_SCALE_GPS ) ///< See ::TM_BIT_SCALE_GPS +#define TM_SCALE_TAI ( 1UL << TM_BIT_SCALE_TAI ) ///< See ::TM_BIT_SCALE_TAI + +/** @} anchor TM_GPS_STATUS_EXT_BIT_MASKS */ + + +#define ANN_LIMIT ( - ( SECS_PER_HOUR - SECS_PER_MIN ) ) +#define ANN_LIMIT_DCF ( - ( SECS_PER_HOUR + SECS_PER_MIN ) ) + #define TM_MSK_TIME_VALID ( TM_UTC | TM_SCALE_GPS | TM_SCALE_TAI ) + /** * @brief A structure used to transmit information on date and time * @@ -2821,7 +3179,7 @@ do \ /* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */ /** - * @brief The synthesizer's phase is only be synchronized if the frequency is below this limit + * @brief The phase of the synthesizer is only synchronized when the frequency is below this limit. */ #define SYNTH_PHASE_SYNC_LIMIT 10000UL ///< 10 kHz @@ -3175,7 +3533,7 @@ enum ENABLE_FLAGS_CODES #ifndef _COM_HS_DEFINED /** - * @brief Enumeration of handshake modes + * @brief Enumeration of handshake modes. */ enum COM_HANSHAKE_MODES { HS_NONE, HS_XONXOFF, HS_RTSCTS, N_COM_HS }; #define _COM_HS_DEFINED @@ -3183,27 +3541,27 @@ enum ENABLE_FLAGS_CODES #ifndef _COM_PARM_DEFINED /** - * @brief A data type to configure a serial port's baud rate + * @brief A data type to configure the baud rate of a serial port. * * @see ::MBG_BAUD_RATES */ typedef int32_t BAUD_RATE; /** - * @brief Indices used to identify a parameter in the framing string + * @brief Indices used to identify a parameter in the framing string. * * @see ::MBG_FRAMING_STRS */ enum MBG_FRAMING_STR_IDXS { F_DBITS, F_PRTY, F_STBITS }; /** - * @brief A structure to store the configuration of a serial port + * @brief A structure to store the configuration of a serial port. */ typedef struct { - BAUD_RATE baud_rate; ///< transmission speed, e.g. 19200L, see ::MBG_BAUD_RATES - char framing[4]; ///< ASCIIZ framing string, e.g. "8N1" or "7E2", see ::MBG_FRAMING_STRS - int16_t handshake; ///< handshake mode, yet only ::HS_NONE supported + BAUD_RATE baud_rate; ///< Transmission speed, e.g. 19200L, see ::MBG_BAUD_RATES. + char framing[4]; ///< ASCIIZ framing string, e.g. "8N1" or "7E2", see ::MBG_FRAMING_STRS. + int16_t handshake; ///< Handshake mode, yet only ::HS_NONE supported. } COM_PARM; @@ -3308,19 +3666,19 @@ enum MBG_BAUD_RATE_CODES */ enum MBG_BAUD_RATE_MASKS { - MBG_PORT_HAS_300 = ( 1UL << MBG_BAUD_RATE_300 ), ///< see ::MBG_BAUD_RATE_300 - MBG_PORT_HAS_600 = ( 1UL << MBG_BAUD_RATE_600 ), ///< see ::MBG_BAUD_RATE_600 - MBG_PORT_HAS_1200 = ( 1UL << MBG_BAUD_RATE_1200 ), ///< see ::MBG_BAUD_RATE_1200 - MBG_PORT_HAS_2400 = ( 1UL << MBG_BAUD_RATE_2400 ), ///< see ::MBG_BAUD_RATE_2400 - MBG_PORT_HAS_4800 = ( 1UL << MBG_BAUD_RATE_4800 ), ///< see ::MBG_BAUD_RATE_4800 - MBG_PORT_HAS_9600 = ( 1UL << MBG_BAUD_RATE_9600 ), ///< see ::MBG_BAUD_RATE_9600 - MBG_PORT_HAS_19200 = ( 1UL << MBG_BAUD_RATE_19200 ), ///< see ::MBG_BAUD_RATE_19200 - MBG_PORT_HAS_38400 = ( 1UL << MBG_BAUD_RATE_38400 ), ///< see ::MBG_BAUD_RATE_38400 - MBG_PORT_HAS_57600 = ( 1UL << MBG_BAUD_RATE_57600 ), ///< see ::MBG_BAUD_RATE_57600 - MBG_PORT_HAS_115200 = ( 1UL << MBG_BAUD_RATE_115200 ), ///< see ::MBG_BAUD_RATE_115200 - MBG_PORT_HAS_230400 = ( 1UL << MBG_BAUD_RATE_230400 ), ///< see ::MBG_BAUD_RATE_230400 - MBG_PORT_HAS_460800 = ( 1UL << MBG_BAUD_RATE_460800 ), ///< see ::MBG_BAUD_RATE_460800 - MBG_PORT_HAS_921600 = ( 1UL << MBG_BAUD_RATE_921600 ) ///< see ::MBG_BAUD_RATE_921600 + MBG_PORT_HAS_300 = ( 1UL << MBG_BAUD_RATE_300 ), ///< See ::MBG_BAUD_RATE_300 + MBG_PORT_HAS_600 = ( 1UL << MBG_BAUD_RATE_600 ), ///< See ::MBG_BAUD_RATE_600 + MBG_PORT_HAS_1200 = ( 1UL << MBG_BAUD_RATE_1200 ), ///< See ::MBG_BAUD_RATE_1200 + MBG_PORT_HAS_2400 = ( 1UL << MBG_BAUD_RATE_2400 ), ///< See ::MBG_BAUD_RATE_2400 + MBG_PORT_HAS_4800 = ( 1UL << MBG_BAUD_RATE_4800 ), ///< See ::MBG_BAUD_RATE_4800 + MBG_PORT_HAS_9600 = ( 1UL << MBG_BAUD_RATE_9600 ), ///< See ::MBG_BAUD_RATE_9600 + MBG_PORT_HAS_19200 = ( 1UL << MBG_BAUD_RATE_19200 ), ///< See ::MBG_BAUD_RATE_19200 + MBG_PORT_HAS_38400 = ( 1UL << MBG_BAUD_RATE_38400 ), ///< See ::MBG_BAUD_RATE_38400 + MBG_PORT_HAS_57600 = ( 1UL << MBG_BAUD_RATE_57600 ), ///< See ::MBG_BAUD_RATE_57600 + MBG_PORT_HAS_115200 = ( 1UL << MBG_BAUD_RATE_115200 ), ///< See ::MBG_BAUD_RATE_115200 + MBG_PORT_HAS_230400 = ( 1UL << MBG_BAUD_RATE_230400 ), ///< See ::MBG_BAUD_RATE_230400 + MBG_PORT_HAS_460800 = ( 1UL << MBG_BAUD_RATE_460800 ), ///< See ::MBG_BAUD_RATE_460800 + MBG_PORT_HAS_921600 = ( 1UL << MBG_BAUD_RATE_921600 ) ///< See ::MBG_BAUD_RATE_921600 }; @@ -3383,16 +3741,16 @@ enum MBG_FRAMING_CODES */ enum MBG_FRAMING_MASKS { - MBG_PORT_HAS_7N2 = ( 1UL << MBG_FRAMING_7N2 ), ///< see ::MBG_FRAMING_7N2 - MBG_PORT_HAS_7E1 = ( 1UL << MBG_FRAMING_7E1 ), ///< see ::MBG_FRAMING_7E1 - MBG_PORT_HAS_7E2 = ( 1UL << MBG_FRAMING_7E2 ), ///< see ::MBG_FRAMING_7E2 - MBG_PORT_HAS_8N1 = ( 1UL << MBG_FRAMING_8N1 ), ///< see ::MBG_FRAMING_8N1 - MBG_PORT_HAS_8N2 = ( 1UL << MBG_FRAMING_8N2 ), ///< see ::MBG_FRAMING_8N2 - MBG_PORT_HAS_8E1 = ( 1UL << MBG_FRAMING_8E1 ), ///< see ::MBG_FRAMING_8E1 - MBG_PORT_HAS_7O1 = ( 1UL << MBG_FRAMING_7O1 ), ///< see ::MBG_FRAMING_7O1 - MBG_PORT_HAS_7O2 = ( 1UL << MBG_FRAMING_7O2 ), ///< see ::MBG_FRAMING_7O2 - MBG_PORT_HAS_8O1 = ( 1UL << MBG_FRAMING_8O1 ), ///< see ::MBG_FRAMING_8O1 - MBG_PORT_HAS_8E2 = ( 1UL << MBG_FRAMING_8E2 ) ///< see ::MBG_FRAMING_8E2 + MBG_PORT_HAS_7N2 = ( 1UL << MBG_FRAMING_7N2 ), ///< See ::MBG_FRAMING_7N2 + MBG_PORT_HAS_7E1 = ( 1UL << MBG_FRAMING_7E1 ), ///< See ::MBG_FRAMING_7E1 + MBG_PORT_HAS_7E2 = ( 1UL << MBG_FRAMING_7E2 ), ///< See ::MBG_FRAMING_7E2 + MBG_PORT_HAS_8N1 = ( 1UL << MBG_FRAMING_8N1 ), ///< See ::MBG_FRAMING_8N1 + MBG_PORT_HAS_8N2 = ( 1UL << MBG_FRAMING_8N2 ), ///< See ::MBG_FRAMING_8N2 + MBG_PORT_HAS_8E1 = ( 1UL << MBG_FRAMING_8E1 ), ///< See ::MBG_FRAMING_8E1 + MBG_PORT_HAS_7O1 = ( 1UL << MBG_FRAMING_7O1 ), ///< See ::MBG_FRAMING_7O1 + MBG_PORT_HAS_7O2 = ( 1UL << MBG_FRAMING_7O2 ), ///< See ::MBG_FRAMING_7O2 + MBG_PORT_HAS_8O1 = ( 1UL << MBG_FRAMING_8O1 ), ///< See ::MBG_FRAMING_8O1 + MBG_PORT_HAS_8E2 = ( 1UL << MBG_FRAMING_8E2 ) ///< See ::MBG_FRAMING_8E2 }; @@ -3558,22 +3916,22 @@ enum MBG_COM_CFG_STATUS_BITS * * @anchor MBG_COM_CFG_STATUS_MASKS @{ */ -#define MBG_PS_MSK_BAUD_RATE_OVR_SW ( 1UL << MBG_PS_BIT_BAUD_RATE_OVR_SW ) ///< see ::MBG_PS_BIT_BAUD_RATE_OVR_SW -#define MBG_PS_MSK_BAUD_RATE_OVR_DEV ( 1UL << MBG_PS_BIT_BAUD_RATE_OVR_DEV ) ///< see ::MBG_PS_BIT_BAUD_RATE_OVR_DEV -#define MBG_PS_MSK_BAUD_RATE ( 1UL << MBG_PS_BIT_BAUD_RATE ) ///< see ::MBG_PS_BIT_BAUD_RATE -#define MBG_PS_MSK_FRAMING_OVR_SW ( 1UL << MBG_PS_BIT_FRAMING_OVR_SW ) ///< see ::MBG_PS_BIT_FRAMING_OVR_SW -#define MBG_PS_MSK_FRAMING_OVR_DEV ( 1UL << MBG_PS_BIT_FRAMING_OVR_DEV ) ///< see ::MBG_PS_BIT_FRAMING_OVR_DEV -#define MBG_PS_MSK_FRAMING ( 1UL << MBG_PS_BIT_FRAMING ) ///< see ::MBG_PS_BIT_FRAMING -#define MBG_PS_MSK_HS_OVR_SW ( 1UL << MBG_PS_BIT_HS_OVR_SW ) ///< see ::MBG_PS_BIT_HS_OVR_SW -#define MBG_PS_MSK_HS ( 1UL << MBG_PS_BIT_HS ) ///< see ::MBG_PS_BIT_HS -#define MBG_PS_MSK_STR_TYPE_OVR_SW ( 1UL << MBG_PS_BIT_STR_TYPE_OVR_SW ) ///< see ::MBG_PS_BIT_STR_TYPE_OVR_SW -#define MBG_PS_MSK_STR_TYPE_OVR_DEV ( 1UL << MBG_PS_BIT_STR_TYPE_OVR_DEV ) ///< see ::MBG_PS_BIT_STR_TYPE_OVR_DEV -#define MBG_PS_MSK_STR_TYPE ( 1UL << MBG_PS_BIT_STR_TYPE ) ///< see ::MBG_PS_BIT_STR_TYPE -#define MBG_PS_MSK_STR_MODE_OVR_SW ( 1UL << MBG_PS_BIT_STR_MODE_OVR_SW ) ///< see ::MBG_PS_BIT_STR_MODE_OVR_SW -#define MBG_PS_MSK_STR_MODE_OVR_DEV ( 1UL << MBG_PS_BIT_STR_MODE_OVR_DEV ) ///< see ::MBG_PS_BIT_STR_MODE_OVR_DEV -#define MBG_PS_MSK_STR_MODE ( 1UL << MBG_PS_BIT_STR_MODE ) ///< see ::MBG_PS_BIT_STR_MODE -#define MBG_PS_MSK_FLAGS_OVR_SW ( 1UL << MBG_PS_BIT_FLAGS_OVR_SW ) ///< see ::MBG_PS_BIT_FLAGS_OVR_SW -#define MBG_PS_MSK_FLAGS ( 1UL << MBG_PS_BIT_FLAGS ) ///< see ::MBG_PS_BIT_FLAGS +#define MBG_PS_MSK_BAUD_RATE_OVR_SW ( 1UL << MBG_PS_BIT_BAUD_RATE_OVR_SW ) ///< See ::MBG_PS_BIT_BAUD_RATE_OVR_SW +#define MBG_PS_MSK_BAUD_RATE_OVR_DEV ( 1UL << MBG_PS_BIT_BAUD_RATE_OVR_DEV ) ///< See ::MBG_PS_BIT_BAUD_RATE_OVR_DEV +#define MBG_PS_MSK_BAUD_RATE ( 1UL << MBG_PS_BIT_BAUD_RATE ) ///< See ::MBG_PS_BIT_BAUD_RATE +#define MBG_PS_MSK_FRAMING_OVR_SW ( 1UL << MBG_PS_BIT_FRAMING_OVR_SW ) ///< See ::MBG_PS_BIT_FRAMING_OVR_SW +#define MBG_PS_MSK_FRAMING_OVR_DEV ( 1UL << MBG_PS_BIT_FRAMING_OVR_DEV ) ///< See ::MBG_PS_BIT_FRAMING_OVR_DEV +#define MBG_PS_MSK_FRAMING ( 1UL << MBG_PS_BIT_FRAMING ) ///< See ::MBG_PS_BIT_FRAMING +#define MBG_PS_MSK_HS_OVR_SW ( 1UL << MBG_PS_BIT_HS_OVR_SW ) ///< See ::MBG_PS_BIT_HS_OVR_SW +#define MBG_PS_MSK_HS ( 1UL << MBG_PS_BIT_HS ) ///< See ::MBG_PS_BIT_HS +#define MBG_PS_MSK_STR_TYPE_OVR_SW ( 1UL << MBG_PS_BIT_STR_TYPE_OVR_SW ) ///< See ::MBG_PS_BIT_STR_TYPE_OVR_SW +#define MBG_PS_MSK_STR_TYPE_OVR_DEV ( 1UL << MBG_PS_BIT_STR_TYPE_OVR_DEV ) ///< See ::MBG_PS_BIT_STR_TYPE_OVR_DEV +#define MBG_PS_MSK_STR_TYPE ( 1UL << MBG_PS_BIT_STR_TYPE ) ///< See ::MBG_PS_BIT_STR_TYPE +#define MBG_PS_MSK_STR_MODE_OVR_SW ( 1UL << MBG_PS_BIT_STR_MODE_OVR_SW ) ///< See ::MBG_PS_BIT_STR_MODE_OVR_SW +#define MBG_PS_MSK_STR_MODE_OVR_DEV ( 1UL << MBG_PS_BIT_STR_MODE_OVR_DEV ) ///< See ::MBG_PS_BIT_STR_MODE_OVR_DEV +#define MBG_PS_MSK_STR_MODE ( 1UL << MBG_PS_BIT_STR_MODE ) ///< See ::MBG_PS_BIT_STR_MODE +#define MBG_PS_MSK_FLAGS_OVR_SW ( 1UL << MBG_PS_BIT_FLAGS_OVR_SW ) ///< See ::MBG_PS_BIT_FLAGS_OVR_SW +#define MBG_PS_MSK_FLAGS ( 1UL << MBG_PS_BIT_FLAGS ) ///< See ::MBG_PS_BIT_FLAGS /** @} anchor MBG_COM_CFG_STATUS_MASKS */ @@ -3593,7 +3951,7 @@ enum MBG_COM_CFG_STATUS_BITS */ typedef struct { - uint16_t idx; ///< port index, 0..::RECEIVER_INFO::n_com_ports-1 + MBG_MSG_IDX idx; ///< Port index, 0..::RECEIVER_INFO::n_com_ports-1 PORT_SETTINGS port_settings; } PORT_SETTINGS_IDX; @@ -3622,7 +3980,7 @@ typedef struct uint32_t supp_framings; ///< bit mask of framings supp. by this port, see ::MBG_FRAMING_MASKS uint32_t supp_str_types; ///< bit mask of string types supp. by this port, i.e. bit 0 set if str_type[0] is supp. uint32_t reserved; ///< reserved for future use, currently always 0 - uint32_t flags; ///< see ::PORT_INFO_FLAGS + uint32_t flags; ///< See ::PORT_INFO_FLAGS } PORT_INFO; @@ -3658,8 +4016,8 @@ enum PORT_INFO_FLAG_BITS */ enum PORT_INFO_FLAGS { - PORT_INFO_FLAG_PORT_INVISIBLE = ( 1UL << PORT_INFO_FLAG_BIT_PORT_INVISIBLE ), ///< see ::PORT_INFO_FLAG_BIT_PORT_INVISIBLE - PORT_INFO_FLAG_BIN_PROT_HS = ( 1UL << PORT_INFO_FLAG_BIT_BIN_PROT_HS ) ///< see ::PORT_INFO_FLAG_BIT_BIN_PROT_HS + PORT_INFO_FLAG_PORT_INVISIBLE = ( 1UL << PORT_INFO_FLAG_BIT_PORT_INVISIBLE ), ///< See ::PORT_INFO_FLAG_BIT_PORT_INVISIBLE + PORT_INFO_FLAG_BIN_PROT_HS = ( 1UL << PORT_INFO_FLAG_BIT_BIN_PROT_HS ) ///< See ::PORT_INFO_FLAG_BIT_BIN_PROT_HS }; @@ -3676,7 +4034,7 @@ enum PORT_INFO_FLAGS */ typedef struct { - uint16_t idx; ///< port index, 0..::RECEIVER_INFO::n_com_ports-1 + MBG_MSG_IDX idx; ///< Port index, 0..::RECEIVER_INFO::n_com_ports-1 PORT_INFO port_info; } PORT_INFO_IDX; @@ -3732,7 +4090,7 @@ do \ */ typedef struct { - uint16_t idx; ///< string type index, 0..::RECEIVER_INFO::n_str_type-1 + MBG_MSG_IDX idx; ///< String type index, 0..::RECEIVER_INFO::n_str_type-1 STR_TYPE_INFO str_type_info; } STR_TYPE_INFO_IDX; @@ -3776,12 +4134,12 @@ enum STR_MODES */ enum STR_MODE_MASKS { - MSK_STR_ON_REQ = ( 1UL << STR_ON_REQ ), ///< see ::STR_ON_REQ - MSK_STR_PER_SEC = ( 1UL << STR_PER_SEC ), ///< see ::STR_PER_SEC - MSK_STR_PER_MIN = ( 1UL << STR_PER_MIN ), ///< see ::STR_PER_MIN - MSK_STR_AUTO = ( 1UL << STR_AUTO ), ///< see ::STR_AUTO - MSK_STR_ON_REQ_SEC = ( 1UL << STR_ON_REQ_SEC ), ///< see ::STR_ON_REQ_SEC - MSK_STR_CR_ON_SEC = ( 1UL << STR_CR_ON_SEC ) ///< see ::STR_CR_ON_SEC + MSK_STR_ON_REQ = ( 1UL << STR_ON_REQ ), ///< See ::STR_ON_REQ + MSK_STR_PER_SEC = ( 1UL << STR_PER_SEC ), ///< See ::STR_PER_SEC + MSK_STR_PER_MIN = ( 1UL << STR_PER_MIN ), ///< See ::STR_PER_MIN + MSK_STR_AUTO = ( 1UL << STR_AUTO ), ///< See ::STR_AUTO + MSK_STR_ON_REQ_SEC = ( 1UL << STR_ON_REQ_SEC ), ///< See ::STR_ON_REQ_SEC + MSK_STR_CR_ON_SEC = ( 1UL << STR_CR_ON_SEC ) ///< See ::STR_CR_ON_SEC }; @@ -3980,8 +4338,8 @@ enum LGCY_STR_MODES * * The following definitions are used to configure an optional * on-board IRIG input or output. Which frame types are supported - * by a device depends on the device type, and may eventually - * depend on the device's firmware version. + * by a device depends on the device type, and may depend on the + * firmware version of the device. * * All IRIG frames transport the day-of-year number plus the time-of-day, * and include a control field segment which can transport user defined @@ -4077,9 +4435,9 @@ enum LGCY_STR_MODES * of the IEEE 1344 standard from 1995. These codes provide the same extensions as IEEE 1344 * but unfortunately determine that the %UTC offset has to be applied with reversed sign. * - * For example, if a -6 hours UTC offset is transmitted in the time code:<br> - * IEEE 1344: (IRIG time 14:43:27 h) - (offs -6 h) = (UTC 20:43:27)<br> - * IEEE C37.118: (IRIG time 14:43:27 h) + (offs -6 h) = (UTC 08:43:27)<br> + * For example, if a -6 hours %UTC offset is transmitted in the time code:<br> + * IEEE 1344: (IRIG time 14:43:27 h) - (offs -6 h) = (%UTC 20:43:27)<br> + * IEEE C37.118: (IRIG time 14:43:27 h) + (offs -6 h) = (%UTC 08:43:27)<br> * * @see @ref MSK_ICODE_RX_UTC_OFFS_ADD and @ref MSK_ICODE_RX_UTC_OFFS_SUB * @@ -4454,11 +4812,11 @@ enum ICODE_TX_CODES ) /** - * @brief IRIG TX formats where UTC offset must be subtracted to yield UTC + * @brief IRIG TX formats where %UTC offset must be subtracted to yield %UTC * - * A mask of IRIG formats where the decoded UTC offset must be - * subtracted from the time decoded from the IRIG signal to yield UTC, e.g.:<br> - * (IRIG time 14:43:27 h) - (offs -6 h) = (UTC 20:43:27) + * A mask of IRIG formats where the decoded %UTC offset must be + * subtracted from the time decoded from the IRIG signal to yield %UTC, e.g.:<br> + * (IRIG time 14:43:27 h) - (offs -6 h) = (%UTC 20:43:27) */ #define MSK_ICODE_TX_UTC_OFFS_SUB \ ( \ @@ -4466,11 +4824,11 @@ enum ICODE_TX_CODES ) /** - * @brief IRIG TX formats where UTC offset must be added to yield UTC + * @brief IRIG TX formats where %UTC offset must be added to yield %UTC * - * A mask of IRIG formats where the decoded UTC offset must be - * added to the time decoded from the IRIG signal to yield UTC, e.g.:<br> - * (IRIG time 14:43:27 h) + (offs -6 h) = (UTC 08:43:27) + * A mask of IRIG formats where the decoded %UTC offset must be + * added to the time decoded from the IRIG signal to yield %UTC, e.g.:<br> + * (IRIG time 14:43:27 h) + (offs -6 h) = (%UTC 08:43:27) */ #define MSK_ICODE_TX_UTC_OFFS_ADD \ ( \ @@ -4925,11 +5283,11 @@ enum ICODE_RX_CODES ) /** - * @brief IRIG RX formats where UTC offset must be subtracted to yield UTC + * @brief IRIG RX formats where %UTC offset must be subtracted to yield %UTC * - * A mask of IRIG formats where the decoded UTC offset must be - * subtracted from the time decoded from the IRIG signal to yield UTC, e.g.:<br> - * (IRIG time 14:43:27 h) - (offs -6 h) = (UTC 20:43:27) + * A mask of IRIG formats where the decoded %UTC offset must be + * subtracted from the time decoded from the IRIG signal to yield %UTC, e.g.:<br> + * (IRIG time 14:43:27 h) - (offs -6 h) = (%UTC 20:43:27) */ #define MSK_ICODE_RX_UTC_OFFS_SUB \ ( \ @@ -4938,11 +5296,11 @@ enum ICODE_RX_CODES ) /** - * @brief IRIG RX formats where UTC offset must be added to yield UTC + * @brief IRIG RX formats where %UTC offset must be added to yield %UTC * - * A mask of IRIG formats where the decoded UTC offset must be - * added to the time decoded from the IRIG signal to yield UTC, e.g.:<br> - * (IRIG time 14:43:27 h) + (offs -6 h) = (UTC 08:43:27) + * A mask of IRIG formats where the decoded %UTC offset must be + * added to the time decoded from the IRIG signal to yield %UTC, e.g.:<br> + * (IRIG time 14:43:27 h) + (offs -6 h) = (%UTC 08:43:27) */ #define MSK_ICODE_RX_UTC_OFFS_ADD \ ( \ @@ -4999,7 +5357,7 @@ enum ICODE_RX_CODES typedef struct { uint16_t icode; ///< IRIG signal code, see ::ICODE_RX_CODES and ::ICODE_TX_CODES - uint16_t flags; ///< see ::IFLAGS_BIT_MASKS + uint16_t flags; ///< See ::IFLAGS_BIT_MASKS } IRIG_SETTINGS; @@ -5038,8 +5396,8 @@ enum IFLAGS_BITS */ enum IFLAGS_BIT_MASKS { - IFLAGS_DISABLE_TFOM = ( 1UL << IFLAGS_BIT_DISABLE_TFOM ), ///< see ::IFLAGS_BIT_DISABLE_TFOM - IFLAGS_TX_GEN_LOCAL_TIME = ( 1UL << IFLAGS_BIT_TX_GEN_LOCAL_TIME ), ///< see ::IFLAGS_BIT_TX_GEN_LOCAL_TIME + IFLAGS_DISABLE_TFOM = ( 1UL << IFLAGS_BIT_DISABLE_TFOM ), ///< See ::IFLAGS_BIT_DISABLE_TFOM + IFLAGS_TX_GEN_LOCAL_TIME = ( 1UL << IFLAGS_BIT_TX_GEN_LOCAL_TIME ), ///< See ::IFLAGS_BIT_TX_GEN_LOCAL_TIME IFLAGS_MASK = ( ( 1UL << N_IFLAGS_BITS ) - 1 ) ///< mask of all known flags }; @@ -5117,8 +5475,8 @@ do \ */ typedef struct { - uint16_t type; ///< record type, see ::CAL_REC_TYPES - uint16_t idx; ///< index if several records of same type are supported, see ::IRIG_RX_COMP_GROUPS + uint16_t type; ///< Record type, see ::CAL_REC_TYPES + uint16_t idx; ///< Index if several records of same type are supported, see ::IRIG_RX_COMP_GROUPS } CAL_REC_HDR; @@ -5195,7 +5553,7 @@ do \ /** - * @brief A data type used to read the board's debug status + * @brief A data type used to read the debug status of the device. * * @note This also includes IRIG decoder status. * @@ -5291,7 +5649,7 @@ enum MBG_DEBUG_STATUS_BITS * @note There's a special flag ::MBG_REF_OFFS_NOT_CFGD indicating that * this parameter is unconfigured, in which case a Meinberg time code * receiver refuses to synchronize to the time code signal unless a time - * code frame has been configured which provides the UTC offset (namely + * code frame has been configured which provides the %UTC offset (namely * IEEE 1344 or IEEE C37.118). */ typedef int16_t MBG_REF_OFFS; @@ -5372,8 +5730,8 @@ enum MBG_OPT_BITS */ enum MBG_OPT_FLAGS { - MBG_OPT_FLAG_STR_UTC = ( 1UL << MBG_OPT_BIT_STR_UTC ), ///< see ::MBG_OPT_BIT_STR_UTC - MBG_OPT_FLAG_EMU_SYNC = ( 1UL << MBG_OPT_BIT_EMU_SYNC ) ///< see ::MBG_OPT_BIT_EMU_SYNC + MBG_OPT_FLAG_STR_UTC = ( 1UL << MBG_OPT_BIT_STR_UTC ), ///< See ::MBG_OPT_BIT_STR_UTC + MBG_OPT_FLAG_EMU_SYNC = ( 1UL << MBG_OPT_BIT_EMU_SYNC ) ///< See ::MBG_OPT_BIT_EMU_SYNC }; @@ -5448,7 +5806,7 @@ typedef struct /** * @defgroup group_time_scale Time Scale Configuration * - * Used to configure the GPS receiver's basic time scale. + * Used to configure the basic time scale of the GPS receiver. * 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 @@ -5479,9 +5837,9 @@ enum MBG_TIME_SCALES */ enum MBG_TIME_SCALE_MASKS { - MBG_TIME_SCALE_MSK_DEFAULT = ( 1UL << MBG_TIME_SCALE_DEFAULT ), ///< see ::MBG_TIME_SCALE_DEFAULT - MBG_TIME_SCALE_MSK_GPS = ( 1UL << MBG_TIME_SCALE_GPS ), ///< see ::MBG_TIME_SCALE_GPS - MBG_TIME_SCALE_MSK_TAI = ( 1UL << MBG_TIME_SCALE_TAI ) ///< see ::MBG_TIME_SCALE_TAI + MBG_TIME_SCALE_MSK_DEFAULT = ( 1UL << MBG_TIME_SCALE_DEFAULT ), ///< See ::MBG_TIME_SCALE_DEFAULT + MBG_TIME_SCALE_MSK_GPS = ( 1UL << MBG_TIME_SCALE_GPS ), ///< See ::MBG_TIME_SCALE_GPS + MBG_TIME_SCALE_MSK_TAI = ( 1UL << MBG_TIME_SCALE_TAI ) ///< See ::MBG_TIME_SCALE_TAI }; #define MBG_TIME_SCALE_STRS \ @@ -5604,9 +5962,10 @@ do \ /** * @brief A structure to define on/off cycle times * - * @note The ::MBG_TIME::sec100 field in ::POUT_TIME:on and - * ::POUT_TIME:off is not evaluated by the firmware and thus - * should always be set to 0. + * @note Eventually the ::MBG_TIME::sec100 fields in + * ::POUT_TIME:on and ::POUT_TIME:off are not evaluated + * by the firmware in ::POUT_TIMER mode, and thus + * should be set to 0 for this mode. */ typedef struct { @@ -5694,12 +6053,12 @@ typedef struct uint16_t mode; ///< Mode of operation, see ::POUT_MODES uint16_t mode_param; ///< Optional parameter depending on the mode, see @ref POUT_MODES_PARAM_MASKS - /// Timeout [min] which can be specified for some modes, see ::POUT_MODES_TIMEOUT, ::MAX_POUT_DCF_TIMOUT. + /// @brief Timeout [min] which can be specified for some modes, see ::POUT_MODES_TIMEOUT, ::MAX_POUT_DCF_TIMOUT. /// /// If the clock looses synchronization then the output - /// - is disabled **immediately** if ::POUT_IF_SYNC_ONLY is set in ::POUT_SETTINGS::flags - /// - is disabled after ::POUT_SETTINGS::timeout, if timeout is not 0 (see ::MAX_POUT_DCF_TIMOUT) - /// - stays enabled if timeout is 0 **and** ::POUT_IF_SYNC_ONLY is **not** set + /// - is disabled ***immediately*** if ::POUT_IF_SYNC_ONLY is set in #flags + /// - is disabled after #timeout, if #timeout is not 0 (see ::MAX_POUT_DCF_TIMOUT) + /// - stays enabled if #timeout is 0 ***and*** ::POUT_IF_SYNC_ONLY is ***not*** set in #flags uint16_t timeout; uint16_t flags; ///< @see ::POUT_SETTINGS_FLAGS @@ -5791,41 +6150,52 @@ do \ */ enum POUT_MODES { - /// Output is normally always 'off', or always 'on', if flag ::POUT_INVERTED is set. + /// Output is normally always 'off', or always 'on' in case + /// flag ::POUT_INVERTED is set in ::POUT_SETTINGS::flags. POUT_IDLE, /// Switch 'on' or 'off' at the times specified in ::POUT_DATA::tm. + /// + /// @note Eventually the ::MBG_TIME::sec100 fields in + /// ::POUT_TIME:on and ::POUT_TIME:off are not evaluated + /// by the firmware in ::POUT_TIMER mode, and thus + /// should be always set to 0 in this mode. POUT_TIMER, - /// Generate a pulse at the time specified in the ::POUT_TIME[0]::on field - /// in ::POUT_DATA::tm of the ::POUT_SETTINGS (POUT_SETTINGS::tm[0].on). - /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. + /// Generate a pulse at the time specified in the tm[0].on field + /// in ::POUT_SETTINGS::pout_data. + /// Pulse length as specified in ::POUT_SETTINGS::mode_param, + /// in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_SINGLE_SHOT, - /// Generate a cyclic pulse at the interval specified in ::MBG_DATE_TIME::t - /// field of ::POUT_TIME[0]::on in ::POUT_DATA::tm of the ::POUT_SETTINGS - /// (POUT_SETTINGS::tm[0].on.t). - /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. + /// Generate a cyclic pulse at the time specified in the tm[0].on.t + /// field in ::POUT_SETTINGS::pout_data. + /// Pulse length as specified in ::POUT_SETTINGS::mode_param, + /// in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_CYCLIC_PULSE, /// Generate a pulse whenever the second changes. - /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. + /// Pulse length as specified in ::POUT_SETTINGS::mode_param, + /// in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_PER_SEC, /// Generate a pulse whenever the minute changes. - /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. + /// Pulse length as specified in ::POUT_SETTINGS::mode_param, + /// in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_PER_MIN, /// Generate a pulse whenever the hour changes. - /// Pulse length according to ::POUT_SETTINGS::mode_param, in [10 ms] units. + /// Pulse length as specified in ::POUT_SETTINGS::mode_param, + /// in [10 ms] units. /// See ::MAX_POUT_PULSE_LEN. POUT_PER_HOUR, /// Generate DCF77-compatible second marks. + /// Pulse length according to the DCF77 specifications. /// See ::POUT_DCF77_M59, ::POUT_SETTINGS::timeout and ::MAX_POUT_DCF_TIMOUT. POUT_DCF77, @@ -5890,26 +6260,26 @@ enum POUT_MODES * * @anchor POUT_MODE_MASKS @{ */ -#define MSK_POUT_IDLE ( 1UL << POUT_IDLE ) ///< see ::POUT_IDLE -#define MSK_POUT_TIMER ( 1UL << POUT_TIMER ) ///< see ::POUT_TIMER -#define MSK_POUT_SINGLE_SHOT ( 1UL << POUT_SINGLE_SHOT ) ///< see ::POUT_SINGLE_SHOT -#define MSK_POUT_CYCLIC_PULSE ( 1UL << POUT_CYCLIC_PULSE ) ///< see ::POUT_CYCLIC_PULSE -#define MSK_POUT_PER_SEC ( 1UL << POUT_PER_SEC ) ///< see ::POUT_PER_SEC -#define MSK_POUT_PER_MIN ( 1UL << POUT_PER_MIN ) ///< see ::POUT_PER_MIN -#define MSK_POUT_PER_HOUR ( 1UL << POUT_PER_HOUR ) ///< see ::POUT_PER_HOUR -#define MSK_POUT_DCF77 ( 1UL << POUT_DCF77 ) ///< see ::POUT_DCF77 -#define MSK_POUT_POS_OK ( 1UL << POUT_POS_OK ) ///< see ::POUT_POS_OK -#define MSK_POUT_TIME_SYNC ( 1UL << POUT_TIME_SYNC ) ///< see ::POUT_TIME_SYNC -#define MSK_POUT_ALL_SYNC ( 1UL << POUT_ALL_SYNC ) ///< see ::POUT_ALL_SYNC -#define MSK_POUT_TIMECODE ( 1UL << POUT_TIMECODE ) ///< see ::POUT_TIMECODE -#define MSK_POUT_TIMESTR ( 1UL << POUT_TIMESTR ) ///< see ::POUT_TIMESTR -#define MSK_POUT_10MHZ ( 1UL << POUT_10MHZ ) ///< see ::POUT_10MHZ -#define MSK_POUT_DCF77_M59 ( 1UL << POUT_DCF77_M59 ) ///< see ::POUT_DCF77_M59 -#define MSK_POUT_SYNTH ( 1UL << POUT_SYNTH ) ///< see ::POUT_SYNTH -#define MSK_POUT_TIME_SLOTS ( 1UL << POUT_TIME_SLOTS ) ///< see ::POUT_TIME_SLOTS -#define MSK_POUT_GPIO ( 1UL << POUT_GPIO ) ///< see ::POUT_GPIO -#define MSK_POUT_PTTI_PPS ( 1UL << POUT_PTTI_PPS ) ///< see ::POUT_PTTI_PPS -#define MSK_POUT_HAVEQUICK ( 1UL << POUT_HAVEQUICK ) ///< see ::POUT_HAVEQUICK +#define MSK_POUT_IDLE ( 1UL << POUT_IDLE ) ///< See ::POUT_IDLE +#define MSK_POUT_TIMER ( 1UL << POUT_TIMER ) ///< See ::POUT_TIMER +#define MSK_POUT_SINGLE_SHOT ( 1UL << POUT_SINGLE_SHOT ) ///< See ::POUT_SINGLE_SHOT +#define MSK_POUT_CYCLIC_PULSE ( 1UL << POUT_CYCLIC_PULSE ) ///< See ::POUT_CYCLIC_PULSE +#define MSK_POUT_PER_SEC ( 1UL << POUT_PER_SEC ) ///< See ::POUT_PER_SEC +#define MSK_POUT_PER_MIN ( 1UL << POUT_PER_MIN ) ///< See ::POUT_PER_MIN +#define MSK_POUT_PER_HOUR ( 1UL << POUT_PER_HOUR ) ///< See ::POUT_PER_HOUR +#define MSK_POUT_DCF77 ( 1UL << POUT_DCF77 ) ///< See ::POUT_DCF77 +#define MSK_POUT_POS_OK ( 1UL << POUT_POS_OK ) ///< See ::POUT_POS_OK +#define MSK_POUT_TIME_SYNC ( 1UL << POUT_TIME_SYNC ) ///< See ::POUT_TIME_SYNC +#define MSK_POUT_ALL_SYNC ( 1UL << POUT_ALL_SYNC ) ///< See ::POUT_ALL_SYNC +#define MSK_POUT_TIMECODE ( 1UL << POUT_TIMECODE ) ///< See ::POUT_TIMECODE +#define MSK_POUT_TIMESTR ( 1UL << POUT_TIMESTR ) ///< See ::POUT_TIMESTR +#define MSK_POUT_10MHZ ( 1UL << POUT_10MHZ ) ///< See ::POUT_10MHZ +#define MSK_POUT_DCF77_M59 ( 1UL << POUT_DCF77_M59 ) ///< See ::POUT_DCF77_M59 +#define MSK_POUT_SYNTH ( 1UL << POUT_SYNTH ) ///< See ::POUT_SYNTH +#define MSK_POUT_TIME_SLOTS ( 1UL << POUT_TIME_SLOTS ) ///< See ::POUT_TIME_SLOTS +#define MSK_POUT_GPIO ( 1UL << POUT_GPIO ) ///< See ::POUT_GPIO +#define MSK_POUT_PTTI_PPS ( 1UL << POUT_PTTI_PPS ) ///< See ::POUT_PTTI_PPS +#define MSK_POUT_HAVEQUICK ( 1UL << POUT_HAVEQUICK ) ///< See ::POUT_HAVEQUICK /** @} anchor POUT_MODE_MASKS */ @@ -6198,7 +6568,7 @@ enum POUT_MODES enum POUT_SETTINGS_FLAG_BITS { /// Output level is to be inverted. Can only be used - /// if ::POUT_NOT_INVERTIBLE is **not** set, but is + /// if ::POUT_NOT_INVERTIBLE is ***not*** set, but is /// supported by all ::POUT_MODES. POUT_BIT_INVERTED, @@ -6229,9 +6599,9 @@ enum POUT_SETTINGS_FLAG_BITS */ enum POUT_SETTINGS_FLAGS { - POUT_INVERTED = ( 1UL << POUT_BIT_INVERTED ), ///< see ::POUT_BIT_INVERTED, ::POUT_NOT_INVERTIBLE - POUT_IF_SYNC_ONLY = ( 1UL << POUT_BIT_IF_SYNC_ONLY ), ///< see ::POUT_BIT_IF_SYNC_ONLY, ::POUT_SUPP_IF_SYNC_ONLY - POUT_TIMEBASE_UTC = ( 1UL << POUT_BIT_TIMEBASE_UTC ) ///< see ::POUT_BIT_TIMEBASE_UTC, ::POUT_SUPP_DCF77_UTC + POUT_INVERTED = ( 1UL << POUT_BIT_INVERTED ), ///< See ::POUT_BIT_INVERTED, ::POUT_NOT_INVERTIBLE + POUT_IF_SYNC_ONLY = ( 1UL << POUT_BIT_IF_SYNC_ONLY ), ///< See ::POUT_BIT_IF_SYNC_ONLY, ::POUT_SUPP_IF_SYNC_ONLY + POUT_TIMEBASE_UTC = ( 1UL << POUT_BIT_TIMEBASE_UTC ) ///< See ::POUT_BIT_TIMEBASE_UTC, ::POUT_SUPP_DCF77_UTC }; @@ -6248,7 +6618,7 @@ enum POUT_SETTINGS_FLAGS */ typedef struct { - uint16_t idx; ///< 0..::RECEIVER_INFO::n_prg_out-1 + MBG_MSG_IDX idx; ///< 0..::RECEIVER_INFO::n_prg_out-1 POUT_SETTINGS pout_settings; } POUT_SETTINGS_IDX; @@ -6328,11 +6698,11 @@ enum POUT_INFO_FLAG_BITS */ enum POUT_INFO_FLAG_MASKS { - POUT_SUPP_IF_SYNC_ONLY = ( 1UL << POUT_BIT_SUPP_IF_SYNC_ONLY ), ///< see ::POUT_BIT_SUPP_IF_SYNC_ONLY, ::POUT_IF_SYNC_ONLY - POUT_SUPP_DCF77_UTC = ( 1UL << POUT_BIT_SUPP_DCF77_UTC ), ///< see ::POUT_BIT_SUPP_DCF77_UTC, ::POUT_SUPP_DCF77_UTC - POUT_FIXED_PULSE_LEN = ( 1UL << POUT_BIT_FIXED_PULSE_LEN ), ///< see ::POUT_BIT_FIXED_PULSE_LEN - POUT_NOT_INVERTIBLE = ( 1UL << POUT_BIT_NOT_INVERTIBLE ), ///< see ::POUT_BIT_NOT_INVERTIBLE, ::POUT_INVERTED - POUT_SUPP_PULSE_SHIFT = ( 1UL << POUT_BIT_SUPP_PULSE_SHIFT ) ///< see ::POUT_BIT_SUPP_PULSE_SHIFT, ::POUT_DATA::pulse_shift + POUT_SUPP_IF_SYNC_ONLY = ( 1UL << POUT_BIT_SUPP_IF_SYNC_ONLY ), ///< See ::POUT_BIT_SUPP_IF_SYNC_ONLY, ::POUT_IF_SYNC_ONLY + POUT_SUPP_DCF77_UTC = ( 1UL << POUT_BIT_SUPP_DCF77_UTC ), ///< See ::POUT_BIT_SUPP_DCF77_UTC, ::POUT_SUPP_DCF77_UTC + POUT_FIXED_PULSE_LEN = ( 1UL << POUT_BIT_FIXED_PULSE_LEN ), ///< See ::POUT_BIT_FIXED_PULSE_LEN + POUT_NOT_INVERTIBLE = ( 1UL << POUT_BIT_NOT_INVERTIBLE ), ///< See ::POUT_BIT_NOT_INVERTIBLE, ::POUT_INVERTED + POUT_SUPP_PULSE_SHIFT = ( 1UL << POUT_BIT_SUPP_PULSE_SHIFT ) ///< See ::POUT_BIT_SUPP_PULSE_SHIFT, ::POUT_DATA::pulse_shift }; @@ -6350,7 +6720,7 @@ enum POUT_INFO_FLAG_MASKS */ typedef struct { - uint16_t idx; ///< 0..::RECEIVER_INFO::n_prg_out-1 + MBG_MSG_IDX idx; ///< 0..::RECEIVER_INFO::n_prg_out-1 POUT_INFO pout_info; } POUT_INFO_IDX; @@ -6414,9 +6784,10 @@ do \ */ enum MULTI_REF_TYPES { - /// This ref type must not be used as index, but marks particular - /// ::XMULTI_REF_SETTINGS structures as "unused". It is only - /// supported if bit ::XMRIF_BIT_MRF_NONE_SUPP is set. + /// @brief This ref type must not be used as index. + /// + /// It marks particular ::XMULTI_REF_SETTINGS structures as "unused". + /// This is only supported if bit ::XMRIF_BIT_MRF_NONE_SUPP is set. MULTI_REF_NONE = -1, MULTI_REF_GPS = 0, ///< standard GPS @@ -6437,6 +6808,8 @@ enum MULTI_REF_TYPES MULTI_REF_HAVEQUICK, ///< HaveQuick input MULTI_REF_EXT_OSC, ///< external oscillator disciplined and looped back via 1 PPS I/O MULTI_REF_SYNCE, ///< Synchronous Ethernet, needs (external) ethernet interface + MULTI_REF_VIDEO_IN, ///< Video In (Blackburst, VITC,...) + MULTI_REF_LTC, ///< Linear Time Code (Audio) N_MULTI_REF ///< the number of defined sources, must not exceed ::MAX_N_MULTI_REF_TYPES }; @@ -6473,7 +6846,9 @@ enum MULTI_REF_TYPES "GNSS Receiver", \ "HaveQuick Input", \ "ext. Osc.", \ - "Synchronous Ethernet" \ + "Synchronous Ethernet", \ + "Video Input", \ + "Linear Time Code" \ } /** @@ -6502,7 +6877,9 @@ enum MULTI_REF_TYPES "GNSS", \ "HQI", \ "EXT", \ - "SYNCE" \ + "SYNCE", \ + "VIDEO_IN", \ + "LTC" \ } @@ -6516,26 +6893,29 @@ enum MULTI_REF_TYPES * * @anchor MULTI_REF_TYPE_MASKS @{ */ -#define HAS_MULTI_REF_GPS ( 1UL << MULTI_REF_GPS ) ///< see ::MULTI_REF_GPS -#define HAS_MULTI_REF_10MHZ ( 1UL << MULTI_REF_10MHZ ) ///< see ::MULTI_REF_10MHZ -#define HAS_MULTI_REF_PPS ( 1UL << MULTI_REF_PPS ) ///< see ::MULTI_REF_PPS -#define HAS_MULTI_REF_10MHZ_PPS ( 1UL << MULTI_REF_10MHZ_PPS ) ///< see ::MULTI_REF_10MHZ_PPS -#define HAS_MULTI_REF_IRIG ( 1UL << MULTI_REF_IRIG ) ///< see ::MULTI_REF_IRIG -#define HAS_MULTI_REF_NTP ( 1UL << MULTI_REF_NTP ) ///< see ::MULTI_REF_NTP -#define HAS_MULTI_REF_PTP ( 1UL << MULTI_REF_PTP ) ///< see ::MULTI_REF_PTP -#define HAS_MULTI_REF_PTP_E1 ( 1UL << MULTI_REF_PTP_E1 ) ///< see ::MULTI_REF_PTP_E1 - -#define HAS_MULTI_REF_FREQ ( 1UL << MULTI_REF_FREQ ) ///< see ::MULTI_REF_FREQ -#define HAS_MULTI_REF_PPS_STRING ( 1UL << MULTI_REF_PPS_STRING ) ///< see ::MULTI_REF_PPS_STRING -#define HAS_MULTI_REF_GPIO ( 1UL << MULTI_REF_GPIO ) ///< see ::MULTI_REF_GPIO -#define HAS_MULTI_REF_INTERNAL ( 1UL << MULTI_REF_INTERNAL ) ///< see ::MULTI_REF_INTERNAL -#define HAS_MULTI_REF_PZF ( 1UL << MULTI_REF_PZF ) ///< see ::MULTI_REF_PZF -#define HAS_MULTI_REF_LWR ( 1UL << MULTI_REF_LWR ) ///< see ::MULTI_REF_LWR -#define HAS_MULTI_REF_GRC ( 1UL << MULTI_REF_GRC ) ///< see ::MULTI_REF_GRC -#define HAS_MULTI_REF_HAVEQUICK ( 1UL << MULTI_REF_HAVEQUICK ) ///< see ::MULTI_REF_HAVEQUICK - -#define HAS_MULTI_REF_EXT_OSC ( 1UL << MULTI_REF_EXT_OSC ) ///< see ::MULTI_REF_EXT_OSC -#define HAS_MULTI_REF_SYNCE ( 1UL << MULTI_REF_SYNCE ) ///< see ::MULTI_REF_SYNCE +#define HAS_MULTI_REF_GPS ( 1UL << MULTI_REF_GPS ) ///< See ::MULTI_REF_GPS +#define HAS_MULTI_REF_10MHZ ( 1UL << MULTI_REF_10MHZ ) ///< See ::MULTI_REF_10MHZ +#define HAS_MULTI_REF_PPS ( 1UL << MULTI_REF_PPS ) ///< See ::MULTI_REF_PPS +#define HAS_MULTI_REF_10MHZ_PPS ( 1UL << MULTI_REF_10MHZ_PPS ) ///< See ::MULTI_REF_10MHZ_PPS +#define HAS_MULTI_REF_IRIG ( 1UL << MULTI_REF_IRIG ) ///< See ::MULTI_REF_IRIG +#define HAS_MULTI_REF_NTP ( 1UL << MULTI_REF_NTP ) ///< See ::MULTI_REF_NTP +#define HAS_MULTI_REF_PTP ( 1UL << MULTI_REF_PTP ) ///< See ::MULTI_REF_PTP +#define HAS_MULTI_REF_PTP_E1 ( 1UL << MULTI_REF_PTP_E1 ) ///< See ::MULTI_REF_PTP_E1 + +#define HAS_MULTI_REF_FREQ ( 1UL << MULTI_REF_FREQ ) ///< See ::MULTI_REF_FREQ +#define HAS_MULTI_REF_PPS_STRING ( 1UL << MULTI_REF_PPS_STRING ) ///< See ::MULTI_REF_PPS_STRING +#define HAS_MULTI_REF_GPIO ( 1UL << MULTI_REF_GPIO ) ///< See ::MULTI_REF_GPIO +#define HAS_MULTI_REF_INTERNAL ( 1UL << MULTI_REF_INTERNAL ) ///< See ::MULTI_REF_INTERNAL +#define HAS_MULTI_REF_PZF ( 1UL << MULTI_REF_PZF ) ///< See ::MULTI_REF_PZF +#define HAS_MULTI_REF_LWR ( 1UL << MULTI_REF_LWR ) ///< See ::MULTI_REF_LWR +#define HAS_MULTI_REF_GRC ( 1UL << MULTI_REF_GRC ) ///< See ::MULTI_REF_GRC +#define HAS_MULTI_REF_HAVEQUICK ( 1UL << MULTI_REF_HAVEQUICK ) ///< See ::MULTI_REF_HAVEQUICK + +#define HAS_MULTI_REF_EXT_OSC ( 1UL << MULTI_REF_EXT_OSC ) ///< See ::MULTI_REF_EXT_OSC +#define HAS_MULTI_REF_SYNCE ( 1UL << MULTI_REF_SYNCE ) ///< See ::MULTI_REF_SYNCE +#define HAS_MULTI_REF_VIDEO_IN ( 1UL << MULTI_REF_VIDEO_IN ) ///< See ::MULTI_REF_VIDEO_IN +#define HAS_MULTI_REF_LTC ( 1UL << MULTI_REF_LTC ) ///< See ::MULTI_REF_LTC + /** @} anchor MULTI_REF_TYPE_MASKS */ @@ -6630,15 +7010,15 @@ enum MULTI_REF_STATUS_BITS */ enum MULTI_REF_STATUS_BIT_MASKS { - MSK_WRN_COLD_BOOT = ( 1UL << WRN_COLD_BOOT ), ///< see ::WRN_COLD_BOOT - MSK_WRN_WARM_BOOT = ( 1UL << WRN_WARM_BOOT ), ///< see ::WRN_WARM_BOOT - MSK_WRN_ANT_DISCONN = ( 1UL << WRN_ANT_DISCONN ), ///< see ::WRN_ANT_DISCONN - MSK_WRN_10MHZ_UNLOCK = ( 1UL << WRN_10MHZ_UNLOCK ), ///< see ::WRN_10MHZ_UNLOCK - MSK_WRN_1PPS_UNLOCK = ( 1UL << WRN_1PPS_UNLOCK ), ///< see ::WRN_1PPS_UNLOCK - MSK_WRN_GPS_UNLOCK = ( 1UL << WRN_GPS_UNLOCK ), ///< see ::WRN_GPS_UNLOCK - MSK_WRN_10MHZ_MISSING = ( 1UL << WRN_10MHZ_MISSING ), ///< see ::WRN_10MHZ_MISSING - MSK_WRN_1PPS_MISSING = ( 1UL << WRN_1PPS_MISSING ), ///< see ::WRN_1PPS_MISSING - MSK_WRN_MODULE_MODE = ( 1UL << WRN_MODULE_MODE ) ///< see ::WRN_MODULE_MODE + MSK_WRN_COLD_BOOT = ( 1UL << WRN_COLD_BOOT ), ///< See ::WRN_COLD_BOOT + MSK_WRN_WARM_BOOT = ( 1UL << WRN_WARM_BOOT ), ///< See ::WRN_WARM_BOOT + MSK_WRN_ANT_DISCONN = ( 1UL << WRN_ANT_DISCONN ), ///< See ::WRN_ANT_DISCONN + MSK_WRN_10MHZ_UNLOCK = ( 1UL << WRN_10MHZ_UNLOCK ), ///< See ::WRN_10MHZ_UNLOCK + MSK_WRN_1PPS_UNLOCK = ( 1UL << WRN_1PPS_UNLOCK ), ///< See ::WRN_1PPS_UNLOCK + MSK_WRN_GPS_UNLOCK = ( 1UL << WRN_GPS_UNLOCK ), ///< See ::WRN_GPS_UNLOCK + MSK_WRN_10MHZ_MISSING = ( 1UL << WRN_10MHZ_MISSING ), ///< See ::WRN_10MHZ_MISSING + MSK_WRN_1PPS_MISSING = ( 1UL << WRN_1PPS_MISSING ), ///< See ::WRN_1PPS_MISSING + MSK_WRN_MODULE_MODE = ( 1UL << WRN_MODULE_MODE ) ///< See ::WRN_MODULE_MODE }; /** @} defgroup group_multi_ref_old */ @@ -6700,7 +7080,7 @@ enum MULTI_REF_STATUS_BIT_MASKS */ typedef struct { - uint8_t type; ///< see ::MULTI_REF_TYPES, and note for ::XMRIF_BIT_MRF_NONE_SUPP + uint8_t type; ///< See ::MULTI_REF_TYPES, and note for ::XMRIF_BIT_MRF_NONE_SUPP uint8_t instance; ///< instance number, if multiple instances are supported, else 0 } XMULTI_REF_ID; @@ -6720,7 +7100,7 @@ do \ typedef struct { XMULTI_REF_ID id; ///< reference time source identifier - uint16_t flags; ///< see ::XMR_SETTINGS_FLAG_MSKS and ::XMR_EXT_SRC_INFO::supp_flags + uint16_t flags; ///< See ::XMR_SETTINGS_FLAG_MSKS and ::XMR_EXT_SRC_INFO::supp_flags NANO_TIME bias; ///< time bias, e.g. path delay @todo specify sign vs. earlier/later NANO_TIME precision; ///< precision of the time source uint32_t reserved; ///< reserved, currently always 0 @@ -6748,8 +7128,8 @@ do \ */ typedef struct { - uint16_t idx; ///< the priority level index (highest == 0), 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1 - XMULTI_REF_SETTINGS settings; ///< the settings configured for this level + MBG_MSG_IDX idx; ///< The priority level index, 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1, 0 == highest. + XMULTI_REF_SETTINGS settings; ///< The settings configured for this level. } XMULTI_REF_SETTINGS_IDX; @@ -6783,13 +7163,13 @@ enum XMR_SETTINGS_FLAG_BITS */ enum XMR_SETTINGS_FLAG_MSKS { - XMRSF_MSK_AUTO_BIAS_MASTER = ( 1UL << XMRSF_BIT_AUTO_BIAS_MASTER ), ///< see ::XMRSF_BIT_AUTO_BIAS_MASTER - XMRSF_MSK_AUTO_BIAS_SLAVE = ( 1UL << XMRSF_BIT_AUTO_BIAS_SLAVE ), ///< see ::XMRSF_BIT_AUTO_BIAS_SLAVE - XMRSF_MSK_ASYMMETRY_STEP_DETECTION = ( 1UL << XMRSF_BIT_ASYMMETRY_STEP_DETECTION ), ///< see ::XMRSF_BIT_ASYMMETRY_STEP_DETECTION - XMRSF_MSK_IS_TRUSTED_SRC = ( 1UL << XMRSF_BIT_IS_TRUSTED_SRC ), ///< see ::XMRSF_BIT_IS_TRUSTED_SRC - XMRSF_MSK_USE_TRUSTED_SRC = ( 1UL << XMRSF_BIT_USE_TRUSTED_SRC ), ///< see ::XMRSF_BIT_USE_TRUSTED_SRC - XMRSF_MSK_IS_TIME_OF_DAY_SRC = ( 1UL << XMRSF_BIT_IS_TIME_OF_DAY_SRC ), ///< see ::XMRSF_BIT_IS_TIME_OF_DAY_SRC - XMRSF_MSK_IS_PHASE_SRC = ( 1UL << XMRSF_BIT_IS_PHASE_SRC ) ///< see ::XMRSF_BIT_IS_PHASE_SRC + XMRSF_MSK_AUTO_BIAS_MASTER = ( 1UL << XMRSF_BIT_AUTO_BIAS_MASTER ), ///< See ::XMRSF_BIT_AUTO_BIAS_MASTER + XMRSF_MSK_AUTO_BIAS_SLAVE = ( 1UL << XMRSF_BIT_AUTO_BIAS_SLAVE ), ///< See ::XMRSF_BIT_AUTO_BIAS_SLAVE + XMRSF_MSK_ASYMMETRY_STEP_DETECTION = ( 1UL << XMRSF_BIT_ASYMMETRY_STEP_DETECTION ), ///< See ::XMRSF_BIT_ASYMMETRY_STEP_DETECTION + XMRSF_MSK_IS_TRUSTED_SRC = ( 1UL << XMRSF_BIT_IS_TRUSTED_SRC ), ///< See ::XMRSF_BIT_IS_TRUSTED_SRC + XMRSF_MSK_USE_TRUSTED_SRC = ( 1UL << XMRSF_BIT_USE_TRUSTED_SRC ), ///< See ::XMRSF_BIT_USE_TRUSTED_SRC + XMRSF_MSK_IS_TIME_OF_DAY_SRC = ( 1UL << XMRSF_BIT_IS_TIME_OF_DAY_SRC ), ///< See ::XMRSF_BIT_IS_TIME_OF_DAY_SRC + XMRSF_MSK_IS_PHASE_SRC = ( 1UL << XMRSF_BIT_IS_PHASE_SRC ) ///< See ::XMRSF_BIT_IS_PHASE_SRC }; @@ -6803,7 +7183,7 @@ typedef struct /** * @deprecated Deprecated by ::XMULTI_REF_INSTANCES::n_inst. - * If ::GPS_HAS_XMRS_MULT_INSTC is *not* set then this field provides + * If ::GPS_HAS_XMRS_MULT_INSTC is ***not*** set then this field provides * a bit mask of supported sources (see @ref MULTI_REF_TYPE_MASKS), * and only a single instance of each source signal type is supported. */ @@ -6811,7 +7191,7 @@ typedef struct /** * @deprecated Deprecated by ::XMULTI_REF_INSTANCES::n_xmr_settings. - * If ::GPS_HAS_XMRS_MULT_INSTC is *not* set then this field + * If ::GPS_HAS_XMRS_MULT_INSTC is ***not*** set then this field * reports the number of priority levels supported by the device. */ uint8_t n_supp_ref; @@ -6838,8 +7218,8 @@ do \ */ typedef struct { - uint16_t idx; ///< the priority level index (highest == 0), 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1 - XMULTI_REF_INFO info; ///< ref source configuration and capabilities + MBG_MSG_IDX idx; ///< The priority level index, 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1, 0 == highest. + XMULTI_REF_INFO info; ///< Ref. source configuration and capabilities. } XMULTI_REF_INFO_IDX; @@ -6884,8 +7264,8 @@ do \ */ typedef struct { - uint16_t idx; ///< the priority level index (highest == 0), 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1 - XMULTI_REF_STATUS status; ///< status information + MBG_MSG_IDX idx; ///< The priority level index, 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1, 0 == highest. + XMULTI_REF_STATUS status; ///< Status information. } XMULTI_REF_STATUS_IDX; @@ -6970,19 +7350,19 @@ enum XMR_REF_STATUS_BITS * * @anchor XMR_REF_STATUS_BIT_MASKS @{ */ -#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP ) ///< see ::XMRS_BIT_NOT_SUPP -#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN ) ///< see ::XMRS_BIT_NO_CONN -#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL ) ///< see ::XMRS_BIT_NO_SIGNAL -#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER ) ///< see ::XMRS_BIT_IS_MASTER -#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED ) ///< see ::XMRS_BIT_IS_LOCKED -#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE ) ///< see ::XMRS_BIT_IS_ACCURATE -#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED ) ///< see ::XMRS_BIT_NOT_SETTLED -#define XMRS_MSK_NOT_PHASE_LOCKED ( 1UL << XMRS_BIT_NOT_PHASE_LOCKED ) ///< see ::XMRS_BIT_NOT_PHASE_LOCKED -#define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC ) ///< see ::XMRS_BIT_NUM_SRC_EXC -#define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL ) ///< see ::XMRS_BIT_IS_EXTERNAL -#define XMRS_MSK_LOW_JITTER ( 1UL << XMRS_BIT_LOW_JITTER ) ///< see ::XMRS_BIT_LOW_JITTER -#define XMRS_MSK_ITU_LIMIT_VIOLATED ( 1UL << XMRS_BIT_ITU_LIMIT_VIOLATED ) ///< see ::XMRS_BIT_ITU_LIMIT_VIOLATED -#define XMRS_MSK_TRS_LIMIT_VIOLATED ( 1UL << XMRS_BIT_TRS_LIMIT_VIOLATED ) ///< see ::XMRS_BIT_TRS_LIMIT_VIOLATED +#define XMRS_MSK_NOT_SUPP ( 1UL << XMRS_BIT_NOT_SUPP ) ///< See ::XMRS_BIT_NOT_SUPP +#define XMRS_MSK_NO_CONN ( 1UL << XMRS_BIT_NO_CONN ) ///< See ::XMRS_BIT_NO_CONN +#define XMRS_MSK_NO_SIGNAL ( 1UL << XMRS_BIT_NO_SIGNAL ) ///< See ::XMRS_BIT_NO_SIGNAL +#define XMRS_MSK_IS_MASTER ( 1UL << XMRS_BIT_IS_MASTER ) ///< See ::XMRS_BIT_IS_MASTER +#define XMRS_MSK_IS_LOCKED ( 1UL << XMRS_BIT_IS_LOCKED ) ///< See ::XMRS_BIT_IS_LOCKED +#define XMRS_MSK_IS_ACCURATE ( 1UL << XMRS_BIT_IS_ACCURATE ) ///< See ::XMRS_BIT_IS_ACCURATE +#define XMRS_MSK_NOT_SETTLED ( 1UL << XMRS_BIT_NOT_SETTLED ) ///< See ::XMRS_BIT_NOT_SETTLED +#define XMRS_MSK_NOT_PHASE_LOCKED ( 1UL << XMRS_BIT_NOT_PHASE_LOCKED ) ///< See ::XMRS_BIT_NOT_PHASE_LOCKED +#define XMRS_MSK_NUM_SRC_EXC ( 1UL << XMRS_BIT_NUM_SRC_EXC ) ///< See ::XMRS_BIT_NUM_SRC_EXC +#define XMRS_MSK_IS_EXTERNAL ( 1UL << XMRS_BIT_IS_EXTERNAL ) ///< See ::XMRS_BIT_IS_EXTERNAL +#define XMRS_MSK_LOW_JITTER ( 1UL << XMRS_BIT_LOW_JITTER ) ///< See ::XMRS_BIT_LOW_JITTER +#define XMRS_MSK_ITU_LIMIT_VIOLATED ( 1UL << XMRS_BIT_ITU_LIMIT_VIOLATED ) ///< See ::XMRS_BIT_ITU_LIMIT_VIOLATED +#define XMRS_MSK_TRS_LIMIT_VIOLATED ( 1UL << XMRS_BIT_TRS_LIMIT_VIOLATED ) ///< See ::XMRS_BIT_TRS_LIMIT_VIOLATED /** @} anchor XMR_REF_STATUS_BIT_MASKS */ @@ -7053,7 +7433,7 @@ enum XMR_REF_STATUS_BITS */ typedef struct { - uint32_t flags; ///< see ::XMR_INST_FLAG_BIT_MASKS + uint32_t flags; ///< See ::XMR_INST_FLAG_BIT_MASKS uint16_t n_xmr_settings; ///< number of ::XMULTI_REF_INFO_IDX or ::XMULTI_REF_STATUS_IDX which can be retrieved uint8_t slot_id; ///< ID of the slot in which this device is installed, 0 or up to 15, if multiple slots not supported uint8_t reserved; ///< reserved, don't use, currently always 0 @@ -7071,12 +7451,37 @@ do \ /** + * @brief Extended information about the reference source of an instance type. + */ +typedef struct +{ + uint8_t integrated [MAX_N_MULTI_REF_TYPES]; ///< See ::SYS_REF_SRC_INTEGRATED + uint8_t peripheral [MAX_N_MULTI_REF_TYPES]; ///< See ::SYS_REF_SRC_PERIPHERAL + uint8_t expansion [MAX_N_MULTI_REF_TYPES]; ///< See ::SYS_REF_SRC_EXPANSION + uint8_t autarkic [MAX_N_MULTI_REF_TYPES]; ///< See ::SYS_REF_SRC_AUTARKIC + uint8_t reserved_1 [MAX_N_MULTI_REF_TYPES]; + uint8_t reserved_2 [MAX_N_MULTI_REF_TYPES]; + uint8_t reserved_3 [MAX_N_MULTI_REF_TYPES]; + uint8_t reserved_4 [MAX_N_MULTI_REF_TYPES]; + +} XMULTI_EXT_REF_INSTANCES; + +#define _mbg_swab_xmulti_ext_ref_instances( _p ) \ +do \ +{ \ +} while ( 0 ) + + + +/** * @brief Enumeration of flag bits used with XMULTI_REF instances * * @see ::XMR_INST_FLAG_BIT_MASKS */ enum XMR_INST_FLAGS { + /// @brief Indicate that the ::MULTI_REF_NONE pseude-type is supported is supported. + /// /// This flag indicates that configuration programs may set /// ::XMULTI_REF_ID::type to ::MULTI_REF_NONE in ::XMULTI_REF_SETTINGS::id /// for unused priority levels, and that this will be reflected in @@ -7084,12 +7489,16 @@ enum XMR_INST_FLAGS /// this was not supported. XMRIF_BIT_MRF_NONE_SUPP, - XMRIF_BIT_HOLDOVER_STATUS_SUPP, ///< ::XMR_HOLDOVER_STATUS and associated types supported + XMRIF_BIT_HOLDOVER_STATUS_SUPP, ///< ::XMR_HOLDOVER_STATUS and associated types supported. - XMRIF_BIT_EXT_SRC_INFO_SUPP, ///< ::XMR_EXT_SRC_INFO structure supported - XMRIF_BIT_GNSS_BIAS_SUPP, ///< ::MULTI_REF_GPS or MULTI_REF_GRC can use XMULTI_REF_SETTINGS::bias + XMRIF_BIT_EXT_SRC_INFO_SUPP, ///< ::XMR_EXT_SRC_INFO structure supported. + XMRIF_BIT_GNSS_BIAS_SUPP, ///< ::MULTI_REF_GPS or MULTI_REF_GRC can use XMULTI_REF_SETTINGS::bias. - N_XMRIF_BITS ///< number of known flag bits + XMRIF_BIT_EXT_REF_INSTANCES_SUPP, ///< Supports ::XMULTI_EXT_REF_INSTANCES structure. + XMRIF_BIT_NOT_CONFIGURABLE, ///< ::XMULTI_REF_SETTINGS cannot be configured. + XMRIF_BIT_NO_STATUS, ///< No status, no stats at all. NOTHING!!! + + N_XMRIF_BITS ///< Number of known flag bits. }; @@ -7102,10 +7511,13 @@ enum XMR_INST_FLAGS */ enum XMR_INST_FLAG_BIT_MASKS { - XMRIF_MSK_MRF_NONE_SUPP = ( 1UL << XMRIF_BIT_MRF_NONE_SUPP ), ///< see ::XMRIF_BIT_MRF_NONE_SUPP - XMRIF_MSK_HOLDOVER_STATUS_SUPP = ( 1UL << XMRIF_BIT_HOLDOVER_STATUS_SUPP ), ///< see ::XMRIF_BIT_HOLDOVER_STATUS_SUPP - XMRIF_MSK_EXT_SRC_INFO_SUPP = ( 1UL << XMRIF_BIT_EXT_SRC_INFO_SUPP ), ///< see ::XMRIF_BIT_EXT_SRC_INFO_SUPP - XMRIF_MSK_GNSS_BIAS_SUPP = ( 1UL << XMRIF_BIT_GNSS_BIAS_SUPP ) ///< see ::XMRIF_BIT_GNSS_BIAS_SUPP + XMRIF_MSK_MRF_NONE_SUPP = ( 1UL << XMRIF_BIT_MRF_NONE_SUPP ), ///< See ::XMRIF_BIT_MRF_NONE_SUPP + XMRIF_MSK_HOLDOVER_STATUS_SUPP = ( 1UL << XMRIF_BIT_HOLDOVER_STATUS_SUPP ), ///< See ::XMRIF_BIT_HOLDOVER_STATUS_SUPP + XMRIF_MSK_EXT_SRC_INFO_SUPP = ( 1UL << XMRIF_BIT_EXT_SRC_INFO_SUPP ), ///< See ::XMRIF_BIT_EXT_SRC_INFO_SUPP + XMRIF_MSK_GNSS_BIAS_SUPP = ( 1UL << XMRIF_BIT_GNSS_BIAS_SUPP ), ///< See ::XMRIF_BIT_GNSS_BIAS_SUPP + XMRIF_MSK_EXT_REF_INSTANCES_SUPP = ( 1UL << XMRIF_BIT_EXT_REF_INSTANCES_SUPP ), ///< See ::XMRIF_BIT_EXT_REF_INSTANCES_SUPP + XMRIF_MSK_NOT_CONFIGURABLE = ( 1UL << XMRIF_BIT_NOT_CONFIGURABLE ), ///< See ::XMRIF_BIT_NOT_CONFIGURABLE + XMRIF_MSK_NO_STATUS = ( 1UL << XMRIF_BIT_NO_STATUS ) ///< See ::XMRIF_BIT_NO_STATUS }; @@ -7154,7 +7566,7 @@ typedef uint32_t XMR_HOLDOVER_INTV; * starts to count down. If the watchdog expires before a remote switch command * has been received the device switches to ::XMR_HLDOVR_AUTONOMOUS. */ -typedef struct +typedef struct xmr_holdover_status_s { uint8_t mode; ///< XMR/holdover mode, see ::XMR_HOLDOVER_STATUS_MODES int8_t curr_prio; ///< current priority level, 0..::XMULTI_REF_INSTANCES::n_xmr_settings, or ::XMR_PRIO_LVL_UNSPEC @@ -7235,10 +7647,10 @@ enum XMR_HOLDOVER_STATUS_FLAG_BITS */ enum XMR_HOLDOVER_STATUS_FLAG_MASKS { - XMR_HLDOVR_MSK_IN_HOLDOVER = ( 1UL << XMR_HLDOVR_BIT_IN_HOLDOVER ), ///< see ::XMR_HLDOVR_BIT_IN_HOLDOVER - XMR_HLDOVR_MSK_TRANSITION_ENBD = ( 1UL << XMR_HLDOVR_BIT_TRANSITION_ENBD ), ///< see ::XMR_HLDOVR_BIT_TRANSITION_ENBD - XMR_HLDOVR_MSK_IN_TRANSITION = ( 1UL << XMR_HLDOVR_BIT_IN_TRANSITION ), ///< see ::XMR_HLDOVR_BIT_IN_TRANSITION - XMR_HLDOVR_MSK_TIME_OFFS_VALID = ( 1UL << XMR_HLDOVR_BIT_TIME_OFFS_VALID ) ///< see ::XMR_HLDOVR_BIT_TIME_OFFS_VALID + XMR_HLDOVR_MSK_IN_HOLDOVER = ( 1UL << XMR_HLDOVR_BIT_IN_HOLDOVER ), ///< See ::XMR_HLDOVR_BIT_IN_HOLDOVER + XMR_HLDOVR_MSK_TRANSITION_ENBD = ( 1UL << XMR_HLDOVR_BIT_TRANSITION_ENBD ), ///< See ::XMR_HLDOVR_BIT_TRANSITION_ENBD + XMR_HLDOVR_MSK_IN_TRANSITION = ( 1UL << XMR_HLDOVR_BIT_IN_TRANSITION ), ///< See ::XMR_HLDOVR_BIT_IN_TRANSITION + XMR_HLDOVR_MSK_TIME_OFFS_VALID = ( 1UL << XMR_HLDOVR_BIT_TIME_OFFS_VALID ) ///< See ::XMR_HLDOVR_BIT_TIME_OFFS_VALID }; @@ -7250,9 +7662,11 @@ enum XMR_HOLDOVER_STATUS_FLAG_MASKS */ enum XMR_EXT_SRC_FEAT_FLAG_BITS { - XMR_EXT_SRC_FEAT_FLAG_BIT_STATS, ///< XMR source provides ::XMR_STATS - XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS, ///< XMR source provides ::XMR_METRICS - XMR_EXT_SRC_FEAT_FLAG_BIT_COASTING, ///< XMR source provides coasting mode + XMR_EXT_SRC_FEAT_FLAG_BIT_STATS, ///< XMR source provides ::XMR_STATS. + XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS, ///< XMR source provides ::XMR_METRICS. + XMR_EXT_SRC_FEAT_FLAG_BIT_COASTING, ///< XMR source supports coasting mode. + XMR_EXT_SRC_FEAT_FLAG_BIT_ADV_METRICS, ///< XMR source supports advanced XMR QL metrics configuration, see ::XMR_QL_LIMITS. + ///< If this feature is not available, ::XMR_METRICS can not be configured. N_XMR_EXT_SRC_FEAT_FLAG_BITS }; @@ -7267,17 +7681,18 @@ enum XMR_EXT_SRC_FEAT_FLAG_BITS */ enum XMR_EXT_SRC_FEAT_FLAG_MSKS { - XMR_EXT_SRC_FEAT_FLAG_MSK_STATS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_STATS ), ///< see ::XMR_EXT_SRC_FEAT_FLAG_BIT_STATS - XMR_EXT_SRC_FEAT_FLAG_MSK_METRICS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS ), ///< see ::XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS - XMR_EXT_SRC_FEAT_FLAG_MSK_COASTING = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_COASTING ) ///< see ::XMR_EXT_SRC_FEAT_FLAG_BIT_COASTING + XMR_EXT_SRC_FEAT_FLAG_MSK_STATS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_STATS ), ///< See ::XMR_EXT_SRC_FEAT_FLAG_BIT_STATS. + XMR_EXT_SRC_FEAT_FLAG_MSK_METRICS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS ), ///< See ::XMR_EXT_SRC_FEAT_FLAG_BIT_METRICS. + XMR_EXT_SRC_FEAT_FLAG_MSK_COASTING = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_COASTING ), ///< See ::XMR_EXT_SRC_FEAT_FLAG_BIT_COASTING. + XMR_EXT_SRC_FEAT_FLAG_MSK_ADV_METRICS = ( 1UL << XMR_EXT_SRC_FEAT_FLAG_BIT_ADV_METRICS ) ///< See ::XMR_EXT_SRC_FEAT_FLAG_BIT_ADV_METRICS. }; typedef struct { - uint16_t supp_flags; ///< indicates which flags are supported by ::XMULTI_REF_SETTINGS::flags, see ::XMR_SETTINGS_FLAG_MSKS - uint16_t feat_flags; ///< see ::XMR_EXT_SRC_FEAT_FLAG_MSKS + uint16_t supp_flags; ///< Indicates which flags are supported by ::XMULTI_REF_SETTINGS::flags, see ::XMR_SETTINGS_FLAG_MSKS. + uint16_t feat_flags; ///< See ::XMR_EXT_SRC_FEAT_FLAG_MSKS. uint32_t reserved_0; } XMR_EXT_SRC_INFO; @@ -7318,9 +7733,9 @@ do \ * @see ::XMR_EXT_SRC_INFO::feat_flags * @see ::XMR_EXT_SRC_FEAT_FLAG_MSK_STATS */ -typedef struct +typedef struct xmr_stats_s { - uint32_t timestamp; ///< time stamp when the record was taken, UTC, seconds since 1970 + uint32_t timestamp; ///< time stamp when the record was taken, %UTC, seconds since 1970 NANO_TIME last_mue; ///< mean value (mue) of prev. interval NANO_TIME last_sigma; ///< standard deviation (sigma) of prev. interval NANO_TIME last_max; ///< maximum value within interval @@ -7330,7 +7745,7 @@ typedef struct NANO_TIME auto_bias; ///< current time automatic bias compensation uint32_t reserved_1; ///< currently reserved, unused, always 0 uint32_t reserved_2; ///< currently reserved, unused, always 0 - uint32_t flags; ///< see ::XMR_STATS_FLAGS_MSKS + uint32_t flags; ///< See ::XMR_STATS_FLAGS_MSKS } XMR_STATS; @@ -7374,9 +7789,9 @@ enum XMR_STATS_FLAGS_BITS */ enum XMR_STATS_FLAGS_MSKS { - XMR_STATS_FLAG_MSK_STEP_DETECTED = ( 1UL << XMR_STATS_FLAG_BIT_STEP_DETECTED ), ///< see ::XMR_STATS_FLAG_BIT_STEP_DETECTED - XMR_STATS_FLAG_MSK_STEP_COMPENSATED = ( 1UL << XMR_STATS_FLAG_BIT_STEP_COMPENSATED ), ///< see ::XMR_STATS_FLAG_BIT_STEP_COMPENSATED - XMR_STATS_FLAG_MSK_AUTO_BIAS_VALID = ( 1UL << XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID ) ///< see ::XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID + XMR_STATS_FLAG_MSK_STEP_DETECTED = ( 1UL << XMR_STATS_FLAG_BIT_STEP_DETECTED ), ///< See ::XMR_STATS_FLAG_BIT_STEP_DETECTED + XMR_STATS_FLAG_MSK_STEP_COMPENSATED = ( 1UL << XMR_STATS_FLAG_BIT_STEP_COMPENSATED ), ///< See ::XMR_STATS_FLAG_BIT_STEP_COMPENSATED + XMR_STATS_FLAG_MSK_AUTO_BIAS_VALID = ( 1UL << XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID ) ///< See ::XMR_STATS_FLAG_BIT_AUTO_BIAS_VALID }; @@ -7402,8 +7817,8 @@ enum XMR_STATS_FLAGS_MSKS */ typedef struct { - uint16_t idx; ///< the priority level index (highest == 0), 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1 - XMR_STATS stats; ///< XMR statistics of the particular source + MBG_MSG_IDX idx; ///< The priority level index, 0..::XMULTI_REF_INSTANCES::n_xmr_settings-1, 0 == highest. + XMR_STATS stats; ///< XMR statistics of the particular source. } XMR_STATS_IDX; @@ -7491,6 +7906,7 @@ do \ */ enum ITU_LIMITS { + ITU_LIMIT_NONE, ITU_LIMIT_G811_PRC, ITU_LIMIT_G823_SSU, ITU_LIMIT_G823_SEC, @@ -7511,6 +7927,7 @@ enum ITU_LIMITS */ enum ITU_LIMIT_MASKS { + MSK_ITU_LIMIT_NONE = ( 1UL << ITU_LIMIT_NONE ), MSK_ITU_LIMIT_G811_PRC = ( 1UL << ITU_LIMIT_G811_PRC ), MSK_ITU_LIMIT_G823_SSU = ( 1UL << ITU_LIMIT_G823_SSU ), MSK_ITU_LIMIT_G823_SEC = ( 1UL << ITU_LIMIT_G823_SEC ), @@ -7530,6 +7947,7 @@ enum ITU_LIMIT_MASKS */ #define ITU_LIMIT_SHORT_STRS \ { \ + "None", \ "G811 (PRC)", \ "G823 (SSU)", \ "G823 (SEC)", \ @@ -7540,48 +7958,58 @@ enum ITU_LIMIT_MASKS /** - * @brief supported limits for qualtity metrics + * @brief Supported limits for qualtity metrics * * @see ::XMR_METRICS */ typedef struct { - uint8_t ql_mask; ///< see :ITU_LIMIT_MASKS - uint8_t hysteresis; ///< hysteresis (percent) between yellow and red alarm - uint16_t reserved_0; - uint32_t reserved_1; + uint32_t supp_ql_masks; ///< see :ITU_LIMIT_MASKS. Masks apply to all sources! + uint32_t reserved_0; + uint32_t reserved_1; + uint32_t reserved_2; -} XMR_QL_SETTINGS; +} XMR_QL_LIMITS; + +#define _mbg_swab_xmr_ql_limits( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->supp_ql_masks ); \ +} while ( 0 ) typedef struct { - uint32_t supp_ql_masks; ///< see :ITU_LIMIT_MASKS - uint32_t reserved_0; - uint32_t reserved_1; - XMR_QL_SETTINGS settings; + uint8_t ql_mask; ///< see :ITU_LIMIT_MASKS + uint8_t hysteresis; ///< hysteresis (percent) between yellow and red alarm + uint16_t reserved_0; + uint32_t reserved_1; -} XMR_QL_INFO; +} XMR_QL_SETTINGS; + +#define _mbg_swab_xmr_ql_settings( _p ) \ +do \ +{ \ +} while ( 0 ) typedef struct { - uint16_t idx; + uint32_t idx; XMR_QL_SETTINGS settings; } XMR_QL_SETTINGS_IDX; +#define _mbg_swab_xmr_ql_settings_idx( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_xmr_ql_settings( &(_p)->settings ); \ +} while ( 0 ) -typedef struct -{ - uint16_t idx; - XMR_QL_INFO info; - -} XMR_QL_INFO_IDX; - /** @} defgroup group_multi_ref_ext */ @@ -7609,7 +8037,7 @@ typedef struct { uint32_t num_io; ///< number of supported GPIO ports uint32_t reserved; ///< reserved, currently always 0 - uint32_t flags; ///< see ::MBG_GPIO_CFG_LIMIT_FLAG_MASKS + uint32_t flags; ///< See ::MBG_GPIO_CFG_LIMIT_FLAG_MASKS } MBG_GPIO_CFG_LIMITS; @@ -7645,7 +8073,7 @@ enum MBG_GPIO_CFG_LIMIT_FLAG_BITS */ enum MBG_GPIO_CFG_LIMIT_FLAG_MASKS { - MBG_GPIO_CFG_LIMIT_FLAG_MASK_STATUS_SUPP = ( 1UL << MBG_GPIO_CFG_LIMIT_FLAG_BIT_STATUS_SUPP ), ///< see ::MBG_GPIO_CFG_LIMIT_FLAG_BIT_STATUS_SUPP + MBG_GPIO_CFG_LIMIT_FLAG_MASK_STATUS_SUPP = ( 1UL << MBG_GPIO_CFG_LIMIT_FLAG_BIT_STATUS_SUPP ), ///< See ::MBG_GPIO_CFG_LIMIT_FLAG_BIT_STATUS_SUPP }; @@ -7671,6 +8099,8 @@ enum MBG_GPIO_TYPES MBG_GPIO_TYPE_VIDEO_SYNC_OUT, ///< Video sync signal output (H-Sync, V-Sync, ...) MBG_GPIO_TYPE_STUDIO_CLOCK_OUT, ///< Studio clock output MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT, ///< Digital Audio output (DARS, ...) + MBG_GPIO_TYPE_VIDEO_IN, ///< Video signal output (PAL, NTSC, ...) + MBG_GPIO_TYPE_LTC_OUT, ///< Linear Timecode output N_MBG_GPIO_TYPES ///< Number of known types }; @@ -7686,7 +8116,9 @@ enum MBG_GPIO_TYPES "Video Out", \ "Video Sync Out", \ "Studio Clock Out", \ - "Digital Audio Out" \ + "Digital Audio Out", \ + "Video In", \ + "LTC Out" \ } @@ -7721,9 +8153,9 @@ enum MBG_GPIO_SIGNAL_SHAPES */ enum MBG_GPIO_SIGNAL_SHAPE_MASKS { - MBG_GPIO_SIGNAL_SHAPE_MSK_UNSPECIFIED = ( 1UL << MBG_GPIO_SIGNAL_SHAPE_UNSPECIFIED ), ///< see ::MBG_GPIO_SIGNAL_SHAPE_UNSPECIFIED - MBG_GPIO_SIGNAL_SHAPE_MSK_SINE = ( 1UL << MBG_GPIO_SIGNAL_SHAPE_SINE ), ///< see ::MBG_GPIO_SIGNAL_SHAPE_SINE - MBG_GPIO_SIGNAL_SHAPE_MSK_SQUARE = ( 1UL << MBG_GPIO_SIGNAL_SHAPE_SQUARE ) ///< see ::MBG_GPIO_SIGNAL_SHAPE_SQUARE + MBG_GPIO_SIGNAL_SHAPE_MSK_UNSPECIFIED = ( 1UL << MBG_GPIO_SIGNAL_SHAPE_UNSPECIFIED ), ///< See ::MBG_GPIO_SIGNAL_SHAPE_UNSPECIFIED + MBG_GPIO_SIGNAL_SHAPE_MSK_SINE = ( 1UL << MBG_GPIO_SIGNAL_SHAPE_SINE ), ///< See ::MBG_GPIO_SIGNAL_SHAPE_SINE + MBG_GPIO_SIGNAL_SHAPE_MSK_SQUARE = ( 1UL << MBG_GPIO_SIGNAL_SHAPE_SQUARE ) ///< See ::MBG_GPIO_SIGNAL_SHAPE_SQUARE }; @@ -7917,14 +8349,14 @@ enum MBG_GPIO_FIXED_FREQS */ enum MBG_GPIO_FIXED_FREQ_MASKS { - MSK_MBG_GPIO_FIXED_FREQ_8kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_8kHz ), ///< see ::MBG_GPIO_FIXED_FREQ_8kHz - MSK_MBG_GPIO_FIXED_FREQ_48kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_48kHz ), ///< see ::MBG_GPIO_FIXED_FREQ_48kHz - MSK_MBG_GPIO_FIXED_FREQ_1MHz = ( 1UL << MBG_GPIO_FIXED_FREQ_1MHz ), ///< see ::MBG_GPIO_FIXED_FREQ_1MHz - MSK_MBG_GPIO_FIXED_FREQ_1544kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_1544kHz ), ///< see ::MBG_GPIO_FIXED_FREQ_1544kHz - MSK_MBG_GPIO_FIXED_FREQ_2048kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_2048kHz ), ///< see ::MBG_GPIO_FIXED_FREQ_2048kHz - MSK_MBG_GPIO_FIXED_FREQ_5MHz = ( 1UL << MBG_GPIO_FIXED_FREQ_5MHz ), ///< see ::MBG_GPIO_FIXED_FREQ_5MHz - MSK_MBG_GPIO_FIXED_FREQ_10MHz = ( 1UL << MBG_GPIO_FIXED_FREQ_10MHz ), ///< see ::MBG_GPIO_FIXED_FREQ_10MHz - MSK_MBG_GPIO_FIXED_FREQ_19440kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_19440kHz ) ///< see ::MBG_GPIO_FIXED_FREQ_19440kHz + MSK_MBG_GPIO_FIXED_FREQ_8kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_8kHz ), ///< See ::MBG_GPIO_FIXED_FREQ_8kHz + MSK_MBG_GPIO_FIXED_FREQ_48kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_48kHz ), ///< See ::MBG_GPIO_FIXED_FREQ_48kHz + MSK_MBG_GPIO_FIXED_FREQ_1MHz = ( 1UL << MBG_GPIO_FIXED_FREQ_1MHz ), ///< See ::MBG_GPIO_FIXED_FREQ_1MHz + MSK_MBG_GPIO_FIXED_FREQ_1544kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_1544kHz ), ///< See ::MBG_GPIO_FIXED_FREQ_1544kHz + MSK_MBG_GPIO_FIXED_FREQ_2048kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_2048kHz ), ///< See ::MBG_GPIO_FIXED_FREQ_2048kHz + MSK_MBG_GPIO_FIXED_FREQ_5MHz = ( 1UL << MBG_GPIO_FIXED_FREQ_5MHz ), ///< See ::MBG_GPIO_FIXED_FREQ_5MHz + MSK_MBG_GPIO_FIXED_FREQ_10MHz = ( 1UL << MBG_GPIO_FIXED_FREQ_10MHz ), ///< See ::MBG_GPIO_FIXED_FREQ_10MHz + MSK_MBG_GPIO_FIXED_FREQ_19440kHz = ( 1UL << MBG_GPIO_FIXED_FREQ_19440kHz ) ///< See ::MBG_GPIO_FIXED_FREQ_19440kHz }; @@ -8030,10 +8462,10 @@ enum MBG_GPIO_BITS_FORMATS */ enum MBG_GPIO_BITS_FORMAT_MASKS { - MSK_MBG_GPIO_BITS_E1_FRAMED = ( 1UL << MBG_GPIO_BITS_E1_FRAMED ), ///< see ::MBG_GPIO_BITS_E1_FRAMED - MSK_MBG_GPIO_BITS_T1_FRAMED = ( 1UL << MBG_GPIO_BITS_T1_FRAMED ), ///< see ::MBG_GPIO_BITS_T1_FRAMED - MSK_MBG_GPIO_BITS_E1_TIMING = ( 1UL << MBG_GPIO_BITS_E1_TIMING ), ///< see ::MBG_GPIO_BITS_E1_TIMING - MSK_MBG_GPIO_BITS_T1_TIMING = ( 1UL << MBG_GPIO_BITS_T1_TIMING ) ///< see ::MBG_GPIO_BITS_T1_TIMING + MSK_MBG_GPIO_BITS_E1_FRAMED = ( 1UL << MBG_GPIO_BITS_E1_FRAMED ), ///< See ::MBG_GPIO_BITS_E1_FRAMED + MSK_MBG_GPIO_BITS_T1_FRAMED = ( 1UL << MBG_GPIO_BITS_T1_FRAMED ), ///< See ::MBG_GPIO_BITS_T1_FRAMED + MSK_MBG_GPIO_BITS_E1_TIMING = ( 1UL << MBG_GPIO_BITS_E1_TIMING ), ///< See ::MBG_GPIO_BITS_E1_TIMING + MSK_MBG_GPIO_BITS_T1_TIMING = ( 1UL << MBG_GPIO_BITS_T1_TIMING ) ///< See ::MBG_GPIO_BITS_T1_TIMING }; @@ -8191,8 +8623,8 @@ enum MBG_GPIO_BITS_ERRS */ enum MBG_GPIO_BITS_ERR_MASKS { - MSK_MBG_GPIO_BITS_ERR_LOS = ( 1UL << MBG_GPIO_BITS_ERR_LOS ), ///< see ::MBG_GPIO_BITS_ERR_LOS - MSK_MBG_GPIO_BITS_ERR_LOF = ( 1UL << MBG_GPIO_BITS_ERR_LOF ) ///< see ::MBG_GPIO_BITS_ERR_LOF + MSK_MBG_GPIO_BITS_ERR_LOS = ( 1UL << MBG_GPIO_BITS_ERR_LOS ), ///< See ::MBG_GPIO_BITS_ERR_LOS + MSK_MBG_GPIO_BITS_ERR_LOF = ( 1UL << MBG_GPIO_BITS_ERR_LOF ) ///< See ::MBG_GPIO_BITS_ERR_LOF }; @@ -8283,8 +8715,8 @@ enum MBG_GPIO_BITS_OUT_FLAGS */ enum MBG_GPIO_BITS_OUT_FLAG_MASKS { - MSK_MBG_GPIO_BITS_OUT_FLAG_HDB3 = ( 1UL << MBG_GPIO_BITS_OUT_FLAG_HDB3 ), ///< see ::MBG_GPIO_BITS_OUT_FLAG_HDB3 - MSK_MBG_GPIO_BITS_OUT_FLAG_B8ZS = ( 1UL << MBG_GPIO_BITS_OUT_FLAG_B8ZS ) ///< see ::MBG_GPIO_BITS_OUT_FLAG_B8ZS + MSK_MBG_GPIO_BITS_OUT_FLAG_HDB3 = ( 1UL << MBG_GPIO_BITS_OUT_FLAG_HDB3 ), ///< See ::MBG_GPIO_BITS_OUT_FLAG_HDB3 + MSK_MBG_GPIO_BITS_OUT_FLAG_B8ZS = ( 1UL << MBG_GPIO_BITS_OUT_FLAG_B8ZS ) ///< See ::MBG_GPIO_BITS_OUT_FLAG_B8ZS }; @@ -8356,14 +8788,14 @@ enum MBG_GPIO_VIDEO_FORMATS */ enum MBG_GPIO_VIDEO_FORMAT_MASKS { - MSK_MBG_GPIO_VIDEO_FORMAT_OFF = ( 1UL << MBG_GPIO_VIDEO_FORMAT_OFF ), ///< see ::MBG_GPIO_VIDEO_FORMAT_OFF - MSK_MBG_GPIO_VIDEO_SD_FORMAT_NTSC = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_NTSC ), ///< see ::MBG_GPIO_VIDEO_SD_FORMAT_NTSC - MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_PAL ), ///< see ::MBG_GPIO_VIDEO_SD_FORMAT_PAL - MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz - MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz - MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz - MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz ), ///< see ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz - MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL_M = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_PAL_M ) ///< see ::MBG_GPIO_VIDEO_SD_FORMAT_PAL_M + MSK_MBG_GPIO_VIDEO_FORMAT_OFF = ( 1UL << MBG_GPIO_VIDEO_FORMAT_OFF ), ///< See ::MBG_GPIO_VIDEO_FORMAT_OFF + MSK_MBG_GPIO_VIDEO_SD_FORMAT_NTSC = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_NTSC ), ///< See ::MBG_GPIO_VIDEO_SD_FORMAT_NTSC + MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_PAL ), ///< See ::MBG_GPIO_VIDEO_SD_FORMAT_PAL + MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz ), ///< See ::MBG_GPIO_VIDEO_HD_FORMAT_720_P_50Hz + MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz ), ///< See ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_50Hz + MSK_MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz ), ///< See ::MBG_GPIO_VIDEO_HD_FORMAT_720_P_59_94Hz + MSK_MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz = ( 1UL << MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz ), ///< See ::MBG_GPIO_VIDEO_HD_FORMAT_1080_I_59_94Hz + MSK_MBG_GPIO_VIDEO_SD_FORMAT_PAL_M = ( 1UL << MBG_GPIO_VIDEO_SD_FORMAT_PAL_M ) ///< See ::MBG_GPIO_VIDEO_SD_FORMAT_PAL_M }; @@ -8384,12 +8816,12 @@ enum MBG_GPIO_VIDEO_FORMAT_MASKS /** - * @brief Initializers for an array of video output name strings + * @brief Initializers for an array of video format strings * * @see ::MBG_GPIO_VIDEO_FORMATS * @see ::MBG_GPIO_VIDEO_FORMAT_MASKS */ -#define MBG_GPIO_VIDEO_OUT_STRS \ +#define MBG_GPIO_VIDEO_FORMAT_STRS \ { \ "OFF", \ "NTSC (525i)", \ @@ -8424,8 +8856,8 @@ enum MBG_GPIO_VIDEO_OUT_FLAGS */ enum MBG_GPIO_VIDEO_OUT_FLAG_MASKS { - MSK_MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF = ( 1UL << MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF ), ///< see ::MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF - MSK_MBG_GPIO_VIDEO_OUT_HAS_TC_SD = ( 1UL << MBG_GPIO_VIDEO_OUT_HAS_TC_SD ) ///< see ::MBG_GPIO_VIDEO_OUT_HAS_TC_SD + MSK_MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF = ( 1UL << MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF ), ///< See ::MBG_GPIO_VIDEO_OUT_HAS_NO_FREE_CONF + MSK_MBG_GPIO_VIDEO_OUT_HAS_TC_SD = ( 1UL << MBG_GPIO_VIDEO_OUT_HAS_TC_SD ) ///< See ::MBG_GPIO_VIDEO_OUT_HAS_TC_SD }; @@ -8459,10 +8891,10 @@ enum MBG_GPIO_VIDEO_EPOCHS */ enum MBG_GPIO_VIDEO_EPOCH_MASKS { - MSK_SMPTE_TAI_EPOCH_1970 = ( 1UL << SMPTE_TAI_EPOCH_1970 ), ///< see ::SMPTE_TAI_EPOCH_1970 - MSK_SMPTE_TAI_EPOCH_1958 = ( 1UL << SMPTE_TAI_EPOCH_1958 ), ///< see ::SMPTE_TAI_EPOCH_1958 - MSK_SMPTE_UTC_EPOCH_1972 = ( 1UL << SMPTE_UTC_EPOCH_1972 ), ///< see ::SMPTE_UTC_EPOCH_1972 - MSK_SMPTE_GPS_EPOCH_1980 = ( 1UL << SMPTE_GPS_EPOCH_1980 ) ///< see ::SMPTE_GPS_EPOCH_1980 + MSK_SMPTE_TAI_EPOCH_1970 = ( 1UL << SMPTE_TAI_EPOCH_1970 ), ///< See ::SMPTE_TAI_EPOCH_1970 + MSK_SMPTE_TAI_EPOCH_1958 = ( 1UL << SMPTE_TAI_EPOCH_1958 ), ///< See ::SMPTE_TAI_EPOCH_1958 + MSK_SMPTE_UTC_EPOCH_1972 = ( 1UL << SMPTE_UTC_EPOCH_1972 ), ///< See ::SMPTE_UTC_EPOCH_1972 + MSK_SMPTE_GPS_EPOCH_1980 = ( 1UL << SMPTE_GPS_EPOCH_1980 ) ///< See ::SMPTE_GPS_EPOCH_1980 }; @@ -8504,8 +8936,8 @@ enum MBG_GPIO_VIDEO_TC_MODES */ enum MBG_GPIO_VIDEO_TC_MODE_MASKS { - MSK_MBG_GPIO_VIDEO_TC_MODE_NONE = ( 1UL << MBG_GPIO_VIDEO_TC_MODE_NONE ), ///< see ::MBG_GPIO_VIDEO_TC_MODE_NONE - MSK_MBG_GPIO_VIDEO_TC_MODE_VITC = ( 1UL << MBG_GPIO_VIDEO_TC_MODE_VITC ) ///< see ::MBG_GPIO_VIDEO_TC_MODE_VITC + MSK_MBG_GPIO_VIDEO_TC_MODE_NONE = ( 1UL << MBG_GPIO_VIDEO_TC_MODE_NONE ), ///< See ::MBG_GPIO_VIDEO_TC_MODE_NONE + MSK_MBG_GPIO_VIDEO_TC_MODE_VITC = ( 1UL << MBG_GPIO_VIDEO_TC_MODE_VITC ) ///< See ::MBG_GPIO_VIDEO_TC_MODE_VITC }; @@ -8765,9 +9197,9 @@ enum MBG_GPIO_STUDIO_CLOCK_BASE_FREQS */ enum MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_MASKS { - MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ ), ///< see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ - MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ ), ///< see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ - MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ ) ///< see ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ + MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ ), ///< See ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_32KHZ + MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ ), ///< See ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_44_1KHZ + MSK_MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ = ( 1UL << MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ ) ///< See ::MBG_GPIO_STUDIO_CLOCK_BASE_FREQ_48KHZ }; @@ -8826,21 +9258,21 @@ enum MBG_GPIO_STUDIO_CLOCK_SCALES */ enum MBG_GPIO_STUDIO_CLOCK_SCALE_MASKS { - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_1 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_2 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_2 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_2 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_4 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_4 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_4 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_8 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_8 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_8 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_16 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_16 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_16 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_32 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_32 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_32 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_64 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_64 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_64 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_128 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_128 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_128 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_256 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_256 ), ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_256 - MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_512 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_512 ) ///< see ::MBG_GPIO_STUDIO_CLOCK_SCALE_512 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_32 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_16 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_8 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_4 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_1_DIV_2 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_1 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_1 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_1 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_2 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_2 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_2 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_4 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_4 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_4 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_8 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_8 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_8 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_16 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_16 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_16 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_32 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_32 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_32 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_64 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_64 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_64 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_128 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_128 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_128 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_256 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_256 ), ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_256 + MSK_MBG_GPIO_STUDIO_CLOCK_SCALE_512 = ( 1U << MBG_GPIO_STUDIO_CLOCK_SCALE_512 ) ///< See ::MBG_GPIO_STUDIO_CLOCK_SCALE_512 }; @@ -8892,7 +9324,7 @@ enum MBG_GPIO_STUDIO_CLOCK_FLAGS */ enum MBG_GPIO_STUDIO_CLOCK_FLAG_MASKS { - MSK_MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED = ( 1UL << MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED ) ///< see ::MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED + MSK_MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED = ( 1UL << MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED ) ///< See ::MBG_GPIO_STUDIO_CLOCK_OUTPUT_ENABLED }; @@ -8990,8 +9422,8 @@ enum MBG_GPIO_DIGITAL_AUDIO_TYPES */ enum MBG_GPIO_DIGITAL_AUDIO_TYPE_MASKS { - MSK_MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF ), ///< see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF - MSK_MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS ) ///< see ::MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS + MSK_MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF ), ///< See ::MBG_GPIO_DIGITAL_AUDIO_TYPE_OFF + MSK_MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS ) ///< See ::MBG_GPIO_DIGITAL_AUDIO_TYPE_DARS }; @@ -9029,7 +9461,7 @@ enum MBG_GPIO_DIGITAL_AUDIO_FLAGS */ enum MBG_GPIO_DIGITAL_AUDIO_FLAG_MASKS { - MSK_MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG ) ///< see ::MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG + MSK_MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG = ( 1UL << MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG ) ///< See ::MBG_GPIO_DIGITAL_AUDIO_RESERVED_FLAG }; @@ -9052,6 +9484,8 @@ typedef struct } MBG_GPIO_DIGITAL_AUDIO_OUT_SETTINGS; + + #define _mbg_swab_mbg_gpio_digital_audio_out_settings( _p ) \ do \ { \ @@ -9082,6 +9516,8 @@ typedef struct } MBG_GPIO_DIGITAL_AUDIO_OUT_SUPP; + + #define _mbg_swab_mbg_gpio_digital_audio_out_supp( _p ) \ do \ { \ @@ -9095,6 +9531,262 @@ do \ /** + * @brief Enumeration of physical video input signal sources + * + * Video can be received over a single or differential signals + * + * @see MBG_GPIO_VIDEO_IN_SETTINGS + */ +enum MBG_GPIO_VIDEO_IN_SIGNAL_SRCS +{ + MBG_GPIO_VIDEO_IN_SIGNAL_SRC_SES, ///< single-ended signal video input + MBG_GPIO_VIDEO_IN_SIGNAL_SRC_DIFFERENTIAL, ///< differential signal line video input + N_MBG_GPIO_VIDEO_IN_SIGNAL_SRCS ///< number of possible signal sources +}; + + + +/** + * @brief Bit masks associated with ::MBG_GPIO_VIDEO_IN_SIGNAL_SRCS + * + * Used with ::MBG_GPIO_VIDEO_IN_SETTINGS::tc_mode + * + */ +enum MBG_GPIO_VIDEO_IN_SIGNAL_SRC_MASKS +{ + MSK_MBG_GPIO_VIDEO_IN_SIGNAL_SRC_SES = ( 1UL << MBG_GPIO_VIDEO_IN_SIGNAL_SRC_SES ), ///< See ::MBG_GPIO_VIDEO_IN_SIGNAL_SRC_SES + MSK_MBG_GPIO_VIDEO_IN_SIGNAL_SRC_DIFFERENTIAL = ( 1UL << MBG_GPIO_VIDEO_IN_SIGNAL_SRC_DIFFERENTIAL ) ///< See ::MBG_GPIO_VIDEO_IN_SIGNAL_SRC_DIFFERENTIAL +}; + + + + +/** + * @brief Initializers for an array of video signal input source strings + * + * @see ::MBG_GPIO_VIDEO_IN_SIGNAL_SRCS + * @see ::MBG_GPIO_VIDEO_IN_SIGNAL_SRC_MASKS + */ +#define MBG_GPIO_VIDEO_IN_SIGNAL_SRC_STRS \ +{ \ + "Single-ended signal input", \ + "Differential signal input" \ +} + + + +/** + * @brief Configuration of a GPIO as video input module + * + * Used as sub-structure of ::MBG_GPIO_SETTINGS + * + * @see ::MBG_GPIO_TYPE_VIDEO_IN + * @see ::MBG_GPIO_SETTINGS + */ +typedef struct +{ + uint32_t format; ///< video format, see ::MBG_GPIO_VIDEO_FORMATS + + uint8_t epoch; ///< epoch, see ::MBG_GPIO_VIDEO_EPOCHS + uint8_t signal_src; ///< video input signal source, see ::MBG_GPIO_VIDEO_IN_SIGNAL_SRCS + uint8_t tc_mode; ///< time code mode, see ::MBG_GPIO_VIDEO_TC_MODES + uint8_t tc_line; ///< time code line location, valid lines: 6-22 + + uint32_t reserved0; ///< reserved, currently always 0 + uint32_t reserved1; ///< reserved, currently always 0 + uint32_t reserved2; ///< reserved, currently always 0 +} MBG_GPIO_VIDEO_IN_SETTINGS; + + + +#define _mbg_swab_mbg_gpio_video_in_settings( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->format ); \ + _mbg_swab8( &(_p)->epoch ); \ + _mbg_swab8( &(_p)->signal_src ); \ + _mbg_swab8( &(_p)->tc_mode ); \ + _mbg_swab8( &(_p)->tc_line ); \ + _mbg_swab32( &(_p)->reserved0 ); \ + _mbg_swab32( &(_p)->reserved1 ); \ + _mbg_swab32( &(_p)->reserved2 ); \ +} while ( 0 ) + + + +typedef struct +{ + uint32_t supp_formats; ///< supported video formats, see ::MBG_GPIO_VIDEO_FORMAT_MASKS + uint32_t supp_epochs; ///< supported epochs, see ::MBG_GPIO_VIDEO_EPOCH_MASKS + + uint32_t supp_signal_srcs; ///< video input signal sources, see ::MBG_GPIO_VIDEO_IN_SIGNAL_SRC_MASKS + uint32_t supp_tc_modes; ///< time code mode, see ::MBG_GPIO_VIDEO_TC_MODE_MASKS + + uint32_t reserved0; ///< reserved, currently always 0 + uint32_t reserved1; ///< reserved, currently always 0 + uint32_t reserved2; ///< reserved, currently always 0 + +} MBG_GPIO_VIDEO_IN_SUPP; + + + +#define _mbg_swab_mbg_gpio_video_in_supp( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->supp_formats ); \ + _mbg_swab32( &(_p)->supp_epochs ); \ + _mbg_swab32( &(_p)->supp_signal_srcs ); \ + _mbg_swab32( &(_p)->supp_tc_modes ); \ + _mbg_swab32( &(_p)->reserved0 ); \ + _mbg_swab32( &(_p)->reserved1 ); \ + _mbg_swab32( &(_p)->reserved2 ); \ + _mbg_swab32( &(_p)->reserved3 ); \ +} while ( 0 ) + + +/** + * @brief Enumeration of types used with GPIO type LTC outputs + * + * Used with ::MBG_GPIO_LTC_OUT_SETTINGS::type, and to + * define ::MBG_GPIO_LTC_OUT_TYPE_MASKS + * + * @see ::MBG_GPIO_LTC_OUT_TYPE_MASKS + * @see ::MBG_GPIO_LTC_OUT_TYPE_STRS + */ +enum MBG_GPIO_LTC_OUT_TYPES +{ + MBG_GPIO_LTC_OUT_OFF, + MBG_GPIO_LTC_OUT_TYPE_24FPS_23_976Hz, + MBG_GPIO_LTC_OUT_TYPE_24FPS, + MBG_GPIO_LTC_OUT_TYPE_25FPS, + MBG_GPIO_LTC_OUT_TYPE_30FPS, + MBG_GPIO_LTC_OUT_TYPE_30FPS_DROP_FRAME, + N_MBG_GPIO_LTC_OUT_TYPES ///< number of known types +}; + + + +/** + * @brief Bit masks associated with ::MBG_GPIO_LTC_OUT_TYPES + * + * Used with :: MBG_GPIO_TYPE_LTC_OUT_SUPP::supp_types + * + * @see ::MBG_GPIO_LTC_OUT_TYPES + */ +enum MBG_GPIO_LTC_OUT_TYPE_MASKS +{ + MSK_MBG_GPIO_LTC_OUT_OFF = ( 1UL << MBG_GPIO_LTC_OUT_OFF ), ///< See ::MBG_GPIO_LTC_OUT_OFF + MSK_MBG_GPIO_LTC_OUT_TYPE_24FPS_23_976Hz = ( 1UL << MBG_GPIO_LTC_OUT_TYPE_24FPS_23_976Hz ), ///< See ::MBG_GPIO_LTC_OUT_TYPE_24FPS_23_976Hz + MSK_MBG_GPIO_LTC_OUT_TYPE_24FPS = ( 1UL << MBG_GPIO_LTC_OUT_TYPE_24FPS ), ///< See ::MBG_GPIO_LTC_OUT_TYPE_24FPS + MSK_MBG_GPIO_LTC_OUT_TYPE_25FPS = ( 1UL << MBG_GPIO_LTC_OUT_TYPE_25FPS ), ///< See ::MBG_GPIO_LTC_OUT_TYPE_25FPS + MSK_MBG_GPIO_LTC_OUT_TYPE_30FPS = ( 1UL << MBG_GPIO_LTC_OUT_TYPE_30FPS ), ///< See ::MBG_GPIO_LTC_OUT_TYPE_30FPS + MSK_MBG_GPIO_LTC_OUT_TYPE_30FPS_DROP_FRAME = ( 1UL << MBG_GPIO_LTC_OUT_TYPE_30FPS_DROP_FRAME ) ///< See ::MBG_GPIO_LTC_OUT_TYPE_30FPS_DROP_FRAME +}; + +/** + * @brief Initializers for an array of ltc out strings + * + * @see ::MBG_GPIO_LTC_OUT_TYPES + */ +#define MBG_GPIO_LTC_OUT_TYPE_STRS \ +{ \ + "OFF", \ + "LTC 24FPS / 23.976Hz", \ + "LTC 24FPS", \ + "LTC 25FPS", \ + "LTC 30FPS", \ + "LTC 30FPS Drop Frame" \ +} + +/** + * @brief Enumeration of flags used with GPIO type LTC outputs + */ +enum MBG_GPIO_LTC_OUT_FLAGS +{ + MBG_GPIO_LTC_OUT_RESERVED_FLAG, ///< reserved + N_MBG_GPIO_LTC_OUT_FLAGS ///< number of known flags +}; + + + +/** + * @brief Bit masks associated with ::MBG_GPIO_LTC_OUT_FLAGS + * + * Used with ::MBG_GPIO_LTC_OUT_SETTINGS::flags + * + * @see ::MBG_GPIO_LTC_OUT_FLAGS + */ +enum MBG_GPIO_LTC_OUT_FLAG_MASKS +{ + MSK_MBG_GPIO_LTC_OUT_RESERVED_FLAG = ( 1UL << MBG_GPIO_LTC_OUT_RESERVED_FLAG ) ///< See ::MBG_GPIO_LTC_OUT_RESERVED_FLAG +}; + + + +/** + * @brief Configuration of a GPIO LTC output + * + * Used as sub-structure of ::MBG_GPIO_SETTINGS. + * + * @see ::MBG_GPIO_TYPE_LTC_OUT + * @see ::MBG_GPIO_SETTINGS + */ +typedef struct +{ + uint32_t type; ///< LTC type, see ::MBG_GPIO_LTC_OUT_TYPES + uint32_t flags; ///< reserved, currently always 0 + uint32_t reserved0; ///< reserved, currently always 0 + uint32_t reserved1; ///< reserved, currently always 0 + uint32_t reserved2; ///< reserved, currently always 0 + +} MBG_GPIO_LTC_OUT_SETTINGS; + + + +#define _mbg_swab_mbg_gpio_ltc_out_settings( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->type ); \ + _mbg_swab32( &(_p)->flags ); \ + _mbg_swab32( &(_p)->reserved0 ); \ + _mbg_swab32( &(_p)->reserved1 ); \ + _mbg_swab32( &(_p)->reserved2 ); \ +} while ( 0 ) + + + +/** + * @brief Supported options for LTC output + * + * Used as sub-structure of ::MBG_GPIO_LIMITS. + * + * @see ::MBG_GPIO_TYPE_LTC_OUT + * @see ::MBG_GPIO_LIMITS + */ +typedef struct +{ + uint32_t supp_types; ///< Supported LTC types, see ::MBG_GPIO_LTC_OUT_TYPE_MASKS. + uint32_t supp_flags; ///< Reserved, currently always 0. + uint32_t reserved_0; ///< Reserved, currently always 0. + uint32_t reserved_1; ///< Reserved, currently always 0. + uint32_t reserved_2; ///< Reserved, currently always 0. + +} MBG_GPIO_LTC_OUT_SUPP; + + +#define _mbg_swab_mbg_gpio_ltc_out_supp( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->supp_types ); \ + _mbg_swab32( &(_p)->supp_flags ); \ + _mbg_swab32( &(_p)->reserved_0 ); \ + _mbg_swab32( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ +} while ( 0 ) + + + +/** * @brief Enumeration of general flags used with a GPIO * * @see ::MBG_GPIO_FLAG_MASKS @@ -9102,50 +9794,55 @@ do \ enum MBG_GPIO_FLAGS { MBG_GPIO_DEPENDS_ON_ASS_IO_IDX, ///< indicates that this output depends on GPIO with ::MBG_GPIO_SETTINGS::ass_io_idx and may not be configured independently + MBG_GPIO_PORT_INVISIBLE, ///< gpio is used internally and should not be displayed by config apps N_MBG_GPIO_FLAGS ///< number of known flags }; /** - * @brief Bit masks associated with ::MBG_GPIO_FLAGS + * @brief Bit masks associated with ::MBG_GPIO_FLAGS. * - * Used with ::MBG_GPIO_LIMITS::supp_flags and ::MBG_GPIO_SETTINGS::flags + * Used with ::MBG_GPIO_LIMITS::supp_flags and ::MBG_GPIO_SETTINGS::flags. * * @see ::MBG_GPIO_FLAGS */ enum MBG_GPIO_FLAG_MASKS { - MSK_MBG_GPIO_DEPENDS_ON_ASS_IO_IDX = ( 1UL << MBG_GPIO_DEPENDS_ON_ASS_IO_IDX ) ///< see ::MBG_GPIO_DEPENDS_ON_ASS_IO_IDX + MSK_MBG_GPIO_DEPENDS_ON_ASS_IO_IDX = ( 1UL << MBG_GPIO_DEPENDS_ON_ASS_IO_IDX ), ///< See ::MBG_GPIO_DEPENDS_ON_ASS_IO_IDX + MSK_MBG_GPIO_PORT_INVISIBLE = ( 1UL << MBG_GPIO_PORT_INVISIBLE ) ///< See ::MBG_GPIO_PORT_INVISIBLE }; /** - * @brief A generic structure used to hold a GPIO port's settings + * @brief A generic structure used to hold the settings of a GPIO port. */ typedef struct { - uint32_t type; ///< GPIO type, see ::MBG_GPIO_TYPES + uint32_t type; ///< GPIO type, see ::MBG_GPIO_TYPES. - uint16_t reserved_1; ///< reserved, currently always 0 - uint8_t reserved_2; ///< reserved, currently always 0 - uint8_t ass_io_idx; ///< associated GPIO index, only valid if ::MSK_MBG_GPIO_DEPENDS_ON_ASS_IO_IDX is set in flags field + uint16_t reserved_1; ///< Reserved, currently always 0. + uint8_t reserved_2; ///< Reserved, currently always 0. + uint8_t ass_io_idx; ///< Associated GPIO index, only valid if ::MSK_MBG_GPIO_DEPENDS_ON_ASS_IO_IDX is set in flags field. - uint32_t flags; ///< flags, see ::MBG_GPIO_FLAG_MASKS + uint32_t flags; ///< Flags, see ::MBG_GPIO_FLAG_MASKS. - /// settings depending on the GPIO type, see ::MBG_GPIO_TYPES + /// @brief Settings depending on the GPIO @a #type, see ::MBG_GPIO_TYPES. union { - MBG_GPIO_FREQ_IN_SETTINGS freq_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN - MBG_GPIO_FREQ_OUT_SETTINGS freq_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT - MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT - MBG_GPIO_BITS_IN_SETTINGS bits_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN - MBG_GPIO_BITS_OUT_SETTINGS bits_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT - MBG_GPIO_VIDEO_OUT_SETTINGS video_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT - MBG_GPIO_VIDEO_SYNC_OUT_SETTINGS video_sync_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT - MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS studio_clk_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT - MBG_GPIO_DIGITAL_AUDIO_OUT_SETTINGS digital_audio_out; ///< if ::MBG_GPIO_SETTINGS::type is ::;MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT + uint32_t b[6]; ///< Just to indicate the size of this union. + MBG_GPIO_FREQ_IN_SETTINGS freq_in; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN + MBG_GPIO_FREQ_OUT_SETTINGS freq_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT + MBG_GPIO_FIXED_FREQ_OUT_SETTINGS ff_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT + MBG_GPIO_BITS_IN_SETTINGS bits_in; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN + MBG_GPIO_BITS_OUT_SETTINGS bits_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT + MBG_GPIO_VIDEO_OUT_SETTINGS video_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT + MBG_GPIO_VIDEO_SYNC_OUT_SETTINGS video_sync_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT + MBG_GPIO_STUDIO_CLOCK_OUT_SETTINGS studio_clk_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT + MBG_GPIO_DIGITAL_AUDIO_OUT_SETTINGS digital_audio_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT + MBG_GPIO_VIDEO_IN_SETTINGS video_in; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_IN + MBG_GPIO_LTC_OUT_SETTINGS ltc_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_LTC_OUT } u; } MBG_GPIO_SETTINGS; @@ -9172,6 +9869,8 @@ do case MBG_GPIO_TYPE_VIDEO_SYNC_OUT : _mbg_swab_mbg_gpio_video_sync_out_settings( &(_p)->u.video_sync_out ); break; \ case MBG_GPIO_TYPE_STUDIO_CLOCK_OUT : _mbg_swab_mbg_gpio_studio_clock_out_settings( &(_p)->u.studio_clk_out ); break; \ case MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT : _mbg_swab_mbg_gpio_digital_audio_out_settings( &(_p)->u.digital_audio_out ); break; \ + case MBG_GPIO_TYPE_VIDEO_IN : _mbg_swab_mbg_gpio_video_in_settings( &(_p)->u.video_in ); break; \ + case MBG_GPIO_TYPE_LTC_OUT : _mbg_swab_mbg_gpio_ltc_out_settings( &(_p)->u.ltc_out ); break; \ default : break; \ } \ } while ( 0 ) @@ -9179,12 +9878,12 @@ do /** - * @brief A GPIO port's current settings, plus port index + * @brief The current settings of a GPIO port, plus port index. */ typedef struct { - uint32_t idx; ///< port index, 0..::MBG_GPIO_CFG_LIMITS::num_io-1 - MBG_GPIO_SETTINGS settings; ///< current settings + MBG_MSG_IDX_32 idx; ///< GPIO port index, 0..::MBG_GPIO_CFG_LIMITS::num_io-1. + MBG_GPIO_SETTINGS settings; ///< Current settings } MBG_GPIO_SETTINGS_IDX; @@ -9198,7 +9897,7 @@ do \ /** - * @brief A generic structure used to specify a GPIO port's limits + * @brief A generic structure used to specify the limits of a GPIO port. */ typedef struct { @@ -9206,18 +9905,21 @@ typedef struct uint32_t reserved; ///< reserved, currently always 0 uint32_t supp_flags; ///< supported flags, see ::MBG_GPIO_FLAG_MASKS - /// limits depending on the GPIO type, see ::MBG_GPIO_TYPES + /// Limits depending on the GPIO type, see ::MBG_GPIO_TYPES. union { - MBG_GPIO_FREQ_IN_SUPP freq_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN - MBG_GPIO_FREQ_OUT_SUPP freq_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT - MBG_GPIO_FIXED_FREQ_OUT_SUPP ff_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT - MBG_GPIO_BITS_IN_SUPP bits_in; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN - MBG_GPIO_BITS_OUT_SUPP bits_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT - MBG_GPIO_VIDEO_OUT_SUPP video_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT - MBG_GPIO_VIDEO_SYNC_OUT_SUPP video_sync_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT - MBG_GPIO_STUDIO_CLOCK_OUT_SUPP studio_clk_out; ///< if ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT - MBG_GPIO_DIGITAL_AUDIO_OUT_SUPP digital_audio_out; ///< if ::MBG_GPIO_SETTINGS::type is ::;MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT + uint32_t b[7]; ///< Just to indicate the size of this union. + MBG_GPIO_FREQ_IN_SUPP freq_in; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_IN + MBG_GPIO_FREQ_OUT_SUPP freq_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FREQ_OUT + MBG_GPIO_FIXED_FREQ_OUT_SUPP ff_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_FIXED_FREQ_OUT + MBG_GPIO_BITS_IN_SUPP bits_in; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_IN + MBG_GPIO_BITS_OUT_SUPP bits_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_BITS_OUT + MBG_GPIO_VIDEO_OUT_SUPP video_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_OUT + MBG_GPIO_VIDEO_SYNC_OUT_SUPP video_sync_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_SYNC_OUT + MBG_GPIO_STUDIO_CLOCK_OUT_SUPP studio_clk_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_STUDIO_CLOCK_OUT + MBG_GPIO_DIGITAL_AUDIO_OUT_SUPP digital_audio_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT + MBG_GPIO_VIDEO_IN_SUPP video_in; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_VIDEO_IN + MBG_GPIO_LTC_OUT_SUPP ltc_out; ///< If ::MBG_GPIO_SETTINGS::type is ::MBG_GPIO_TYPE_LTC_OUT } u; } MBG_GPIO_LIMITS; @@ -9242,6 +9944,8 @@ do case MBG_GPIO_TYPE_VIDEO_SYNC_OUT : _mbg_swab_mbg_gpio_video_sync_out_supp( &(_p)->u.video_sync_out ); break; \ case MBG_GPIO_TYPE_STUDIO_CLOCK_OUT : _mbg_swab_mbg_gpio_studio_clock_out_supp( &(_p)->u.studio_clk_out ); break; \ case MBG_GPIO_TYPE_DIGITAL_AUDIO_OUT : _mbg_swab_mbg_gpio_digital_audio_out_supp( &(_p)->u.digital_audio_out ); break; \ + case MBG_GPIO_TYPE_VIDEO_IN : _mbg_swab_mbg_gpio_video_in_supp( &(_p)->u.video_in ); break; \ + case MBG_GPIO_TYPE_LTC_OUT : _mbg_swab_mbg_gpio_ltc_out_supp( &(_p)->u.ltc_out ); break; \ default : break; \ } \ } while ( 0 ) @@ -9249,12 +9953,12 @@ do /** - * @brief A GPIO port's current settings and limits + * @brief The current settings and limits of a GPIO port. */ typedef struct { - MBG_GPIO_SETTINGS settings; ///< current settings - MBG_GPIO_LIMITS limits; ///< limits of this GPIO port + MBG_GPIO_SETTINGS settings; ///< Current settings. + MBG_GPIO_LIMITS limits; ///< Limits of this GPIO port. } MBG_GPIO_INFO; @@ -9268,12 +9972,12 @@ do \ /** - * @brief A GPIO port's current settings and limits, plus port index + * @brief The current settings and limits of a GPIO port, plus port index. */ typedef struct { - uint32_t idx; ///< port index, 0..::MBG_GPIO_CFG_LIMITS::num_io-1 - MBG_GPIO_INFO info; ///< limits and current settings of this GPIO port + MBG_MSG_IDX_32 idx; ///< Port index, 0..::MBG_GPIO_CFG_LIMITS::num_io-1. + MBG_GPIO_INFO info; ///< Limits and current settings of this GPIO port. } MBG_GPIO_INFO_IDX; @@ -9291,11 +9995,11 @@ do \ */ typedef struct { - uint8_t port_state; ///< see ::MBG_GPIO_PORT_STATES - uint8_t reserved_0; ///< reserved, currently unused and always 0 - uint16_t reserved_1; ///< reserved, currently unused and always 0 - uint32_t reserved_2; ///< reserved, currently unused and always 0 - uint32_t reserved_3; ///< reserved, currently unused and always 0 + uint8_t port_state; ///< See ::MBG_GPIO_PORT_STATES. + uint8_t reserved_0; ///< Reserved, currently unused and always 0. + uint16_t reserved_1; ///< Reserved, currently unused and always 0. + uint32_t reserved_2; ///< Reserved, currently unused and always 0. + uint32_t reserved_3; ///< Reserved, currently unused and always 0. } MBG_GPIO_STATUS; @@ -9316,8 +10020,8 @@ do \ */ typedef struct { - uint16_t idx; ///< port index, 0..::MBG_GPIO_CFG_LIMITS::num_io-1 - MBG_GPIO_STATUS status; ///< status information + MBG_MSG_IDX idx; ///< GPIO port index, 0..::MBG_GPIO_CFG_LIMITS::num_io-1. + MBG_GPIO_STATUS status; ///< Status information. } MBG_GPIO_STATUS_IDX; @@ -9399,12 +10103,12 @@ enum HAVEQUICK_FORMATS */ enum HAVEQUICK_FORMAT_MASKS { - HQ_MSK_STANAG4246_1 = ( 1UL << HQ_FMT_STANAG4246_1 ), ///< see ::HQ_FMT_STANAG4246_1 - HQ_MSK_STANAG4246_2 = ( 1UL << HQ_FMT_STANAG4246_2 ), ///< see ::HQ_FMT_STANAG4246_2 - HQ_MSK_STANAG4246_PTTI = ( 1UL << HQ_FMT_STANAG4246_PTTI ), ///< see ::HQ_FMT_STANAG4246_PTTI - HQ_MSK_STANAG4372_SATURN_1 = ( 1UL << HQ_FMT_STANAG4372_SATURN_1 ), ///< see ::HQ_FMT_STANAG4372_SATURN_1 - HQ_MSK_STANAG4372_SATURN_2 = ( 1UL << HQ_FMT_STANAG4372_SATURN_2 ), ///< see ::HQ_FMT_STANAG4372_SATURN_2 - HQ_MSK_STANAG4430_EXTD = ( 1UL << HQ_FMT_STANAG4430_EXTD ) ///< see ::HQ_FMT_STANAG4430_EXTD + HQ_MSK_STANAG4246_1 = ( 1UL << HQ_FMT_STANAG4246_1 ), ///< See ::HQ_FMT_STANAG4246_1 + HQ_MSK_STANAG4246_2 = ( 1UL << HQ_FMT_STANAG4246_2 ), ///< See ::HQ_FMT_STANAG4246_2 + HQ_MSK_STANAG4246_PTTI = ( 1UL << HQ_FMT_STANAG4246_PTTI ), ///< See ::HQ_FMT_STANAG4246_PTTI + HQ_MSK_STANAG4372_SATURN_1 = ( 1UL << HQ_FMT_STANAG4372_SATURN_1 ), ///< See ::HQ_FMT_STANAG4372_SATURN_1 + HQ_MSK_STANAG4372_SATURN_2 = ( 1UL << HQ_FMT_STANAG4372_SATURN_2 ), ///< See ::HQ_FMT_STANAG4372_SATURN_2 + HQ_MSK_STANAG4430_EXTD = ( 1UL << HQ_FMT_STANAG4430_EXTD ) ///< See ::HQ_FMT_STANAG4430_EXTD }; /* @@ -9455,8 +10159,8 @@ enum HAVEQUICK_FORMAT_MASKS */ typedef struct { - uint16_t format; ///< see ::HAVEQUICK_FORMATS - uint16_t flags; ///< see ::HAVEQUICK_FLAG_MASKS + uint16_t format; ///< See ::HAVEQUICK_FORMATS + uint16_t flags; ///< See ::HAVEQUICK_FLAG_MASKS int32_t offset; ///< Tx: unused, Rx: offset of incoming time in [s] uint32_t reserved_0; ///< reserved, currently always 0 uint32_t reserved_1; ///< reserved, currently always 0 @@ -9479,7 +10183,7 @@ do \ typedef struct { HAVEQUICK_SETTINGS settings; ///< current settings - uint32_t supp_formats; ///< see ::HAVEQUICK_FORMAT_MASKS + uint32_t supp_formats; ///< See ::HAVEQUICK_FORMAT_MASKS uint16_t supp_flags; ///< mask of flags supported in settings, see ::HAVEQUICK_FLAG_MASKS uint16_t reserved; ///< reserved, currently always 0 @@ -9518,9 +10222,9 @@ enum HAVEQUICK_FLAG_BITS */ enum HAVEQUICK_FLAG_MASKS { - HQ_MSK_TX_GEN_LOCAL_TIME = ( 1UL << HQ_FLAG_TX_GEN_LOCAL_TIME ), ///< see ::HQ_FLAG_TX_GEN_LOCAL_TIME - HQ_MSK_SIGNAL_INVERTED = ( 1UL << HQ_FLAG_SIGNAL_INVERTED ), ///< see ::HQ_FLAG_SIGNAL_INVERTED - HQ_MSK_USE_EXT_PPS = ( 1UL << HQ_FLAG_USE_EXT_PPS ) ///< see ::HQ_FLAG_USE_EXT_PPS + HQ_MSK_TX_GEN_LOCAL_TIME = ( 1UL << HQ_FLAG_TX_GEN_LOCAL_TIME ), ///< See ::HQ_FLAG_TX_GEN_LOCAL_TIME + HQ_MSK_SIGNAL_INVERTED = ( 1UL << HQ_FLAG_SIGNAL_INVERTED ), ///< See ::HQ_FLAG_SIGNAL_INVERTED + HQ_MSK_USE_EXT_PPS = ( 1UL << HQ_FLAG_USE_EXT_PPS ) ///< See ::HQ_FLAG_USE_EXT_PPS }; /** @} defgroup group_havequick */ @@ -9639,6 +10343,9 @@ enum MBG_EVT_IDS MBG_EVT_ID_UFU_FLASHED, ///< UFU file has been flashed MBG_EVT_ID_UFU_PROGRESS, ///< UFU flashing is in progress MBG_EVT_ID_DATABASE_CONNECTED, ///< Database(s) have been (re-)connected + MBG_EVT_ID_NTP_STATE_SYNC, ///< NTP is sync + MBG_EVT_ID_NTP_STATE_NOT_SYNC, ///< NTP not sync + MBG_EVT_ID_FW_OSV, ///< Firmware has been set to OSV N_MBG_EVT_ID }; @@ -9654,21 +10361,25 @@ enum MBG_EVT_IDS #define ENG_EVT_ID_NAME_ANT_OK "Antenna OK" #define ENG_EVT_ID_NAME_LOW_SATS "Few Sats Only" #define ENG_EVT_ID_NAME_FW_INSTALLED "Firmware installed" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_UNINITIALIZED "PTP state: UNINITIALIZED" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_INITIALIZING "PTP state: INITIALIZING" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_FAULTY "PTP state: FAULTY" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_DISABLED "PTP state: DISABLED" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_LISTENING "PTP state: LISTENING" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_PRE_MASTER "PTP state: PRE_MASTER" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_MASTER "PTP state: MASTER" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_PASSIVE "PTP state: PASSIVE" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_UNCALIBRATED "PTP state: UNCALIBRATED" -#define ENG_EVT_ID_NAME_PTP_PORT_STATE_SLAVE "PTP state: SLAVE" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_UNINITIALIZED "PTP state: Uninitialized" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_INITIALIZING "PTP state: Initializing" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_FAULTY "PTP state: Faulty" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_DISABLED "PTP state: Disabled" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_LISTENING "PTP state: Listening" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_PRE_MASTER "PTP state: Pre-Master" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_MASTER "PTP state: Master" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_PASSIVE "PTP state: Passive" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_UNCALIBRATED "PTP state: Uncalibrated" +#define ENG_EVT_ID_NAME_PTP_PORT_STATE_SLAVE "PTP state: Slave" #define ENG_EVT_ID_NAME_FW_ACTIVATED "Firmware activated" #define ENG_EVT_ID_NAME_FW_DELETED "Firmware deleted" #define ENG_EVT_ID_NAME_FW_ROLLBACK "Firmware rollback" #define ENG_EVT_ID_NAME_UFU_FLASHED "UFU flashed" +#define ENG_EVT_ID_NAME_UFU_PROGRESS "UFU is being transferred..." #define ENG_EVT_ID_NAME_DATABASE_CONNECTED "Database(s) connected" +#define ENG_EVT_ID_NAME_NTP_STATE_SYNC "NTP state: Sync to system peer" +#define ENG_EVT_ID_NAME_NTP_STATE_NOT_SYNC "NTP state: Not sync" +#define ENG_EVT_ID_NAME_FW_OSV "Firmware set to OSV" #define MBG_EVT_ID_NAMES_ENG \ @@ -9698,7 +10409,10 @@ enum MBG_EVT_IDS ENG_EVT_ID_NAME_FW_DELETED, \ ENG_EVT_ID_NAME_FW_ROLLBACK, \ ENG_EVT_ID_NAME_UFU_FLASHED, \ - ENG_EVT_ID_NAME_DATABASE_CONNECTED \ + ENG_EVT_ID_NAME_UFU_PROGRESS, \ + ENG_EVT_ID_NAME_DATABASE_CONNECTED, \ + ENG_EVT_ID_NAME_NTP_STATE_SYNC, \ + ENG_EVT_ID_NAME_FW_OSV \ } @@ -9770,6 +10484,11 @@ enum MBG_EVT_LVLS #define MBG_EVT_PTP_PORT_STATE_PASSIVE _mbg_mk_evt_code( MBG_EVT_ID_PTP_PORT_STATE_PASSIVE, MBG_EVT_LVL_INFO ) #define MBG_EVT_PTP_PORT_STATE_UNCALIBRATED _mbg_mk_evt_code( MBG_EVT_ID_PTP_PORT_STATE_UNCALIBRATED, MBG_EVT_LVL_INFO ) #define MBG_EVT_PTP_PORT_STATE_SLAVE _mbg_mk_evt_code( MBG_EVT_ID_PTP_PORT_STATE_SLAVE, MBG_EVT_LVL_INFO ) +#define MBG_EVT_FW_ACTIVATED _mbg_mk_evt_code( MBG_EVT_ID_FW_ACTIVATED, MBG_EVT_LVL_INFO ) +#define MBG_EVT_DATABASE_CONNECTED _mbg_mk_evt_code( MBG_EVT_ID_DATABASE_CONNTECTED, MBG_EVT_LVL_INFO ) +#define MBG_EVT_NTP_STATE_SYNC _mbg_mk_evt_code( MBG_EVT_ID_NTP_STATE_SYNC, MBG_EVT_LVL_INFO ) +#define MBG_EVT_NTP_STATE_NOT_SYNC _mbg_mk_evt_code( MBG_EVT_ID_NTP_STATE_NOT_SYNC, MBG_EVT_LVL_WARN ) +#define MBG_EVT_FW_OSV _mbg_mk_evt_code( MBG_EVT_ID_FW_OSV, MBG_EVT_LVL_INFO ) /** @} anchor MBG_EVENT_CODES */ @@ -9787,13 +10506,13 @@ enum MBG_EVT_LVLS /** * @brief Generic state of an IMS device */ -typedef struct +typedef struct mbg_ims_state_s { uint8_t chassis_id; ///< chassis ID, 0 if installed on the backplane uint8_t slot_id; ///< slot number on the chassis uint16_t num_sensors; ///< number of sensors provided by the device uint32_t reserved; ///< reserved, currently always 0 - uint32_t flags; ///< see ::MBG_IMS_STATE_FLAG_MASKS + uint32_t flags; ///< See ::MBG_IMS_STATE_FLAG_MASKS } MBG_IMS_STATE; @@ -9826,7 +10545,7 @@ enum MBG_IMS_STATE_FLAG_BITS */ enum MBG_IMS_STATE_FLAG_MASKS { - MBG_IMS_STATE_FLAG_MSK_HAS_FDM = ( 1UL << MBG_IMS_STATE_FLAG_BIT_HAS_FDM ) ///< see ::MBG_IMS_STATE_FLAG_BIT_HAS_FDM + MBG_IMS_STATE_FLAG_MSK_HAS_FDM = ( 1UL << MBG_IMS_STATE_FLAG_BIT_HAS_FDM ) ///< See ::MBG_IMS_STATE_FLAG_BIT_HAS_FDM }; @@ -9834,7 +10553,7 @@ enum MBG_IMS_STATE_FLAG_MASKS /** * @brief Generic state of an IMS sensor */ -typedef struct +typedef struct mbg_ims_sensor_state_s { uint16_t type; ///< sensor type, see ::MBG_IMS_SENSORS uint16_t idx; ///< index of the sensor of this type @@ -9862,7 +10581,7 @@ do \ */ typedef struct { - uint32_t idx; ///< sensor index, 0..::MBG_IMS_STATE::num_sensors-1 + MBG_MSG_IDX_32 idx; ///< sensor index, 0..::MBG_IMS_STATE::num_sensors-1 MBG_IMS_SENSOR_STATE state; ///< sensor state } MBG_IMS_SENSOR_STATE_IDX; @@ -9957,7 +10676,7 @@ do \ * * @note This is only supported if ::MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in ::MBG_IMS_STATE::flags */ -typedef struct +typedef struct mbg_ims_fdm_output_state_s { int32_t dac_val; ///< current DAC value, positive or negative uint32_t mode; ///< current output mode, see ::MBG_IMS_FDM_OUTPUT_MODES @@ -9986,7 +10705,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_IMS_FDM_OUTPUT_STATE state; } MBG_IMS_FDM_OUTPUT_STATE_IDX; @@ -10025,7 +10744,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_IMS_FDM_OUTPUT_SETTINGS settings; } MBG_IMS_FDM_OUTPUT_SETTINGS_IDX; @@ -10042,7 +10761,7 @@ do \ /** * @brief Specific output settings and limits. */ -typedef struct +typedef struct mbg_ims_fdm_output_info_s { MBG_IMS_FDM_OUTPUT_SETTINGS settings; ///< current settings uint32_t supp_modes; ///< supported modes, see ::MBG_IMS_FDM_OUTPUT_MODE_MASKS @@ -10065,7 +10784,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_IMS_FDM_OUTPUT_INFO info; } MBG_IMS_FDM_OUTPUT_INFO_IDX; @@ -10102,8 +10821,8 @@ enum MBG_IMS_FDM_OUTPUT_MODES */ enum MBG_IMS_FDM_OUTPUT_MODE_MASKS { - MBG_IMS_FDM_OUTPUT_MODE_MSK_FD = ( 1UL << MBG_IMS_FDM_OUTPUT_MODE_FD ), ///< see ::MBG_IMS_FDM_OUTPUT_MODE_FD - MBG_IMS_FDM_OUTPUT_MODE_MSK_TD = ( 1UL << MBG_IMS_FDM_OUTPUT_MODE_TD ) ///< see ::MBG_IMS_FDM_OUTPUT_MODE_TD + MBG_IMS_FDM_OUTPUT_MODE_MSK_FD = ( 1UL << MBG_IMS_FDM_OUTPUT_MODE_FD ), ///< See ::MBG_IMS_FDM_OUTPUT_MODE_FD + MBG_IMS_FDM_OUTPUT_MODE_MSK_TD = ( 1UL << MBG_IMS_FDM_OUTPUT_MODE_TD ) ///< See ::MBG_IMS_FDM_OUTPUT_MODE_TD }; @@ -10111,7 +10830,7 @@ enum MBG_IMS_FDM_OUTPUT_MODE_MASKS /** * @brief A generic structure used to specify FDM limits */ -typedef struct +typedef struct mbg_ims_fdm_limits_s { uint8_t n_outputs; ///< number of outputs per module uint8_t reserved_0; ///< reserved, currently always 0 @@ -10155,7 +10874,7 @@ do \ * @note This is only supported if ::MBG_IMS_STATE_FLAG_MSK_HAS_FDM is set in ::MBG_IMS_STATE::flags. * */ -typedef struct +typedef struct mbg_ims_fdm_state_s { MBG_GPIO_FREQ freq; ///< Current frequency @@ -10206,9 +10925,9 @@ enum MBG_IMS_FDM_LINE_FREQS */ enum MBG_IMS_FDM_LINE_FREQ_MASKS { - MBG_IMS_FDM_LINE_FREQ_MSK_AUTO = ( 1UL << MBG_IMS_FDM_LINE_FREQ_AUTO ), ///< see ::MBG_IMS_FDM_LINE_FREQ_AUTO - MBG_IMS_FDM_LINE_FREQ_MSK_50HZ = ( 1UL << MBG_IMS_FDM_LINE_FREQ_50HZ ), ///< see ::MBG_IMS_FDM_LINE_FREQ_50HZ - MBG_IMS_FDM_LINE_FREQ_MSK_60HZ = ( 1UL << MBG_IMS_FDM_LINE_FREQ_60HZ ) ///< see ::MBG_IMS_FDM_LINE_FREQ_60HZ + MBG_IMS_FDM_LINE_FREQ_MSK_AUTO = ( 1UL << MBG_IMS_FDM_LINE_FREQ_AUTO ), ///< See ::MBG_IMS_FDM_LINE_FREQ_AUTO + MBG_IMS_FDM_LINE_FREQ_MSK_50HZ = ( 1UL << MBG_IMS_FDM_LINE_FREQ_50HZ ), ///< See ::MBG_IMS_FDM_LINE_FREQ_50HZ + MBG_IMS_FDM_LINE_FREQ_MSK_60HZ = ( 1UL << MBG_IMS_FDM_LINE_FREQ_60HZ ) ///< See ::MBG_IMS_FDM_LINE_FREQ_60HZ }; @@ -10245,10 +10964,10 @@ enum MBG_IMS_FDM_STATE_FLAG_BITS */ enum MBG_IMS_FDM_STATE_FLAG_MASKS { - MBG_IMS_FDM_STATE_FLAG_MSK_SYNC_AFTER_RESET = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET ), ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET - MBG_IMS_FDM_STATE_FLAG_MSK_PLT_IS_LOCKED = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED ), ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED - MBG_IMS_FDM_STATE_FLAG_MSK_FD_OVERFLOW = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW ), ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW - MBG_IMS_FDM_STATE_FLAG_MSK_TD_OVERFLOW = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW ) ///< see ::MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW + MBG_IMS_FDM_STATE_FLAG_MSK_SYNC_AFTER_RESET = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET ), ///< See ::MBG_IMS_FDM_STATE_FLAG_BIT_SYNC_AFTER_RESET + MBG_IMS_FDM_STATE_FLAG_MSK_PLT_IS_LOCKED = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED ), ///< See ::MBG_IMS_FDM_STATE_FLAG_BIT_PLT_IS_LOCKED + MBG_IMS_FDM_STATE_FLAG_MSK_FD_OVERFLOW = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW ), ///< See ::MBG_IMS_FDM_STATE_FLAG_BIT_FD_OVERFLOW + MBG_IMS_FDM_STATE_FLAG_MSK_TD_OVERFLOW = ( 1UL << MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW ) ///< See ::MBG_IMS_FDM_STATE_FLAG_BIT_TD_OVERFLOW }; @@ -10305,7 +11024,7 @@ enum MBG_IMS_FDM_FLAGS */ enum MBG_IMS_FDM_FLAG_MASKS { - MBG_IMS_FDM_FLAG_MASK_CAN_SET_TDEV = ( 1UL << MBG_IMS_FDM_FLAG_CAN_SET_TDEV ) ///< see ::MBG_IMS_FDM_FLAG_CAN_SET_TDEV + MBG_IMS_FDM_FLAG_MASK_CAN_SET_TDEV = ( 1UL << MBG_IMS_FDM_FLAG_CAN_SET_TDEV ) ///< See ::MBG_IMS_FDM_FLAG_CAN_SET_TDEV }; @@ -10313,7 +11032,7 @@ enum MBG_IMS_FDM_FLAG_MASKS /** * @brief Specific FDM settings and limits. */ -typedef struct +typedef struct mbg_ims_fdm_info_s { MBG_IMS_FDM_SETTINGS settings; uint32_t supp_line_freqs; ///< Bit mask of supported line frequencies, see ::MBG_IMS_FDM_LINE_FREQ_MASKS @@ -10588,7 +11307,7 @@ typedef int16_t DAC_VAL; /** * @brief Satellite receiver status information */ -typedef struct +typedef struct stat_info_s { uint16_t mode; ///< Mode of operation, see ::RECEIVER_MODES uint16_t good_svs; ///< Numb. of satellites that can currently be received and used @@ -10615,6 +11334,90 @@ do \ /** + * @brief Bit masks for a legacy GPS SV status. + * + * Used with ::SV_INFO::stat_flags. + */ +enum SV_STAT_FLAG_MASKS +{ + SV_EXISTS = 0x0001, ///< The SV exists physically. + SV_IS_IN_VIEW = 0x0002, ///< SV should be visible at this moment. + SV_CAN_BE_RECEIVED = 0x0004, ///< SV can be tracked. + SV_MIGHT_BE_USED = 0x0008 ///< SV might be used. +}; + +/** + * @brief A combination of ::SV_STAT_FLAG_MASKS indicating an SV is "good". + * + * Used with ::SV_INFO::stat_flags. + */ +#define SV_IS_GOOD ( SV_EXISTS | SV_IS_IN_VIEW | SV_CAN_BE_RECEIVED | SV_MIGHT_BE_USED ) + + + +/** + * @brief A legacy satellite info structure. + * + * Used with pure GPS receivers. Newer GNSS receivers should + * support the ::GNSS_SV_STATUS structure. + * + * @see ::GNSS_SV_STATUS + */ +typedef struct sv_info_s +{ + SVNO svno; ///< The satellite number, ::MIN_SVNO_GPS...::MAX_SVNO_GPS. + int16_t stat_flags; ///< See ::SV_STAT_FLAG_MASKS. + int16_t elev; ///< Elevetion of the satellite [degrees]. + int16_t azim; ///< Azimuth of the satellite [degrees]. + int16_t doppler; ///< Doppler frequency of the satellite [Hz]. + int32_t est_dly; ///< Estimated signal propagation delay [100 ns units]. + int32_t cap_dly; ///< Measured signal propagation delay [100 ns units]. + +} SV_INFO; + + + +/** + * @brief Information on usage of a receiver channel. + * + * Used with pure GPS receivers. + * + * @note Very old GPS receivers which supported only 5 channels + * provided the ::CHANNEL_5 structure instead. + * + * @see ::CHANNEL_5 + */ +typedef struct +{ + int8_t num; ///< The receiver channel index, starting at 0. + int8_t svno; ///< The satellite number, ::MIN_SVNO_GPS...::MAX_SVNO_GPS. + int16_t doppler; ///< Doppler frequency of the satellite [Hz]. + int16_t elev; ///< Elevetion of the satellite [degrees]. + int16_t status; ///< 1: synchronized to data stream from satellite, else 0. + +} CHANNEL; + + + +/** + * @brief Information on usage of a receiver channel. + * + * Very old GPS receivers which supported only 5 channels + * provided this structure instead of the ::CHANNEL structure. + * + * @see ::CHANNEL + */ +typedef struct +{ + int8_t num; ///< The receiver channel index, starting at 0. + int8_t svno; ///< The satellite number, ::MIN_SVNO_GPS...::MAX_SVNO_GPS. + int16_t status; ///< 1: synchronized to data stream from satellite, else 0. + +} CHANNEL_5; + + + +/** * @brief An enumeration of known satellite navigation systems * * @see ::MBG_GNSS_TYPE_MASKS @@ -10640,13 +11443,13 @@ enum MBG_GNSS_TYPES */ enum MBG_GNSS_TYPE_MASKS { - MBG_GNSS_TYPE_MSK_GPS = ( 1UL << GNSS_TYPE_GPS ), ///< see ::GNSS_TYPE_GPS - MBG_GNSS_TYPE_MSK_GLONASS = ( 1UL << GNSS_TYPE_GLONASS ), ///< see ::GNSS_TYPE_GLONASS - MBG_GNSS_TYPE_MSK_BEIDOU = ( 1UL << GNSS_TYPE_BEIDOU ), ///< see ::GNSS_TYPE_BEIDOU - MBG_GNSS_TYPE_MSK_GALILEO = ( 1UL << GNSS_TYPE_GALILEO ), ///< see ::GNSS_TYPE_GALILEO - MBG_GNSS_TYPE_MSK_WAAS = ( 1UL << GNSS_TYPE_WAAS ), ///< see ::GNSS_TYPE_WAAS - MBG_GNSS_TYPE_MSK_EGNOS = ( 1UL << GNSS_TYPE_EGNOS ), ///< see ::GNSS_TYPE_EGNOS - MBG_GNSS_TYPE_MSK_QZSS = ( 1UL << GNSS_TYPE_QZSS ) ///< see ::GNSS_TYPE_QZSS + MBG_GNSS_TYPE_MSK_GPS = ( 1UL << GNSS_TYPE_GPS ), ///< See ::GNSS_TYPE_GPS + MBG_GNSS_TYPE_MSK_GLONASS = ( 1UL << GNSS_TYPE_GLONASS ), ///< See ::GNSS_TYPE_GLONASS + MBG_GNSS_TYPE_MSK_BEIDOU = ( 1UL << GNSS_TYPE_BEIDOU ), ///< See ::GNSS_TYPE_BEIDOU + MBG_GNSS_TYPE_MSK_GALILEO = ( 1UL << GNSS_TYPE_GALILEO ), ///< See ::GNSS_TYPE_GALILEO + MBG_GNSS_TYPE_MSK_WAAS = ( 1UL << GNSS_TYPE_WAAS ), ///< See ::GNSS_TYPE_WAAS + MBG_GNSS_TYPE_MSK_EGNOS = ( 1UL << GNSS_TYPE_EGNOS ), ///< See ::GNSS_TYPE_EGNOS + MBG_GNSS_TYPE_MSK_QZSS = ( 1UL << GNSS_TYPE_QZSS ) ///< See ::GNSS_TYPE_QZSS }; @@ -10677,7 +11480,7 @@ enum MBG_GNSS_TYPE_MASKS typedef struct { uint32_t gnss_set; ///< bit mask of currently used GNSS systems, see ::MBG_GNSS_TYPE_MASKS - uint8_t prio[N_GNSS_MODE_PRIO]; ///< see ::MBG_GNSS_TYPES, unused fields set to 0xFF, idx 0 is highest prio + uint8_t prio[N_GNSS_MODE_PRIO]; ///< See ::MBG_GNSS_TYPES, unused fields set to 0xFF, idx 0 is highest prio uint32_t flags; ///< unused, currently always 0 (should be named MBG_GNSS_MODE_SETTINGS_FLAG_MASKS) } MBG_GNSS_MODE_SETTINGS; @@ -10710,7 +11513,6 @@ do \ } while ( 0 ) - /** * @brief Flag bits used to define ::MBG_GNSS_MODE_INFO_FLAG_MASKS * @@ -10722,6 +11524,8 @@ enum MBG_GNSS_MODE_INFO_FLAG_BITS MBG_GNSS_FLAG_HAS_PRIORITY, ///< Priority can be configured using the ::MBG_GNSS_MODE_SETTINGS::prio field MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER, ///< The ::GNSS_SAT_INFO_IDX structure is supported by the device MBG_GNSS_FLAG_HAS_SV_STATUS, ///< The ::GNSS_SV_STATUS_IDX structure is supported by the device + MBG_GNSS_FLAG_IS_MULTIBAND, ///< Indicates, that the receiver is a multiband receiver and therefore + ///< supports usage of any combination of GNSS types (even more than 3 types) N_MBG_GNSS_FLAGS }; @@ -10733,20 +11537,20 @@ enum MBG_GNSS_MODE_INFO_FLAG_BITS */ enum MBG_GNSS_MODE_INFO_FLAG_MASKS { - MBG_GNSS_FLAG_MSK_EXCLUSIVE = ( 1UL << MBG_GNSS_FLAG_EXCLUSIVE ), ///< see ::MBG_GNSS_FLAG_EXCLUSIVE - MBG_GNSS_FLAG_MSK_HAS_PRIORITY = ( 1UL << MBG_GNSS_FLAG_HAS_PRIORITY ), ///< see ::MBG_GNSS_FLAG_HAS_PRIORITY - MBG_GNSS_FLAG_MSK_SAT_INFO_IDX_SUPP_SER = ( 1UL << MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER ), ///< see ::MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER - MBG_GNSS_FLAG_MSK_HAS_SV_STATUS = ( 1UL << MBG_GNSS_FLAG_HAS_SV_STATUS ) ///< see ::MBG_GNSS_FLAG_HAS_SV_STATUS + MBG_GNSS_FLAG_MSK_EXCLUSIVE = ( 1UL << MBG_GNSS_FLAG_EXCLUSIVE ), ///< See ::MBG_GNSS_FLAG_EXCLUSIVE + MBG_GNSS_FLAG_MSK_HAS_PRIORITY = ( 1UL << MBG_GNSS_FLAG_HAS_PRIORITY ), ///< See ::MBG_GNSS_FLAG_HAS_PRIORITY + MBG_GNSS_FLAG_MSK_SAT_INFO_IDX_SUPP_SER = ( 1UL << MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER ), ///< See ::MBG_GNSS_FLAG_SAT_INFO_IDX_SUPP_SER + MBG_GNSS_FLAG_MSK_HAS_SV_STATUS = ( 1UL << MBG_GNSS_FLAG_HAS_SV_STATUS ), ///< See ::MBG_GNSS_FLAG_HAS_SV_STATUS + MBG_GNSS_FLAG_MSK_IS_MULTIBAND = ( 1UL << MBG_GNSS_FLAG_IS_MULTIBAND ) ///< See ::MBG_GNSS_FLAG_IS_MULTIBAND }; - #define MAX_USED_SATS 32 /** * @brief Satellite information for a particular GNSS type. */ -typedef struct +typedef struct gnss_sat_info_s { uint8_t gnss_type; ///< GNSS type as enumerated in ::MBG_GNSS_TYPES uint8_t reserved; ///< Reserved, currently always 0 @@ -10772,14 +11576,17 @@ do \ */ typedef struct { - /// GNSS system type index according to ::MBG_GNSS_MODE_INFO::supp_gnss_types. + /// @brief GNSS system type index according to ::MBG_GNSS_MODE_INFO::supp_gnss_types. + /// /// I.e., idx 0 corresponds to the GNSS system for which the least significant /// bit is set in ::MBG_GNSS_MODE_INFO::supp_gnss_types, idx 1 corresponds to - /// GNSS system for which the next higher bit is set, etc. This must *not* - /// necessarily match the sequence of the ::MBG_GNSS_TYPES enumeration. - uint16_t idx; + /// GNSS system for which the next higher bit is set, etc. + /// + /// @note This must ***not*** necessarily match the sequence + /// of the ::MBG_GNSS_TYPES enumeration. + MBG_MSG_IDX idx; - GNSS_SAT_INFO gnss_sat_info; ///< see ::GNSS_SAT_INFO + GNSS_SAT_INFO gnss_sat_info; ///< See ::GNSS_SAT_INFO } GNSS_SAT_INFO_IDX; @@ -10803,10 +11610,13 @@ do \ /** * @brief Detailed GNSS satellite status * + * @note Pure GPS receivers may only support the ::SV_INFO structure. + * * @see ::GNSS_SV_STATUS_IDX + * @see ::SV_INFO * @see @ref group_gnss_sv_stat_flags */ -typedef struct +typedef struct gnss_sv_status_s { uint8_t gnss_type; ///< GNSS type as enumerated in ::MBG_GNSS_TYPES uint8_t svno; ///< Satellite number, see ::TODO @@ -10906,6 +11716,16 @@ do \ ( ( (__stat_flags) & 0x00400000UL ) != 0 ) /// Bits 23 to 31 are reserved. +/// +/// However, we use the MSB (bit 31) here as a private extension +/// to indicate that the satellite can be received on two frequencies, +/// and the ionosphere correction is derived from the dual frequency +/// observation. +/// See ::_gnss_sv_stat_dual_freq +#define GNSS_SV_STAT_DUAL_FREQ_MSK 0x80000000UL + +#define _gnss_sv_stat_dual_freq( __stat_flags ) \ + ( ( (__stat_flags) & GNSS_SV_STAT_DUAL_FREQ_MSK ) != 0 ) /** @} defgroup group_gnss_sv_stat_flags */ @@ -10967,7 +11787,7 @@ enum GNSS_SV_STAT_ORBIT_SOURCES */ typedef struct { - uint32_t idx; ///< Range 0..::MBG_GNSS_MODE_INFO::n_sv_status-1 + MBG_MSG_IDX_32 idx; ///< Range 0..::MBG_GNSS_MODE_INFO::n_sv_status-1 GNSS_SV_STATUS gnss_sv_status; } GNSS_SV_STATUS_IDX; @@ -11028,7 +11848,7 @@ typedef uint16_t ANT_CABLE_LEN; /** * @brief The MAC address of a network interface */ -typedef struct +typedef struct mbg_mac_addr_s { uint8_t b[6]; @@ -11242,7 +12062,7 @@ typedef struct IP4_ADDR netmask; ///< the network mask IP4_ADDR broad_addr; ///< the broadcast address IP4_ADDR gateway; ///< the default gateway - uint16_t flags; ///< see ::MBG_IP4_FLAG_MASKS + uint16_t flags; ///< See ::MBG_IP4_FLAG_MASKS MBG_VLAN_CFG vlan_cfg; ///< VLAN configuration } IP4_SETTINGS; @@ -11263,8 +12083,8 @@ do \ /** * @brief Simple LAN interface information * - * This structure can be retrieved from a device - * to check the device's capabilities. + * This structure can be obtained from a device + * to check the capabilities of the device. * * It is only supported if the flag ::GPS_HAS_LAN_IP4 is set * in ::RECEIVER_INFO::features. @@ -11279,7 +12099,7 @@ typedef struct char ver_str[GPS_ID_STR_SIZE]; ///< version string char sernum[GPS_ID_STR_SIZE]; ///< serial number uint32_t rsvd_0; ///< reserved, currently always 0 - uint16_t flags; ///< see ::MBG_IP4_FLAG_MASKS + uint16_t flags; ///< See ::MBG_IP4_FLAG_MASKS uint16_t rsvd_1; ///< reserved, currently always 0 } LAN_IF_INFO; @@ -11338,9 +12158,9 @@ enum MBG_IP4_FLAG_BITS */ enum MBG_IP4_FLAG_MASKS { - IP4_MSK_DHCP = ( 1UL << IP4_BIT_DHCP ), ///< see ::IP4_BIT_DHCP - IP4_MSK_LINK = ( 1UL << IP4_BIT_LINK ), ///< see ::IP4_BIT_LINK - IP4_MSK_VLAN = ( 1UL << IP4_BIT_VLAN ), ///< see ::IP4_BIT_VLAN + IP4_MSK_DHCP = ( 1UL << IP4_BIT_DHCP ), ///< See ::IP4_BIT_DHCP + IP4_MSK_LINK = ( 1UL << IP4_BIT_LINK ), ///< See ::IP4_BIT_LINK + IP4_MSK_VLAN = ( 1UL << IP4_BIT_VLAN ), ///< See ::IP4_BIT_VLAN }; /** @} defgroup group_ip4_cfg */ @@ -11401,10 +12221,10 @@ enum MBG_NET_GLB_CFG_INFO_FLAGS */ enum MBG_NET_GLB_CFG_INFO_MASKS { - MBG_NET_GLB_SUPP_STAGE_2_MASK = (1UL << MBG_NET_GLB_SUPP_STAGE_2), ///< see ::MBG_NET_GLB_SUPP_STAGE_2 - MBG_NET_GLB_SUPP_BONDING_MASK = (1UL << MBG_NET_GLB_SUPP_BONDING), ///< see ::MBG_NET_GLB_SUPP_BONDING - MBG_NET_GLB_SUPP_ADD_CONF_MASK = (1UL << MBG_NET_GLB_SUPP_ADD_CONF), ///< see ::MBG_NET_GLB_SUPP_ADD_CONF - MBG_NET_GLB_SUPP_EXT_ROUTING_MASK = (1UL << MBG_NET_GLB_SUPP_EXT_ROUTING) ///< see ::MBG_NET_GLB_SUPP_EXT_ROUTING + MBG_NET_GLB_SUPP_STAGE_2_MASK = (1UL << MBG_NET_GLB_SUPP_STAGE_2), ///< See ::MBG_NET_GLB_SUPP_STAGE_2 + MBG_NET_GLB_SUPP_BONDING_MASK = (1UL << MBG_NET_GLB_SUPP_BONDING), ///< See ::MBG_NET_GLB_SUPP_BONDING + MBG_NET_GLB_SUPP_ADD_CONF_MASK = (1UL << MBG_NET_GLB_SUPP_ADD_CONF), ///< See ::MBG_NET_GLB_SUPP_ADD_CONF + MBG_NET_GLB_SUPP_EXT_ROUTING_MASK = (1UL << MBG_NET_GLB_SUPP_EXT_ROUTING) ///< See ::MBG_NET_GLB_SUPP_EXT_ROUTING }; @@ -11454,31 +12274,31 @@ enum MBG_NET_INTF_LINK_SPEED_MODES * * @anchor MBG_NET_INTF_LINK_SPEED_MODE_MASKS @{ */ -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_UNKNOWN ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_KX_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL - -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_2500_X_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_KX4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_KR_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_R_FEC ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_20000_MLD2_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_20000_KR2_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_KR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL - -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_CR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_SR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_LR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_KR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_CR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_SR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL -#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_LR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL ) ///< see ::MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_UNKNOWN ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_UNKNOWN +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_10_T_HALF +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_10_T_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_100_T_HALF +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_100_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_100_T_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_T_HALF ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_1000_T_HALF +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_1000_T_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_1000_KX_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_1000_KX_FULL + +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_2500_X_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_2500_X_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_T_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_10000_T_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_KX4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_10000_KX4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_KR_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_10000_KR_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_10000_R_FEC ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_10000_R_FEC +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_20000_MLD2_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_20000_MLD2_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_20000_KR2_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_20000_KR2_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_KR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_40000_KR4_FULL + +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_CR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_40000_CR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_SR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_40000_SR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_40000_LR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_40000_LR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_KR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_56000_KR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_CR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_56000_CR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_SR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_56000_SR4_FULL +#define MBG_NET_INTF_LINK_SPEED_MODE_MASK_56000_LR4_FULL ( 1UL << MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL ) ///< See ::MBG_NET_INTF_LINK_SPEED_MODE_56000_LR4_FULL /** @} anchor MBG_NET_INTF_LINK_SPEED_MODE_MASKS */ @@ -11530,13 +12350,13 @@ enum MBG_NET_INTF_LINK_PORT_TYPES */ enum MBG_NET_INTF_LINK_PORT_TYPE_MASKS { - MBG_NET_INTF_LINK_PORT_TYPE_MASK_UNKNOWN = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN - MBG_NET_INTF_LINK_PORT_TYPE_MASK_TP = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_TP ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_TP - MBG_NET_INTF_LINK_PORT_TYPE_MASK_FIBRE = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_FIBRE ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_FIBRE - MBG_NET_INTF_LINK_PORT_TYPE_MASK_BNC = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_BNC ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_BNC - MBG_NET_INTF_LINK_PORT_TYPE_MASK_AUI = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_AUI ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_AUI - MBG_NET_INTF_LINK_PORT_TYPE_MASK_MII = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_MII ), ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_MII - MBG_NET_INTF_LINK_PORT_TYPE_MASK_DA = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_DA ) ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_DA + MBG_NET_INTF_LINK_PORT_TYPE_MASK_UNKNOWN = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN ), ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_UNKNOWN + MBG_NET_INTF_LINK_PORT_TYPE_MASK_TP = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_TP ), ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_TP + MBG_NET_INTF_LINK_PORT_TYPE_MASK_FIBRE = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_FIBRE ), ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_FIBRE + MBG_NET_INTF_LINK_PORT_TYPE_MASK_BNC = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_BNC ), ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_BNC + MBG_NET_INTF_LINK_PORT_TYPE_MASK_AUI = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_AUI ), ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_AUI + MBG_NET_INTF_LINK_PORT_TYPE_MASK_MII = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_MII ), ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_MII + MBG_NET_INTF_LINK_PORT_TYPE_MASK_DA = ( 1UL << MBG_NET_INTF_LINK_PORT_TYPE_DA ) ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_DA }; @@ -11575,7 +12395,6 @@ enum MBG_NET_INTF_LINK_PORT_TYPE_MASKS } - /** * @brief Network interface link state bits * @@ -11623,27 +12442,27 @@ enum MBG_NET_INTF_LINK_STATE_BITS * * @anchor MBG_NET_INTF_LINK_STATE_MASKS @{ */ -#define MBG_NET_INTF_LINK_STATE_MASK_UP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_UP ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_UP -#define MBG_NET_INTF_LINK_STATE_MASK_RUNNING ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_RUNNING ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_RUNNING -#define MBG_NET_INTF_LINK_STATE_MASK_LOWER_UP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP -#define MBG_NET_INTF_LINK_STATE_MASK_DORMANT ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DORMANT ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DORMANT -#define MBG_NET_INTF_LINK_STATE_MASK_BROADCAST ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_BROADCAST ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_BROADCAST -#define MBG_NET_INTF_LINK_STATE_MASK_MULTICAST ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MULTICAST ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_MULTICAST -#define MBG_NET_INTF_LINK_STATE_MASK_ALL_MULTI ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI -#define MBG_NET_INTF_LINK_STATE_MASK_DEBUG ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DEBUG ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DEBUG - -#define MBG_NET_INTF_LINK_STATE_MASK_LOOPBACK ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK -#define MBG_NET_INTF_LINK_STATE_MASK_POINT_TO_POINT ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT -#define MBG_NET_INTF_LINK_STATE_MASK_NO_ARP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_ARP ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_NO_ARP -#define MBG_NET_INTF_LINK_STATE_MASK_PROMISC ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PROMISC ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_PROMISC -#define MBG_NET_INTF_LINK_STATE_MASK_MASTER ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MASTER ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_MASTER -#define MBG_NET_INTF_LINK_STATE_MASK_SLAVE ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_SLAVE ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_SLAVE -#define MBG_NET_INTF_LINK_STATE_MASK_PORT_SEL ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL -#define MBG_NET_INTF_LINK_STATE_MASK_AUTO_MEDIA ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA - -#define MBG_NET_INTF_LINK_STATE_MASK_ECHO ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ECHO ) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_ECHO -#define MBG_NET_INTF_LINK_STATE_MASK_DYNAMIC ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC -#define MBG_NET_INTF_LINK_STATE_MASK_NO_TRAILERS ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS) ///< see ::MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS +#define MBG_NET_INTF_LINK_STATE_MASK_UP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_UP ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_UP +#define MBG_NET_INTF_LINK_STATE_MASK_RUNNING ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_RUNNING ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_RUNNING +#define MBG_NET_INTF_LINK_STATE_MASK_LOWER_UP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_LOWER_UP +#define MBG_NET_INTF_LINK_STATE_MASK_DORMANT ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DORMANT ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_DORMANT +#define MBG_NET_INTF_LINK_STATE_MASK_BROADCAST ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_BROADCAST ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_BROADCAST +#define MBG_NET_INTF_LINK_STATE_MASK_MULTICAST ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MULTICAST ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_MULTICAST +#define MBG_NET_INTF_LINK_STATE_MASK_ALL_MULTI ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_ALL_MULTI +#define MBG_NET_INTF_LINK_STATE_MASK_DEBUG ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DEBUG ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_DEBUG + +#define MBG_NET_INTF_LINK_STATE_MASK_LOOPBACK ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_LOOPBACK +#define MBG_NET_INTF_LINK_STATE_MASK_POINT_TO_POINT ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_POINT_TO_POINT +#define MBG_NET_INTF_LINK_STATE_MASK_NO_ARP ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_ARP ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_NO_ARP +#define MBG_NET_INTF_LINK_STATE_MASK_PROMISC ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PROMISC ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_PROMISC +#define MBG_NET_INTF_LINK_STATE_MASK_MASTER ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_MASTER ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_MASTER +#define MBG_NET_INTF_LINK_STATE_MASK_SLAVE ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_SLAVE ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_SLAVE +#define MBG_NET_INTF_LINK_STATE_MASK_PORT_SEL ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_PORT_SEL +#define MBG_NET_INTF_LINK_STATE_MASK_AUTO_MEDIA ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_AUTO_MEDIA + +#define MBG_NET_INTF_LINK_STATE_MASK_ECHO ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_ECHO ) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_ECHO +#define MBG_NET_INTF_LINK_STATE_MASK_DYNAMIC ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_DYNAMIC +#define MBG_NET_INTF_LINK_STATE_MASK_NO_TRAILERS ( 1UL << MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS) ///< See ::MBG_NET_INTF_LINK_STATE_BIT_NO_TRAILERS /** @} anchor MBG_NET_INTF_LINK_STATE_MASKS */ @@ -11662,6 +12481,9 @@ enum MBG_NET_INTF_LINK_OPTS MBG_NET_INTF_LINK_OPT_CAN_AUTONEG, MBG_NET_INTF_LINK_OPT_CAN_NTP_HW_TS, MBG_NET_INTF_LINK_OPT_CAN_PTP_HW_TS, + MBG_NET_INTF_LINK_OPT_HAS_NTP_LIC, ///< Indicates, that the physical interface has a license for number of NTP clients + MBG_NET_INTF_LINK_OPT_HAS_PTP_LIC, ///< Indicates, that the physical interface has a license for number of PTP clients + MBG_NET_INTF_LINK_OPT_HAS_SYNCE_STATUS, N_MBG_NET_INTF_LINK_OPTS }; @@ -11674,12 +12496,15 @@ enum MBG_NET_INTF_LINK_OPTS */ enum MBG_NET_INTF_LINK_OPT_MASKS { - MBG_NET_INTF_LINK_OPT_MASK_CAN_SET_MAC = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SET_MAC ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SET_MAC - MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_IN = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN - MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_OUT = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT - MBG_NET_INTF_LINK_OPT_MASK_CAN_AUTONEG = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_AUTONEG ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_AUTONEG - MBG_NET_INTF_LINK_OPT_MASK_CAN_NTP_HW_TS = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_NTP_HW_TS ), ///< see ::MBG_NET_INTF_LINK_OPT_CAN_NTP_HW_TS - MBG_NET_INTF_LINK_OPT_MASK_CAN_PTP_HW_TS = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_PTP_HW_TS ) ///< see ::MBG_NET_INTF_LINK_OPT_CAN_PTP_HW_TS + MBG_NET_INTF_LINK_OPT_MASK_CAN_SET_MAC = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SET_MAC ), ///< See ::MBG_NET_INTF_LINK_OPT_CAN_SET_MAC + MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_IN = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN ), ///< See ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE_IN + MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_OUT = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT ), ///< See ::MBG_NET_INTF_LINK_OPT_CAN_SYNCE_OUT + MBG_NET_INTF_LINK_OPT_MASK_CAN_AUTONEG = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_AUTONEG ), ///< See ::MBG_NET_INTF_LINK_OPT_CAN_AUTONEG + MBG_NET_INTF_LINK_OPT_MASK_CAN_NTP_HW_TS = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_NTP_HW_TS ), ///< See ::MBG_NET_INTF_LINK_OPT_CAN_NTP_HW_TS + MBG_NET_INTF_LINK_OPT_MASK_CAN_PTP_HW_TS = ( 1UL << MBG_NET_INTF_LINK_OPT_CAN_PTP_HW_TS ), ///< See ::MBG_NET_INTF_LINK_OPT_CAN_PTP_HW_TS + MBG_NET_INTF_LINK_OPT_MASK_HAS_NTP_LIC = ( 1UL << MBG_NET_INTF_LINK_OPT_HAS_NTP_LIC ), ///< See ::MBG_NET_INTF_LINK_OPT_HAS_NTP_LIC + MBG_NET_INTF_LINK_OPT_MASK_HAS_PTP_LIC = ( 1UL << MBG_NET_INTF_LINK_OPT_HAS_PTP_LIC ), ///< See ::MBG_NET_INTF_LINK_OPT_HAS_PTP_LIC + MBG_NET_INTF_LINK_OPT_MASK_HAS_SYNCE_STATUS = ( 1UL << MBG_NET_INTF_LINK_OPT_HAS_SYNCE_STATUS ) ///< See ::MBG_NET_INTF_LINK_OPT_HAS_SYNCE_STATUS }; @@ -11714,13 +12539,13 @@ enum MBG_NET_INTF_LINK_BOND_MODES */ enum MBG_NET_INTF_LINK_BOND_MODE_MASKS { - MBG_NET_INTF_LINK_BOND_MODE_MASK_ROUNDROBIN = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN - MBG_NET_INTF_LINK_BOND_MODE_MASK_ACTIVEBACKUP = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP - MBG_NET_INTF_LINK_BOND_MODE_MASK_XOR = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_XOR ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_XOR - MBG_NET_INTF_LINK_BOND_MODE_MASK_BROADCAST = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_BROADCAST ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_BROADCAST - MBG_NET_INTF_LINK_BOND_MODE_MASK_8023AD = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_8023AD ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_8023AD - MBG_NET_INTF_LINK_BOND_MODE_MASK_TLB = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_TLB ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_TLB - MBG_NET_INTF_LINK_BOND_MODE_MASK_ALB = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ALB ), ///< see ::MBG_NET_INTF_LINK_BOND_MODE_ALB + MBG_NET_INTF_LINK_BOND_MODE_MASK_ROUNDROBIN = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_ROUNDROBIN + MBG_NET_INTF_LINK_BOND_MODE_MASK_ACTIVEBACKUP = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_ACTIVEBACKUP + MBG_NET_INTF_LINK_BOND_MODE_MASK_XOR = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_XOR ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_XOR + MBG_NET_INTF_LINK_BOND_MODE_MASK_BROADCAST = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_BROADCAST ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_BROADCAST + MBG_NET_INTF_LINK_BOND_MODE_MASK_8023AD = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_8023AD ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_8023AD + MBG_NET_INTF_LINK_BOND_MODE_MASK_TLB = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_TLB ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_TLB + MBG_NET_INTF_LINK_BOND_MODE_MASK_ALB = ( 1UL << MBG_NET_INTF_LINK_BOND_MODE_ALB ), ///< See ::MBG_NET_INTF_LINK_BOND_MODE_ALB }; @@ -11781,9 +12606,9 @@ enum MBG_NET_INTF_LINK_TYPES */ enum MBG_NET_INTF_LINK_TYPE_MASKS { - MBG_NET_INTF_LINK_TYPE_MASK_PHYS = ( 1UL << MBG_NET_INTF_LINK_TYPE_PHYS ), ///< see ::MBG_NET_INTF_LINK_TYPE_PHYS - MBG_NET_INTF_LINK_TYPE_MASK_VLAN = ( 1UL << MBG_NET_INTF_LINK_TYPE_VLAN ), ///< see ::MBG_NET_INTF_LINK_TYPE_VLAN - MBG_NET_INTF_LINK_TYPE_MASK_BOND = ( 1UL << MBG_NET_INTF_LINK_TYPE_BOND ) ///< see ::MBG_NET_INTF_LINK_TYPE_BOND + MBG_NET_INTF_LINK_TYPE_MASK_PHYS = ( 1UL << MBG_NET_INTF_LINK_TYPE_PHYS ), ///< See ::MBG_NET_INTF_LINK_TYPE_PHYS + MBG_NET_INTF_LINK_TYPE_MASK_VLAN = ( 1UL << MBG_NET_INTF_LINK_TYPE_VLAN ), ///< See ::MBG_NET_INTF_LINK_TYPE_VLAN + MBG_NET_INTF_LINK_TYPE_MASK_BOND = ( 1UL << MBG_NET_INTF_LINK_TYPE_BOND ) ///< See ::MBG_NET_INTF_LINK_TYPE_BOND }; @@ -11811,9 +12636,9 @@ enum MBG_NET_INTF_ADDR_BITS */ enum MBG_NET_INTF_ADDR_MASKS { - MBG_NET_INTF_ADDR_MASK_DHCP4 = ( 1UL << MBG_NET_INTF_ADDR_BIT_DHCP4 ), ///< see ::MBG_NET_INTF_ADDR_BIT_DHCP4 - MBG_NET_INTF_ADDR_MASK_DHCP6 = ( 1UL << MBG_NET_INTF_ADDR_BIT_DHCP6 ), ///< see ::MBG_NET_INTF_ADDR_BIT_DHCP6 - MBG_NET_INTF_ADDR_MASK_AUTOCONF = ( 1UL << MBG_NET_INTF_ADDR_BIT_AUTOCONF ) ///< see ::MBG_NET_INTF_ADDR_BIT_AUTOCONF + MBG_NET_INTF_ADDR_MASK_DHCP4 = ( 1UL << MBG_NET_INTF_ADDR_BIT_DHCP4 ), ///< See ::MBG_NET_INTF_ADDR_BIT_DHCP4 + MBG_NET_INTF_ADDR_MASK_DHCP6 = ( 1UL << MBG_NET_INTF_ADDR_BIT_DHCP6 ), ///< See ::MBG_NET_INTF_ADDR_BIT_DHCP6 + MBG_NET_INTF_ADDR_MASK_AUTOCONF = ( 1UL << MBG_NET_INTF_ADDR_BIT_AUTOCONF ) ///< See ::MBG_NET_INTF_ADDR_BIT_AUTOCONF }; @@ -11903,9 +12728,9 @@ do \ /** * @brief An IPv4 or IPv6 network address */ -typedef struct +typedef struct mbg_ip_addr_s { - uint8_t type; ///< see ::MBG_IP_ADDR_TYPES + uint8_t type; ///< See ::MBG_IP_ADDR_TYPES uint8_t reserved_1; ///< reserved, currently always 0 @todo Do we need this as scope indicator? uint16_t reserved_2; ///< reserved, currently always 0 @@ -11944,7 +12769,7 @@ do \ */ typedef struct { - uint16_t idx; + MBG_MSG_IDX idx; MBG_IP_ADDR addr; ///< network address } MBG_IP_ADDR_IDX; @@ -11962,7 +12787,7 @@ do \ */ typedef struct { - MBG_IP_ADDR addr; ///< see ::MBG_IP_ADDR + MBG_IP_ADDR addr; ///< See ::MBG_IP_ADDR uint16_t port; ///< UDP or TCP port uint16_t flags; ///< currently always 0 @@ -12002,7 +12827,7 @@ do \ */ typedef struct { - uint16_t idx; + MBG_MSG_IDX idx; MBG_NET_NAME net_name; } MBG_NET_NAME_IDX; @@ -12015,48 +12840,84 @@ do \ } while ( 0 ) +enum MBG_NET_INTF_SYNC_E_FLAGS +{ + MBG_NET_INTF_SYNC_E_FLAG_SYNC_E_ACTIVE, ///< Indicates, whether SyncE is activated + MBG_NET_INTF_SYNC_E_FLAG_SYNC_E_AUTO_QL, ///< Indicates, whether the quality level is determined automatically, + ///< otherwise, the fixed input/output SSMs are being used + N_MBG_NET_INTF_SYNC_E_FLAGS + +}; + + +enum MBG_NET_INTF_SYNC_E_FLAG_MASKS +{ + MBG_NET_INTF_SYNC_E_FLAG_MASK_SYNC_E_ACTIVE = ( 1UL << MBG_NET_INTF_SYNC_E_FLAG_SYNC_E_ACTIVE ), ///< See ::MBG_NET_INTF_SYNC_E_FLAG_SYNC_E_ACTIVE + MBG_NET_INTF_SYNC_E_FLAG_MASK_SYNC_E_AUTO_QL = ( 1UL << MBG_NET_INTF_SYNC_E_FLAG_SYNC_E_AUTO_QL ) ///< See ::MBG_NET_INTF_SYNC_E_FLAG_SYNC_E_AUTO_QL + +}; + + +typedef struct +{ + uint8_t flags; ///< SyncE flags, see ::MBG_NET_INTF_SYNC_E_FLAG_MASKS + uint8_t min_input_ssm; ///< minimum accepted SSM-QL as synchronization input + uint8_t fixed_input_ssm; ///< assumed SSM value for SyncE input (0xFF if taken from network) + ///< or currently incoming SSM in status structs + uint8_t fixed_output_ssm; ///< Fixed SSM output override + + uint8_t current_output_ssm; ///< current quality level for SyncE output (automatically assigned or fixed) + ///< or currently outgoing SSM in status structs + uint8_t sdh_net_opt; ///< SDH network option, see ::SDH_NETWORK_OPTIONS and ::MBG_NET_INTF_LINK_INFO::supp_sdh_net_opts + uint8_t gb_copper_mode; ///< GBit link copper mode, see ::GBIT_LINK_COPPER_MODES and ::MBG_NET_INTF_LINK_INFO::supp_gb_copper_modes + uint8_t local_priority; ///< user defined priority value (0-255) + +} MBG_NET_INTF_SYNC_E_SETTINGS; + /** * @brief Physical network interface link specific settings */ typedef struct { - char name[MBG_IFNAMSIZ]; ///< Interface name - MBG_MAC_ADDR mac_addr; ///< Physical hardware address - MBG_MAC_ADDR broadcast; ///< Physical broadcast address + char name[MBG_IFNAMSIZ]; ///< Interface name + MBG_MAC_ADDR mac_addr; ///< Physical hardware address + MBG_MAC_ADDR broadcast; ///< Physical broadcast address - uint32_t if_index; ///< Interface index assigned by the kernel - uint32_t common_if_index; ///< Common interface index assigned by the lib (associated with the MAC address), - ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_PHYS - uint32_t ass_if_index; ///< Interface index of the associated physical interface link, - ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_VLAN + uint32_t if_index; ///< Interface index assigned by the kernel + uint32_t common_if_index; ///< Common interface index assigned by the lib (associated with the MAC address), + ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_PHYS + uint32_t ass_if_index; ///< Interface index of the associated physical interface link, + ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_VLAN - uint32_t flags; ///< Reserved, currently 0 - uint32_t states; ///< see @ref MBG_NET_INTF_LINK_STATE_MASKS + uint32_t reserved_1; ///< Reserved, currently 0 + uint32_t states; ///< see @ref MBG_NET_INTF_LINK_STATE_MASKS - uint32_t hw_type; ///< Hardware type of interface (see ::MBG_NET_HW_TYPES) - uint32_t mtu; ///< Max. packet size in bytes - uint32_t txqlen; ///< Transmission queue length (number of packets) - uint32_t speed; ///< Link speed in MBit/s + uint32_t hw_type; ///< Hardware type of interface (see ::MBG_NET_HW_TYPES) + uint32_t mtu; ///< Max. packet size in bytes + uint32_t txqlen; ///< Transmission queue length (number of packets) + uint32_t speed; ///< Link speed in MBit/s - uint8_t type; ///< see ::MBG_NET_INTF_LINK_TYPES - uint8_t duplex; ///< Duplex mode, half (0) or full (1) - uint8_t autoneg; ///< Indicates, whether autonegotiation is enabled or disabled - uint8_t port_type; ///< see ::MBG_NET_INTF_LINK_PORT_TYPES + uint8_t type; ///< See ::MBG_NET_INTF_LINK_TYPES + uint8_t duplex; ///< Duplex mode, half (0) or full (1) + uint8_t autoneg; ///< Indicates, whether autonegotiation is enabled or disabled + uint8_t port_type; ///< See ::MBG_NET_INTF_LINK_PORT_TYPES - uint8_t bond_mode; ///< Bonding mode, see ::MBG_NET_INTF_LINK_BOND_MODES - ///< Valid if ::MBG_NET_INTF_LINK_STATE_MASK_MASTER is set in ::MBG_NET_INTF_LINK_SETTINGS::states - uint8_t bond_state; ///< Status of this interface in the bonding group, see ::MBG_NET_INTF_LINK_BOND_STATES - ///< Valid if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in ::MBG_NET_INTF_LINK_SETTINGS::states - uint16_t bond_idx; ///< Interface index of the bonding master link, see ::MBG_NET_INTF_LINK_SETTINGS::if_index - ///< Valid, if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in ::MBG_NET_INTF_LINK_SETTINGS::states + uint8_t bond_mode; ///< Bonding mode, see ::MBG_NET_INTF_LINK_BOND_MODES + ///< Valid if ::MBG_NET_INTF_LINK_STATE_MASK_MASTER is set in ::MBG_NET_INTF_LINK_SETTINGS::states + uint8_t bond_state; ///< Status of this interface in the bonding group, see ::MBG_NET_INTF_LINK_BOND_STATES + ///< Valid if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in ::MBG_NET_INTF_LINK_SETTINGS::states + uint16_t bond_idx; ///< Interface index of the bonding master link, see ::MBG_NET_INTF_LINK_SETTINGS::if_index + ///< Valid, if MBG_NET_INTF_LINK_STATE_MASK_SLAVE is set in ::MBG_NET_INTF_LINK_SETTINGS::states - uint16_t vlan_cfg; ///< VLAN configuration options, see ::MBG_VLAN_CFG - ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_VLAN - uint16_t reserved_1; ///< Reserved, currently 0 + uint16_t vlan_cfg; ///< VLAN configuration options, see ::MBG_VLAN_CFG + ///< Valid if ::MBG_NET_INTF_LINK_SETTINGS::type is ::MBG_NET_INTF_LINK_TYPE_VLAN + uint16_t reserved_2; ///< Reserved, currently 0 - uint32_t reserved_2; ///< Reserved, currently 0 - uint32_t reserved_3; ///< Reserved, currently 0 + MBG_NET_INTF_SYNC_E_SETTINGS sync_e; ///< SyncE settings for this port, only valid if ::MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_IN or + ///< ::MBG_NET_INTF_LINK_OPT_MASK_CAN_SYNCE_OUT is set in ::MBG_NET_INTF_LINK_INFO::supp_opts + ///< For network status structs, this can also be the SyncE status, if ::MBG_NET_INTF_LINK_OPT_HAS_SYNCE_STATUS + ///< is set in ::MBG_NET_INTF_LINK_INFO::supp_opts } MBG_NET_INTF_LINK_SETTINGS; @@ -12086,7 +12947,7 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_INFO::n_supp_intf_link-1 + MBG_MSG_IDX idx; ///< 0..::MBG_NET_GLB_CFG_INFO::n_supp_intf_link-1. MBG_NET_INTF_LINK_SETTINGS settings; } MBG_NET_INTF_LINK_SETTINGS_IDX; @@ -12105,35 +12966,39 @@ do \ */ typedef struct { - MBG_NET_INTF_LINK_SETTINGS link_settings; ///< see ::MBG_NET_INTF_LINK_SETTINGS - uint32_t supp_flags; ///< Reserved, currently 0 - uint32_t supp_states; ///< see @ref MBG_NET_INTF_LINK_STATE_MASKS - uint32_t supp_types; ///< see ::MBG_NET_INTF_LINK_TYPE_MASKS - uint32_t supp_speed_modes; ///< see @ref MBG_NET_INTF_LINK_SPEED_MODE_MASKS - uint32_t supp_port_types; ///< see ::MBG_NET_INTF_LINK_PORT_TYPE_MASKS - uint32_t supp_opts; ///< see ::MBG_NET_INTF_LINK_OPT_MASKS - uint32_t supp_bond_modes; ///< see ::MBG_NET_INTF_LINK_BOND_MODE_MASKS + MBG_NET_INTF_LINK_SETTINGS link_settings; ///< See ::MBG_NET_INTF_LINK_SETTINGS + uint16_t supp_sdh_net_opts; ///< supported SDH network options for SyncE, see ::SDH_NETWORK_OPTION_MASKS + uint16_t supp_gb_copper_modes; ///< supported GBit link copper modes for SyncE, see ::GBIT_LINK_COPPER_MODE_MASKS + uint32_t supp_states; ///< see @ref MBG_NET_INTF_LINK_STATE_MASKS + uint32_t supp_types; ///< See ::MBG_NET_INTF_LINK_TYPE_MASKS + uint32_t supp_speed_modes; ///< see @ref MBG_NET_INTF_LINK_SPEED_MODE_MASKS + uint32_t supp_port_types; ///< See ::MBG_NET_INTF_LINK_PORT_TYPE_MASKS + uint32_t supp_opts; ///< See ::MBG_NET_INTF_LINK_OPT_MASKS + uint32_t supp_bond_modes; ///< See ::MBG_NET_INTF_LINK_BOND_MODE_MASKS + uint16_t lic_ntp_clients; ///< number of supported NTP clients, only valid if ::MBG_NET_INTF_LINK_OPT_MASK_HAS_NTP_LIC + uint16_t lic_ptp_clients; ///< number of supported PTP clients, only valid if ::MBG_NET_INTF_LINK_OPT_MASK_HAS_PTP_LIC uint32_t reserved_1; uint32_t reserved_2; uint32_t reserved_3; - uint32_t reserved_4; } MBG_NET_INTF_LINK_INFO; #define _mbg_swab_net_intf_link_info( _p ) \ do \ { \ _mbg_swab_net_intf_link_settings( &(_p)->link_settings ); \ - _mbg_swab32( &(_p)->supp_flags ); \ + _mbg_swab16( &(_p)->supp_sdh_net_opts ); \ + _mbg_swab16( &(_p)->supp_gb_copper_mds ); \ _mbg_swab32( &(_p)->supp_states ); \ _mbg_swab32( &(_p)->supp_types ); \ _mbg_swab32( &(_p)->supp_speed_modes ); \ _mbg_swab32( &(_p)->supp_port_types ); \ _mbg_swab32( &(_p)->supp_opts ); \ _mbg_swab32( &(_p)->supp_bond_modes ); \ + _mbg_swab16( &(_p)->lic_ntp_clients ); \ + _mbg_swab16( &(_p)->lic_ptp_clients ); \ _mbg_swab32( &(_p)->reserved_1 ); \ _mbg_swab32( &(_p)->reserved_2 ); \ _mbg_swab32( &(_p)->reserved_3 ); \ - _mbg_swab32( &(_p)->reserved_4 ); \ } while ( 0 ) @@ -12141,10 +13006,10 @@ do \ /** * @brief Query MBG_NET_INTF_LINK_INFO by its index */ -typedef struct +typedef struct mbg_net_intf_link_info_idx_s { - uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_link-1 - MBG_NET_INTF_LINK_INFO info; ///< see ::MBG_NET_INTF_LINK_INFO + MBG_MSG_IDX idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_link-1. + MBG_NET_INTF_LINK_INFO info; ///< See ::MBG_NET_INTF_LINK_INFO. } MBG_NET_INTF_LINK_INFO_IDX; @@ -12168,7 +13033,7 @@ typedef struct uint32_t addr_index; ///< Index of the address on the physical interface it is assigned to uint32_t ass_if_index; ///< Index of the associated interface link, see ::MBG_NET_INTF_LINK_SETTINGS::if_index - uint32_t flags; ///< see ::MBG_NET_INTF_ADDR_MASKS + uint32_t flags; ///< See ::MBG_NET_INTF_ADDR_MASKS MBG_IP_ADDR ip; ///< IP address associated with this interface MBG_IP_ADDR broadcast; ///< Broadcast address associated with this interface @@ -12203,8 +13068,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1 - MBG_NET_INTF_ADDR_SETTINGS settings; ///< see ::MBG_NET_INTF_ADDR_SETTINGS + MBG_MSG_IDX idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1. + MBG_NET_INTF_ADDR_SETTINGS settings; ///< See ::MBG_NET_INTF_ADDR_SETTINGS. } MBG_NET_INTF_ADDR_SETTINGS_IDX; @@ -12221,8 +13086,8 @@ do \ */ typedef struct { - MBG_NET_INTF_ADDR_SETTINGS addr_settings; ///< see ::MBG_NET_INTF_ADDR_SETTINGS - uint32_t supp_flags; ///< see ::MBG_NET_INTF_ADDR_MASKS + MBG_NET_INTF_ADDR_SETTINGS addr_settings; ///< See ::MBG_NET_INTF_ADDR_SETTINGS + uint32_t supp_flags; ///< See ::MBG_NET_INTF_ADDR_MASKS uint32_t reserved_1; ///< Reserved, currently 0 uint32_t reserved_2; ///< Reserved, currently 0 @@ -12241,10 +13106,10 @@ do \ /** * @brief Query MBG_NET_INTF_ADDR_INFO by its index */ -typedef struct +typedef struct mbg_net_intf_addr_info_idx_s { - uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1 - MBG_NET_INTF_ADDR_INFO info; ///< see ::MBG_NET_INTF_ADDR_INFO + MBG_MSG_IDX idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_addr-1. + MBG_NET_INTF_ADDR_INFO info; ///< See ::MBG_NET_INTF_ADDR_INFO. } MBG_NET_INTF_ADDR_INFO_IDX; @@ -12302,8 +13167,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1 - MBG_NET_INTF_ROUTE_SETTINGS settings; ///< see ::MBG_NET_INTF_ROUTE_SETTINGS + MBG_MSG_IDX idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1. + MBG_NET_INTF_ROUTE_SETTINGS settings; ///< See ::MBG_NET_INTF_ROUTE_SETTINGS. } MBG_NET_INTF_ROUTE_SETTINGS_IDX; @@ -12320,7 +13185,7 @@ do \ */ typedef struct { - MBG_NET_INTF_ROUTE_SETTINGS route_settings; ///< see ::MBG_NET_INTF_ROUTE_SETTINGS + MBG_NET_INTF_ROUTE_SETTINGS route_settings; ///< See ::MBG_NET_INTF_ROUTE_SETTINGS uint32_t reserved_1; ///< Reserved, currently 0 uint32_t reserved_2; ///< Reserved, currently 0 uint32_t reserved_3; ///< Reserved, currently 0 @@ -12343,8 +13208,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1 - MBG_NET_INTF_ROUTE_INFO info; ///< see ::MBG_NET_INTF_ROUTE_INFO + MBG_MSG_IDX idx; ///< 0..::MBG_NET_GLB_CFG_SETTINGS::num_intf_route-1. + MBG_NET_INTF_ROUTE_INFO info; ///< See ::MBG_NET_INTF_ROUTE_INFO. } MBG_NET_INTF_ROUTE_INFO_IDX; @@ -12399,9 +13264,9 @@ enum MBG_UCAP_NET_TRANSF_MODE */ enum MBG_UCAP_NET_TRANSF_MODE_MASKS { - MBG_UCAP_NET_TRANSF_MODE_MASK_UNKNOWN = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_UNKNOWN ), ///< see ::MBG_UCAP_NET_TRANSF_MODE_UNKNOWN - MBG_UCAP_NET_TRANSF_MODE_MASK_ON_REQ = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_ON_REQ ), ///< see ::MBG_UCAP_NET_TRANSF_MODE_ON_REQ - MBG_UCAP_NET_TRANSF_MODE_MASK_AUTO = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_AUTO ) ///< see ::MBG_UCAP_NET_TRANSF_MODE_AUTO + MBG_UCAP_NET_TRANSF_MODE_MASK_UNKNOWN = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_UNKNOWN ), ///< See ::MBG_UCAP_NET_TRANSF_MODE_UNKNOWN + MBG_UCAP_NET_TRANSF_MODE_MASK_ON_REQ = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_ON_REQ ), ///< See ::MBG_UCAP_NET_TRANSF_MODE_ON_REQ + MBG_UCAP_NET_TRANSF_MODE_MASK_AUTO = ( 1UL << MBG_UCAP_NET_TRANSF_MODE_AUTO ) ///< See ::MBG_UCAP_NET_TRANSF_MODE_AUTO }; @@ -12428,8 +13293,8 @@ enum MBG_UCAP_NET_TRANSF_PROTO */ enum MBG_UCAP_NET_TRANSF_PROTO_MASKS { - MBG_UCAP_NET_TRANSF_PROTO_MASK_UNKNOWN = ( 1UL << MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN ), ///< see ::MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN - MBG_UCAP_NET_TRANSF_PROTO_MASK_UDP = ( 1UL << MBG_UCAP_NET_TRANSF_PROTO_UDP ) ///< see ::MBG_UCAP_NET_TRANSF_PROTO_UDP + MBG_UCAP_NET_TRANSF_PROTO_MASK_UNKNOWN = ( 1UL << MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN ), ///< See ::MBG_UCAP_NET_TRANSF_PROTO_UNKNOWN + MBG_UCAP_NET_TRANSF_PROTO_MASK_UDP = ( 1UL << MBG_UCAP_NET_TRANSF_PROTO_UDP ) ///< See ::MBG_UCAP_NET_TRANSF_PROTO_UDP }; @@ -12453,7 +13318,7 @@ enum MBG_UCAP_NET_SUPP_FLAGS */ enum MBG_UCAP_NET_SUPP_FLAG_MASKS { - MBG_UCAP_NET_SUPP_FLAG_MASK_IPV6 = ( 1UL << MBG_UCAP_NET_SUPP_FLAG_IPV6 ) ///< see ::MBG_UCAP_NET_SUPP_FLAG_IPV6 + MBG_UCAP_NET_SUPP_FLAG_MASK_IPV6 = ( 1UL << MBG_UCAP_NET_SUPP_FLAG_IPV6 ) ///< See ::MBG_UCAP_NET_SUPP_FLAG_IPV6 }; @@ -12492,7 +13357,7 @@ do \ */ typedef struct { - MBG_UCAP_NET_GLB_SETTINGS settings; ///< see ::MBG_UCAP_NET_GLB_SETTINGS + MBG_UCAP_NET_GLB_SETTINGS settings; ///< See ::MBG_UCAP_NET_GLB_SETTINGS uint32_t n_supp_recvs; ///< Number of supported network receivers, see ::MBG_UCAP_NET_RECV_INFO_IDX uint32_t supp_modes; ///< Supported transfer modes, see ::MBG_UCAP_NET_TRANSF_MODE_MASKS @@ -12559,8 +13424,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_UCAP_NET_GLB_SETTINGS::num_recvs-1 - MBG_UCAP_NET_RECV_SETTINGS settings; ///< see ::MBG_UCAP_NET_RECV_SETTINGS + MBG_MSG_IDX idx; ///< 0..::MBG_UCAP_NET_GLB_SETTINGS::num_recvs-1. + MBG_UCAP_NET_RECV_SETTINGS settings; ///< See ::MBG_UCAP_NET_RECV_SETTINGS. } MBG_UCAP_NET_RECV_SETTINGS_IDX; @@ -12579,7 +13444,7 @@ do \ */ typedef struct { - MBG_UCAP_NET_RECV_SETTINGS settings; ///< see ::MBG_UCAP_NET_RECV_SETTINGS + MBG_UCAP_NET_RECV_SETTINGS settings; ///< See ::MBG_UCAP_NET_RECV_SETTINGS uint32_t reserved_0; ///< Reserved, currently always 0 uint32_t reserved_1; ///< Reserved, currently always 0 @@ -12612,8 +13477,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_UCAP_NET_GLB_INFO::n_supp_recvs-1 - MBG_UCAP_NET_RECV_INFO info; ///< see ::MBG_UCAP_NET_RECV_INFO + MBG_MSG_IDX idx; ///< 0..::MBG_UCAP_NET_GLB_INFO::n_supp_recvs-1. + MBG_UCAP_NET_RECV_INFO info; ///< See ::MBG_UCAP_NET_RECV_INFO. } MBG_UCAP_NET_RECV_INFO_IDX; @@ -12659,13 +13524,13 @@ enum PTP_NW_PROTS */ enum PTP_NW_PROT_MASKS { - PTP_NW_PROT_MSK_RESERVED = ( 1UL << PTP_NW_PROT_RESERVED ), ///< see ::PTP_NW_PROT_RESERVED - PTP_NW_PROT_MSK_UDP_IPV4 = ( 1UL << PTP_NW_PROT_UDP_IPV4 ), ///< see ::PTP_NW_PROT_UDP_IPV4 - PTP_NW_PROT_MSK_UDP_IPV6 = ( 1UL << PTP_NW_PROT_UDP_IPV6 ), ///< see ::PTP_NW_PROT_UDP_IPV6 - PTP_NW_PROT_MSK_IEEE_802_3 = ( 1UL << PTP_NW_PROT_IEEE_802_3 ), ///< see ::PTP_NW_PROT_IEEE_802_3 - PTP_NW_PROT_MSK_DEVICE_NET = ( 1UL << PTP_NW_PROT_DEVICE_NET ), ///< see ::PTP_NW_PROT_DEVICE_NET - PTP_NW_PROT_MSK_CONTROL_NET = ( 1UL << PTP_NW_PROT_CONTROL_NET ), ///< see ::PTP_NW_PROT_CONTROL_NET - PTP_NW_PROT_MSK_PROFINET = ( 1UL << PTP_NW_PROT_PROFINET ) ///< see ::PTP_NW_PROT_PROFINET + PTP_NW_PROT_MSK_RESERVED = ( 1UL << PTP_NW_PROT_RESERVED ), ///< See ::PTP_NW_PROT_RESERVED + PTP_NW_PROT_MSK_UDP_IPV4 = ( 1UL << PTP_NW_PROT_UDP_IPV4 ), ///< See ::PTP_NW_PROT_UDP_IPV4 + PTP_NW_PROT_MSK_UDP_IPV6 = ( 1UL << PTP_NW_PROT_UDP_IPV6 ), ///< See ::PTP_NW_PROT_UDP_IPV6 + PTP_NW_PROT_MSK_IEEE_802_3 = ( 1UL << PTP_NW_PROT_IEEE_802_3 ), ///< See ::PTP_NW_PROT_IEEE_802_3 + PTP_NW_PROT_MSK_DEVICE_NET = ( 1UL << PTP_NW_PROT_DEVICE_NET ), ///< See ::PTP_NW_PROT_DEVICE_NET + PTP_NW_PROT_MSK_CONTROL_NET = ( 1UL << PTP_NW_PROT_CONTROL_NET ), ///< See ::PTP_NW_PROT_CONTROL_NET + PTP_NW_PROT_MSK_PROFINET = ( 1UL << PTP_NW_PROT_PROFINET ) ///< See ::PTP_NW_PROT_PROFINET }; @@ -12723,21 +13588,33 @@ enum PTP_PORT_STATES }; +#define PTP_PORT_ST_STR_UNINITIALIZED "Uninitialized" +#define PTP_PORT_ST_STR_INITIALIZED "Initializing" +#define PTP_PORT_ST_STR_FAULTY "Faulty" +#define PTP_PORT_ST_STR_DISABLED "Disabled" +#define PTP_PORT_ST_STR_LISTENING "Listening" +#define PTP_PORT_ST_STR_PREMASTER "Pre-Master" +#define PTP_PORT_ST_STR_MASTER "Master" +#define PTP_PORT_ST_STR_PASSIVE "Passive" +#define PTP_PORT_ST_STR_UNCALIBRATED "Uncalibrated" +#define PTP_PORT_ST_STR_SLAVE "Slave" + + /** * @brief Name strings for the PTP port states */ -#define PTP_PORT_STATE_STRS \ -{ \ - "UNINITIALIZED", \ - "INITIALIZING", \ - "FAULTY", \ - "DISABLED", \ - "LISTENING", \ - "PRE_MASTER", \ - "MASTER", \ - "PASSIVE", \ - "UNCALIBRATED", \ - "SLAVE" \ +#define PTP_PORT_STATE_STRS \ +{ \ + PTP_PORT_ST_STR_UNINITIALIZED, \ + PTP_PORT_ST_STR_INITIALIZED, \ + PTP_PORT_ST_STR_FAULTY, \ + PTP_PORT_ST_STR_DISABLED, \ + PTP_PORT_ST_STR_LISTENING, \ + PTP_PORT_ST_STR_PREMASTER, \ + PTP_PORT_ST_STR_MASTER, \ + PTP_PORT_ST_STR_PASSIVE, \ + PTP_PORT_ST_STR_UNCALIBRATED, \ + PTP_PORT_ST_STR_SLAVE \ } @@ -12778,8 +13655,8 @@ enum PTP_DELAY_MECHS */ enum PTP_DELAY_MECH_MASKS { - PTP_DELAY_MECH_MSK_E2E = ( 1UL << PTP_DELAY_MECH_E2E ), ///< see ::PTP_DELAY_MECH_E2E - PTP_DELAY_MECH_MSK_P2P = ( 1UL << PTP_DELAY_MECH_P2P ) ///< see ::PTP_DELAY_MECH_P2P + PTP_DELAY_MECH_MSK_E2E = ( 1UL << PTP_DELAY_MECH_E2E ), ///< See ::PTP_DELAY_MECH_E2E + PTP_DELAY_MECH_MSK_P2P = ( 1UL << PTP_DELAY_MECH_P2P ) ///< See ::PTP_DELAY_MECH_P2P }; @@ -12961,17 +13838,17 @@ enum PTP_ROLES */ enum PTP_ROLE_MASKS { - PTP_ROLE_MSK_MULTICAST_SLAVE = ( 1UL << PTP_ROLE_MULTICAST_SLAVE ), ///< see ::PTP_ROLE_MULTICAST_SLAVE - PTP_ROLE_MSK_UNICAST_SLAVE = ( 1UL << PTP_ROLE_UNICAST_SLAVE ), ///< see ::PTP_ROLE_UNICAST_SLAVE - PTP_ROLE_MSK_MULTICAST_MASTER = ( 1UL << PTP_ROLE_MULTICAST_MASTER ), ///< see ::PTP_ROLE_MULTICAST_MASTER - PTP_ROLE_MSK_UNICAST_MASTER = ( 1UL << PTP_ROLE_UNICAST_MASTER ), ///< see ::PTP_ROLE_UNICAST_MASTER - PTP_ROLE_MSK_MULTICAST_AUTO = ( 1UL << PTP_ROLE_MULTICAST_AUTO ), ///< see ::PTP_ROLE_MULTICAST_AUTO - PTP_ROLE_MSK_BOTH_MASTER = ( 1UL << PTP_ROLE_BOTH_MASTER ), ///< see ::PTP_ROLE_BOTH_MASTER - PTP_ROLE_MSK_NTP_SERVER = ( 1UL << PTP_ROLE_NTP_SERVER ), ///< see ::PTP_ROLE_NTP_SERVER - PTP_ROLE_MSK_NTP_CLIENT = ( 1UL << PTP_ROLE_NTP_CLIENT ), ///< see ::PTP_ROLE_NTP_CLIENT - PTP_ROLE_MSK_TIME_MONITOR = ( 1UL << PTP_ROLE_TIME_MONITOR ), ///< see ::PTP_ROLE_TIME_MONITOR - PTP_ROLE_MSK_V1_MASTER = ( 1UL << PTP_ROLE_V1_MASTER ), ///< see ::PTP_ROLE_MULTICAST_MASTER - PTP_ROLE_MSK_V1_SLAVE = ( 1UL << PTP_ROLE_V1_SLAVE ) ///< see ::PTP_ROLE_UNICAST_SLAVE + PTP_ROLE_MSK_MULTICAST_SLAVE = ( 1UL << PTP_ROLE_MULTICAST_SLAVE ), ///< See ::PTP_ROLE_MULTICAST_SLAVE + PTP_ROLE_MSK_UNICAST_SLAVE = ( 1UL << PTP_ROLE_UNICAST_SLAVE ), ///< See ::PTP_ROLE_UNICAST_SLAVE + PTP_ROLE_MSK_MULTICAST_MASTER = ( 1UL << PTP_ROLE_MULTICAST_MASTER ), ///< See ::PTP_ROLE_MULTICAST_MASTER + PTP_ROLE_MSK_UNICAST_MASTER = ( 1UL << PTP_ROLE_UNICAST_MASTER ), ///< See ::PTP_ROLE_UNICAST_MASTER + PTP_ROLE_MSK_MULTICAST_AUTO = ( 1UL << PTP_ROLE_MULTICAST_AUTO ), ///< See ::PTP_ROLE_MULTICAST_AUTO + PTP_ROLE_MSK_BOTH_MASTER = ( 1UL << PTP_ROLE_BOTH_MASTER ), ///< See ::PTP_ROLE_BOTH_MASTER + PTP_ROLE_MSK_NTP_SERVER = ( 1UL << PTP_ROLE_NTP_SERVER ), ///< See ::PTP_ROLE_NTP_SERVER + PTP_ROLE_MSK_NTP_CLIENT = ( 1UL << PTP_ROLE_NTP_CLIENT ), ///< See ::PTP_ROLE_NTP_CLIENT + PTP_ROLE_MSK_TIME_MONITOR = ( 1UL << PTP_ROLE_TIME_MONITOR ), ///< See ::PTP_ROLE_TIME_MONITOR + PTP_ROLE_MSK_V1_MASTER = ( 1UL << PTP_ROLE_V1_MASTER ), ///< See ::PTP_ROLE_MULTICAST_MASTER + PTP_ROLE_MSK_V1_SLAVE = ( 1UL << PTP_ROLE_V1_SLAVE ) ///< See ::PTP_ROLE_UNICAST_SLAVE }; @@ -13035,7 +13912,7 @@ enum PTP_ROLE_MASKS * @note This usually consists of a 6 byte MAC address with * 2 fixed bytes inserted, or all ones as wildcard. */ -typedef struct +typedef struct ptp_clock_id_s { uint8_t b[8]; @@ -13080,6 +13957,30 @@ typedef struct /** + * @brief A PTP port identity + * + * @note For further information, see IEEE 1588-2008, chapter 5.3.5 + * + * @see ::PTP_CLOCK_ID + * @see ::PTP_PORT_ID + */ +typedef struct ptp_ng_port_identity_s +{ + PTP_CLOCK_ID clock_identity; + PTP_PORT_ID port_number; + uint16_t reserved_1; + uint32_t reserved_2; +} PTP_NG_PORT_IDENTITY; + + +#define _mbg_swab_ptp_ng_port_identity( _p ) \ +{ \ + _mbg_swab_ptp_clock_id( &(_p)->clock_identity ); \ + _mbg_swab_ptp_port_id( &(_p)->port_number ); \ +} + + +/** * @brief PTP clock quality * * @note For further information, see IEEE 1588-2008, chapter 5.3.7 @@ -13087,7 +13988,7 @@ typedef struct typedef struct { uint8_t clock_class; ///< PTP clock class representing the current sync status - int8_t clock_accuracy; ///< see ::PTP_CLOCK_ACCURACIES + int8_t clock_accuracy; ///< See ::PTP_CLOCK_ACCURACIES uint16_t log_variance; ///< PTP offset scaled log variance representing the time stability } PTP_CLOCK_QUALITY; @@ -13105,7 +14006,6 @@ typedef struct * @brief PTP time interval * * @note For further information, see IEEE 1588-2008, chapter 5.3.2 - * */ typedef struct { @@ -13120,6 +14020,76 @@ typedef struct } + +/** + * @brief PTP packet timestamp seconds field. + * + * PTP timestamps used in network packets use an 48 bit (i.e. 6 bytes) only + * seconds fields, so a conversion is required whenever such a seconds field + * is to be read or written. + * + * In the PTP specs this is referenced as @a UInteger48. + * + * This is defined as a structure with an array member to avoid + * potential problems when passing the address as a reference, + * e.g. sizeof( *p ). + * + * @see ::PTP_PKT_TSTAMP + */ +typedef struct +{ + uint8_t b[6]; + +} PTP_PKT_TSTAMP_SECS; + + + +/** + * @brief PTP packet timestamp nanoseconds field. + * + * @see ::PTP_PKT_TSTAMP + */ +typedef uint32_t PTP_PKT_TSTAMP_NSECS; + + + +/** + * @brief PTP packet timestamp. + */ +typedef struct +{ + PTP_PKT_TSTAMP_SECS secs; + PTP_PKT_TSTAMP_NSECS nsecs; + +} PTP_PKT_TSTAMP; + + + +/** + * @brief Data type to store daylight saving flags in TLVs. + * + * @see ::PTP_TLV_DST_FLAG_MSKS + */ +typedef uint8_t PTP_TLV_DST_FLAGS; + + + +/** + * @brief Data type to store leap second flags in TLVs. + * + * @see ::PTP_TLV_LS_FLAG_MSKS + */ +typedef uint8_t PTP_TLV_LS_FLAGS; + + + +/** + * @brief Data type to store time offsets of whole seconds in TLVs. + */ +typedef int32_t PTP_TLV_TIME_OFFS; + + + /** * @brief An enumeration of time scales used with PTP * @@ -13186,7 +14156,7 @@ typedef struct uint16_t nw_prot; ///< one of the enumerated protocols, see ::PTP_NW_PROTS uint8_t ptp_prot_version; ///< PTP protocol version, 1, or 2, usually 2 for v2 uint8_t port_state; ///< one of the enumerated port states, see ::PTP_PORT_STATES - uint32_t flags; ///< see ::PTP_STATE_FLAGS + uint32_t flags; ///< See ::PTP_STATE_FLAGS NANO_TIME offset; ///< estimated time offset from the upstream time source NANO_TIME path_delay; NANO_TIME mean_path_delay; @@ -13196,14 +14166,14 @@ typedef struct uint16_t clock_offset_scaled_log_variance; uint8_t clock_class; - uint8_t clock_accuracy; ///< see ::PTP_CLOCK_ACCURACIES + uint8_t clock_accuracy; ///< See ::PTP_CLOCK_ACCURACIES uint32_t tsu_secs; ///< current seconds value of time stamp unit uint32_t reserved_2; ///< reserved, currently always 0 uint8_t domain_number; ///< the PTP clock domain number, 0:3 - uint8_t time_source; ///< see ::PTP_TIME_SOURCES - uint8_t delay_mech; ///< see ::PTP_DELAY_MECHS + uint8_t time_source; ///< See ::PTP_TIME_SOURCES + uint8_t delay_mech; ///< See ::PTP_DELAY_MECHS int8_t log_delay_req_intv; int16_t utc_offset; ///< %UTC offset observed against TAI @@ -13260,14 +14230,14 @@ enum PTP_STATE_FLAGS */ enum PTP_STATE_FLAG_MASKS { - PTP_FLAG_MSK_SLAVE_ONLY = ( 1UL << PTP_FLAG_SLAVE_ONLY ), ///< see ::PTP_FLAG_SLAVE_ONLY - PTP_FLAG_MSK_IS_SLAVE = ( 1UL << PTP_FLAG_IS_SLAVE ), ///< see ::PTP_FLAG_IS_SLAVE - PTP_FLAG_MSK_TIMESCALE_IS_PTP = ( 1UL << PTP_FLAG_TIMESCALE_IS_PTP ), ///< see ::PTP_FLAG_TIMESCALE_IS_PTP - PTP_FLAG_MSK_LS_ANN = ( 1UL << PTP_FLAG_LS_ANN ), ///< see ::PTP_FLAG_LS_ANN - PTP_FLAG_MSK_LS_ANN_NEG = ( 1UL << PTP_FLAG_LS_ANN_NEG ), ///< see ::PTP_FLAG_LS_ANN_NEG - PTP_FLAG_MSK_IS_UNICAST = ( 1UL << PTP_FLAG_IS_UNICAST ), ///< see ::PTP_FLAG_IS_UNICAST - PTP_FLAG_MSK_UTC_VALID = ( 1UL << PTP_FLAG_UTC_VALID ), ///< see ::PTP_FLAG_UTC_VALID - PTP_FLAG_MSK_ONE_STEP = ( 1UL << PTP_FLAG_ONE_STEP ) ///< see ::PTP_FLAG_ONE_STEP + PTP_FLAG_MSK_SLAVE_ONLY = ( 1UL << PTP_FLAG_SLAVE_ONLY ), ///< See ::PTP_FLAG_SLAVE_ONLY + PTP_FLAG_MSK_IS_SLAVE = ( 1UL << PTP_FLAG_IS_SLAVE ), ///< See ::PTP_FLAG_IS_SLAVE + PTP_FLAG_MSK_TIMESCALE_IS_PTP = ( 1UL << PTP_FLAG_TIMESCALE_IS_PTP ), ///< See ::PTP_FLAG_TIMESCALE_IS_PTP + PTP_FLAG_MSK_LS_ANN = ( 1UL << PTP_FLAG_LS_ANN ), ///< See ::PTP_FLAG_LS_ANN + PTP_FLAG_MSK_LS_ANN_NEG = ( 1UL << PTP_FLAG_LS_ANN_NEG ), ///< See ::PTP_FLAG_LS_ANN_NEG + PTP_FLAG_MSK_IS_UNICAST = ( 1UL << PTP_FLAG_IS_UNICAST ), ///< See ::PTP_FLAG_IS_UNICAST + PTP_FLAG_MSK_UTC_VALID = ( 1UL << PTP_FLAG_UTC_VALID ), ///< See ::PTP_FLAG_UTC_VALID + PTP_FLAG_MSK_ONE_STEP = ( 1UL << PTP_FLAG_ONE_STEP ) ///< See ::PTP_FLAG_ONE_STEP }; @@ -13277,11 +14247,11 @@ enum PTP_STATE_FLAG_MASKS */ typedef struct { - uint16_t nw_prot; ///< see ::PTP_NW_PROTS + uint16_t nw_prot; ///< See ::PTP_NW_PROTS uint8_t selected_presets; ///< selected PTP presets, see ::PTP_PRESETS uint8_t domain_number; ///< the PTP clock domain number, 0:3 - uint8_t delay_mech; ///< see ::PTP_DELAY_MECHS + uint8_t delay_mech; ///< See ::PTP_DELAY_MECHS uint8_t ptp_role; ///< one of the supported PTP roles, see ::PTP_ROLES uint8_t priority_1; ///< priority 1 uint8_t priority_2; ///< priority 2 @@ -13456,41 +14426,41 @@ enum PTP_CFG_FLAGS * * @{ */ -#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_TIME_SCALE_IS_PTP ) ///< see ::PTP_CFG_TIME_SCALE_IS_PTP -#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_V1_HW_COMPAT ) ///< see ::PTP_CFG_V1_HW_COMPAT -#define PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE ( 1UL << PTP_CFG_CAN_BE_UNICAST_SLAVE ) ///< see ::PTP_CFG_CAN_BE_UNICAST_SLAVE -#define PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER ( 1UL << PTP_CFG_CAN_BE_MULTICAST_MASTER ) ///< see ::PTP_CFG_CAN_BE_MULTICAST_MASTER -#define PTP_CFG_MSK_CAN_BE_UNICAST_MASTER ( 1UL << PTP_CFG_CAN_BE_UNICAST_MASTER ) ///< see ::PTP_CFG_CAN_BE_UNICAST_MASTER -#define PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO ( 1UL << PTP_CFG_CAN_BE_MULTICAST_AUTO ) ///< see ::PTP_CFG_CAN_BE_MULTICAST_AUTO -#define PTP_CFG_MSK_SUPP_UTC_VALID ( 1UL << PTP_CFG_SUPP_UTC_VALID ) ///< see ::PTP_CFG_SUPP_UTC_VALID -#define PTP_CFG_MSK_CAN_BE_BOTH_MASTER ( 1UL << PTP_CFG_CAN_BE_BOTH_MASTER ) ///< see ::PTP_CFG_CAN_BE_BOTH_MASTER - -#define PTP_CFG_MSK_HYBRID_MASTER ( 1UL << PTP_CFG_HYBRID_MASTER ) ///< see ::PTP_CFG_HYBRID_MASTER -#define PTP_CFG_MSK_HYBRID_SLAVE ( 1UL << PTP_CFG_HYBRID_SLAVE ) ///< see ::PTP_CFG_HYBRID_SLAVE -#define PTP_CFG_MSK_ONE_STEP_MASTER ( 1UL << PTP_CFG_ONE_STEP_MASTER ) ///< see ::PTP_CFG_ONE_STEP_MASTER -#define PTP_CFG_MSK_MNGMNT_MSGS_DISB ( 1UL << PTP_CFG_MNGMNT_MSGS_DISB ) ///< see ::PTP_CFG_MNGMNT_MSGS_DISB -#define PTP_CFG_MSK_SUPP_MCAST_SLAVE_FLAG ( 1UL << PTP_CFG_SUPP_MCAST_SLAVE_FLAG ) ///< see ::PTP_CFG_SUPP_MCAST_SLAVE_FLAG -#define PTP_CFG_MSK_CAN_BE_MULTICAST_SLAVE ( 1UL << PTP_CFG_CAN_BE_MULTICAST_SLAVE ) ///< see ::PTP_CFG_CAN_BE_MULTICAST_SLAVE -#define PTP_CFG_MSK_ONE_STEP_L2 ( 1UL << PTP_CFG_ONE_STEP_L2 ) ///< see ::PTP_CFG_ONE_STEP_L2 -#define PTP_CFG_MSK_ONE_STEP_P2P ( 1UL << PTP_CFG_ONE_STEP_P2P ) ///< see ::PTP_CFG_ONE_STEP_P2P - -#define PTP_CFG_MSK_TSU_RESET ( 1UL << PTP_CFG_TSU_RESET ) ///< see ::PTP_CFG_TSU_RESET -#define PTP_CFG_MSK_NTP_HW_TS_MASTER ( 1UL << PTP_CFG_NTP_HW_TS_MASTER ) ///< see ::PTP_CFG_NTP_HW_TS_MASTER -#define PTP_CFG_MSK_NTP_HW_TS_SLAVE ( 1UL << PTP_CFG_NTP_HW_TS_SLAVE) ///< see ::PTP_CFG_NTP_HW_TS_SLAVE -#define PTP_CFG_MSK_SYNCE_MASTER ( 1UL << PTP_CFG_SYNCE_MASTER ) ///< see ::PTP_CFG_SYNCE_MASTER -#define PTP_CFG_MSK_SYNCE_SLAVE ( 1UL << PTP_CFG_SYNCE_SLAVE ) ///< see ::PTP_CFG_SYNCE_SLAVE -#define PTP_CFG_MSK_HAS_MUX ( 1UL << PTP_CFG_HAS_MUX ) ///< see ::PTP_CFG_HAS_MUX -#define PTP_CFG_MSK_CAN_BE_TIME_MONITOR ( 1UL << PTP_CFG_CAN_BE_TIME_MONITOR ) ///< see ::PTP_CFG_CAN_BE_TIME_MONITOR -#define PTP_CFG_MSK_HAS_STATISTICS ( 1UL << PTP_CFG_HAS_STATISTICS ) ///< see ::PTP_CFG_HAS_STATISTICS - -#define PTP_CFG_MSK_CAN_BE_V1_MASTER ( 1UL << PTP_CFG_CAN_BE_V1_MASTER ) ///< see ::PTP_CFG_CAN_BE_V1_MASTER -#define PTP_CFG_MSK_CAN_BE_V1_SLAVE ( 1UL << PTP_CFG_CAN_BE_V1_SLAVE ) ///< see ::PTP_CFG_CAN_BE_V1_SLAVE -#define PTP_CFG_MSK_HAS_V2_COMMON_DATASETS ( 1UL << PTP_CFG_HAS_V2_COMMON_DATASETS ) ///< see ::PTP_CFG_HAS_V2_COMMON_DATASETS -#define PTP_CFG_MSK_HAS_V1_COMMON_DATASETS ( 1UL << PTP_CFG_HAS_V1_COMMON_DATASETS ) ///< see ::PTP_CFG_HAS_V1_COMMON_DATASETS -#define PTP_CFG_MSK_ATOI ( 1UL << PTP_CFG_ATOI ) ///< see ::PTP_CFG_ATOI -#define PTP_CFG_MSK_HAS_SMPTE_TLV_STATE ( 1UL << PTP_CFG_HAS_SMPTE_TLV_STATE ) ///< see ::PTP_CFG_HAS_SMPTE_TLV_STATE -#define PTP_CFG_MSK_NTP_SW_SERVER ( 1UL << PTP_CFG_NTP_SW_SERVER ) ///< see ::PTP_CFG_NTP_SW_SERVER -#define PTP_CFG_MSK_HAS_EXT_SUPP_FLAGS ( 1UL << PTP_CFG_HAS_EXT_SUPP_FLAGS ) ///< see ::PTP_CFG_CAN_BE_PTP_PROBE +#define PTP_CFG_MSK_TIME_SCALE_IS_PTP ( 1UL << PTP_CFG_TIME_SCALE_IS_PTP ) ///< See ::PTP_CFG_TIME_SCALE_IS_PTP +#define PTP_CFG_MSK_V1_HW_COMPAT ( 1UL << PTP_CFG_V1_HW_COMPAT ) ///< See ::PTP_CFG_V1_HW_COMPAT +#define PTP_CFG_MSK_CAN_BE_UNICAST_SLAVE ( 1UL << PTP_CFG_CAN_BE_UNICAST_SLAVE ) ///< See ::PTP_CFG_CAN_BE_UNICAST_SLAVE +#define PTP_CFG_MSK_CAN_BE_MULTICAST_MASTER ( 1UL << PTP_CFG_CAN_BE_MULTICAST_MASTER ) ///< See ::PTP_CFG_CAN_BE_MULTICAST_MASTER +#define PTP_CFG_MSK_CAN_BE_UNICAST_MASTER ( 1UL << PTP_CFG_CAN_BE_UNICAST_MASTER ) ///< See ::PTP_CFG_CAN_BE_UNICAST_MASTER +#define PTP_CFG_MSK_CAN_BE_MULTICAST_AUTO ( 1UL << PTP_CFG_CAN_BE_MULTICAST_AUTO ) ///< See ::PTP_CFG_CAN_BE_MULTICAST_AUTO +#define PTP_CFG_MSK_SUPP_UTC_VALID ( 1UL << PTP_CFG_SUPP_UTC_VALID ) ///< See ::PTP_CFG_SUPP_UTC_VALID +#define PTP_CFG_MSK_CAN_BE_BOTH_MASTER ( 1UL << PTP_CFG_CAN_BE_BOTH_MASTER ) ///< See ::PTP_CFG_CAN_BE_BOTH_MASTER + +#define PTP_CFG_MSK_HYBRID_MASTER ( 1UL << PTP_CFG_HYBRID_MASTER ) ///< See ::PTP_CFG_HYBRID_MASTER +#define PTP_CFG_MSK_HYBRID_SLAVE ( 1UL << PTP_CFG_HYBRID_SLAVE ) ///< See ::PTP_CFG_HYBRID_SLAVE +#define PTP_CFG_MSK_ONE_STEP_MASTER ( 1UL << PTP_CFG_ONE_STEP_MASTER ) ///< See ::PTP_CFG_ONE_STEP_MASTER +#define PTP_CFG_MSK_MNGMNT_MSGS_DISB ( 1UL << PTP_CFG_MNGMNT_MSGS_DISB ) ///< See ::PTP_CFG_MNGMNT_MSGS_DISB +#define PTP_CFG_MSK_SUPP_MCAST_SLAVE_FLAG ( 1UL << PTP_CFG_SUPP_MCAST_SLAVE_FLAG ) ///< See ::PTP_CFG_SUPP_MCAST_SLAVE_FLAG +#define PTP_CFG_MSK_CAN_BE_MULTICAST_SLAVE ( 1UL << PTP_CFG_CAN_BE_MULTICAST_SLAVE ) ///< See ::PTP_CFG_CAN_BE_MULTICAST_SLAVE +#define PTP_CFG_MSK_ONE_STEP_L2 ( 1UL << PTP_CFG_ONE_STEP_L2 ) ///< See ::PTP_CFG_ONE_STEP_L2 +#define PTP_CFG_MSK_ONE_STEP_P2P ( 1UL << PTP_CFG_ONE_STEP_P2P ) ///< See ::PTP_CFG_ONE_STEP_P2P + +#define PTP_CFG_MSK_TSU_RESET ( 1UL << PTP_CFG_TSU_RESET ) ///< See ::PTP_CFG_TSU_RESET +#define PTP_CFG_MSK_NTP_HW_TS_MASTER ( 1UL << PTP_CFG_NTP_HW_TS_MASTER ) ///< See ::PTP_CFG_NTP_HW_TS_MASTER +#define PTP_CFG_MSK_NTP_HW_TS_SLAVE ( 1UL << PTP_CFG_NTP_HW_TS_SLAVE) ///< See ::PTP_CFG_NTP_HW_TS_SLAVE +#define PTP_CFG_MSK_SYNCE_MASTER ( 1UL << PTP_CFG_SYNCE_MASTER ) ///< See ::PTP_CFG_SYNCE_MASTER +#define PTP_CFG_MSK_SYNCE_SLAVE ( 1UL << PTP_CFG_SYNCE_SLAVE ) ///< See ::PTP_CFG_SYNCE_SLAVE +#define PTP_CFG_MSK_HAS_MUX ( 1UL << PTP_CFG_HAS_MUX ) ///< See ::PTP_CFG_HAS_MUX +#define PTP_CFG_MSK_CAN_BE_TIME_MONITOR ( 1UL << PTP_CFG_CAN_BE_TIME_MONITOR ) ///< See ::PTP_CFG_CAN_BE_TIME_MONITOR +#define PTP_CFG_MSK_HAS_STATISTICS ( 1UL << PTP_CFG_HAS_STATISTICS ) ///< See ::PTP_CFG_HAS_STATISTICS + +#define PTP_CFG_MSK_CAN_BE_V1_MASTER ( 1UL << PTP_CFG_CAN_BE_V1_MASTER ) ///< See ::PTP_CFG_CAN_BE_V1_MASTER +#define PTP_CFG_MSK_CAN_BE_V1_SLAVE ( 1UL << PTP_CFG_CAN_BE_V1_SLAVE ) ///< See ::PTP_CFG_CAN_BE_V1_SLAVE +#define PTP_CFG_MSK_HAS_V2_COMMON_DATASETS ( 1UL << PTP_CFG_HAS_V2_COMMON_DATASETS ) ///< See ::PTP_CFG_HAS_V2_COMMON_DATASETS +#define PTP_CFG_MSK_HAS_V1_COMMON_DATASETS ( 1UL << PTP_CFG_HAS_V1_COMMON_DATASETS ) ///< See ::PTP_CFG_HAS_V1_COMMON_DATASETS +#define PTP_CFG_MSK_ATOI ( 1UL << PTP_CFG_ATOI ) ///< See ::PTP_CFG_ATOI +#define PTP_CFG_MSK_HAS_SMPTE_TLV_STATE ( 1UL << PTP_CFG_HAS_SMPTE_TLV_STATE ) ///< See ::PTP_CFG_HAS_SMPTE_TLV_STATE +#define PTP_CFG_MSK_NTP_SW_SERVER ( 1UL << PTP_CFG_NTP_SW_SERVER ) ///< See ::PTP_CFG_NTP_SW_SERVER +#define PTP_CFG_MSK_HAS_EXT_SUPP_FLAGS ( 1UL << PTP_CFG_HAS_EXT_SUPP_FLAGS ) ///< See ::PTP_CFG_CAN_BE_PTP_PROBE /** @} defgroup group_PTP_CFG_FLAG_MASKS */ @@ -13524,7 +14494,6 @@ enum PTP_CFG_FLAGS_EX PTP_CFG_DISABLE_PTP, ///< [R/W] PTP Port state can be set to DISABLED permanentely PTP_CFG_HAS_NTP_PKTGEN_IPV6, ///< [R/-] PTP packet generator supports IPv6 PTP_CFG_HAS_DELAY_ASYMMETRY_CFG,///< [R/-] PTP stack supports configuration of static delay asymmetry to be compensated - PTP_CFG_HAS_SOFT_NTP, ///< [R/-] PTP device supports software NTP daemon in parallel to PTP N_PTP_CFG_FLAGS_EX }; @@ -13540,11 +14509,10 @@ enum PTP_CFG_FLAGS_EX * * @{ */ -#define PTP_CFG_MSK_CAN_BE_PTP_PROBE ( 1UL << PTP_CFG_CAN_BE_PTP_PROBE ) ///< see ::PTP_CFG_CAN_BE_PTP_PROBE -#define PTP_CFG_MSK_DISABLE_PTP ( 1UL << PTP_CFG_DISABLE_PTP ) ///< see ::PTP_CFG_DISABLE_PTP -#define PTP_CFG_MSK_HAS_NTP_PKTGEN_IPV6 ( 1UL << PTP_CFG_HAS_NTP_PKTGEN_IPV6 ) ///< see ::PTP_CFG_HAS_NTP_PKTGEN_IPV6 -#define PTP_CFG_MSK_HAS_DELAY_ASYMMETRY_CFG ( 1UL << PTP_CFG_HAS_DELAY_ASYMMETRY_CFG ) ///< see ::PTP_CFG_HAS_DELAY_ASYMMETRY_CFG -#define PTP_CFG_MSK_HAS_SOFT_NTP ( 1UL << PTP_CFG_HAS_SOFT_NTP ) ///< see ::PTP_CFG_HAS_SOFT_NTP +#define PTP_CFG_MSK_CAN_BE_PTP_PROBE ( 1UL << PTP_CFG_CAN_BE_PTP_PROBE ) ///< See ::PTP_CFG_CAN_BE_PTP_PROBE +#define PTP_CFG_MSK_DISABLE_PTP ( 1UL << PTP_CFG_DISABLE_PTP ) ///< See ::PTP_CFG_DISABLE_PTP +#define PTP_CFG_MSK_HAS_NTP_PKTGEN_IPV6 ( 1UL << PTP_CFG_HAS_NTP_PKTGEN_IPV6 ) ///< See ::PTP_CFG_HAS_NTP_PKTGEN_IPV6 +#define PTP_CFG_MSK_HAS_DELAY_ASYMMETRY_CFG ( 1UL << PTP_CFG_HAS_DELAY_ASYMMETRY_CFG ) ///< See ::PTP_CFG_HAS_DELAY_ASYMMETRY_CFG /** @} defgroup group_PTP_CFG_FLAG_EX_MASKS */ @@ -13581,7 +14549,7 @@ enum PTP_HW_FEAT_BITS */ enum PTP_HW_FEAT_MASKS { - PTP_HW_FEAT_MSK_SYNCE_EXT_MUX = ( 1UL << PTP_FEAT_SYNCE_EXT_MUX ) ///< see ::PTP_FEAT_SYNCE_EXT_MUX + PTP_HW_FEAT_MSK_SYNCE_EXT_MUX = ( 1UL << PTP_FEAT_SYNCE_EXT_MUX ) ///< See ::PTP_FEAT_SYNCE_EXT_MUX }; @@ -13614,14 +14582,14 @@ enum PTP_OPT_EXTS enum PTP_OPT_EXT_MASKS { PTP_MSK_OPT_EXT_NONE = ( 1UL << PTP_OPT_EXT_NONE ), ///< this is actually not used, see ::PTP_OPT_EXT_NONE - PTP_MSK_OPT_EXT_POWER = ( 1UL << PTP_OPT_EXT_POWER ), ///< see ::PTP_OPT_EXT_POWER - PTP_MSK_OPT_EXT_TELECOM = ( 1UL << PTP_OPT_EXT_TELECOM ), ///< see ::PTP_OPT_EXT_TELECOM - PTP_MSK_OPT_EXT_TELECOM_PHASE = ( 1UL << PTP_OPT_EXT_TELECOM_PHASE ), ///< see ::PTP_OPT_EXT_TELECOM_PHASE - PTP_MSK_OPT_EXT_SMPTE = ( 1UL << PTP_OPT_EXT_SMPTE ), ///< see ::PTP_OPT_EXT_SMPTE - PTP_MSK_OPT_EXT_8021AS = ( 1UL << PTP_OPT_EXT_8021AS ), ///< see ::PTP_OPT_EXT_8021AS - PTP_MSK_OPT_EXT_6185093 = ( 1UL << PTP_OPT_EXT_6185093 ), ///< see ::PTP_OPT_EXT_6185093 - PTP_MSK_OPT_EXT_TELECOM_PTS = ( 1UL << PTP_OPT_EXT_TELECOM_PTS ), ///< see ::PTP_OPT_EXT_TELECOM_PTS - PTP_MSK_OPT_EXT_C37238_2017 = ( 1UL << PTP_OPT_EXT_C37238_2017 ) ///< see ::PTP_MSK_OPT_EXT_C37238_2017 + PTP_MSK_OPT_EXT_POWER = ( 1UL << PTP_OPT_EXT_POWER ), ///< See ::PTP_OPT_EXT_POWER + PTP_MSK_OPT_EXT_TELECOM = ( 1UL << PTP_OPT_EXT_TELECOM ), ///< See ::PTP_OPT_EXT_TELECOM + PTP_MSK_OPT_EXT_TELECOM_PHASE = ( 1UL << PTP_OPT_EXT_TELECOM_PHASE ), ///< See ::PTP_OPT_EXT_TELECOM_PHASE + PTP_MSK_OPT_EXT_SMPTE = ( 1UL << PTP_OPT_EXT_SMPTE ), ///< See ::PTP_OPT_EXT_SMPTE + PTP_MSK_OPT_EXT_8021AS = ( 1UL << PTP_OPT_EXT_8021AS ), ///< See ::PTP_OPT_EXT_8021AS + PTP_MSK_OPT_EXT_6185093 = ( 1UL << PTP_OPT_EXT_6185093 ), ///< See ::PTP_OPT_EXT_6185093 + PTP_MSK_OPT_EXT_TELECOM_PTS = ( 1UL << PTP_OPT_EXT_TELECOM_PTS ), ///< See ::PTP_OPT_EXT_TELECOM_PTS + PTP_MSK_OPT_EXT_C37238_2017 = ( 1UL << PTP_OPT_EXT_C37238_2017 ) ///< See ::PTP_MSK_OPT_EXT_C37238_2017 }; @@ -13661,19 +14629,19 @@ enum PTP_PRESETS */ enum PTP_PRESETS_MASKS { - PTP_MSK_PRESETS_CUSTOM = ( 1UL << PTP_PRESETS_CUSTOM ), ///< see ::PTP_PRESETS_CUSTOM - PTP_MSK_PRESETS_DFLT_E2E = ( 1UL << PTP_PRESETS_DFLT_E2E ), ///< see ::PTP_PRESETS_DFLT_E2E - PTP_MSK_PRESETS_DFLT_P2P = ( 1UL << PTP_PRESETS_DFLT_P2P ), ///< see ::PTP_PRESETS_DFLT_P2P - PTP_MSK_PRESETS_POWER = ( 1UL << PTP_PRESETS_POWER ), ///< see ::PTP_PRESETS_POWER - PTP_MSK_PRESETS_TELECOM = ( 1UL << PTP_PRESETS_TELECOM ), ///< see ::PTP_PRESETS_TELECOM - PTP_MSK_PRESETS_TELECOM_PHASE = ( 1UL << PTP_PRESETS_TELECOM_PHASE ), ///< see ::PTP_PRESETS_TELECOM_PHASE - PTP_MSK_PRESETS_SMPTE = ( 1UL << PTP_PRESETS_SMPTE ), ///< see ::PTP_PRESETS_SMPTE - PTP_MSK_PRESETS_AES67 = ( 1UL << PTP_PRESETS_AES67 ), ///< see ::PTP_PRESETS_AES67 - PTP_MSK_PRESETS_8021AS = ( 1UL << PTP_PRESETS_8021AS ), ///< see ::PTP_PRESETS_8021AS - PTP_MSK_PRESETS_6185093 = ( 1UL << PTP_PRESETS_6185093), ///< see ::PTP_PRESETS_6185093 - PTP_MSK_PRESETS_TELECOM_PTS = ( 1UL << PTP_PRESETS_TELECOM_PTS), ///< see ::PTP_PRESETS_TELECOM_PTS - PTP_MSK_PRESETS_DOCSIS_31 = ( 1UL << PTP_PRESETS_DOCSIS_31), ///< see ::PTP_PRESETS_DOCSIS_31 - PTP_MSK_PRESETS_C37238_2017 = ( 1UL << PTP_PRESETS_C37238_2017) ///< see ::PTP_PRESETS_C37238_2017 + PTP_MSK_PRESETS_CUSTOM = ( 1UL << PTP_PRESETS_CUSTOM ), ///< See ::PTP_PRESETS_CUSTOM + PTP_MSK_PRESETS_DFLT_E2E = ( 1UL << PTP_PRESETS_DFLT_E2E ), ///< See ::PTP_PRESETS_DFLT_E2E + PTP_MSK_PRESETS_DFLT_P2P = ( 1UL << PTP_PRESETS_DFLT_P2P ), ///< See ::PTP_PRESETS_DFLT_P2P + PTP_MSK_PRESETS_POWER = ( 1UL << PTP_PRESETS_POWER ), ///< See ::PTP_PRESETS_POWER + PTP_MSK_PRESETS_TELECOM = ( 1UL << PTP_PRESETS_TELECOM ), ///< See ::PTP_PRESETS_TELECOM + PTP_MSK_PRESETS_TELECOM_PHASE = ( 1UL << PTP_PRESETS_TELECOM_PHASE ), ///< See ::PTP_PRESETS_TELECOM_PHASE + PTP_MSK_PRESETS_SMPTE = ( 1UL << PTP_PRESETS_SMPTE ), ///< See ::PTP_PRESETS_SMPTE + PTP_MSK_PRESETS_AES67 = ( 1UL << PTP_PRESETS_AES67 ), ///< See ::PTP_PRESETS_AES67 + PTP_MSK_PRESETS_8021AS = ( 1UL << PTP_PRESETS_8021AS ), ///< See ::PTP_PRESETS_8021AS + PTP_MSK_PRESETS_6185093 = ( 1UL << PTP_PRESETS_6185093), ///< See ::PTP_PRESETS_6185093 + PTP_MSK_PRESETS_TELECOM_PTS = ( 1UL << PTP_PRESETS_TELECOM_PTS), ///< See ::PTP_PRESETS_TELECOM_PTS + PTP_MSK_PRESETS_DOCSIS_31 = ( 1UL << PTP_PRESETS_DOCSIS_31), ///< See ::PTP_PRESETS_DOCSIS_31 + PTP_MSK_PRESETS_C37238_2017 = ( 1UL << PTP_PRESETS_C37238_2017) ///< See ::PTP_PRESETS_C37238_2017 }; @@ -13692,7 +14660,7 @@ enum PTP_PRESETS_MASKS "Telecom ITU-T G.8265.1", \ "Telecom ITU-T G.8275.1", \ "SMPTE ST 2059-2", \ - "AES67 Media Profile", \ + "AES67 Media", \ "IEEE 802.1AS", \ "Utility IEC 61850-9-3", \ "Telecom ITU-T G.8275.2", \ @@ -13794,7 +14762,8 @@ enum SMPTE_SYSTEM_FRAME_RATES */ typedef struct { - /// Default system frame rate + /// @brief Default system frame rate. + /// /// Default video frame rate of the slave system as a lowest term rational. /// The data type shall be composed of a pair of unsigned Int32 values coded /// in big-endian form where the first shall be the numerator and the second @@ -13802,68 +14771,75 @@ typedef struct /// that represents the frame rate denominator /// For example, 29.97 Hz: (30000/1001) or 25 Hz: (25/1). uint32_t defaultSystemFrameRateNum; + + /// @brief The denominator associated with @a #defaultSystemFrameRateNum. uint32_t defaultSystemFrameRateDenum; - /// Master locking status + + /// @brief Master locking status + /// /// Complementary information to clockClass (0: Not in use, 1: Free Run, /// 2: Cold Locking, 3: Warm Locking, 4: Locked) uint8_t masterLockingStatus; - /// Time Address Flags + + /// @brief Time Address Flags + /// /// Indicates the intended ST 12-1 flags. /// Bit 0: Drop frame (0: Non-drop-frame, 1: Drop-frame) /// Bit 1: Color Frame Identification (0: Not in use, 1: In use) /// Bits 2-7: Reserved uint8_t timeAddressFlags; - /// Current local offset - /// Offset in seconds of Local Time from grandmaster PTP time. For example, - /// if Local Time is Eastern Standard Time (North America) UTC-5 and the - /// number of leap seconds is 35, the value will be -18035 (decimal). uint8_t reserved_1; uint8_t reserved_2; + /// @brief Current local offset. + /// + /// Offset in seconds of Local Time from grandmaster PTP time. For example, + /// if Local Time is Eastern Standard Time (North America) %UTC-5 and the + /// number of leap seconds is 35, the value will be -18035 (decimal). int32_t currentLocalOffset; - /// Jump seconds + + /// @brief Jump seconds. + /// /// The size of the next discontinuity, in seconds, of Local Time. A value /// of zero indicates that no discontinuity is expected. A positive value - /// indicates that the discontinuity will cause the currentLocalOffset to increase. + /// indicates that the discontinuity will cause @a #currentLocalOffset to increase. int32_t jumpSeconds; - /// Time of next jump - /// The value of the seconds portion of the grandmastermaster PTP time at the time - /// that the next discontinuity of the currentLocalOffset will occur. The - /// discontinuity occurs at the start of the second indicated - uint8_t timeOfNextJump[6]; - /// Time of next jam + + /// @brief Time of next jump. + /// + /// The value of the seconds portion of the grandmaster PTP time at the time + /// that the next discontinuity of the @a #currentLocalOffset will occur. The + /// discontinuity occurs at the start of the second indicated. + PTP_PKT_TSTAMP_SECS timeOfNextJump; + + /// @brief Time of next jam. + /// /// The value of the seconds portion of the PTP time corresponding to the next /// scheduled occurrence of the Daily Jam. If no Daily Jam is scheduled, the - /// value of timeOfNextJam shall be zero. - uint8_t timeOfNextJam[6]; - /// Time of previous jam + /// value of @a #timeOfNextJam shall be zero. + PTP_PKT_TSTAMP_SECS timeOfNextJam; + + /// @brief Time of previous jam. + /// /// The value of the seconds portion of the PTP time corresponding to the /// previous occurrence of the Daily Jam. - uint8_t timeOfPreviousJam[6]; - /// Previous jam local offset - /// The value of currentLocalOffset at the previous daily jam time. - /// If a discontinuity of Local Time occurs at the jam time, this parameter - /// reflects the offset after the discontinuity. + PTP_PKT_TSTAMP_SECS timeOfPreviousJam; + uint8_t reserved_3; uint8_t reserved_4; uint32_t reserved_5; - int32_t previousJamLocalOffset; - /// Daylight saving - /// Bit 0: Current Daylight Saving (0: Not in effect, 1: In effect) - /// Bit 1: Daylight Saving at next discontinuity (0: Not in effect, 1: In effect) - /// Bit 2: Daylight Saving at previous daily jam time (0: Not in effect, 1: In effect) - /// Bits 3-7: Reserved - uint8_t daylightSaving; - /// Leap second jump - /// The reason for the forthcoming discontinuity of currentLocalOffset indicated by - /// timeOfNextJump - /// Bit 0: - /// 0: Other than a change in the number of leap seconds (default) - /// 1: A change in number of leap seconds - /// Bits 1-7: Reserved - uint8_t leapSecondJump; + /// @brief Previous jam local offset. + /// + /// The value of @a #currentLocalOffset at the previous daily jam time. + /// If a discontinuity of Local Time occurs at the jam time, this parameter + /// reflects the offset after the discontinuity. + PTP_TLV_TIME_OFFS previousJamLocalOffset; + + PTP_TLV_DST_FLAGS daylightSaving; ///< Daylight saving flags, see ::PTP_TLV_DST_FLAG_MSKS. + + PTP_TLV_LS_FLAGS leapSecondJump; ///< Leap second flags, see ::PTP_TLV_LS_FLAG_MSKS. uint8_t reserved_6; uint8_t reserved_7; @@ -13890,6 +14866,7 @@ do \ } while ( 0 ) + /** * @brief Additional parameters for Telecom8275.1 profile */ @@ -14126,14 +15103,14 @@ enum SDH_NETWORK_OPTIONS /** - * @brief Flag masks used with MBG_SYNC_E_INFO::supp_sdh_network_opts ::FIXME + * @brief Flag masks used with :: MBG_NET_INTF_LINK_INFO::supp_sdh_net_opts * * @see ::SDH_NETWORK_OPTIONS */ enum SDH_NETWORK_OPTION_MASKS { - SDH_NETWORK_OPTION_1_MSK = ( 1UL << SDH_NETWORK_OPTION_1 ), ///< see ::SDH_NETWORK_OPTION_1 - SDH_NETWORK_OPTION_2_MSK = ( 1UL << SDH_NETWORK_OPTION_2 ), ///< see ::SDH_NETWORK_OPTION_2 + SDH_NETWORK_OPTION_1_MSK = ( 1UL << SDH_NETWORK_OPTION_1 ), ///< See ::SDH_NETWORK_OPTION_1 + SDH_NETWORK_OPTION_2_MSK = ( 1UL << SDH_NETWORK_OPTION_2 ), ///< See ::SDH_NETWORK_OPTION_2 }; @@ -14150,10 +15127,8 @@ enum SDH_NETWORK_OPTION_MASKS } - -//##++++ TODO: shouldn't this be merged with / replaced by MBG_NET_LINK_MODES? /** - * @brief Link modes for SyncE on a 1000BASE-T interface + * @brief Link modes for SyncE on a 1000BASE-T interface. * * @see ::GBIT_LINK_COPPER_MODE_MASKS */ @@ -14171,18 +15146,18 @@ enum GBIT_LINK_COPPER_MODES /** - * @brief Flag masks used with MBG_SYNC_E_INFO::supp_gbit_link_copper_modes ::FIXME + * @brief Flag masks used with ::MBG_NET_INTF_LINK_INFO::supp_gb_copper_modes. * * @see ::GBIT_LINK_COPPER_MODES */ enum GBIT_LINK_COPPER_MODE_MASKS { - GBIT_LINK_COPPER_AUTO_MSK = ( 1UL << GBIT_LINK_COPPER_AUTO ), ///< see ::GBIT_LINK_COPPER_AUTO_MSK - GBIT_LINK_COPPER_FORCE_SYNCE_AUTO_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_SYNCE_AUTO ), ///< see ::GBIT_LINK_COPPER_FORCE_SYNCE_AUTO - GBIT_LINK_COPPER_FORCE_OR_IS_MASTER_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_OR_IS_MASTER ), ///< see ::GBIT_LINK_COPPER_FORCE_OR_IS_MASTER - GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE ), ///< see ::GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE - GBIT_LINK_COPPER_PREFER_MASTER_MSK = ( 1UL << GBIT_LINK_COPPER_PREFER_MASTER ), ///< see ::GBIT_LINK_COPPER_PREFER_MASTER - GBIT_LINK_COPPER_PREFER_SLAVE_MSK = ( 1UL << GBIT_LINK_COPPER_PREFER_SLAVE ) ///< see ::GBIT_LINK_COPPER_PREFER_SLAVE + GBIT_LINK_COPPER_AUTO_MSK = ( 1UL << GBIT_LINK_COPPER_AUTO ), ///< See ::GBIT_LINK_COPPER_AUTO_MSK + GBIT_LINK_COPPER_FORCE_SYNCE_AUTO_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_SYNCE_AUTO ), ///< See ::GBIT_LINK_COPPER_FORCE_SYNCE_AUTO + GBIT_LINK_COPPER_FORCE_OR_IS_MASTER_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_OR_IS_MASTER ), ///< See ::GBIT_LINK_COPPER_FORCE_OR_IS_MASTER + GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE_MSK = ( 1UL << GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE ), ///< See ::GBIT_LINK_COPPER_FORCE_OR_IS_SLAVE + GBIT_LINK_COPPER_PREFER_MASTER_MSK = ( 1UL << GBIT_LINK_COPPER_PREFER_MASTER ), ///< See ::GBIT_LINK_COPPER_PREFER_MASTER + GBIT_LINK_COPPER_PREFER_SLAVE_MSK = ( 1UL << GBIT_LINK_COPPER_PREFER_SLAVE ) ///< See ::GBIT_LINK_COPPER_PREFER_SLAVE }; @@ -14273,17 +15248,17 @@ do \ */ typedef struct { - MBG_HOSTNAME gm_host; ///< grandmaster's hostname or IP address - PTP_CLOCK_ID gm_clock_id; ///< use clock ID of master port, or ::PTP_CLOCK_ID_WILDCARD - PTP_PORT_ID gm_port_id; ///< use target port ID of master port (e.g. 135) or ::PTP_PORT_ID_WILDCARD - int16_t sync_intv; ///< sync interval [log2 s] - int16_t ann_intv; ///< announce interval [log2 s] - int16_t delay_req_intv; ///< delay request interval [log2 s] - int32_t fix_offset; ///< constant time offset to be compensated [ns] - uint16_t message_duration; ///< time period until master stops sending messages [s] - uint16_t reserved_0; ///< reserved, currently always 0 - uint32_t reserved_1; ///< reserved, currently always 0 - uint32_t flags; ///< reserved, currently always 0 + MBG_HOSTNAME gm_host; ///< Hostname or IP address of the grandmaster. + PTP_CLOCK_ID gm_clock_id; ///< Clock ID of the master port, or ::PTP_CLOCK_ID_WILDCARD. + PTP_PORT_ID gm_port_id; ///< Target port ID of the master port (e.g. 135) or ::PTP_PORT_ID_WILDCARD. + int16_t sync_intv; ///< Sync interval [log2 s]. + int16_t ann_intv; ///< Announce interval [log2 s]. + int16_t delay_req_intv; ///< Delay request interval [log2 s]. + int32_t fix_offset; ///< Constant time offset to be compensated [ns]. + uint16_t message_duration; ///< Time period until master stops sending messages [s]. + uint16_t reserved_0; ///< Reserved, currently always 0. + uint32_t reserved_1; ///< Reserved, currently always 0. + uint32_t flags; ///< Reserved, currently always 0. } PTP_UC_MASTER_SETTINGS; @@ -14328,7 +15303,7 @@ enum PTP_UC_MSG_DURATION_LIMITS */ typedef struct { - uint32_t idx; ///< index, 0..PTP_UC_MASTER_CFG_LIMITS::n_supp_master-1 + MBG_MSG_IDX_32 idx; ///< index, 0..PTP_UC_MASTER_CFG_LIMITS::n_supp_master-1 PTP_UC_MASTER_SETTINGS settings; ///< specification for the unicast master with that index } PTP_UC_MASTER_SETTINGS_IDX; @@ -14381,7 +15356,7 @@ do \ */ typedef struct { - uint32_t idx; ///< index, 0..PTP_UC_MASTER_CFG_LIMITS::n_supp_master-1 + MBG_MSG_IDX_32 idx; ///< index, 0..PTP_UC_MASTER_CFG_LIMITS::n_supp_master-1 PTP_UC_MASTER_INFO info; ///< capabilities and current settings } PTP_UC_MASTER_INFO_IDX; @@ -14418,63 +15393,65 @@ typedef struct typedef struct { - uint32_t status; ///< status word flags (use PacketCounterStat_e) - uint32_t rx; ///< overall Rx packet counter - uint32_t rxPerSec; ///< overall Rx packet counter - uint32_t tx; ///< overall Tx packet counter - uint32_t txPerSec; ///< overall Tx packet counter - /// invalid Rx packet counter + uint32_t status; ///< Status word flags (use PacketCounterStat_e) + uint32_t rx; ///< Overall RX packet counter + uint32_t rxPerSec; ///< Overall RX packet counter + uint32_t tx; ///< Overall TX packet counter + uint32_t txPerSec; ///< Overall TX packet counter + + /// @brief Invalid RX packet counter. + /// /// Indicates one of the following issues: wrong PTP version, wrong domain number, /// message from self, message from other BC port, multicast message in unicast mode /// or message extraction error (size error or inconsistent format). uint32_t errorRx; - uint32_t announceMsgRx; ///< Accepted Announce message Rx counter - uint32_t announceMsgPerSecRx; ///< Accepted Announce message Rx counter - uint32_t announceMsgTx; ///< Announce message Tx counter - uint32_t announceMsgPerSecTx; ///< Announce message Tx counter - uint32_t syncMsgRx; ///< Accepted Sync message Rx counter - uint32_t syncMsgPerSecRx; ///< Accepted Sync message Rx counter - uint32_t syncMsgTx; ///< Sync message Tx counter - uint32_t syncMsgPerSecTx; ///< Sync message Tx counter - uint32_t followUpMsgRx; ///< Accepted Follow-up message Rx counter - uint32_t followUpMsgPerSecRx; ///< Accepted Follow-up message Rx counter - uint32_t followUpMsgTx; ///< Follow-up message Tx counter - uint32_t followUpMsgPerSecTx; ///< Follow-up message Tx counter - uint32_t dlyReqMsgRx; ///< Accepted Delay request message Rx counter - uint32_t dlyReqMsgPerSecRx; ///< Accepted Delay request message Rx counter - uint32_t dlyReqMsgTx; ///< Delay request message Tx counter - uint32_t dlyReqMsgPerSecTx; ///< Delay request message Tx counter - uint32_t dlyRespMsgRx; ///< Accepted Delay response message Rx counter - uint32_t dlyRespMsgPerSecRx; ///< Accepted Delay response message Rx counter - uint32_t dlyRespMsgTx; ///< Delay response message Tx counter - uint32_t dlyRespMsgPerSecTx; ///< Delay response message Tx counter - uint32_t pDlyReqMsgRx; ///< Accepted PDelay Request message Rx counter - uint32_t pDlyReqMsgPerSecRx; ///< Accepted PDelay Request message Rx counter - uint32_t pDlyReqMsgTx; ///< PDelay Request message Tx counter - uint32_t pDlyReqMsgPerSecTx; ///< PDelay Request message Tx counter - uint32_t pDlyRespMsgRx; ///< Accepted PDelay Response message Rx counter - uint32_t pDlyRespMsgPerSecRx; ///< Accepted PDelay Response message Rx counter - uint32_t pDlyRespMsgTx; ///< PDelay Response message Tx counter - uint32_t pDlyRespMsgPerSecTx; ///< PDelay Response message Tx counter - uint32_t pDlyFollowUpRx; ///< Accepted PDelay Follow-Up message Rx counter - uint32_t pDlyFollowUpPerSecRx; ///< Accepted PDelay Follow-Up message Rx counter - uint32_t pDlyFollowUpTx; ///< PDelay Follow-Up message Tx counter - uint32_t pDlyFollowUpPerSecTx; ///< PDelay Follow-Up message Tx counter - uint32_t signallingRx; ///< Accepted Signalling message Rx counter - uint32_t signallingPerSecRx; ///< Accepted Signalling message Rx counter - uint32_t signallingTx; ///< Signalling message Tx counter - uint32_t signallingPerSecTx; ///< Signalling message Tx counter - uint32_t mgmtRx; ///< Accepted Management message Rx counter - uint32_t mgmtPerSecRx; ///< Accepted Management message Rx counter - uint32_t mgmtTx; ///< Management message Tx counter - uint32_t mgmtPerSecTx; ///< Management message Tx counter - uint32_t mgmtErr; ///< Management error counter (rx) - uint32_t annReceptTout; ///< Announce recept timeout count + uint32_t announceMsgRx; ///< Accepted Announce message RX counter + uint32_t announceMsgPerSecRx; ///< Accepted Announce message RX counter + uint32_t announceMsgTx; ///< Announce message TX counter + uint32_t announceMsgPerSecTx; ///< Announce message TX counter + uint32_t syncMsgRx; ///< Accepted Sync message RX counter + uint32_t syncMsgPerSecRx; ///< Accepted Sync message RX counter + uint32_t syncMsgTx; ///< Sync message TX counter + uint32_t syncMsgPerSecTx; ///< Sync message TX counter + uint32_t followUpMsgRx; ///< Accepted Follow-up message RX counter + uint32_t followUpMsgPerSecRx; ///< Accepted Follow-up message RX counter + uint32_t followUpMsgTx; ///< Follow-up message TX counter + uint32_t followUpMsgPerSecTx; ///< Follow-up message TX counter + uint32_t dlyReqMsgRx; ///< Accepted Delay request message RX counter + uint32_t dlyReqMsgPerSecRx; ///< Accepted Delay request message RX counter + uint32_t dlyReqMsgTx; ///< Delay request message TX counter + uint32_t dlyReqMsgPerSecTx; ///< Delay request message TX counter + uint32_t dlyRespMsgRx; ///< Accepted Delay response message RX counter + uint32_t dlyRespMsgPerSecRx; ///< Accepted Delay response message RX counter + uint32_t dlyRespMsgTx; ///< Delay response message TX counter + uint32_t dlyRespMsgPerSecTx; ///< Delay response message TX counter + uint32_t pDlyReqMsgRx; ///< Accepted PDelay Request message RX counter + uint32_t pDlyReqMsgPerSecRx; ///< Accepted PDelay Request message RX counter + uint32_t pDlyReqMsgTx; ///< PDelay Request message TX counter + uint32_t pDlyReqMsgPerSecTx; ///< PDelay Request message TX counter + uint32_t pDlyRespMsgRx; ///< Accepted PDelay Response message RX counter + uint32_t pDlyRespMsgPerSecRx; ///< Accepted PDelay Response message RX counter + uint32_t pDlyRespMsgTx; ///< PDelay Response message TX counter + uint32_t pDlyRespMsgPerSecTx; ///< PDelay Response message TX counter + uint32_t pDlyFollowUpRx; ///< Accepted PDelay Follow-Up message RX counter + uint32_t pDlyFollowUpPerSecRx; ///< Accepted PDelay Follow-Up message RX counter + uint32_t pDlyFollowUpTx; ///< PDelay Follow-Up message TX counter + uint32_t pDlyFollowUpPerSecTx; ///< PDelay Follow-Up message TX counter + uint32_t signallingRx; ///< Accepted Signalling message RX counter + uint32_t signallingPerSecRx; ///< Accepted Signalling message RX counter + uint32_t signallingTx; ///< Signalling message TX counter + uint32_t signallingPerSecTx; ///< Signalling message TX counter + uint32_t mgmtRx; ///< Accepted Management message RX counter + uint32_t mgmtPerSecRx; ///< Accepted Management message RX counter + uint32_t mgmtTx; ///< Management message TX counter + uint32_t mgmtPerSecTx; ///< Management message TX counter + uint32_t mgmtErr; ///< Management error counter (RX) + uint32_t annReceptTout; ///< Announce receipt timeout count uint32_t numUcConn; ///< Number of current Unicast client connections uint32_t maxNumUcConn; ///< Maximum Number of Unicast client connections (due to licence or CPU performance) uint32_t numMsgPerSec; ///< Number of all messages per second (TX/RX) - uint32_t maxMsgPerSec; ///< max allowed number of all messages per second in Multicast/Hybrid mode (due to licence or CPU performance) + uint32_t maxMsgPerSec; ///< Max. allowed number of all messages per second in Multicast/Hybrid mode (due to licence or CPU performance) } MBG_PTP_STATISTICS_STATUS; @@ -14527,6 +15504,7 @@ typedef struct PTP_CLOCK_ID clock_uuid; PTP_PORT_ID port_id; uint16_t reserved_3; + } PTP_V1_UUID; @@ -14564,15 +15542,14 @@ enum PTP_V1_DEFAULT_DATASET_FLAGS */ enum PTP_V1_DEFAULT_DATASET_FLAGS_MASKS { - V1_DFLT_MSK_CLK_FOLLOWUP_CAPABLE = ( 1UL << V1_DFLT_CLK_FOLLOWUP_CAPABLE ), ///< see ::V1_DFLT_CLK_FOLLOWUP_CAPABLE - V1_DFLT_MSK_PREFERRED = ( 1UL << V1_DFLT_PREFERRED ), ///< see ::V1_DFLT_PREFERRED - V1_DFLT_MSK_INITIALIZABLE = ( 1UL << V1_DFLT_INITIALIZABLE ), ///< see ::V1_DFLT_INITIALIZABLE - V1_DFLT_MSK_EXT_TIMING = ( 1UL << V1_DFLT_EXT_TIMING), ///< see ::V1_DFLT_EXT_TIMING - V1_DFLT_MSK_IS_BC = ( 1UL << V1_DFLT_IS_BC ) ///< see ::V1_DFLT_IS_BC + V1_DFLT_MSK_CLK_FOLLOWUP_CAPABLE = ( 1UL << V1_DFLT_CLK_FOLLOWUP_CAPABLE ), ///< See ::V1_DFLT_CLK_FOLLOWUP_CAPABLE + V1_DFLT_MSK_PREFERRED = ( 1UL << V1_DFLT_PREFERRED ), ///< See ::V1_DFLT_PREFERRED + V1_DFLT_MSK_INITIALIZABLE = ( 1UL << V1_DFLT_INITIALIZABLE ), ///< See ::V1_DFLT_INITIALIZABLE + V1_DFLT_MSK_EXT_TIMING = ( 1UL << V1_DFLT_EXT_TIMING), ///< See ::V1_DFLT_EXT_TIMING + V1_DFLT_MSK_IS_BC = ( 1UL << V1_DFLT_IS_BC ) ///< See ::V1_DFLT_IS_BC }; - /** * @brief PTPv1 default dataset containing global information about the device * @@ -14588,6 +15565,7 @@ typedef struct { uint16_t number_ports; uint16_t number_foreign_records; uint32_t flags; + } MBG_PTP_V1_DEFAULT_DATASET; @@ -14605,8 +15583,6 @@ do \ /** * @brief PTPv1 current dataset containing information about the synchronization status of the device - * - * @see ::NANO_TIME */ typedef struct { @@ -14614,6 +15590,7 @@ typedef struct uint16_t reserved_1; NANO_TIME offset_from_master; NANO_TIME one_way_delay; + } MBG_PTP_V1_CURRENT_DATASET; @@ -14652,12 +15629,12 @@ enum PTP_V1_PARENT_DATASET_FLAGS */ enum PTP_V1_PARENT_DATASET_FLAGS_MASKS { - V1_PARENT_MSK_FOLLOWUP_CAPABLE = ( 1UL << V1_PARENT_FOLLOWUP_CAPABLE ), ///< see ::V1_PARENT_FOLLOWUP_CAPABLE - V1_PARENT_MSK_EXT_TIMING = ( 1UL << V1_PARENT_EXT_TIMING ), ///< see ::V1_PARENT_EXT_TIMING - V1_PARENT_MSK_STATS = ( 1UL << V1_PARENT_STATS ), ///< see ::V1_PARENT_STATS - V1_PARENT_MSK_UTC_REASONABLE = ( 1UL << V1_PARENT_UTC_REASONABLE ), ///< see ::V1_PARENT_UTC_REASONABLE - V1_PARENT_MSK_GM_PREFERRED = ( 1UL << V1_PARENT_GM_PREFERRED ), ///< see ::V1_PARENT_GM_PREFERRED - V1_PARENT_MSK_GM_IS_BC = ( 1UL << V1_PARENT_GM_IS_BC ) ///< see ::V1_PARENT_GM_IS_BC + V1_PARENT_MSK_FOLLOWUP_CAPABLE = ( 1UL << V1_PARENT_FOLLOWUP_CAPABLE ), ///< See ::V1_PARENT_FOLLOWUP_CAPABLE + V1_PARENT_MSK_EXT_TIMING = ( 1UL << V1_PARENT_EXT_TIMING ), ///< See ::V1_PARENT_EXT_TIMING + V1_PARENT_MSK_STATS = ( 1UL << V1_PARENT_STATS ), ///< See ::V1_PARENT_STATS + V1_PARENT_MSK_UTC_REASONABLE = ( 1UL << V1_PARENT_UTC_REASONABLE ), ///< See ::V1_PARENT_UTC_REASONABLE + V1_PARENT_MSK_GM_PREFERRED = ( 1UL << V1_PARENT_GM_PREFERRED ), ///< See ::V1_PARENT_GM_PREFERRED + V1_PARENT_MSK_GM_IS_BC = ( 1UL << V1_PARENT_GM_IS_BC ) ///< See ::V1_PARENT_GM_IS_BC }; @@ -14681,7 +15658,7 @@ typedef struct int16_t grandmaster_variance; uint16_t grandmaster_sequence_number; uint16_t reserved_2; - uint32_t flags; ///< see ::PTP_V1_PARENT_DATASET_FLAGS_MASKS + uint32_t flags; ///< See ::PTP_V1_PARENT_DATASET_FLAGS_MASKS } MBG_PTP_V1_PARENT_DATASET; @@ -14724,8 +15701,8 @@ enum PTP_V1_TIME_PROP_DATASET_DATASET_FLAGS */ enum PTP_V1_TIME_PROP_DATASET_FLAGS_MASKS { - V1_TPROP_MSK_LEAP_59 = ( 1UL << V1_TPROP_LEAP_59 ), ///< see ::V1_TPROP_LEAP_59 - V1_TPROP_MSK_LEAP_61 = ( 1UL << V1_TPROP_LEAP_61 ) ///< see ::V1_TPROP_LEAP_61 + V1_TPROP_MSK_LEAP_59 = ( 1UL << V1_TPROP_LEAP_59 ), ///< See ::V1_TPROP_LEAP_59 + V1_TPROP_MSK_LEAP_61 = ( 1UL << V1_TPROP_LEAP_61 ) ///< See ::V1_TPROP_LEAP_61 }; @@ -14738,7 +15715,7 @@ typedef struct { int16_t current_utc_offset; uint16_t epoch_number; - uint32_t flags; ///< see ::PTP_V1_TIME_PROP_DATASET_FLAGS_MASKS + uint32_t flags; ///< See ::PTP_V1_TIME_PROP_DATASET_FLAGS_MASKS } MBG_PTP_V1_TIME_PROPERTIES_DATASET; @@ -14772,7 +15749,7 @@ enum PTP_V1_PORT_DATASET_DATASET_FLAGS */ enum PTP_V1_PORT_DATASET_FLAGS_MASKS { - V1_PORT_DATASET_MSK_BURST_ENB = ( 1UL << V1_PORT_DATASET_BURST_ENB ), ///< see ::V1_PORT_DATASET_BURST_ENB + V1_PORT_DATASET_MSK_BURST_ENB = ( 1UL << V1_PORT_DATASET_BURST_ENB ), ///< See ::V1_PORT_DATASET_BURST_ENB }; @@ -14815,14 +15792,14 @@ do \ /** * @brief Index structure for PTPv1 port dataset * - * @note Port dataset with index 0..::MBG_PTP_V1_DEFAULT_DATASET::number_ports - 1 can be queried from a device + * @note Port datasets with index 0..::MBG_PTP_V1_DEFAULT_DATASET::number_ports-1 can be queried from a device. * * @see ::MBG_PTP_V1_PORT_DATASET */ typedef struct { - uint16_t idx; ///< Index of the port dataset, 0..::MBG_PTP_V1_DEFAULT_DATASET::number_ports - 1 - MBG_PTP_V1_PORT_DATASET port_dataset; ///< see ::MBG_PTP_V1_PORT_DATASET + MBG_MSG_IDX idx; ///< Index of the port dataset, 0..::MBG_PTP_V1_DEFAULT_DATASET::number_ports-1. + MBG_PTP_V1_PORT_DATASET port_dataset; ///< See ::MBG_PTP_V1_PORT_DATASET. } MBG_PTP_V1_PORT_DATASET_IDX; @@ -14892,6 +15869,60 @@ typedef struct /** + * @brief Flags for the PTPv2 NG default dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.1 and 15.5.3.3.1 + * + * @see ::MBG_PTP_V2_DEFAULT_DATASET + */ +enum MBG_PTP_V2_NG_DFLT_DS_FLAGS +{ + MBG_PTP_V2_NG_DFLT_DS_FLAG_TWO_STEP, + MBG_PTP_V2_NG_DFLT_DS_FLAG_SLAVE_ONLY, + N_MBG_PTP_V2_NG_DFLT_DS_FLAGS + +}; + +enum MBG_PTP_V2_NG_DFLT_DS_FLAG_MASKS +{ + MBG_PTP_V2_NG_DFLT_DS_FLAG_MSK_TWO_STEP = ( 1UL << MBG_PTP_V2_NG_DFLT_DS_FLAG_TWO_STEP), + MBG_PTP_V2_NG_DFLT_DS_FLAG_MSK_SLAVE_ONLY = ( 1UL << MBG_PTP_V2_NG_DFLT_DS_FLAG_SLAVE_ONLY) +}; + +/** + * @brief PTPv2 default dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.1 and 15.5.3.3.1 + * + * @see ::MBG_PTP_V2_DEFAULT_DATASET_FLAGS + * @see ::PTP_CLOCK_QUALITY + * @see ::PTP_CLOCK_ID + */ +typedef struct mbg_ptp_v2_ng_default_dataset_s +{ + uint8_t flags; ///< flags field, see ::MBG_PTP_V2_NG_DFLT_DS_FLAGS + uint8_t reserved_1; ///< reserved, currently always 0 + uint16_t number_ports; ///< number of PTP ports on the device + PTP_CLOCK_QUALITY clock_quality; ///< quality of the local clock, see ::PTP_CLOCK_QUALITY + uint8_t priority_1; ///< priority 1 attribute for the local clock + uint8_t priority_2; ///< priority 2 attribute for the local clock + uint8_t domain_number; ///< domain attribute of the local clock + uint8_t reserved_2; ///< reserved, currently always 0 + uint32_t reserved_3; + PTP_CLOCK_ID clock_identity; ///< identity of the local clock, see ::PTP_CLOCK_ID + +} MBG_PTP_V2_NG_DEFAULT_DATASET; + + +#define _mbg_swab_ptp_v2_ng_default_dataset( _p ) \ +{ \ + _mbg_swab16( &(_p)->number_ports ); \ + _mbg_swab_ptp_clock_quality( &(_p)->clock_quality ); \ + _mbg_swab_ptp_clock_id( &(_p)->clock_identity ); \ +} + + +/** * @brief PTPv2 current dataset * * @note For further information, see IEEE 1588-2008, chapters 8.2.2 and 15.5.3.4.1 @@ -14915,6 +15946,32 @@ typedef struct } + +/** + * @brief PTPv2 current dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.2 and 15.5.3.4.1 + * + * @see ::PTP_TIME_INTERVAL + */ +typedef struct mbg_ptp_v2_ng_current_dataset_s +{ + PTP_TIME_INTERVAL offset_from_master; ///< current time difference between master and slave, see ::PTP_TIME_INTERVAL + PTP_TIME_INTERVAL mean_path_delay; ///< current mean propagation time between master and slave, see ::PTP_TIME_INTERVAL + uint16_t steps_removed; ///< number of communication paths between local clock and grandmaster + uint16_t reserved_1; + uint32_t reserved_2; +} MBG_PTP_V2_NG_CURRENT_DATASET; + + +#define _mbg_swab_ptp_v2_ng_current_dataset( _p ) \ +{ \ + _mbg_swab_ptp_time_interval( &(_p)->offset_from_master ); \ + _mbg_swab_ptp_time_interval( &(_p)->mean_path_delay ); \ + _mbg_swab16( &(_p)->steps_removed ); \ +} + + /** * @brief Flags structure for the PTPv2 parent dataset * @@ -14949,14 +16006,14 @@ typedef struct PTP_PORT_IDENTITY parent_port_identity; ///< Identity of the master port, that issues the sync messages, see ::PTP_PORT_IDENTITY MBG_PTP_V2_PARENT_DATASET_FLAGS flags; ///< Flags field, see ::MBG_PTP_V2_PARENT_DATASET_FLAGS uint8_t reserved; ///< Reserved, currently always 0 - uint16_t parent_log_variance; ///< Estimate of the parent clock's PTP variance, only valid if - ///< ::MBG_PTP_V2_PARENT_DATASET_FLAGS::parent_stats is set in ::MBG_PTP_V2_PARENT_DATASET::flags - int32_t parent_phase_change_rate; ///< Estimate of the parent clock's phase change rate, only valid if - ///< ::MBG_PTP_V2_PARENT_DATASET_FLAGS::parent_stats is set in ::MBG_PTP_V2_PARENT_DATASET::flags - uint8_t grandmaster_priority_1; ///< Priority 1 attribute of the grandmaster clock - PTP_CLOCK_QUALITY grandmaster_clock_quality; ///< Quality of the grandmaster clock, see ::PTP_CLOCK_QUALITY - uint8_t grandmaster_priority_2; ///< Priority 2 attribute of the grandmaster clock - PTP_CLOCK_ID grandmaster_identity; ///< Identity of the grandmaster clock, see ::PTP_CLOCK_ID + uint16_t parent_log_variance; ///< Estimate of the PTP variance of the parent clock. Only valid if + ///< ::MBG_PTP_V2_PARENT_DATASET_FLAGS::parent_stats is set in ::MBG_PTP_V2_PARENT_DATASET::flags. + int32_t parent_phase_change_rate; ///< Estimate of the phase change rate of the parent clock. Only valid if + ///< ::MBG_PTP_V2_PARENT_DATASET_FLAGS::parent_stats is set in ::MBG_PTP_V2_PARENT_DATASET::flags. + uint8_t grandmaster_priority_1; ///< Priority 1 attribute of the grandmaster clock. + PTP_CLOCK_QUALITY grandmaster_clock_quality; ///< Quality of the grandmaster clock, see ::PTP_CLOCK_QUALITY. + uint8_t grandmaster_priority_2; ///< Priority 2 attribute of the grandmaster clock. + PTP_CLOCK_ID grandmaster_identity; ///< Identity of the grandmaster clock, see ::PTP_CLOCK_ID. } MBG_PTP_V2_PARENT_DATASET; @@ -14975,6 +16032,63 @@ typedef struct } + +/** + * @brief Flags structure for the PTPv2 NG parent dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.3.3 and 15.5.3.5.1.2 + * + * @see ::MBG_PTP_V2_NG_PARENT_DATASET + */ +enum MBG_PTP_V2_NG_PARENT_DATASET_FLAGS +{ + MBG_PTP_V2_NG_PARENT_DS_FLAG_PARENT_STATS, + N_MBG_PTP_V2_NG_PARENT_DS_FLAGS +}; + +enum MBG_PTP_V2_NG_PARENT_DATASET_FLAG_MASKS +{ + MBG_PTP_V2_NG_PARENT_DS_FLAG_MSK_PARENT_STATS = ( 1UL << MBG_PTP_V2_NG_PARENT_DS_FLAG_PARENT_STATS), +}; + +/** + * @brief PTPv2 NG parent dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.3 and 15.5.3.5.1 + * + * @see ::PTP_NG_PORT_IDENTITY + * @see ::MBG_PTP_V2_NG_PARENT_DATASET_FLAGS + * @see ::PTP_CLOCK_QUALITY + * @see ::PTP_CLOCK_ID + */ +typedef struct mbg_ptp_v2_ng_parent_dataset_s +{ + PTP_NG_PORT_IDENTITY parent_port_identity; ///< Identity of the master port, that issues the sync messages, see ::PTP_NG_PORT_IDENTITY. + uint8_t flags; ///< Flags field, see ::MBG_PTP_V2_NG_PARENT_DATASET_FLAGS. + uint8_t reserved_1; ///< Reserved, currently always 0. + uint16_t parent_log_variance; ///< Estimate of the PTP variance of the parent clock, only valid if + ///< ::MBG_PTP_V2_NG_PARENT_DS_FLAG_MSK_PARENT_STATS is set. + int32_t parent_phase_change_rate; ///< Estimate of the phase change rate of the parent clock, only valid if + ///< ::MBG_PTP_V2_NG_PARENT_DS_FLAG_MSK_PARENT_STATS is set. + PTP_CLOCK_QUALITY grandmaster_clock_quality; ///< Quality of the grandmaster clock, see ::PTP_CLOCK_QUALITY. + uint8_t grandmaster_priority_1; ///< Priority 1 attribute of the grandmaster clock. + uint8_t grandmaster_priority_2; ///< Priority 2 attribute of the grandmaster clock. + uint16_t reserved_2; + PTP_CLOCK_ID grandmaster_identity; ///< Identity of the grandmaster clock, see ::PTP_CLOCK_ID. + +} MBG_PTP_V2_NG_PARENT_DATASET; + + +#define _mbg_swab_ptp_v2_ng_parent_dataset( _p ) \ +{ \ + _mbg_swab_ptp_ng_port_identity( &(_p)->parent_port_identity ); \ + _mbg_swab16( &(_p)->parent_log_variance ); \ + _mbg_swab32( &(_p)->parent_phase_change_rate ); \ + _mbg_swab_ptp_clock_quality( &(_p)->grandmaster_clock_quality ); \ + _mbg_swab_ptp_clock_id( &(_p)->grandmaster_identity ); \ +} + + /** * @brief Flags structure for the PTPv2 time properties dataset * @@ -14984,11 +16098,11 @@ typedef struct */ typedef struct { - uint8_t leap_61 : 1; ///< set, if the last minute of the current UTC day containts 61 seconds - uint8_t leap_59 : 1; ///< set, if the last minute of the current UTC day containts 59 seconds - uint8_t utc_offset_valid : 1; ///< set, if the current UTC offset is known to be correct + uint8_t leap_61 : 1; ///< set, if the last minute of the current %UTC day has 61 seconds + uint8_t leap_59 : 1; ///< set, if the last minute of the current %UTC day has 59 seconds + uint8_t utc_offset_valid : 1; ///< set, if the current %UTC offset is known to be correct uint8_t ptp_timescale : 1; ///< set, if the timescale of the grandmaster clock is PTP - uint8_t time_traceable : 1; ///< set, if timescale and utc offset are traceable to a primary reference + uint8_t time_traceable : 1; ///< set, if timescale and %UTC offset are traceable to a primary reference uint8_t frequency_traceable : 1; ///< set, if the frequency determining the timescale is traceable to a primary reference uint8_t reserved : 2; ///< reserved, currently always 0 @@ -15008,7 +16122,7 @@ typedef struct */ typedef struct { - int16_t current_utc_offset; ///< offset between TAI and UTC in seconds + int16_t current_utc_offset; ///< offset between TAI and %UTC in seconds MBG_PTP_V2_TIME_PROPERTIES_DATASET_FLAGS flags; ///< flags field, see ::MBG_PTP_V2_TIME_PROPERTIES_DATASET_FLAGS uint8_t time_source; ///< source of time used by the grandmaster clock, see ::PTP_TIME_SOURCES @@ -15023,6 +16137,50 @@ typedef struct } +enum MBG_PTP_V2_NG_TIME_PROPERTIES_DATASET_FLAGS +{ + MBG_PTP_V2_NG_TPROP_DS_FLAG_LEAP_61, + MBG_PTP_V2_NG_TPROP_DS_FLAG_LEAP_59, + MBG_PTP_V2_NG_TPROP_DS_FLAG_UTC_OFFSET_VALID, + MBG_PTP_V2_NG_TPROP_DS_FLAG_PTP_TIMESCALE, + MBG_PTP_V2_NG_TPROP_DS_FLAG_TIME_TRACEABLE, + MBG_PTP_V2_NG_TPROP_DS_FLAG_FREQUENCY_TRACEABLE, + N_MBG_PTP_V2_NG_TPROP_DS_FLAGS +}; + +enum MBG_PTP_V2_NG_TIME_PROPERTIES_DATASET_FLAG_MASKS +{ + MBG_PTP_V2_NG_TPROP_DS_FLAG_MSK_LEAP_61 = ( 1UL << MBG_PTP_V2_NG_TPROP_DS_FLAG_LEAP_61), + MBG_PTP_V2_NG_TPROP_DS_FLAG_MSK_LEAP_59 = ( 1UL << MBG_PTP_V2_NG_TPROP_DS_FLAG_LEAP_59), + MBG_PTP_V2_NG_TPROP_DS_FLAG_MSK_UTC_OFFSET_VALID = ( 1UL << MBG_PTP_V2_NG_TPROP_DS_FLAG_UTC_OFFSET_VALID), + MBG_PTP_V2_NG_TPROP_DS_FLAG_MSK_PTP_TIMESCALE = ( 1UL << MBG_PTP_V2_NG_TPROP_DS_FLAG_PTP_TIMESCALE), + MBG_PTP_V2_NG_TPROP_DS_FLAG_MSK_TIME_TRACEABLE = ( 1UL << MBG_PTP_V2_NG_TPROP_DS_FLAG_TIME_TRACEABLE), + MBG_PTP_V2_NG_TPROP_DS_FLAG_MSK_FREQUENCY_TRACEABLE = ( 1UL << MBG_PTP_V2_NG_TPROP_DS_FLAG_FREQUENCY_TRACEABLE) +}; + + +/** + * @brief PTPv2 time properties dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.4 and 15.5.3.6.1 + * + * @see ::MBG_PTP_V2_TIME_PROPERTIES_DATASET_FLAGS + */ +typedef struct mbg_ptp_v2_ng_time_properties_dataset_s +{ + int16_t current_utc_offset; ///< offset between TAI and %UTC in seconds + uint8_t flags; ///< flags field, see ::MBG_PTP_V2_NG_TIME_PROPERTIES_DATASET_FLAGS + uint8_t time_source; ///< source of time used by the grandmaster clock, see ::PTP_TIME_SOURCES + uint32_t reserved; +} MBG_PTP_V2_NG_TIME_PROPERTIES_DATASET; + + +#define _mbg_swab_ptp_v2_ng_time_properties_dataset( _p ) \ +{ \ + _mbg_swab16( &(_p)->current_utc_offset ); \ +} + + /** * @brief PTPv2 port dataset * @@ -15063,17 +16221,67 @@ typedef struct } +typedef struct +{ + int8_t ann_intv; + int8_t sync_intv; + int8_t del_req_intv; + int8_t pdel_req_intv; + +} MBG_PTP_NG_INTV_CFG; + + +#define _mbg_swab_ptp_ng_intv_cfg( _p ) \ +do \ +{ \ + _mbg_swab8( &(_p)->ann_intv ); \ + _mbg_swab8( &(_p)->sync_intv ); \ + _mbg_swab8( &(_p)->del_req_intv ); \ + _mbg_swab8( &(_p)->pdel_req_intv ); \ +} while ( 0 ) + + +/** + * @brief PTPv2 port dataset + * + * @note For further information, see IEEE 1588-2008, chapters 8.2.5 and 15.5.3.7.1 + * + * @see ::PTP_PORT_IDENTITY + * @see ::PTP_TIME_INTERVAL + * @see ::MBG_PTP_V2_PORT_DATASET_IDX + */ +typedef struct mbg_ptp_v2_ng_port_dataset_s +{ + PTP_TIME_INTERVAL peer_mean_path_delay; ///< estimate of the current one-way propagation delay on the link, only valid if P2P is used, see ::PTP_TIME_INTERVAL + PTP_NG_PORT_IDENTITY port_identity; ///< identity of the local port, see ::PTP_PORT_IDENTITY + MBG_PTP_NG_INTV_CFG intvs; ///< interval settings for this port, see ::MBG_PTP_NG_INTV_CFG + uint8_t port_state; ///< state of the protocol engine associated with this port, see ::PTP_PORT_STATES + uint8_t announce_receipt_timeout; ///< shall be an integral multiple of ::MBG_PTP_V2_PORT_DATASET::log_announce_interval + uint8_t delay_mechanism; ///< propagation delay measuring option, see ::PTP_DELAY_MECHS + uint8_t version_number; ///< PTP version in use on the port + +} MBG_PTP_V2_NG_PORT_DATASET; + + +#define _mbg_swab_ptp_v2_ng_port_dataset( _p ) \ +{ \ + _mbg_swab_ptp_time_interval( &(_p)->peer_mean_path_delay ); \ + _mbg_swab_ptp_ng_port_identity( &(_p)->port_identity ); \ + _mbg_swab_ptp_ng_intv_cfg( &(_p)->intvs ); \ +} + + /** * @brief Index structure for PTPv2 port dataset * - * @note Port dataset with index 0..::MBG_PTP_V2_DEFAULT_DATASET::number_ports - 1 can be queried from a device + * @note Port dataset with index 0..::MBG_PTP_V2_DEFAULT_DATASET::number_ports-1 can be queried from a device. * * @see ::MBG_PTP_V2_PORT_DATASET */ typedef struct { - uint16_t idx; ///< Index of the port dataset, 0..::MBG_PTP_V2_DEFAULT_DATASET::number_ports - 1 - MBG_PTP_V2_PORT_DATASET port_dataset; ///< see ::MBG_PTP_V2_PORT_DATASET + MBG_MSG_IDX idx; ///< Index of the port dataset, 0..::MBG_PTP_V2_DEFAULT_DATASET::number_ports-1. + MBG_PTP_V2_PORT_DATASET port_dataset; ///< See ::MBG_PTP_V2_PORT_DATASET. } MBG_PTP_V2_PORT_DATASET_IDX; @@ -15084,6 +16292,1689 @@ typedef struct _mbg_swab_ptp_v2_port_dataset( &(_p)->port_dataset ); \ } +/** + * @brief Index structure for PTPv2 port dataset + * + * @note Port dataset with index 0..::MBG_PTP_V2_DEFAULT_DATASET::number_ports - 1 can be queried from a device + * + * @see ::MBG_PTP_V2_PORT_DATASET + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; ///< Index of the port dataset, 0..::MBG_PTP_V2_DEFAULT_DATASET::number_ports - 1 + uint32_t reserved; + MBG_PTP_V2_NG_PORT_DATASET port_dataset; ///< See ::MBG_PTP_V2_PORT_DATASET + +} MBG_PTP_V2_NG_PORT_DATASET_IDX; + + +/** + * @defgroup group_ptp_ng Next gen structures and definitions used with PTP/IEEE1588 + * + * @{ */ + +typedef char PTP_INTF[MBG_IFNAMSIZ]; ///< interface name (IPv4/L2) or IPv6 address of logical interface linked to this config + + +/** + * @brief PTP version flags + * + * @see ::PTP_NG_VERSION_MASKS + */ +enum PTP_NG_VERSION_FLAGS +{ + PTP_NG_VERSION_1 = 0, + PTP_NG_VERSION_2, + PTP_NG_VERSION_2_1, + N_PTP_NG_VERSIONS +}; + + +/** + * @brief PTP version flag masks used with ::MBG_PTP_NG_GLB_INFO::supp_versions + * + * @see ::PTP_NG_VERSION_FLAGS + */ +enum PTP_NG_VERSION_MASKS +{ + PTP_NG_VERSION_1_MSK = ( 1UL << PTP_NG_VERSION_1 ), ///< See ::PTP_NG_VERSION_1 + PTP_NG_VERSION_2_MSK = ( 1UL << PTP_NG_VERSION_2 ), ///< See ::PTP_NG_VERSION_2 + PTP_NG_VERSION_2_1_MSK = ( 1UL << PTP_NG_VERSION_2_1 ) ///< See ::PTP_NG_VERSION_2_1 +}; + + +#define PTP_NG_VERSION_STRS \ +{ \ + "PTPv1", \ + "PTPv2", \ + "PTPv2.1" \ +} + + +enum MBG_PTP_NG_FLAGS +{ + MBG_PTP_NG_FLAG_ARB_TIMESCALE, ///< Use arbitrary timescale instead of default PTP (TAI) timescale + MBG_PTP_NG_FLAG_V1_HW_COMPATIBILITY, ///< V1 hardware compatibility is used (fill Sync Message with padding bytes) + MBG_PTP_NG_FLAG_BOUNDARY_CLOCK, ///< Indicates, that an instance is part of a boundary clock setup + MBG_PTP_NG_FLAG_SW_TSTAMPING, ///< No hardware timestamps are used + MBG_PTP_NG_FLAG_MANAGEMENT, ///< PTP Management Messages are enabled + MBG_PTP_NG_FLAG_NO_CLK_ADJ, ///< No Adjustment of the hardware clock in slave mode (measurement only) + MBG_PTP_NG_FLAG_PATH_TRACE, ///< Use path trace TLV + MBG_PTP_NG_FLAG_CUSTOM_PORT_ID, ///< A user-defined CLOCK IDENTITY is used for this PTP instance + MBG_PTP_NG_FLAG_FIXED_QUALITY, ///< A user-defined set of fixed BMCA parameters is configured + MBG_PTP_NG_FLAG_AUTHENTICATION, ///< Use authentication as used in PTP v2.1 + MBG_PTP_NG_FLAG_DELAY_ASYMMETRY, ///< Delay asymmetry configuration is supported + MBG_PTP_NG_FLAG_GLB_CLOCK_ID, ///< Use system-wide clock ID for all instances, otherwise use one ID per phys port + MBG_PTP_NG_FLAG_SERVO_SETTINGS, ///< User-defined servo settings, see ::MBG_PTP_NG_SERVO_SETTINGS + MBG_PTP_NG_FLAG_HYBRID_MODE, ///< Use hybrid mode (DelReq. in unicast) + MBG_PTP_NG_FLAG_PKT_CNTRS, ///< Indicates, that an instance supplies packet counters, see ::MBG_PTP_NG_INSTC_PKT_CNTRS + MBG_PTP_NG_FLAG_MIN_GM_CLK_QUALITY, ///< User-defined set of minimum clock quality parameters for synchronization + MBG_PTP_NG_FLAG_DISABLED, ///< Indicates, that an instance is temporarily disabled + N_MBG_PTP_NG_FLAGS +}; + + +enum MBG_PTP_NG_FLAG_MASKS +{ + MBG_PTP_NG_FLAG_ARB_TIMESCALE_MSK = ( 1UL << MBG_PTP_NG_FLAG_ARB_TIMESCALE ), ///< See ::MBG_PTP_NG_FLAG_ARB_TIMESCALE + MBG_PTP_NG_FLAG_V1_HW_COMPATIBILITY_MSK = ( 1UL << MBG_PTP_NG_FLAG_V1_HW_COMPATIBILITY ), ///< See ::MBG_PTP_NG_FLAG_V1_HW_COMPATIBILITY + MBG_PTP_NG_FLAG_BOUNDARY_CLOCK_MSK = ( 1UL << MBG_PTP_NG_FLAG_BOUNDARY_CLOCK ), ///< See ::MBG_PTP_NG_FLAG_BOUNDARY_CLOCK + MBG_PTP_NG_FLAG_SW_TSTAMPING_MSK = ( 1UL << MBG_PTP_NG_FLAG_SW_TSTAMPING ), ///< See ::MBG_PTP_NG_FLAG_SW_TSTAMPING + MBG_PTP_NG_FLAG_MANAGEMENT_MSK = ( 1UL << MBG_PTP_NG_FLAG_MANAGEMENT ), ///< See ::MBG_PTP_NG_FLAG_MANAGEMENT + MBG_PTP_NG_FLAG_NO_CLK_ADJ_MSK = ( 1UL << MBG_PTP_NG_FLAG_NO_CLK_ADJ ), ///< See ::MBG_PTP_NG_FLAG_NO_CLK_ADJ + MBG_PTP_NG_FLAG_PATH_TRACE_MSK = ( 1UL << MBG_PTP_NG_FLAG_PATH_TRACE ), ///< See ::MBG_PTP_NG_FLAG_PATH_TRACE + MBG_PTP_NG_FLAG_CUSTOM_PORT_ID_MSK = ( 1UL << MBG_PTP_NG_FLAG_CUSTOM_PORT_ID ), ///< See ::MBG_PTP_NG_FLAG_CUSTOM_PORT_ID + MBG_PTP_NG_FLAG_FIXED_QUALITY_MSK = ( 1UL << MBG_PTP_NG_FLAG_FIXED_QUALITY ), ///< See ::MBG_PTP_NG_FLAG_FIXED_QUALITY + MBG_PTP_NG_FLAG_AUTHENTICATION_MSK = ( 1UL << MBG_PTP_NG_FLAG_AUTHENTICATION ), ///< See ::MBG_PTP_NG_FLAG_AUTHENTICATION + MBG_PTP_NG_FLAG_DELAY_ASYMMETRY_MSK = ( 1UL << MBG_PTP_NG_FLAG_DELAY_ASYMMETRY ), ///< See ::MBG_PTP_NG_FLAG_DELAY_ASYMMETRY + MBG_PTP_NG_FLAG_GLB_CLOCK_ID_MSK = ( 1UL << MBG_PTP_NG_FLAG_GLB_CLOCK_ID ), ///< See ::MBG_PTP_NG_FLAG_GLB_CLOCK_ID + MBG_PTP_NG_FLAG_SERVO_SETTINGS_MSK = ( 1UL << MBG_PTP_NG_FLAG_SERVO_SETTINGS ), ///< See ::MBG_PTP_NG_FLAG_SERVO_SETTINGS + MBG_PTP_NG_FLAG_HYBRID_MODE_MSK = ( 1UL << MBG_PTP_NG_FLAG_HYBRID_MODE ), ///< See ::MBG_PTP_NG_FLAG_HYBRID_MODE + MBG_PTP_NG_FLAG_PKT_CNTRS_MSK = ( 1UL << MBG_PTP_NG_FLAG_PKT_CNTRS ), ///< See ::MBG_PTP_NG_FLAG_PKT_CNTRS + MBG_PTP_NG_FLAG_MIN_GM_CLK_QUALITY_MSK = ( 1UL << MBG_PTP_NG_FLAG_MIN_GM_CLK_QUALITY ), ///< See ::MBG_PTP_NG_FLAG_MIN_GM_CLK_QUALITY + MBG_PTP_NG_FLAG_DISABLED_MSK = ( 1UL << MBG_PTP_NG_FLAG_DISABLED ) ///< See ::MBG_PTP_NG_FLAG_DISABLED +}; + + +enum MBG_PTP_NG_V1_FLAGS +{ + MBG_PTP_NG_V1_FLAG_PREFERRED, ///< Set preferred flag in PTPv1 stack + MBG_PTP_NG_V1_FLAG_INITIALIZABLE, ///< Set initializable flag in PTPv1 stack + MBG_PTP_NG_V1_FLAG_EXT_TIMING, ///< Set external timing flag in PTPv1 stack + N_MBG_PTP_NG_V1_FLAGS +}; + + +enum MBG_PTP_NG_V1_FLAG_MASKS +{ + MBG_PTP_NG_V1_FLAG_PREFERRED_MSK = ( 1UL << MBG_PTP_NG_V1_FLAG_PREFERRED ), ///< See ::MBG_PTP_NG_V1_FLAG_PREFERRED + MBG_PTP_NG_V1_FLAG_INITIALIZABLE_MSK = ( 1UL << MBG_PTP_NG_V1_FLAG_INITIALIZABLE ), ///< See ::MBG_PTP_NG_V1_FLAG_INITIALIZABLE + MBG_PTP_NG_V1_FLAG_EXT_TIMING_MSK = ( 1UL << MBG_PTP_NG_V1_FLAG_EXT_TIMING ) ///< See ::MBG_PTP_NG_V1_FLAG_EXT_TIMING +}; + + +/** + * @brief Pre-defined alternate time offset indicators + */ +enum MBG_PTP_NG_ATOIS +{ + MBG_PTP_NG_ATOI_UTC, ///< %UTC (Coordinated Universal Time), meaning an almost empty ATOI (minimum requirement for C37.238-2011). + MBG_PTP_NG_ATOI_CUSTOM, ///< Custom, manually configured ATOI stored as ::TZDL structure. + MBG_PTP_NG_ATOI_CET_CEST, ///< CET/CEST (Central European (Summer) Time). + N_MBG_PTP_NG_ATOIS +}; + + +enum MBG_PTP_NG_ATOI_MASKS +{ + MBG_PTP_NG_ATOI_UTC_MSK = ( 1UL << MBG_PTP_NG_ATOI_UTC ), ///< See ::MBG_PTP_NG_ATOI_UTC + MBG_PTP_NG_ATOI_CUSTOM_MSK = ( 1UL << MBG_PTP_NG_ATOI_CUSTOM ), ///< See ::MBG_PTP_NG_ATOI_CUSTOM + MBG_PTP_NG_ATOI_CET_CEST_MSK = ( 1UL << MBG_PTP_NG_ATOI_CET_CEST ) ///< See ::MBG_PTP_NG_ATOI_CET_CEST +}; + + +#define MBG_PTP_NG_ATOI_SHORT_NAMES \ +{ \ + "UTC", \ + "Custom", \ + "CET/CEST" \ +} + + +#define MBG_PTP_NG_ATOI_NAMES \ +{ \ + "UTC (Coordinated Universal Time)", \ + "Custom", \ + "CET/CEST (Central European [Summer] Time)" \ +} + + + +/** + * @brief Predefined time scales for PTP SMPTE jam event times. + * + * Used with ::MBG_PTP_NG_SMPTE_20592_SETTINGS::event_timescale, + * and to define ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_MASKS. + * + * This is only relevant for the way the ***configuration is stored***, + * and the effective time sent in the SMPTE TLV has to be calculated + * by the appropriate time scale conversion. + * + * @see ::MBG_PTP_NG_SMPTE_20592_SETTINGS::event_timescale + * @see ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_MASKS + */ +enum MBG_PTP_NG_SMPTE_EVT_TIMESCALES +{ + /// @brief Time scale refers to local time. + /// + /// If the local time scale is used to configure the daily jam + /// then the jam occurs at exactly the same time, e.g. always + /// at 2 o'clock according to the configured time zone, regardless + /// whether DST is in effect, or not, and it is not affected by + /// another leap second that might be inserted at some point + /// during operation. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_LOCAL_TIME, + + /// @brief Time scale refers to %UTC. + /// + /// If %UTC is used for the configuration then the jam always occurs + /// at exactly the same %UTC time, which is not affected by another + /// leap second that might be inserted at some point during operation. + /// + /// However, the local time when the jam occurs depends on the + /// local time zone offset, and on the DST status of the + /// configured time zone. + /// + /// For example, if 3 o'clock %UTC has been configured and the + /// local time zone is CET/CEST (i.e. %UTC+1h/%UTC+2h), + /// the jam occurs at 4 o'clock while DST is not in effect, + /// and at 5 o'clock if DST is in effect. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_UTC, + + /// @brief Time scale refers to TAI. + /// + /// If the jam times are configured using the TAI time scale, + /// the effective local time sent in the SMPTE TLV depends on + /// the local time zone offset and DST status just as for + /// ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_UTC, but in addition + /// changes whenefer the TAI/%UTC offset changes due to + /// a leap second. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_TAI, + + /// @brief Time scale refers to GPS system time. + /// + /// Basically the same behavior as with ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_TAI, + /// except that an additional constant offset ::GPS_SEC_BIAS has to be + /// taken into account. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_GPS, + + ///< The number of predefined SMPTE event time scales. + N_MBG_PTP_NG_SMPTE_EVT_TIMESCALES +}; + + + +/** + * @brief Bit masks of predefined time scales for PTP SMPTE jam event times. + * + * Used with ::MBG_PTP_NG_GLB_INFO::supp_smpte_tscales. + * + * @see ::MBG_PTP_NG_SMPTE_EVT_TIMESCALES + */ +enum MBG_PTP_NG_SMPTE_EVT_TIMESCALE_MASKS +{ + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_LOCAL_TIME_MSK = ( 1UL << MBG_PTP_NG_SMPTE_EVT_TIMESCALE_LOCAL_TIME ), ///< See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_LOCAL_TIME. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_UTC_MSK = ( 1UL << MBG_PTP_NG_SMPTE_EVT_TIMESCALE_UTC ), ///< See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_UTC. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_TAI_MSK = ( 1UL << MBG_PTP_NG_SMPTE_EVT_TIMESCALE_TAI ), ///< See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_TAI. + MBG_PTP_NG_SMPTE_EVT_TIMESCALE_GPS_MSK = ( 1UL << MBG_PTP_NG_SMPTE_EVT_TIMESCALE_GPS ) ///< See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_GPS. +}; + + +#define MBG_PTP_NG_SMPTE_EVT_TIMESCALE_STRS \ +{ \ + "PTP (TAI)", \ + "UTC", \ + "Local Time", \ + "GPS" \ +} + + +typedef struct +{ + uint16_t num_instances; ///< Number of currently configured PTP instances. + uint16_t num_uc_masters; ///< Total number of currently configured unicast masters. + uint32_t flags; ///< Current flags, see ::MBG_PTP_NG_FLAG_MASKS. + + uint32_t reserved_2[6]; ///< Reserved, currently always 0. + +} MBG_PTP_NG_GLB_SETTINGS; + + +#define _mbg_swab_ptp_ng_glb_settings( _p ) \ +{ \ + _mbg_swab16( &(_p)->num_instances ); \ + _mbg_swab16( &(_p)->num_uc_masters ); \ + _mbg_swab32( &(_p)->flags ); \ +} + + + +typedef struct mbg_ptp_ng_glb_info_s +{ + MBG_PTP_NG_GLB_SETTINGS settings; ///< The current global configuration for this firmware. + + PTP_CLOCK_ID system_clock_id; ///< System-wide global clock ID, which can be used by all instances. + ///< Only supp., if ::MBG_PTP_NG_FLAG_GLB_CLOCK_ID_MSK is set in ::MBG_PTP_NG_GLB_INFO::supp_flags. + ///< Only used, if ::MBG_PTP_NG_FLAG_GLB_CLOCK_ID_MSK is set in ::MBG_PTP_NG_GLB_SETTINGS::flags. + + uint16_t num_timestampers; ///< Total number of hardware timestampers for this firmware. + uint16_t max_instances; ///< Maximum number of PTP instances (software) for this firmware. + + uint16_t max_uc_masters; ///< Maximum number of uncast masters that can be configured in total for this firmware. + uint16_t max_instc_uc_masters; ///< Maximum number of unicast masters per instance. + + uint32_t supp_protocols; ///< Bitmask of supported network protocols, see ::PTP_NW_PROT_MASKS. + uint32_t supp_delay_mechs; ///< Bit mask of supported delay mechanisms, see ::PTP_DELAY_MECH_MASKS. + uint32_t supp_profiles; ///< Bit mask of supported PTP profiles, see ::PTP_PRESETS: + uint32_t supp_versions; ///< Bit mask of supported PTP protocol versions, see ::PTP_NG_VERSION_MASKS. + uint32_t supp_roles; ///< Bit mask of supported PTP roles, see ::PTP_ROLE_MASKS. + uint32_t supp_flags; ///< Bit mask of supported flags, see ::MBG_PTP_NG_FLAG_MASKS. + uint32_t supp_v1_flags; ///< Bit mask of supported PTPv1 flags, see ::MBG_PTP_NG_V1_FLAG_MASKS. + uint32_t supp_atois; ///< Bit mask of supported Alternate Time Offset Indicators (ATOIs), see ::MBG_PTP_NG_ATOI_MASKS. + + MBG_PTP_NG_INTV_CFG intvs_min; ///< log2 of minimum intervals [s] + MBG_PTP_NG_INTV_CFG intvs_max; ///< log2 of maximum intervals [s] + + uint16_t max_atois; ///< Maximum number of ATOIs that may be used in parallel, see ::MBG_PTP_NG_ATOI_MASKS. + uint16_t supp_smpte_tscales; ///< Bit mask of supported SMPTE event timescales, see ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_MASKS. + uint32_t reserved_2[7]; ///< Reserved, currently always 0. + +} MBG_PTP_NG_GLB_INFO; + + +#define _mbg_swab_ptp_ng_glb_info( _p ) \ +{ \ + _mbg_swab_ptp_ng_glb_settings( &(_p)->settings ); \ + _mbg_swab16( &(_p)->num_timestampers ); \ + _mbg_swab16( &(_p)->max_instances ); \ + _mbg_swab16( &(_p)->max_uc_masters ); \ + _mbg_swab16( &(_p)->max_instc_uc_masters ); \ + _mbg_swab32( &(_p)->supp_protocols ); \ + _mbg_swab32( &(_p)->supp_delay_mechs ); \ + _mbg_swab32( &(_p)->supp_profiles ); \ + _mbg_swab32( &(_p)->supp_versions ); \ + _mbg_swab32( &(_p)->supp_roles ); \ + _mbg_swab32( &(_p)->supp_flags ); \ + _mbg_swab32( &(_p)->supp_v1_flags ); \ + _mbg_swab32( &(_p)->supp_atois ); \ + _mbg_swab_ptp_ng_intv_cfg( &(_p)->intvs_min ); \ + _mbg_swab_ptp_ng_intv_cfg( &(_p)->intvs_max ); \ + _mbg_swab16( &(_p)->max_atois ); \ +} + + +typedef struct +{ + uint16_t sec_h; ///< Seconds (47:32) + uint16_t reserved_1; + uint32_t reserved_2; + uint32_t sec_l; ///< Seconds (31:0) + uint32_t nsec; ///< Nanoseconds + +} MBG_PTP_NG_TIMESTAMP; + + +#define _mbg_swab_ptp_ng_timestamp( _p ) \ +{ \ + _mbg_swab16( &(_p)->sec_h ); \ + _mbg_swab32( &(_p)->sec_l ); \ + _mbg_swab32( &(_p)->nsec ); \ +} + + +/** + * @brief PTP timestamper modes + * + * @see ::PTP_NG_TSTAMPER_MODE_MASKS + */ +enum PTP_NG_TSTAMPER_MODES +{ + PTP_NG_TSTAMPER_MODE_ALL, ///< Timestamp all incoming packets. + PTP_NG_TSTAMPER_MODE_NTP, ///< Timestamp only NTP packets. + PTP_NG_TSTAMPER_MODE_PTP_V1, ///< Timestamp only PTPv1 packets. + PTP_NG_TSTAMPER_MODE_PTP_V2, ///< Timestamp only PTPv2 (+2.1) packets. + N_PTP_NG_TSTAMPER_MODES +}; + + +/** + * @brief PTP timestamper mode masks used with ::MBG_PTP_NG_TSTAMPER_INFO::supp_modes + * + * @see ::PTP_NG_TSTAMPER_MODES + */ +enum PTP_NG_TSTAMPER_MODE_MASKS +{ + PTP_NG_TSTAMPER_MODE_ALL_MSK = ( 1UL << PTP_NG_TSTAMPER_MODE_ALL ), ///< See ::PTP_NG_TSTAMPER_MODE_ALL + PTP_NG_TSTAMPER_MODE_NTP_MSK = ( 1UL << PTP_NG_TSTAMPER_MODE_NTP ), ///< See ::PTP_NG_TSTAMPER_MODE_NTP + PTP_NG_TSTAMPER_MODE_PTP_V1_MSK = ( 1UL << PTP_NG_TSTAMPER_MODE_PTP_V1 ), ///< See ::PTP_NG_TSTAMPER_MODE_PTP_V1 + PTP_NG_TSTAMPER_MODE_PTP_V2_MSK = ( 1UL << PTP_NG_TSTAMPER_MODE_PTP_V2 ) ///< See ::PTP_NG_TSTAMPER_MODE_PTP_V2 +}; + + +#define PTP_NG_TSTAMPER_MODE_STRS \ +{ \ + "All", \ + "NTP", \ + "PTPv1", \ + "PTPv2" \ +} + + +/** + * @brief PTP timestamper flags + * + * @see ::PTP_NG_TSTAMPER_FLAG_MASKS + */ +enum PTP_NG_TSTAMPER_FLAGS +{ + PTP_NG_TSTAMPER_FLAG_ONE_STEP, ///< timestamp in one-step mode + PTP_NG_TSTAMPER_FLAG_PACKET_GENERATOR, ///< use packet generator to timestamp packets in hardware + PTP_NG_TSTAMPER_FLAG_HYBRID_MODE, ///< use hybrid mode (DelReq. in unicast), only when packet generator is enabled; + ///< otherwise hybrid mode can be enabled/disabled per software instance + PTP_NG_TSTAMPER_FLAG_ALL_DOMAINS, ///< timestamp PTP packets in all domains + PTP_NG_TSTAMPER_FLAG_ALL_PROTOCOLS, ///< timestamp PTP packets of all protocols + PTP_NG_TSTAMPER_FLAG_ALL_IPV6_SCOPES, ///< timestamp PTP packets in all IPv6 multicast scopes + PTP_NG_TSTAMPER_FLAG_SUPP_MULTIPLE_INSTCS, ///< timestamper supports multiple instances (VLANs), not configurable + PTP_NG_TSTAMPER_FLAG_SUPP_P2P_ONE_STEP, ///< timestamper supports P2P one-step mode, not configurable + N_PTP_NG_TSTAMPER_FLAGS +}; + + +/** + * @brief PTP timestamper flag masks used with ::MBG_PTP_NG_TSTAMPER_SETTINGS::flags and ::MBG_PTP_NG_TSTAMPER_INFO::supp_flags + * + * @see ::PTP_NG_TSTAMPER_FLAGS + */ +enum PTP_NG_TSTAMPER_FLAG_MASKS +{ + PTP_NG_TSTAMPER_FLAG_ONE_STEP_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_ONE_STEP ), ///< See ::PTP_NG_TSTAMPER_FLAG_ONE_STEP + PTP_NG_TSTAMPER_FLAG_PACKET_GENERATOR_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_PACKET_GENERATOR ), ///< See ::PTP_NG_TSTAMPER_FLAG_PACKET_GENERATOR + PTP_NG_TSTAMPER_FLAG_HYBRID_MODE_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_HYBRID_MODE ), ///< See ::PTP_NG_TSTAMPER_FLAG_HYBRID_MODE + PTP_NG_TSTAMPER_FLAG_ALL_DOMAINS_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_ALL_DOMAINS ), ///< See ::PTP_NG_TSTAMPER_FLAG_ALL_DOMAINS + PTP_NG_TSTAMPER_FLAG_ALL_PROTOCOLS_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_ALL_PROTOCOLS ), ///< See ::PTP_NG_TSTAMPER_FLAG_ALL_PROTOCOLS + PTP_NG_TSTAMPER_FLAG_ALL_IPV6_SCOPES_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_ALL_IPV6_SCOPES ), ///< See ::PTP_NG_TSTAMPER_FLAG_ALL_IPV6_SCOPES + PTP_NG_TSTAMPER_FLAG_SUPP_MULTIPLE_INSTCS_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_SUPP_MULTIPLE_INSTCS ), ///< See ::PTP_NG_TSTAMPER_FLAG_SUPP_MULTIPLE_INSTCS + PTP_NG_TSTAMPER_FLAG_SUPP_P2P_ONE_STEP_MSK = ( 1UL << PTP_NG_TSTAMPER_FLAG_SUPP_P2P_ONE_STEP ) ///< See ::PTP_NG_TSTAMPER_FLAG_SUPP_P2P_ONE_STEP +}; + + +typedef struct mbg_ptp_ng_tstamper_settings_s +{ + uint8_t mode; ///< timestamper mode, see ::PTP_NG_TSTAMPER_MODES + uint8_t protocol; ///< current protocol, see ::PTP_NW_PROTS + uint8_t domain; ///< current PTPv2 domain number (0..255) + uint8_t ipv6_multicast_scope; ///< One of the ::IPV6_MULTICAST_SCOPES used for PTP IPv6 multicast. + + uint32_t flags; ///< See ::PTP_NG_TSTAMPER_FLAG_MASKS + + uint32_t reserved_2[6]; ///< reserved, currently always 0 + +} MBG_PTP_NG_TSTAMPER_SETTINGS; + + +#define _mbg_swab_ptp_ng_tstamper_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->flags ); \ +} + + +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + MBG_PTP_NG_TSTAMPER_SETTINGS settings; + +} MBG_PTP_NG_TSTAMPER_SETTINGS_IDX; + + +#define _mbg_swab_ptp_ng_tstamper_settings_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_tstamper_settings( &(_p)->settings ); \ +} + + +typedef struct mbg_ptp_ng_tstamper_info_s +{ + MBG_PTP_NG_TSTAMPER_SETTINGS settings; + + PTP_INTF phys_intf; ///< the physical interface name this timestamper belongs to + uint32_t supp_modes; ///< bitmask of supported timestamper modes, see ::PTP_NG_TSTAMPER_MODE_MASKS + uint32_t supp_protocols; ///< bitmask of supported network protocols, see ::PTP_NW_PROT_MASKS + uint32_t supp_roles; ///< bitmask of supported PTP roles on this timestamper, see ::PTP_ROLE_MASKS + uint32_t supp_flags; ///< bitmask of supported features, see ::PTP_NG_TSTAMPER_FLAG_MASKS + uint32_t max_ptp_packets; ///< Maximum number of PTP generated packets per second + uint32_t max_ntp_packets; ///< Maximum number of NTP generated packets per second + uint16_t max_ptp_uc_slaves; ///< Maximum number of PTP Unicast slaves + uint16_t reserved_1; ///< reserved, currently always 0 + + uint32_t reserved_2[5]; ///< reserved, currently always 0 + +} MBG_PTP_NG_TSTAMPER_INFO; + + +#define _mbg_swab_ptp_ng_tstamper_info( _p ) \ +{ \ + _mbg_swab_ptp_ng_tstamper_settings( &(_p)->settings ); \ + _mbg_swab32( &(_p)->supp_modes ); \ + _mbg_swab32( &(_p)->supp_protocols ); \ + _mbg_swab32( &(_p)->supp_roles ); \ + _mbg_swab32( &(_p)->supp_flags ); \ +} + + +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + MBG_PTP_NG_TSTAMPER_INFO info; + +} MBG_PTP_NG_TSTAMPER_INFO_IDX; + + +#define _mbg_swab_ptp_ng_tstamper_info_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_tstamper_info( &(_p)->info ); \ +} + + +typedef struct mbg_ptp_ng_tstamper_status_s +{ + MBG_PTP_NG_TIMESTAMP current_time; ///< current tstamper time + PTP_TIME_INTERVAL offset_from_int_ref; ///< current offset between tstamper time and internal reference + uint8_t utilization; ///< current resource utilization (msg/sec) in % + uint8_t reserved_1[7]; ///< reserved, currently always 0 + + uint32_t reserved_2[12]; ///< reserved, currently always 0 + +} MBG_PTP_NG_TSTAMPER_STATUS; + + +#define _mbg_swab_ptp_ng_tstamper_status( _p ) \ +{ \ + _mbg_swab_ptp_ng_timestamp( &(_p)->current_time ); \ + _mbg_swab_ptp_time_interval( &(_p)->offset_from_int_ref ); \ +} + + +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + MBG_PTP_NG_TSTAMPER_STATUS status; + +} MBG_PTP_NG_TSTAMPER_STATUS_IDX; + + +#define _mbg_swab_ptp_ng_tstamper_status_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_tstamper_status( &(_p)->status ); \ +} + + +enum MBG_PTP_NG_SERVO_FLAGS +{ + MBG_PTP_NG_SERVO_FLAG_USE_IIR_FILTER, ///< TODO: Please add describing comment + MBG_PTP_NG_SERVO_FLAG_USE_SPIKE_FILTER, ///< TODO: Please add describing comment + MBG_PTP_NG_SERVO_FLAG_USE_SAMPLE_RATE_CONVERTER, ///< TODO: Please add describing comment + MBG_PTP_NG_SERVO_FLAG_COLD_START, ///< PTP stack starts with a default drift value + N_MBG_PTP_NG_SERVO_FLAGS +}; + + +enum MBG_PTP_NG_SERVO_FLAG_MASKS +{ + MBG_PTP_NG_SERVO_FLAG_USE_IIR_FILTER_MSK = (1UL << MBG_PTP_NG_SERVO_FLAG_USE_IIR_FILTER), ///< See ::MBG_PTP_NG_SERVO_FLAG_USE_IIR_FILTER + MBG_PTP_NG_SERVO_FLAG_USE_SPIKE_FILTER_MSK = (1UL << MBG_PTP_NG_SERVO_FLAG_USE_SPIKE_FILTER), ///< See ::MBG_PTP_NG_SERVO_FLAG_USE_SPIKE_FILTER + MBG_PTP_NG_SERVO_FLAG_USE_SAMPLE_RATE_CONVERTER_MSK = (1UL << MBG_PTP_NG_SERVO_FLAG_USE_SAMPLE_RATE_CONVERTER), ///< See ::MBG_PTP_NG_SERVO_FLAG_USE_SAMPLE_RATE_CONVERTER + MBG_PTP_NG_SERVO_FLAG_COLD_START_MSK = (1UL << MBG_PTP_NG_SERVO_FLAG_COLD_START), ///< See ::MBG_PTP_NG_SERVO_FLAG_COLD_START +}; + + +typedef struct +{ + int64_t inbound_delta_rate_max; ///< TODO: Please add describing comment + int64_t inbound_anti_windup_max; ///< TODO: Please add describing comment + int64_t outbound_delta_rate_max; ///< TODO: Please add describing comment + int64_t outbound_anti_windup_max; ///< TODO: Please add describing comment + + uint8_t reserved_1; ///< reserved, currently always 0 + int8_t lucky_packet_flt_depth; ///< TODO: Please add describing comment + uint16_t lucky_packet_median; ///< TODO: Please add describing comment + uint32_t flags; ///< See ::MBG_PTP_NG_SERVO_FLAG_MASKS + + uint32_t outbound_pi_k; ///< TODO: Please add describing comment + uint32_t outbound_pi_t; ///< TODO: Please add describing comment + + uint16_t iir_m2s_smin; ///< TODO: Please add describing comment + uint16_t iir_path_smin; ///< TODO: Please add describing comment + int8_t iir_log_adj_prd; ///< TODO: Please add describing comment + int8_t iir_log_adj_gain; ///< TODO: Please add describing comment + uint16_t reserved_2; ///< reserved, currently always 0 + + uint32_t inbound_pi_k; ///< TODO: Please add describing comment + uint32_t inbound_pi_t; ///< TODO: Please add describing comment + + int32_t boundary; ///< Sync Boundary in scaledNs [65536000] -> 1 microsecond + int32_t change_epoch_boundary; ///< Max epoch jump in scaledNs before hard time step is done [32768000000000] -> 0.5 sec + + uint8_t adjust_interval; ///< -8..+8 + uint8_t reserved_3; ///< reserved, currently always 0 + uint16_t reserved_4; ///< reserved, currently always 0 + uint32_t reserved_5; ///< reserved, currently always 0 + + uint32_t reserved_6[4]; ///< reserved, currently always 0 + +} MBG_PTP_NG_SERVO_SETTINGS; + + +#define _mbg_swab_ptp_ng_servo_settings( _p ) \ +{ \ + _mbg_swab64( &(_p)->inbound_delta_rate_max ); \ + _mbg_swab64( &(_p)->inbound_anti_windup_max ); \ + _mbg_swab64( &(_p)->outbound_delta_rate_max ); \ + _mbg_swab64( &(_p)->outbound_anti_windup_max ); \ + _mbg_swab16( &(_p)->lucky_packet_median ); \ + _mbg_swab32( &(_p)->flags ); \ + _mbg_swab32( &(_p)->outbound_pi_k ); \ + _mbg_swab32( &(_p)->outbound_pi_t ); \ + _mbg_swab16( &(_p)->iir_m2s_smin ); \ + _mbg_swab16( &(_p)->iir_path_smin ); \ + _mbg_swab32( &(_p)->inbound_pi_k ); \ + _mbg_swab32( &(_p)->inbound_pi_t ); \ + _mbg_swab32( &(_p)->boundary ); \ + _mbg_swab32( &(_p)->change_epoch_boundary ); \ +} + + +typedef struct +{ + uint8_t clk_class_never_sync; ///< Fixed clock class if clock is free running, 0 means automatic + uint8_t clk_class_sync; ///< Fixed clock class if clock is synced, 0 means automatic + uint8_t clk_class_holdover; ///< Fixed clock class if clock is in holdover, 0 means automatic + uint8_t time_source; ///< Fixed PTP Time Source, 0 means automatic + uint8_t clk_accuracy; ///< Fixed clock accuracy, 0 means automatic + + uint8_t reserved_1; ///< Fixed clock accuracy, 0 means automatic + uint16_t fixed_clk_variance; ///< Fixed clock variance, 0 means automatic + + uint32_t reserved_2[4]; ///< reserved, currently always 0 + +} MBG_PTP_NG_FIXED_CLK_QLTY; + + +#define _mbg_swab_ptp_ng_fixed_clk_qlty( _p ) \ +{ \ + _mbg_swab16( &(_p)->fixed_clk_variance ); \ +} + + + +/** + * @brief Additional parameters for PTP Power Profile + */ +typedef struct +{ + uint32_t gm_time_incaccuracy; ///< Pre-defined GM time inaccuracy from master [ns] + uint32_t network_time_incaccuracy; ///< Configurable network inaccuracy from master [ns] + + uint8_t grandmaster_id; ///< [::PTP_POWER_PROFILE_GM_ID_MIN..::PTP_POWER_PROFILE_GM_ID_MAX] + uint8_t reserved[7]; ///< reserved, currently always 0 + +} MBG_PTP_NG_C37238_2011_SETTINGS; + + +#define _mbg_swab_ptp_ng_c37238_2011_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->gm_time_incaccuracy ); \ + _mbg_swab32( &(_p)->network_time_incaccuracy ); \ +} + + +typedef struct +{ + uint32_t total_inaccuracy; ///< Total inaccuracy in [ns] + uint16_t grandmaster_id; ///< Full 16 Bit Grandmaster ID + uint16_t reserved_1; ///< reserved, currently always 0 + +} MBG_PTP_NG_C37238_2017_SETTINGS; + + +#define _mbg_swab_ptp_ng_c37238_2017_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->total_inaccuracy ); \ + _mbg_swab16( &(_p)->grandmaster_id ); \ +} + + +/** + * @brief SMPTE System Frame Rates according to SMPTE ST 2059-2 + * + */ +enum MBG_PTP_NG_SMPTE_FRAME_RATES +{ + MBG_PTP_NG_SMPTE_FRAME_RATE_23_98HZ, + MBG_PTP_NG_SMPTE_FRAME_RATE_24HZ, + MBG_PTP_NG_SMPTE_FRAME_RATE_25HZ, + MBG_PTP_NG_SMPTE_FRAME_RATE_29_97HZ, + MBG_PTP_NG_SMPTE_FRAME_RATE_50HZ, + MBG_PTP_NG_SMPTE_FRAME_RATE_59_94HZ, + N_MBG_PTP_NG_SMPTE_FRAME_RATES +}; + + +#define MBG_PTP_NG_SMPTE_FRAME_RATE_STR \ +{ \ + "23.98 Hz", \ + "24 Hz", \ + "25 Hz", \ + "29.97 Hz", \ + "50 Hz", \ + "59.94 Hz" \ +} + + +#define MBG_PTP_NG_SMPTE_FRAME_RATE_NUM \ +{ \ + 24000, \ + 24000, \ + 25000, \ + 30000, \ + 50000, \ + 60000 \ +} + + +#define MBG_PTP_NG_SMPTE_FRAME_RATE_DENUM \ +{ \ + 1001, \ + 1000, \ + 1000, \ + 1001, \ + 1000, \ + 1001 \ +} + + +/** + * @brief SMPTE Time Address Flags according to SMPTE ST 2059-2 + * + */ +enum MBG_PTP_NG_SMPTE_TIME_ADDR_FLAGS +{ + MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_DROP_FRAME, + MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_COLOR_FRAME, + N_MBG_PTP_NG_SMPTE_TIME_ADDR_FLAGS +}; + + +enum MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_MASKS +{ + MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_DROP_FRAME_MSK = ( 1UL << MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_DROP_FRAME ), ///< See ::MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_DROP_FRAME + MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_COLOR_FRAME_MSK = ( 1UL << MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_COLOR_FRAME ) ///< See ::MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_COLOR_FRAME +}; + + +/** + * @brief SMPTE jam modes. + * + * Used with ::MBG_PTP_NG_SMPTE_20592_SETTINGS::next_jam_mode, which determines + * how to interpret the value in ::MBG_PTP_NG_SMPTE_20592_SETTINGS::jam_event. + */ +enum MBG_PTP_NG_SMPTE_JAM_MODES +{ + /// @brief Jam mode is disabled. + MBG_PTP_NG_SMPTE_JAM_MODE_DISABLED, + + /// @brief Daily jam at the specified seconds since midnight. + /// + /// The variable ::MBG_PTP_NG_SMPTE_20592_SETTINGS::jam_event + /// contains the number of seconds since midnight when the + /// jam is to occur. + /// The code in ::MBG_PTP_NG_SMPTE_20592_SETTINGS::event_timescale + /// indicates which time scale 'midnight' refers to. The default + /// timescale should be ::MBG_PTP_NG_SMPTE_EVT_TIMESCALE_LOCAL_TIME. + /// See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALES. + MBG_PTP_NG_SMPTE_JAM_MODE_DAILY, + + /// @brief Next jam at the specified next absolute time. + /// + /// The variable ::MBG_PTP_NG_SMPTE_20592_SETTINGS::jam_event + /// contains the absolute time in POSIX time_t-like format when + /// the jam is to occur. + /// The code in ::MBG_PTP_NG_SMPTE_20592_SETTINGS::event_timescale + /// indicates the time scale associated with the time stamp. + /// See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALES. + MBG_PTP_NG_SMPTE_JAM_MODE_SINGLE, + + /// @brief Next jam occurs when the local time is stepped. + /// + /// The variable ::MBG_PTP_NG_SMPTE_20592_SETTINGS::jam_event + /// contains the absolute time in POSIX time_t-like format when + /// the jam is to occur, and this time should match + /// ::MBG_PTP_NG_SMPTE_20592_STATUS::time_of_next_jump. + MBG_PTP_NG_SMPTE_JAM_MODE_NEXT_DISCONT_ON_LOCAL_TIME_CHANGE, + + N_MBG_PTP_NG_SMPTE_JAM_MODES ///< The number of known PTP SMPTE jam modes. +}; + + +#define MBG_PTP_NG_SMPTE_JAM_MODE_STRS \ +{ \ + "Disabled", \ + "Daily Jam Event", \ + "Single Jam Event", \ + "Next discontinuity in Local Time" \ +} + + +/** + * @brief Additional parameters for SMPTE ST 2059-2 profile + * + * This stucture holds the configuration for PTP NG SMPTE profile. + * The status can not be represented by this structure, because it does not contain jam and jump times + */ +typedef struct +{ + uint32_t default_frame_rate_num; ///< See ::MBG_PTP_NG_SMPTE_FRAME_RATES and ::MBG_PTP_NG_SMPTE_FRAME_RATE_NUM. + uint32_t default_frame_rate_denum; ///< See ::MBG_PTP_NG_SMPTE_FRAME_RATES and ::MBG_PTP_NG_SMPTE_FRAME_RATE_DENUM. + + uint32_t time_address_flags; ///< See ::MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_MASKS. + uint16_t reserved; ///< Reserved, currently always 0. + uint8_t next_jam_mode; ///< See ::MBG_PTP_NG_SMPTE_JAM_MODES. + uint8_t event_timescale; ///< See ::MBG_PTP_NG_SMPTE_EVT_TIMESCALES. + + /// @brief Jam event time configuration. + /// + /// Depending on the values of #next_jam_mode (see ::MBG_PTP_NG_SMPTE_JAM_MODES) + /// and #event_timescale (see ::MBG_PTP_NG_SMPTE_EVT_TIMESCALES), + /// this field can contain an absolute time for a single jam event, + /// or a number of seconds since midnight indicating when the + /// daily jam is to occur. + /// + /// The jam time sent in the SMPTE TLVs has to be calculated + /// according to these settings. + int64_t jam_event; + +} MBG_PTP_NG_SMPTE_20592_SETTINGS; + + +#define _mbg_swab_ptp_ng_smpte_20592_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->default_frame_rate_num ); \ + _mbg_swab32( &(_p)->default_frame_rate_denum ); \ + _mbg_swab32( &(_p)->time_address_flags ); \ + _mbg_swab64( &(_p)->jam_event ); \ +} + + + +enum MBG_PTP_NG_82751_FLAGS +{ + MBG_PTP_NG_82751_FLAG_USE_ALT_MC_ADDRESS, ///< Use Alternative (non-forwardable) multicast address + MBG_PTP_NG_82751_FLAG_PORT_NOT_SLAVE, ///< PTP Instance cannot become a SLAVE + N_MBG_PTP_NG_82751_FLAGS +}; + + +enum MBG_PTP_NG_82751_FLAG_MSKS +{ + MBG_PTP_NG_82751_FLAG_USE_ALT_MC_ADDRESS_MSK = (1UL << MBG_PTP_NG_82751_FLAG_USE_ALT_MC_ADDRESS), ///< See ::MBG_PTP_NG_82751_FLAG_USE_ALT_MC_ADDRESS + MBG_PTP_NG_82751_FLAG_PORT_NOT_SLAVE_MSK = (1UL << MBG_PTP_NG_82751_FLAG_PORT_NOT_SLAVE) ///< See ::MBG_PTP_NG_82751_FLAG_PORT_NOT_SLAVE +}; + + +/** + * @brief Additional parameters for Telecom8275.1 profile + */ +typedef struct +{ + uint8_t port_local_priority; ///< TODO: Please add describing comment + uint8_t default_local_priority; ///< TODO: Please add describing comment + uint16_t reserved; ///< reserved, currently always 0 + + uint32_t flags; ///< Bitmask used with ::MBG_PTP_NG_82751_FLAG_MSKS + +} MBG_PTP_NG_TELECOM_G82751_SETTINGS; + + +#define _mbg_swab_ptp_ng_telecom_g82751_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->flags ); \ +} + + +/** + * @brief Large Scaled nanoseconds structure (96 bit integer). + * This format is only used by 802.1as. + */ +typedef struct +{ + int64_t ns_l; + int32_t ns_h; + int32_t reserved; // used for alignment +} MBG_PTP_NG_LARGE_SCALED_NS; + + +enum MBG_PTP_NG_8021AS_FLAGS +{ + MBG_PTP_NG_8021AS_FLAG_AS_CAPABLE, ///< this time-aware system and the time-aware system at the other end of the link attached to this port can interoperate with each other via IEEE 802.1AS + N_MBG_PTP_NG_8021AS_FLAGS +}; + + +enum MBG_PTP_NG_8021AS_FLAG_MSKS +{ + MBG_PTP_NG_8021AS_FLAG_AS_CAPABLE_MSK = (1UL << MBG_PTP_NG_8021AS_FLAG_AS_CAPABLE), ///< See ::MBG_PTP_NG_8021AS_FLAG_AS_CAPABLE +}; + + +/** + * @brief Additional parameters for IEEE 802.1AS profile + * TODO: Shall this really be settings or rather status? + */ +typedef struct +{ + PTP_TIME_INTERVAL port_neighbor_prop_delay_thresh; ///< Propagation time threshold, above which a port is not considered capable of participating in the IEEE 802.1AS protocol. + int64_t port_last_gm_phase_change; ///< Current phase difference (offset) to the current GM (in slave and passive state) on the current port. + ///< Will be used as @a last_gm_phase_change after this clock becomes GM. + MBG_PTP_NG_LARGE_SCALED_NS last_gm_phase_change; ///< Global last phase change of the clockSource/GM. Is changed whenever the time base changes. + PTP_NG_PORT_IDENTITY port_as_neighbor; ///< PortId of the current @a asCapable neighbor, only if @a asCapable is true. + int32_t port_last_gm_freq_change; ///< Current frequency rate ratio to the current GM (in slave and passive state). + ///< Will be used as lastGmFreqChange after this clock becomes GM. + int32_t cumulative_scaled_rate_offset; ///< Ratio of the frequency of the clockSource/GM to the frequency of the local clock (rateRatio * 1.0) * (2^41). + int32_t last_gm_freq_change; ///< (rateRatio * 2^41) Fractional frequency offset of the current clockSource/GM to the last clockSource/GM. + ///< Changes whenever the time base changes. + int32_t port_neighbor_rate_ratio; ///< Current rate ratio to the port neighbor in scaled ratio (rateRatio * 2^41). + uint16_t gm_time_base_indicator; ///< Used to identify the time base. If this clock acts as GM, it has to be managed + ///< via shared mem., equivalent to clockSourceTimeBaseIndicator. + uint16_t reserved_1; + uint32_t flags; ///< See ::MBG_PTP_NG_8021AS_FLAGS. + uint32_t reserved_2[2]; + +} MBG_PTP_NG_IEEE_8021AS_SETTINGS; + + + +typedef union +{ + char u[128]; + + MBG_PTP_NG_C37238_2011_SETTINGS c37238_2011; ///< Power Profile C37.238-2011 + MBG_PTP_NG_C37238_2017_SETTINGS c37238_2017; ///< Power Profile C37.238-2017 + MBG_PTP_NG_SMPTE_20592_SETTINGS smpte_20592; ///< SMPTE Profile ST 2059-2 + MBG_PTP_NG_TELECOM_G82751_SETTINGS g82751; ///< Telecom Profile ITU-T. G.8275.1 + MBG_PTP_NG_IEEE_8021AS_SETTINGS ieee8021as; ///< IEEE 802.1AS Profile + +} MBG_PTP_NG_PROFILE_SETTINGS_U; + + +#define _mbg_swab_ptp_ng_profile_settings_u( _profile, _p ) \ +do \ +{ \ + switch ( (_profile) ) \ + { \ + case PTP_PRESETS_POWER: \ + _mbg_swab_ptp_ng_c37238_2011_settings( &(_p)->c37238_2011 ); \ + break; \ + \ + case PTP_PRESETS_C37238_2017: \ + _mbg_swab_ptp_ng_c37238_2017_settings( &(_p)->c37238_2017 ); \ + break; \ + \ + case PTP_PRESETS_SMPTE: \ + _mbg_swab_ptp_ng_smpte_20592_settings( &(_p)->smpte_20592 ); \ + break; \ + \ + case PTP_PRESETS_TELECOM_PHASE: \ + _mbg_swab_ptp_ng_telecom_g82751_settings( &(_p)->g82751 ); \ + break; \ + \ + default: break; \ + } \ +} while ( 0 ) + + + +/** + * @brief A name of a local time zone which can be longer than used in::TZDL. + */ +typedef char MBG_PTP_NG_ATOI_TZ_NAME[12]; + + + +/** + * @brief A structure used to configure a PTP instance. + */ +typedef struct mbg_ptp_ng_instc_settings_s +{ + uint32_t tstamper_idx; ///< Index of the timestamper that is active for this config running on interface @a #intf_label. + uint16_t assigned_port_id; ///< Port ID for this instance. Read-only for user interfaces, must be assigned by the managing process. + uint16_t reserved_1; ///< Reserved, currently always 0. + + PTP_INTF intf_label; ///< Interface name (IPv4/L2) or IPv6 address of logical/VLAN interface linked to this config. + + PTP_PORT_IDENTITY custom_port_id; ///< Overwrite port ID of this PTP port with global clock ID and suitable port ID. + ///< Only used if ::MBG_PTP_NG_FLAG_CUSTOM_PORT_ID_MSK is set in @a #flags. + uint16_t reserved_2; ///< Reserved, currently always 0. + uint8_t log_severity; ///< Sets the log level of the PTP Stack. Range from 0 (errors only) to 4. + uint8_t dsf; ///< Differentiated service field (IPv4) for PTP event messages -> 6 bit (MSB) DSCP, 2 bit ECN. + uint8_t ipv6_multicast_scope; ///< One of the ::IPV6_MULTICAST_SCOPES used for PTP IPv6 multicast. + uint8_t role; ///< One of the supported PTP roles, see ::PTP_ROLES. + + uint8_t profile; ///< Selected PTP preset or profile, see ::PTP_PRESETS. + uint8_t domain_number; ///< The PTP clock domain number, 0..255. + uint8_t reserved_4[6]; ///< Reserved, currently always 0. + + uint8_t delay_mech; ///< See ::PTP_DELAY_MECHS. + uint8_t protocol; ///< See ::PTP_NW_PROTS. + uint8_t priority_1; ///< Default DS priority 1. + uint8_t priority_2; ///< Default DS priority 2. + MBG_PTP_NG_INTV_CFG intvs; ///< Interval settings for this PTP instance. + + uint8_t min_gm_clk_class; ///< Minimum acceptable GM clock class for clock adjustment in slave mode, 0 means accept all. + uint8_t min_gm_clk_accuracy; ///< Minimum acceptable GM clock accuracy for clock adjustment in slave mode, 0 means accept all. + uint16_t min_gm_clk_variance; ///< Minimum acceptable GM clock variance for clock adjustment in slave mode, 0 means accept all. + uint8_t multicast_ttl; ///< Sets the multicast TTL value in IPv4 or multicast hop count in IPv6. 1..255, default 5. + uint8_t unicast_ttl; ///< Sets the unicast TTL value in IPv4 or unicast hop count in IPv6. 1..255, default 128. + uint8_t ann_rcpt_timeout; ///< Announce msg. receipt timeout, see ::PTP_ANN_RCPT_TIMEOUT_LIMITS. + uint8_t v1_clock_stratum; ///< Clock stratum parameter for PTPv1 stack + + char v1_subdomain_name[PTP_SUBDOMAIN_NAME_LENGTH]; ///< Subdomain string for PTPv1 stack. + + uint32_t upper_bound; ///< Sync. state set to uncalibrated if above this limit [ns], default 0 (ignored). + uint32_t lower_bound; ///< Sync. state set to slave if below this limit [ns], default 0 (ignored). + + int32_t fast_locking_boundary; ///< Determines if fast locking is used after a master was selected or changed [ns], in slave mode only. + int32_t delay_asymmetry; ///< Used to compensate asymmetries [ns], default 0. + + MBG_PTP_NG_FIXED_CLK_QLTY fixed_quality; ///< Fixed Clock Quality as manual override used in BMCA. + ///< Only used if ::MBG_PTP_NG_FLAG_FIXED_QUALITY_MSK is set in @a #flags. + MBG_PTP_NG_SERVO_SETTINGS servo_settings; ///< PTP Clock Servo Settings used in slave mode to adjust TSU time. + MBG_PTP_NG_PROFILE_SETTINGS_U profile_settings; ///< Union that includes all profile specific parameters. + ///< The profile type to be used is determined by the @a #profile parameter. + + uint32_t atois; ///< Activated ATOI TLVs, see ::MBG_PTP_NG_GLB_INFO::max_atois and ::MBG_PTP_NG_ATOI_MASKS + uint32_t flags; ///< See ::MBG_PTP_NG_FLAG_MASKS. + + TZDL custom_atoi; ///< Alternate Time Offset Indicator, used to derive local time + ///< from the TAI time of the grandmaster. + MBG_PTP_NG_ATOI_TZ_NAME names[2]; ///< Local time zone names for DST off and DST on. + ///< Can be longer than the names in ::TZDL @a #custom_atoi. + + uint32_t v1_flags; ///< See ::MBG_PTP_NG_V1_FLAG_MASKS. + uint32_t reserved_5[3]; ///< Reserved, currently always 0. + + char alias[32]; ///< A configurable, descriptive name for the PTP instance, just informational. + +} MBG_PTP_NG_INSTC_SETTINGS; + + +#define _mbg_swab_ptp_ng_instc_settings( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->tstamper_idx ); \ + _mbg_swab16( &(_p)->assigned_port_id ); \ + _mbg_swab_ptp_port_identity( &(_p)->custom_port_id ); \ + _mbg_swab_ptp_ng_intv_cfg( &(_p)->intvs ); \ + _mbg_swab16( &(_p)->min_gm_clk_variance ); \ + _mbg_swab32( &(_p)->upper_bound ); \ + _mbg_swab32( &(_p)->lower_bound ); \ + _mbg_swab32( &(_p)->fast_locking_boundary ); \ + _mbg_swab32( &(_p)->delay_asymmetry ); \ + _mbg_swab_ptp_ng_fixed_clk_qlty( &(_p)->fixed_quality ); \ + _mbg_swab_ptp_ng_servo_settings( &(_p)->servo_settings ); \ + _mbg_swab_ptp_ng_profile_settings_u( (_p)->profile, &(_p)->profile_settings ); \ + _mbg_swab32( &(_p)->atois ); \ + _mbg_swab32( &(_p)->flags ); \ + _mbg_swab_tzdl( &(_p)->custom_atoi ); \ + _mbg_swab32( &(_p)->v1_flags ); \ +} \ +while(0) + + + +/** + * @brief ::TODO + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< Padding for 8-byte alignment, some settings contain int64_t. + + MBG_PTP_NG_INSTC_SETTINGS settings; + +} MBG_PTP_NG_INSTC_SETTINGS_IDX; + + +#define _mbg_swab_ptp_ng_instc_settings_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_instc_settings( &(_p)->settings ); \ +} + + +/** + * @brief A structure to used to query the current configuration of a PTP Instance + */ +typedef struct mbg_ptp_ng_instc_info_s +{ + MBG_PTP_NG_INSTC_SETTINGS settings; ///< The current configuration. + + uint32_t reserved[4]; ///< Reserved, currently always 0 + +} MBG_PTP_NG_INSTC_INFO; + + +#define _mbg_swab_ptp_ng_instc_info( _p ) \ +{ \ + _mbg_swab_ptp_ng_instc_settings( &(_p)->settings ); \ +} + + +/** + * @brief + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< Padding for 8-byte alignment, some settings contain int64_t. + + MBG_PTP_NG_INSTC_INFO info; + +} MBG_PTP_NG_INSTC_INFO_IDX; + + +#define _mbg_swab_ptp_ng_instc_info_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_instc_info( &(_p)->info ); \ +} + +typedef struct +{ + int64_t min; + int64_t mean; + int64_t median; + int64_t stdDev; +} MBG_PTP_NG_PKT_STATS; + + +#define _mbg_swab_ptp_ng_pkt_stats( _p ) \ +{ \ + _mbg_swab64( &(_p)->min ); \ + _mbg_swab64( &(_p)->mean ); \ + _mbg_swab64( &(_p)->median ); \ + _mbg_swab64( &(_p)->stdDev ); \ +} + + +#define MAX_MBG_PTP_NG_ATOI_STATUS 3 + + +typedef struct +{ + uint8_t key; ///< An index number, see ::MBG_PTP_NG_ATOIS. + uint8_t reserved_1; ///< Reserved, currently always 0. + PTP_PKT_TSTAMP_SECS time_of_next_jump; ///< Time when the next discontinuity will occur, in seconds. + + PTP_TLV_TIME_OFFS current_offset; ///< Offset of the current time scale, in seconds. + PTP_TLV_TIME_OFFS jump_seconds; ///< Size of next discontinuity, in seconds. + + MBG_PTP_NG_ATOI_TZ_NAME display_name; ///< Name of the ATOI timezone. + uint8_t flags; ///< Reserved, currently always 0. + uint8_t reserved_2[3]; ///< Reserved, currently always 0. + +} MBG_PTP_NG_ATOI_STATUS; + + +#define _mbg_swab_ptp_ng_atoi_status( _p ) \ +{ \ + _mbg_swab32( &(_p)->current_offset ); \ + _mbg_swab32( &(_p)->jump_seconds ); \ +} + + +enum MBG_PTP_NG_SMPTE_MASTER_LOCKING_STATUS +{ + MBG_PTP_NG_SMPTE_MASTER_NOT_IN_USE, + MBG_PTP_NG_SMPTE_MASTER_FREE_RUN, + MBG_PTP_NG_SMPTE_MASTER_COLD_LOCKING, + MBG_PTP_NG_SMPTE_MASTER_WARM_LOCKING, + MBG_PTP_NG_SMPTE_MASTER_LOCKED, + N_MBG_PTP_NG_SMPTE_MASTER_LOCKING_STATUS +}; + + +#define MBG_PTP_NG_SMPTE_MASTER_LOCKING_STATUS_STRS \ +{ \ + "Not in use", \ + "Free Run", \ + "Cold Locking", \ + "Warm Locking", \ + "Locked" \ +} + + +typedef struct +{ + uint32_t system_frame_rate_num; ///< See ::MBG_PTP_NG_SMPTE_FRAME_RATES and ::MBG_PTP_NG_SMPTE_FRAME_RATE_NUM. + uint32_t system_frame_rate_denum; ///< See ::MBG_PTP_NG_SMPTE_FRAME_RATES and ::MBG_PTP_NG_SMPTE_FRAME_RATE_DENUM. + + uint32_t time_address_flags; ///< See ::MBG_PTP_NG_SMPTE_TIME_ADDR_FLAG_MASKS. + uint8_t master_locking_status; ///< See ::MBG_PTP_NG_SMPTE_MASTER_LOCKING_STATUS. + PTP_TLV_DST_FLAGS daylight_saving; ///< Daylight saving flags, see ::PTP_TLV_DST_FLAG_MSKS. + PTP_TLV_LS_FLAGS leap_second_jump; ///< Leap second Flags, see ::PTP_TLV_LS_FLAG_MSKS. + uint8_t reserved_1; ///< Reserved, currently always 0 + + /// @brief Offset in seconds of Local Time from grandmaster PTP time. + /// + /// For example, if Local Time is Eastern Standard Time (North America) %UTC-5 and the + /// number of leap seconds is 37, the value will be -18037 s. + PTP_TLV_TIME_OFFS current_local_offset; + + /// @brief The size of the next discontinuity in local time, in seconds. + /// + /// A value of 0 indicates that no discontinuity is expected. A positive value + /// indicates that the discontinuity will increase the @a #current_local_offset. + PTP_TLV_TIME_OFFS jump_seconds; + + /// @brief Time at which the next discontinuity of the @a #current_local_offset will occur. + /// + /// Refers to the second portion of the grandmaster PTP time. + /// The discontinuity occurs at the start of the second indicated. + /// If no discontinuity has been scheduled, the value is 0. + PTP_PKT_TSTAMP_SECS time_of_next_jump; + + /// @brief Time at which the next daily jam is to occur. + /// + /// Refers to the second portion of the grandmaster PTP time. + /// If no daily jam has been scheduled, the value is 0. + PTP_PKT_TSTAMP_SECS time_of_next_jam; + + /// @brief Time at which the previous daily jam occurred. + /// + /// Refers to the second portion of the grandmaster PTP time. + /// If the time of the previous jam is unknown, the value is 0. + PTP_PKT_TSTAMP_SECS time_of_previous_jam; + + /// @brief Reserved, currently always 0. + uint16_t reserved_2; + + /// @brief Local time offset at the previous daily jam. + /// + /// The value of @a #current_local_offset at the previous daily jam time. + /// If a discontinuity of local time occurs at the jam time, this parameter + /// reflects the offset after the discontinuity. + PTP_TLV_TIME_OFFS previous_jam_local_offset; + +} MBG_PTP_NG_SMPTE_20592_STATUS; + + +#define _mbg_swab_ptp_ng_smpte_20592_status( _p ) \ +{ \ + _mbg_swab32( &(_p)->system_frame_rate_num ); \ + _mbg_swab32( &(_p)->system_frame_rate_denum ); \ + _mbg_swab32( &(_p)->time_address_flags ); \ + _mbg_swab32( &(_p)->current_local_offset ); \ + _mbg_swab32( &(_p)->jump_seconds ); \ + _mbg_swab32( &(_p)->previous_jam_local_offset ); \ +} + + + +/** + * @brief Daylight saving flags used in PTP TLVs. + * + * Used with ::PTP_TLV_DST_FLAGS. + */ +enum PTP_TLV_DST_FLAG_MSKS +{ + PTP_TLV_DST_FLAG_DST = 0x01, ///< Bit 0: DST currently in effect. + PTP_TLV_DST_FLAG_DST_AT_NEXT_JMP = 0x02, ///< Bit 1: DST in effect at next discontinuity. + PTP_TLV_DST_FLAG_DST_AT_PRV_JAM = 0x04 ///< Bit 2: DST in effect at previous jam time. + // Other bits are reserved. +}; + + + +/** + * @brief Leap second flags used in PTP TLVs. + * + * Used with ::PTP_TLV_LS_FLAGS. + */ +enum PTP_TLV_LS_FLAG_MSKS +{ + PTP_TLV_LS_FLAG_LEAP_SEC = 0x01 ///< Bit 0: Next discontinuity due to leap second. + // Other bits are reserved. +}; + + + +typedef union +{ + char u[128]; + + MBG_PTP_NG_C37238_2011_SETTINGS c37238_2011; ///< Power Profile C37.238-2011 + MBG_PTP_NG_C37238_2017_SETTINGS c37238_2017; ///< Power Profile C37.238-2017 + MBG_PTP_NG_SMPTE_20592_STATUS smpte_20592; ///< SMPTE Profile ST 2059-2 + MBG_PTP_NG_TELECOM_G82751_SETTINGS g82751; ///< Telecom Profile ITU-T. G.8275.1 + MBG_PTP_NG_IEEE_8021AS_SETTINGS ieee8021as; ///< IEEE 802.1AS Profile + +} MBG_PTP_NG_PROFILE_STATUS_U; + + +#define _mbg_swab_ptp_ng_profile_status_u( _profile, _p ) \ +do \ +{ \ + switch ( (_profile) ) \ + { \ + case PTP_PRESETS_POWER: \ + _mbg_swab_ptp_ng_c37238_2011_settings( &(_p)->c37238_2011 ); \ + break; \ + \ + case PTP_PRESETS_C37238_2017: \ + _mbg_swab_ptp_ng_c37238_2017_settings( &(_p)->c37238_2017 ); \ + break; \ + \ + case PTP_PRESETS_SMPTE: \ + _mbg_swab_ptp_ng_smpte_20592_status( &(_p)->smpte_20592 ); \ + break; \ + \ + case PTP_PRESETS_TELECOM_PHASE: \ + _mbg_swab_ptp_ng_telecom_g82751_settings( &(_p)->g82751 ); \ + break; \ + \ + default: break; \ + } \ +} while ( 0 ) + + +enum MBG_PTP_NG_INSTC_STATUS_FLAGS +{ + MBG_PTP_NG_INSTC_STATUS_FLAG_STACK_NOT_RUNNING, ///< Indicates, that the PTP stack for this instance is not running + MBG_PTP_NG_INSTC_STATUS_FLAG_M2S_DELAY_VALID, + MBG_PTP_NG_INSTC_STATUS_FLAG_S2M_DELAY_VALID, + + N_MBG_PTP_NG_INSTC_STATUS_FLAGS +}; + + + +enum MBG_PTP_NG_INSTC_STATUS_FLAG_MASKS +{ + MBG_PTP_NG_INSTC_STATUS_FLAG_STACK_NOT_RUNNING_MSK = (1UL << MBG_PTP_NG_INSTC_STATUS_FLAG_STACK_NOT_RUNNING), ///< See ::MBG_PTP_NG_INSTC_STATUS_FLAG_STACK_NOT_RUNNING + MBG_PTP_NG_INSTC_STATUS_FLAG_M2S_DELAY_VALID_MSK = (1UL << MBG_PTP_NG_INSTC_STATUS_FLAG_M2S_DELAY_VALID), ///< See ::MBG_PTP_NG_INSTC_STATUS_FLAG_M2S_DELAY_VALID + MBG_PTP_NG_INSTC_STATUS_FLAG_S2M_DELAY_VALID_MSK = (1UL << MBG_PTP_NG_INSTC_STATUS_FLAG_S2M_DELAY_VALID), ///< See ::MBG_PTP_NG_INSTC_STATUS_FLAG_S2M_DELAY_VALID +}; + + +/** + * @brief A structure used to read the status of a PTP instance + */ +typedef struct mbg_ptp_ng_instc_status_s +{ + MBG_PTP_NG_PKT_STATS m2s_delay; ///< current statistics of the Master to Slave delay + MBG_PTP_NG_PKT_STATS s2m_delay; ///< current statistics of the Slave to Master delay + uint16_t num_uc_slaves; ///< current number of unicast slaves in unicast master mode + uint8_t utilization; ///< current resource utilization (msg/sec) in % + uint8_t profile; ///< Selected PTP preset or profile, see ::PTP_PRESETS. + uint8_t num_atois; ///< number of valid atois status, see #atoi_status + uint8_t protocol; ///< current network protocol, see ::PTP_NW_PROTS + uint8_t reserved_1[2]; ///< reserved, currently always 0 + MBG_PTP_V2_NG_DEFAULT_DATASET default_ds; ///< the default dataset of the PTP instance + MBG_PTP_V2_NG_CURRENT_DATASET current_ds; ///< the current dataset of the PTP instance + MBG_PTP_V2_NG_PARENT_DATASET parent_ds; ///< the parent dataset of the PTP instance + MBG_PTP_V2_NG_TIME_PROPERTIES_DATASET time_properties_ds; ///< the time properties dataset of the PTP instance + MBG_PTP_V2_NG_PORT_DATASET port_ds; ///< the port dataset of the PTP instance + MBG_PTP_NG_PROFILE_STATUS_U profile_status; ///< Union that includes all profile specific parameters; the profile is selected with the #profile parameter. + MBG_PTP_NG_ATOI_STATUS atoi_status[MAX_MBG_PTP_NG_ATOI_STATUS]; ///< current status of available ATOIs + uint32_t flags; ///< See ::MBG_PTP_NG_INSTC_STATUS_FLAG_MASKS + uint32_t reserved_2[3]; ///< reserved, currently always 0 + +} MBG_PTP_NG_INSTC_STATUS; + + +#define _mbg_swab_ptp_ng_instc_status( _p ) \ +{ \ + unsigned i; \ + _mbg_swab_ptp_ng_pkt_stats( &(_p)->m2s_delay ); \ + _mbg_swab_ptp_ng_pkt_stats( &(_p)->s2m_delay ); \ + _mbg_swab16( &(_p)->num_uc_slaves ); \ + _mbg_swab_ptp_v2_ng_default_dataset( &(_p)->default_ds ); \ + _mbg_swab_ptp_v2_ng_current_dataset( &(_p)->current_ds ); \ + _mbg_swab_ptp_v2_ng_parent_dataset( &(_p)->parent_ds ); \ + _mbg_swab_ptp_v2_ng_time_properties_dataset( &(_p)->time_properties_ds ); \ + _mbg_swab_ptp_v2_ng_port_dataset( &(_p)->port_ds ); \ + _mbg_swab_ptp_ng_profile_status_u( (_p)->profile, &(_p)->profile_status ); \ + for ( i = 0; i < MAX_MBG_PTP_NG_ATOI_STATUS; ++i) \ + _mbg_swab_ptp_ng_atoi_status( &(_p)->atoi_status[i] ); \ + _mbg_swab32( &(_p)->flags ); \ +} + + +/** + * @brief + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + + MBG_PTP_NG_INSTC_STATUS status; + +} MBG_PTP_NG_INSTC_STATUS_IDX; + + +#define _mbg_swab_ptp_ng_instc_status_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_instc_status( &(_p)->status ); \ +} + + +typedef struct mbg_ptp_ng_instc_pkt_cntrs_s +{ + uint32_t rx_all; ///< overall Rx packet counter + uint32_t rx_announce; ///< Accepted Announce message Rx counter + uint32_t rx_sync; ///< Accepted Sync message Rx counter + uint32_t rx_follow_up; ///< Accepted Follow-up message Rx counter + uint32_t rx_delay_req; ///< Accepted Delay request message Rx counter + uint32_t rx_delay_resp; ///< Accepted Delay response message Rx counter + uint32_t rx_pdelay_req; ///< Accepted PDelay Request message Rx counter + uint32_t rx_pdelay_resp; ///< Accepted PDelay Response message Rx counter + uint32_t rx_pdelay_follow_up; ///< Accepted PDelay Follow-Up message Rx counter + uint32_t rx_signalling; ///< Accepted Signalling message Rx counter + uint32_t rx_management; ///< Accepted Management message Rx counter + uint32_t rx_management_err; ///< Management error counter (rx) + + uint32_t tx_all; ///< overall Tx packet counter + uint32_t tx_announce; ///< Announce message Tx counter + uint32_t tx_sync; ///< Sync message Tx counter + uint32_t tx_follow_up; ///< Follow-up message Tx counter + uint32_t tx_delay_req; ///< Delay request message Tx counter + uint32_t tx_delay_resp; ///< Delay response message Tx counter + uint32_t tx_pdelay_req; ///< PDelay Request message Tx counter + uint32_t tx_pdelay_resp; ///< PDelay Response message Tx counter + uint32_t tx_pdelay_follow_up; ///< PDelay Follow-Up message Tx counter + uint32_t tx_signalling; ///< Signalling message Tx counter + uint32_t tx_management; ///< Management message Tx counter + uint32_t reserved_1; ///< Reserved, currently always 0 + + uint32_t ann_receipt_timeout; ///< Announce receipt timeout counter + uint32_t reserved_2; ///< Reserved, currently always 0 + + // The following counters (msg/second counter) are represented in + // fixed point format. The lower 8 bit represent digits after the + // radix (comma), the higher 24 bits digits before it. That's a + // scaling factor of 1/(2^8). To display the number in decimal + // notation use: + // printf("%d.%d", rxPerSec >> 8, ((rxPerSec & 0xFF) * 100) >> 8) + uint32_t rx_all_per_sec; ///< overall Rx msg/second + uint32_t rx_announce_per_sec; ///< Accepted Announce msg Rx msg/second + uint32_t rx_sync_per_sec; ///< Accepted Sync msg Rx msg/second + uint32_t rx_follow_up_per_sec; ///< Accepted Follow-up msg Rx msg/second + uint32_t rx_delay_req_per_sec; ///< Accepted Delay request msg Rx msg/second + uint32_t rx_delay_resp_per_sec; ///< Accepted Delay response msg Rx msg/second + uint32_t rx_pdelay_req_per_sec; ///< Accepted PDelay Request msg Rx msg/second + uint32_t rx_pdelay_resp_per_sec; ///< Accepted PDelay Response msg Rx msg/second + uint32_t rx_pdelay_follow_up_per_sec; ///< Accepted PDelay Follow-Up msg Rx msg/sec. + uint32_t rx_signalling_per_sec; ///< Accepted Signalling msg Rx msg/second + uint32_t rx_management_per_sec; ///< Accepted Management msg Rx msg/second + uint32_t reserved_3; ///< Reserved, currently always 0 + + uint32_t tx_all_per_sec; ///< overall Tx msg/second + uint32_t tx_announce_per_sec; ///< Announce msg Tx msg/second + uint32_t tx_sync_per_sec; ///< Sync msg Tx msg/second + uint32_t tx_follow_up_per_sec; ///< Follow-up msg Tx msg/second + uint32_t tx_delay_req_per_sec; ///< Delay request msg Tx msg/second + uint32_t tx_delay_resp_per_sec; ///< Delay response msg Tx msg/second + uint32_t tx_pdelay_req_per_sec; ///< PDelay Request msg Tx msg/second + uint32_t tx_pdelay_resp_per_sec; ///< PDelay Response msg Tx msg/second + uint32_t tx_pdelay_follow_up_per_sec; ///< PDelay Follow-Up msg Tx msg/second + uint32_t tx_signalling_per_sec; ///< Signalling msg Tx msg/second + uint32_t tx_management_per_sec; ///< Management msg Tx msg/second + uint32_t reserved_4; ///< Reserved, currently always 0 + +} MBG_PTP_NG_INSTC_PKT_CNTRS; + + +#define _mbg_swab_ptp_ng_instc_pkt_cntrs( _p ) \ +{ \ + _mbg_swab32( &(_p)->rx_all ); \ + _mbg_swab32( &(_p)->rx_announce ); \ + _mbg_swab32( &(_p)->rx_sync ); \ + _mbg_swab32( &(_p)->rx_follow_up ); \ + _mbg_swab32( &(_p)->rx_delay_req ); \ + _mbg_swab32( &(_p)->rx_delay_resp ); \ + _mbg_swab32( &(_p)->rx_pdelay_req ); \ + _mbg_swab32( &(_p)->rx_pdelay_resp ); \ + _mbg_swab32( &(_p)->rx_pdelay_follow_up ); \ + _mbg_swab32( &(_p)->rx_signalling ); \ + _mbg_swab32( &(_p)->rx_management ); \ + _mbg_swab32( &(_p)->rx_management_err ); \ + \ + _mbg_swab32( &(_p)->tx_all ); \ + _mbg_swab32( &(_p)->tx_announce ); \ + _mbg_swab32( &(_p)->tx_sync ); \ + _mbg_swab32( &(_p)->tx_follow_up ); \ + _mbg_swab32( &(_p)->tx_delay_req ); \ + _mbg_swab32( &(_p)->tx_delay_resp ); \ + _mbg_swab32( &(_p)->tx_pdelay_req ); \ + _mbg_swab32( &(_p)->tx_pdelay_resp ); \ + _mbg_swab32( &(_p)->tx_pdelay_follow_up ); \ + _mbg_swab32( &(_p)->tx_signalling ); \ + _mbg_swab32( &(_p)->tx_management ); \ + \ + _mbg_swab32( &(_p)->ann_receipt_timeout ); \ + \ + _mbg_swab32( &(_p)->rx_all_per_sec ); \ + _mbg_swab32( &(_p)->rx_announce_per_sec ); \ + _mbg_swab32( &(_p)->rx_sync_per_sec ); \ + _mbg_swab32( &(_p)->rx_follow_up_per_sec ); \ + _mbg_swab32( &(_p)->rx_delay_req_per_sec ); \ + _mbg_swab32( &(_p)->rx_delay_resp_per_sec ); \ + _mbg_swab32( &(_p)->rx_pdelay_req_per_sec ); \ + _mbg_swab32( &(_p)->rx_pdelay_resp_per_sec ); \ + _mbg_swab32( &(_p)->rx_pdelay_follow_up_per_sec ); \ + _mbg_swab32( &(_p)->rx_signalling_per_sec ); \ + _mbg_swab32( &(_p)->rx_management_per_sec ); \ + \ + _mbg_swab32( &(_p)->tx_all_per_sec ); \ + _mbg_swab32( &(_p)->tx_announce_per_sec ); \ + _mbg_swab32( &(_p)->tx_sync_per_sec ); \ + _mbg_swab32( &(_p)->tx_follow_up_per_sec ); \ + _mbg_swab32( &(_p)->tx_delay_req_per_sec ); \ + _mbg_swab32( &(_p)->tx_delay_resp_per_sec ); \ + _mbg_swab32( &(_p)->tx_pdelay_req_per_sec ); \ + _mbg_swab32( &(_p)->tx_pdelay_resp_per_sec ); \ + _mbg_swab32( &(_p)->tx_pdelay_follow_up_per_sec ); \ + _mbg_swab32( &(_p)->tx_signalling_per_sec ); \ + _mbg_swab32( &(_p)->tx_management_per_sec ); \ +} + + +/** + * @brief + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + + MBG_PTP_NG_INSTC_PKT_CNTRS cntrs; + +} MBG_PTP_NG_INSTC_PKT_CNTRS_IDX; + + +#define _mbg_swab_ptp_ng_instc_pkt_cntrs_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_instc_pkt_cntrs( &(_p)->cntrs ); \ +} + + +/** + * @brief A structure used to read the status of a unicast slave of an instance running in unicast master mode + * @see ::MBG_PTP_NG_INSTC_STATUS::num_uc_slaves + */ +typedef struct mbg_ptp_ng_uc_slave_status_s +{ + uint8_t addr[IP6_ADDR_BYTES]; ///< IPv4, IPv6 or MAC address + ///< Depending on the appropriate ::MBG_PTP_NG_INSTC_SETTINGS::protocol + + MBG_PTP_NG_INTV_CFG intvs; ///< Granted message intervals + uint32_t ann_duration; ///< Remaining announce message duration + + uint32_t sync_duration; ///< Remaining sync message duration + uint32_t resp_duration; ///< Remaining delay reponse duration + + uint32_t reserved_4[8]; ///< reserved, currently always 0 + +} MBG_PTP_NG_UC_SLAVE_STATUS; + + +#define _mbg_swab_ptp_ng_uc_slave_status( _p ) \ +{ \ + _mbg_swab_ptp_ng_intv_cfg( &(_p)->intvs ); \ + _mbg_swab32( &(_p)->ann_duration ); \ + _mbg_swab32( &(_p)->sync_duration ); \ + _mbg_swab32( &(_p)->resp_duration ); \ +} + + +/** + * @brief + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t instc_idx; + + MBG_PTP_NG_UC_SLAVE_STATUS status; + +} MBG_PTP_NG_UC_SLAVE_STATUS_IDX; + + +#define _mbg_swab_ptp_ng_uc_slave_status_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab32( &(_p)->instc_idx ); \ + _mbg_swab_ptp_ng_uc_slave_status( &(_p)->status ); \ +} + + +/** + * @brief Configuration settings specifiying how to query a PTP unicast master + * + * This structure is used on a unicast slave to specify the settings of + * a unicast master polled by the slave. The number of unicast masters + * which can be specified depends on the capabilities of the slave device + * and is returned in ::MBG_PTP_NG_GLB_INFO::max_uc_masters. + */ +typedef struct mbg_ptp_ng_uc_master_settings_s +{ + uint32_t instc_idx; ///< Index of the PTP instance this master belongs to + uint32_t reserved_1; ///< reserved, currently always 0. + + uint8_t grantor_addr[IP6_ADDR_BYTES]; ///< IPv4, IPv6 or MAC address of the grandmaster, depending on + ///< the associated ::MBG_PTP_NG_INSTC_SETTINGS::protocol value. + + PTP_PORT_IDENTITY gm_port_identity; ///< Specified port identity of master port, or ::PTP_CLOCK_ID_WILDCARD and ::PTP_PORT_ID_WILDCARD. + MBG_PTP_NG_INTV_CFG intvs; ///< Intervals to be requested by the Slave instance for this master. + uint16_t message_duration; ///< Subscription period [s]. + + uint32_t reserved_3[4]; ///< Reserved, currently always 0. + +} MBG_PTP_NG_UC_MASTER_SETTINGS; + + +#define _mbg_swab_ptp_ng_uc_master_settings( _p ) \ +{ \ + _mbg_swab32( &(_p)->instc_idx ); \ + _mbg_swab_ptp_port_identity( &(_p)->gm_port_identity ); \ + _mbg_swab_ptp_ng_intv_cfg( &(_p)->intvs ); \ + _mbg_swab16( &(_p)->message_duration ); \ +} + + +/** + * @brief Configuration settings for a specific PTP unicast master + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + + MBG_PTP_NG_UC_MASTER_SETTINGS settings; + +} MBG_PTP_NG_UC_MASTER_SETTINGS_IDX; + + +#define _mbg_swab_ptp_ng_uc_master_settings_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_uc_master_settings( &(_p)->settings ); \ +} + + +/** + * @brief Current settings and general capabilities of a unicast master + * + * This structure is used with a PTP unicast slave device to specify + * a PTP unicast master which can be queried by the slave device. + */ +typedef struct mbg_ptp_ng_uc_master_info_s +{ + MBG_PTP_NG_UC_MASTER_SETTINGS settings; + + uint32_t reserved[4]; ///< reserved, currently always 0 + +} MBG_PTP_NG_UC_MASTER_INFO; + + +#define _mbg_swab_ptp_ng_uc_master_info( _p ) \ +{ \ + _mbg_swab_ptp_ng_uc_master_settings( &(_p)->settings ); \ +} + + +/** + * @brief Current settings and general capabilities of a specific unicast master + * + * This structure is used with a PTP unicast slave device to specify + * a PTP unicast master which can be queried by the slave device. + */ +typedef struct +{ + MBG_MSG_IDX_32 idx; + uint32_t reserved; ///< padding for 8-byte alignment, some settings contain int64_t + + MBG_PTP_NG_UC_MASTER_INFO info; + +} MBG_PTP_NG_UC_MASTER_INFO_IDX; + + +#define _mbg_swab_ptp_ng_uc_master_info_idx( _p ) \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_ptp_ng_uc_master_info( &(_p)->info ); \ +} + + +/** @} defgroup group_ptp_ng */ /** @} defgroup group_ptp */ @@ -15117,10 +18008,10 @@ enum NTP_ROLES */ enum NTP_ROLE_MASKS { - NTP_MSK_ROLE_NONE = ( 1UL << NTP_ROLE_NONE ), ///< see ::NTP_ROLE_NONE - NTP_MSK_ROLE_CLIENT = ( 1UL << NTP_ROLE_CLIENT ), ///< see ::NTP_ROLE_CLIENT - NTP_MSK_ROLE_SERVER = ( 1UL << NTP_ROLE_SERVER ), ///< see ::NTP_ROLE_SERVER - NTP_MSK_ROLE_CLIENT_SERVER = ( 1UL << NTP_ROLE_CLIENT_SERVER ), ///< see ::NTP_ROLE_CLIENT_SERVER + NTP_MSK_ROLE_NONE = ( 1UL << NTP_ROLE_NONE ), ///< See ::NTP_ROLE_NONE + NTP_MSK_ROLE_CLIENT = ( 1UL << NTP_ROLE_CLIENT ), ///< See ::NTP_ROLE_CLIENT + NTP_MSK_ROLE_SERVER = ( 1UL << NTP_ROLE_SERVER ), ///< See ::NTP_ROLE_SERVER + NTP_MSK_ROLE_CLIENT_SERVER = ( 1UL << NTP_ROLE_CLIENT_SERVER ), ///< See ::NTP_ROLE_CLIENT_SERVER }; @@ -15131,33 +18022,32 @@ enum NTP_ROLE_MASKS */ enum NTP_FLAGS { - NTP_IPV4, ///< NTP via IPv4/UDP - NTP_IPV6, ///< NTP via IPv6/UDP - NTP_SYMM_KEYS, ///< support symmetric key authentication (MD5) - NTP_AUTOKEY, ///< include authentication fields encrypted using the autokey scheme - NTP_BURST, ///< send a burst of eight packets at each polling cycle - NTP_IBURST, ///< send a burst of eight packets at the first polling cycle - NTP_NO_SELECT, ///< marks a server as not to be selected for time synchronization - NTP_PREEMPT, ///< specifies the association as preemptable rather than the default persistent - NTP_PREFER, ///< marks a server as preferred peer for time synchronization - NTP_TRUE, ///< force the association to assume truechimer status; always survive the selection and clustering algorithms - NTP_BROADCAST, ///< transmission via broadcast, point to multipoint - NTP_MULTICAST, ///< transmission via multicast, point to multipoint - NTP_MANYCAST, ///< transmission via manycast, point to multipoint - NTP_POOL, ///< peer shall be treated as a pool server - NTP_PEER, ///< specifies a symmetric-active association should be used with this server - NTP_BROADCASTCLIENT, ///< receive broadcast messages on all interfaces - NTP_MULTICASTCLIENT, ///< receive messages from the given multicast group - NTP_MANYCASTCLIENT, ///< manycast shall be used on the given multicast address to discover peers - NTP_RESTRICTIONS, ///< NTP supports restrictions - NTP_DISCARD, ///< NTP supports "discard" rate limiting - NTP_REFCLOCKS, ///< NTP supports refclocks - NTP_STATISTICS, ///< NTP supports statistics (e.g. clockstats, loopstats, etc...) - NTP_MISCELLANEOUS, ///< NTP supports misc options (e.g. tinker, driftfile, orphan mode, etc...) - NTP_TRUSTED_KEYS, ///< NTP supports specifying trusted symmetric keys - NTP_FIXED_REFCLOCKS, ///< NTP refclocks not configurable - NTP_ADD_CONF, ///< Supports additional NTP configuration (i.e. via script) - + NTP_IPV4, ///< NTP via IPv4/UDP + NTP_IPV6, ///< NTP via IPv6/UDP + NTP_SYMM_KEYS, ///< support symmetric key authentication (MD5) + NTP_AUTOKEY, ///< include authentication fields encrypted using the autokey scheme + NTP_BURST, ///< send a burst of eight packets at each polling cycle + NTP_IBURST, ///< send a burst of eight packets at the first polling cycle + NTP_NO_SELECT, ///< marks a server as not to be selected for time synchronization + NTP_PREEMPT, ///< specifies the association as preemptable rather than the default persistent + NTP_PREFER, ///< marks a server as preferred peer for time synchronization + NTP_TRUE, ///< force the association to assume truechimer status; always survive the selection and clustering algorithms + NTP_BROADCAST, ///< transmission via broadcast, point to multipoint + NTP_MULTICAST, ///< transmission via multicast, point to multipoint + NTP_MANYCAST, ///< transmission via manycast, point to multipoint + NTP_POOL, ///< peer shall be treated as a pool server + NTP_PEER, ///< specifies a symmetric-active association should be used with this server + NTP_BROADCASTCLIENT, ///< receive broadcast messages on all interfaces + NTP_MULTICASTCLIENT, ///< receive messages from the given multicast group + NTP_MANYCASTCLIENT, ///< manycast shall be used on the given multicast address to discover peers + NTP_RESTRICTIONS, ///< NTP supports restrictions + NTP_DISCARD, ///< NTP supports "discard" rate limiting + NTP_REFCLOCKS, ///< NTP supports refclocks + NTP_STATISTICS, ///< NTP supports statistics (e.g. clockstats, loopstats, etc...) + NTP_MISCELLANEOUS, ///< NTP supports misc options (e.g. tinker, driftfile, orphan mode, etc...) + NTP_TRUSTED_KEYS, ///< NTP supports specifying trusted symmetric keys + NTP_FIXED_REFCLOCKS, ///< NTP refclocks not configurable + NTP_ADD_CONF, ///< Supports additional NTP configuration (i.e. via script) N_NTP_FLAGS }; @@ -15176,33 +18066,32 @@ enum NTP_FLAGS * * @anchor NTP_FLAG_MASKS @{ */ -#define NTP_MSK_IPV4 ( 1UL << NTP_IPV4 ) ///< see ::NTP_IPV4 -#define NTP_MSK_IPV6 ( 1UL << NTP_IPV6 ) ///< see ::NTP_IPV6 -#define NTP_MSK_SYMM_KEYS ( 1UL << NTP_SYMM_KEYS ) ///< see ::NTP_SYMM_KEYS; if set, ::NTP_SYMM_KEY_LIMITS can be queried -#define NTP_MSK_AUTOKEY ( 1UL << NTP_AUTOKEY ) ///< see ::NTP_AUTOKEY -#define NTP_MSK_BURST ( 1UL << NTP_BURST ) ///< see ::NTP_BURST -#define NTP_MSK_IBURST ( 1UL << NTP_IBURST ) ///< see ::NTP_IBURST -#define NTP_MSK_NO_SELECT ( 1UL << NTP_NO_SELECT ) ///< see ::NTP_NO_SELECT -#define NTP_MSK_PREEMPT ( 1UL << NTP_PREEMPT ) ///< see ::NTP_PREEMPT -#define NTP_MSK_PREFER ( 1UL << NTP_PREFER ) ///< see ::NTP_PREFER -#define NTP_MSK_TRUE ( 1UL << NTP_TRUE ) ///< see ::NTP_TRUE -#define NTP_MSK_BROADCAST ( 1UL << NTP_BROADCAST ) ///< see ::NTP_BROADCAST -#define NTP_MSK_MULTICAST ( 1UL << NTP_MULTICAST ) ///< see ::NTP_MULTICAST -#define NTP_MSK_MANYCAST ( 1UL << NTP_MANYCAST ) ///< see ::NTP_MANYCAST -#define NTP_MSK_POOL ( 1UL << NTP_POOL ) ///< see ::NTP_POOL -#define NTP_MSK_PEER ( 1UL << NTP_PEER ) ///< see ::NTP_PEER -#define NTP_MSK_BROADCASTCLIENT ( 1UL << NTP_BROADCASTCLIENT) ///< see ::NTP_BROADCASTCLIENT -#define NTP_MSK_MULTICASTCLIENT ( 1UL << NTP_MULTICASTCLIENT) ///< see ::NTP_MULTICASTCLIENT -#define NTP_MSK_MANYCASTCLIENT ( 1UL << NTP_MANYCASTCLIENT) ///< see ::NTP_MANYCASTCLIENT -#define NTP_MSK_RESTRICTIONS ( 1UL << NTP_RESTRICTIONS ) ///< see ::NTP_RESTRICTIONS -#define NTP_MSK_DISCARD ( 1UL << NTP_DISCARD ) ///< see ::NTP_DISCARD -#define NTP_MSK_REFCLOCKS ( 1UL << NTP_REFCLOCKS ) ///< see ::NTP_REFCLOCKS -#define NTP_MSK_STATISTICS ( 1UL << NTP_STATISTICS ) ///< see ::NTP_STATISTICS; if set, ::NTP_STATS_GLB_INFO can be queried -#define NTP_MSK_MISCELLANEOUS ( 1UL << NTP_MISCELLANEOUS ) ///< see ::NTP_MISCELLANEOUS -#define NTP_MSK_TRUSTED_KEYS ( 1UL << NTP_TRUSTED_KEYS ) ///< see ::NTP_TRUSTED_KEYS -#define NTP_MSK_FIXED_REFCLOCKS ( 1UL << NTP_FIXED_REFCLOCKS ) ///< see ::NTP_FIXED_REFCLOCKS -#define NTP_MSK_ADD_CONF ( 1UL << NTP_ADD_CONF ) ///< see ::NTP_ADD_CONF - +#define NTP_MSK_IPV4 ( 1UL << NTP_IPV4 ) ///< See ::NTP_IPV4 +#define NTP_MSK_IPV6 ( 1UL << NTP_IPV6 ) ///< See ::NTP_IPV6 +#define NTP_MSK_SYMM_KEYS ( 1UL << NTP_SYMM_KEYS ) ///< See ::NTP_SYMM_KEYS; if set, ::NTP_SYMM_KEY_LIMITS can be queried +#define NTP_MSK_AUTOKEY ( 1UL << NTP_AUTOKEY ) ///< See ::NTP_AUTOKEY +#define NTP_MSK_BURST ( 1UL << NTP_BURST ) ///< See ::NTP_BURST +#define NTP_MSK_IBURST ( 1UL << NTP_IBURST ) ///< See ::NTP_IBURST +#define NTP_MSK_NO_SELECT ( 1UL << NTP_NO_SELECT ) ///< See ::NTP_NO_SELECT +#define NTP_MSK_PREEMPT ( 1UL << NTP_PREEMPT ) ///< See ::NTP_PREEMPT +#define NTP_MSK_PREFER ( 1UL << NTP_PREFER ) ///< See ::NTP_PREFER +#define NTP_MSK_TRUE ( 1UL << NTP_TRUE ) ///< See ::NTP_TRUE +#define NTP_MSK_BROADCAST ( 1UL << NTP_BROADCAST ) ///< See ::NTP_BROADCAST +#define NTP_MSK_MULTICAST ( 1UL << NTP_MULTICAST ) ///< See ::NTP_MULTICAST +#define NTP_MSK_MANYCAST ( 1UL << NTP_MANYCAST ) ///< See ::NTP_MANYCAST +#define NTP_MSK_POOL ( 1UL << NTP_POOL ) ///< See ::NTP_POOL +#define NTP_MSK_PEER ( 1UL << NTP_PEER ) ///< See ::NTP_PEER +#define NTP_MSK_BROADCASTCLIENT ( 1UL << NTP_BROADCASTCLIENT) ///< See ::NTP_BROADCASTCLIENT +#define NTP_MSK_MULTICASTCLIENT ( 1UL << NTP_MULTICASTCLIENT) ///< See ::NTP_MULTICASTCLIENT +#define NTP_MSK_MANYCASTCLIENT ( 1UL << NTP_MANYCASTCLIENT) ///< See ::NTP_MANYCASTCLIENT +#define NTP_MSK_RESTRICTIONS ( 1UL << NTP_RESTRICTIONS ) ///< See ::NTP_RESTRICTIONS +#define NTP_MSK_DISCARD ( 1UL << NTP_DISCARD ) ///< See ::NTP_DISCARD +#define NTP_MSK_REFCLOCKS ( 1UL << NTP_REFCLOCKS ) ///< See ::NTP_REFCLOCKS +#define NTP_MSK_STATISTICS ( 1UL << NTP_STATISTICS ) ///< See ::NTP_STATISTICS; if set, ::NTP_STATS_GLB_INFO can be queried +#define NTP_MSK_MISCELLANEOUS ( 1UL << NTP_MISCELLANEOUS ) ///< See ::NTP_MISCELLANEOUS +#define NTP_MSK_TRUSTED_KEYS ( 1UL << NTP_TRUSTED_KEYS ) ///< See ::NTP_TRUSTED_KEYS +#define NTP_MSK_FIXED_REFCLOCKS ( 1UL << NTP_FIXED_REFCLOCKS ) ///< See ::NTP_FIXED_REFCLOCKS +#define NTP_MSK_ADD_CONF ( 1UL << NTP_ADD_CONF ) ///< See ::NTP_ADD_CONF /** @} anchor NTP_FLAG_MASKS */ @@ -15296,9 +18185,9 @@ enum NTP_RESTR_TYPES */ enum NTP_RESTR_TYPE_MSKS { - NTP_RESTR_TYPE_MSK_DEFAULT = ( 1UL << NTP_RESTR_TYPE_DEFAULT ), ///< see ::NTP_RESTR_TYPE_DEFAULT - NTP_RESTR_TYPE_MSK_SOURCE = ( 1UL << NTP_RESTR_TYPE_SOURCE ), ///< see ::NTP_RESTR_TYPE_SOURCE - NTP_RESTR_TYPE_MSK_ADDRESS = ( 1UL << NTP_RESTR_TYPE_ADDRESS ) ///< see ::NTP_RESTR_TYPE_ADDRESS + NTP_RESTR_TYPE_MSK_DEFAULT = ( 1UL << NTP_RESTR_TYPE_DEFAULT ), ///< See ::NTP_RESTR_TYPE_DEFAULT + NTP_RESTR_TYPE_MSK_SOURCE = ( 1UL << NTP_RESTR_TYPE_SOURCE ), ///< See ::NTP_RESTR_TYPE_SOURCE + NTP_RESTR_TYPE_MSK_ADDRESS = ( 1UL << NTP_RESTR_TYPE_ADDRESS ) ///< See ::NTP_RESTR_TYPE_ADDRESS }; @@ -15343,22 +18232,22 @@ enum NTP_RESTR_FLAGS */ enum NTP_RESTR_FLAG_MSKS { - NTP_RESTR_FLAG_MSK_FLAKE = ( 1UL << NTP_RESTR_FLAG_FLAKE ), ///< see ::NTP_RESTR_FLAG_FLAKE - NTP_RESTR_FLAG_MSK_IGNORE = ( 1UL << NTP_RESTR_FLAG_IGNORE ), ///< see ::NTP_RESTR_FLAG_IGNORE - NTP_RESTR_FLAG_MSK_KOD = ( 1UL << NTP_RESTR_FLAG_KOD ), ///< see ::NTP_RESTR_FLAG_KOD - NTP_RESTR_FLAG_MSK_LIMITED = ( 1UL << NTP_RESTR_FLAG_LIMITED ), ///< see ::NTP_RESTR_FLAG_LIMITED - NTP_RESTR_FLAG_MSK_LOWPRIOTRAP = ( 1UL << NTP_RESTR_FLAG_LOWPRIOTRAP ),///< see ::NTP_RESTR_FLAG_LOWPRIOTRAP - NTP_RESTR_FLAG_MSK_MSSNTP = ( 1UL << NTP_RESTR_FLAG_MSSNTP ), ///< see ::NTP_RESTR_FLAG_MSSNTP - NTP_RESTR_FLAG_MSK_NOMODIFY = ( 1UL << NTP_RESTR_FLAG_NOMODIFY ), ///< see ::NTP_RESTR_FLAG_NOMODIFY - NTP_RESTR_FLAG_MSK_NOQUERY = ( 1UL << NTP_RESTR_FLAG_NOQUERY ), ///< see ::NTP_RESTR_FLAG_NOQUERY - NTP_RESTR_FLAG_MSK_NOPEER = ( 1UL << NTP_RESTR_FLAG_NOPEER ), ///< see ::NTP_RESTR_FLAG_NOPEER - NTP_RESTR_FLAG_MSK_NOSERVE = ( 1UL << NTP_RESTR_FLAG_NOSERVE ), ///< see ::NTP_RESTR_FLAG_NOSERVE - NTP_RESTR_FLAG_MSK_NOTRAP = ( 1UL << NTP_RESTR_FLAG_NOTRAP ), ///< see ::NTP_RESTR_FLAG_NOTRAP - NTP_RESTR_FLAG_MSK_NOTRUST = ( 1UL << NTP_RESTR_FLAG_NOTRUST ), ///< see ::NTP_RESTR_FLAG_NOTRUST - NTP_RESTR_FLAG_MSK_NTPPORT = ( 1UL << NTP_RESTR_FLAG_NTPPORT ), ///< see ::NTP_RESTR_FLAG_NTPPORT - NTP_RESTR_FLAG_MSK_VERSION = ( 1UL << NTP_RESTR_FLAG_VERSION ), ///< see ::NTP_RESTR_FLAG_VERSION - NTP_RESTR_FLAG_MSK_IPV4 = ( 1UL << NTP_RESTR_FLAG_IPV4 ), ///< see ::NTP_RESTR_FLAG_IPV4 - NTP_RESTR_FLAG_MSK_IPV6 = ( 1UL << NTP_RESTR_FLAG_IPV6 ) ///< see ::NTP_RESTR_FLAG_IPV6 + NTP_RESTR_FLAG_MSK_FLAKE = ( 1UL << NTP_RESTR_FLAG_FLAKE ), ///< See ::NTP_RESTR_FLAG_FLAKE + NTP_RESTR_FLAG_MSK_IGNORE = ( 1UL << NTP_RESTR_FLAG_IGNORE ), ///< See ::NTP_RESTR_FLAG_IGNORE + NTP_RESTR_FLAG_MSK_KOD = ( 1UL << NTP_RESTR_FLAG_KOD ), ///< See ::NTP_RESTR_FLAG_KOD + NTP_RESTR_FLAG_MSK_LIMITED = ( 1UL << NTP_RESTR_FLAG_LIMITED ), ///< See ::NTP_RESTR_FLAG_LIMITED + NTP_RESTR_FLAG_MSK_LOWPRIOTRAP = ( 1UL << NTP_RESTR_FLAG_LOWPRIOTRAP ),///< See ::NTP_RESTR_FLAG_LOWPRIOTRAP + NTP_RESTR_FLAG_MSK_MSSNTP = ( 1UL << NTP_RESTR_FLAG_MSSNTP ), ///< See ::NTP_RESTR_FLAG_MSSNTP + NTP_RESTR_FLAG_MSK_NOMODIFY = ( 1UL << NTP_RESTR_FLAG_NOMODIFY ), ///< See ::NTP_RESTR_FLAG_NOMODIFY + NTP_RESTR_FLAG_MSK_NOQUERY = ( 1UL << NTP_RESTR_FLAG_NOQUERY ), ///< See ::NTP_RESTR_FLAG_NOQUERY + NTP_RESTR_FLAG_MSK_NOPEER = ( 1UL << NTP_RESTR_FLAG_NOPEER ), ///< See ::NTP_RESTR_FLAG_NOPEER + NTP_RESTR_FLAG_MSK_NOSERVE = ( 1UL << NTP_RESTR_FLAG_NOSERVE ), ///< See ::NTP_RESTR_FLAG_NOSERVE + NTP_RESTR_FLAG_MSK_NOTRAP = ( 1UL << NTP_RESTR_FLAG_NOTRAP ), ///< See ::NTP_RESTR_FLAG_NOTRAP + NTP_RESTR_FLAG_MSK_NOTRUST = ( 1UL << NTP_RESTR_FLAG_NOTRUST ), ///< See ::NTP_RESTR_FLAG_NOTRUST + NTP_RESTR_FLAG_MSK_NTPPORT = ( 1UL << NTP_RESTR_FLAG_NTPPORT ), ///< See ::NTP_RESTR_FLAG_NTPPORT + NTP_RESTR_FLAG_MSK_VERSION = ( 1UL << NTP_RESTR_FLAG_VERSION ), ///< See ::NTP_RESTR_FLAG_VERSION + NTP_RESTR_FLAG_MSK_IPV4 = ( 1UL << NTP_RESTR_FLAG_IPV4 ), ///< See ::NTP_RESTR_FLAG_IPV4 + NTP_RESTR_FLAG_MSK_IPV6 = ( 1UL << NTP_RESTR_FLAG_IPV6 ) ///< See ::NTP_RESTR_FLAG_IPV6 }; @@ -15395,7 +18284,7 @@ do \ * @brief NTP restriction * * Structure contains all flags and information needed for a valid NTP restriction - * as described at ntp.org's manual page. + * as described in the manual pages at ntp.org. */ typedef struct { @@ -15404,9 +18293,9 @@ typedef struct uint16_t reserved_2; ///< Future use uint32_t flags; ///< Restriction flags, see ::NTP_RESTR_FLAG_MSKS - MBG_HOSTNAME addr; ///< used if ::NTP_RESTR::type == ::NTP_RESTR_TYPE_ADDRESS - ///< can contain a hostname, or an IPv4 or IPv6 address - ///< with or without CIDR extension (eg. 172.16.0.0/16). + MBG_HOSTNAME addr; ///< Used if ::NTP_RESTR::type == ::NTP_RESTR_TYPE_ADDRESS. + ///< Can contain a hostname, or an IPv4 or IPv6 address + ///< with or without CIDR extension (e.g. 172.16.0.0/16). } NTP_RESTR; #define _mbg_swab_ntp_restr( _p ) \ @@ -15470,7 +18359,7 @@ do \ /** - * @brief NTP "discard" rate limiting settings as described at ntp.org's manual + * @brief NTP "discard" rate limiting settings as described at ntp.org. */ typedef struct { @@ -15625,23 +18514,23 @@ enum NTP_REFCLK_TYPES */ enum NTP_REFCLK_TYPE_MSKS { - NTP_REFCLK_TYPE_MSK_LOCAL = ( 1UL << NTP_REFCLK_TYPE_LOCAL ), ///< see ::NTP_REFCLK_TYPE_LOCAL - NTP_REFCLK_TYPE_MSK_TRUETIME = ( 1UL << NTP_REFCLK_TYPE_TRUETIME ), ///< see ::NTP_REFCLK_TYPE_TRUETIME - NTP_REFCLK_TYPE_MSK_PARSE = ( 1UL << NTP_REFCLK_TYPE_PARSE ), ///< see ::NTP_REFCLK_TYPE_PARSE - NTP_REFCLK_TYPE_MSK_NMEA = ( 1UL << NTP_REFCLK_TYPE_NMEA ), ///< see ::NTP_REFCLK_TYPE_NMEA - NTP_REFCLK_TYPE_MSK_PPS = ( 1UL << NTP_REFCLK_TYPE_PPS ), ///< see ::NTP_REFCLK_TYPE_PPS - NTP_REFCLK_TYPE_MSK_SHM = ( 1UL << NTP_REFCLK_TYPE_SHM ) ///< see ::NTP_REFCLK_TYPE_SHM + NTP_REFCLK_TYPE_MSK_LOCAL = ( 1UL << NTP_REFCLK_TYPE_LOCAL ), ///< See ::NTP_REFCLK_TYPE_LOCAL + NTP_REFCLK_TYPE_MSK_TRUETIME = ( 1UL << NTP_REFCLK_TYPE_TRUETIME ), ///< See ::NTP_REFCLK_TYPE_TRUETIME + NTP_REFCLK_TYPE_MSK_PARSE = ( 1UL << NTP_REFCLK_TYPE_PARSE ), ///< See ::NTP_REFCLK_TYPE_PARSE + NTP_REFCLK_TYPE_MSK_NMEA = ( 1UL << NTP_REFCLK_TYPE_NMEA ), ///< See ::NTP_REFCLK_TYPE_NMEA + NTP_REFCLK_TYPE_MSK_PPS = ( 1UL << NTP_REFCLK_TYPE_PPS ), ///< See ::NTP_REFCLK_TYPE_PPS + NTP_REFCLK_TYPE_MSK_SHM = ( 1UL << NTP_REFCLK_TYPE_SHM ) ///< See ::NTP_REFCLK_TYPE_SHM }; /** - * @brief Numbers related to the "fudge" flags used with ntpd's refclock interface + * @brief Numbers related to the "fudge" flags used with ntpd's refclock interface. * * Used with ::NTP_REFCLK_CFG_SETTINGS::drv_flags_enable - * and ::NTP_REFCLK_CFG_SETTINGS::drv_flags_value + * and ::NTP_REFCLK_CFG_SETTINGS::drv_flags_value. * - * The refclock interface provided by ntpd supports a number of flags - * (flag1..flag4) which can be "fudged" in ntp.conf to control specific + * The refclock interface provided by @a ntpd supports a number of flags + * (flag1..flag4) which can be "fudged" in @a ntp.conf to control specific * features of a particular refclock driver, e.g.: * "fudge 127.127.8.0 flag1 1" * @@ -15651,13 +18540,13 @@ enum NTP_REFCLK_TYPE_MSKS * * There are different cases to be distinguished: * - * - if a flag is not specified at all in ntp.conf then + * - If a flag is not specified at all in @a ntp.conf then * the controlled feature is enabled or disabled - * according to the driver's default settings + * according to the driver's default settings. * - * - if a flag is specified as '0' or '1' in ntp.conf then + * - If a flag is specified as '0' or '1' in @a ntp.conf then * the controlled feature is enabled or disabled - * according to the flag's setting. + * according to the value of the flag. * * Thus, the bit mask in ::NTP_REFCLK_CFG_SETTINGS::drv_flags_enable * controls if the associated fudge flag should be specified in ntp.conf, @@ -15723,7 +18612,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_REFCLK_CFG_SETTINGS settings; ///< See ::NTP_REFCLK_CFG_SETTINGS } NTP_REFCLK_CFG_SETTINGS_IDX; @@ -15757,7 +18646,7 @@ enum NTP_REFCLK_CFG_FLAGS * * @anchor NTP_REFCLK_CFG_FLAGS_MASKS @{ */ -#define NTP_MSK_REFCLK_CFG_TRUSTTIME ( 1UL << NTP_REFCLK_CFG_TRUSTTIME ) ///< see ::NTP_REFCLK_CFG_TRUSTTIME +#define NTP_MSK_REFCLK_CFG_TRUSTTIME ( 1UL << NTP_REFCLK_CFG_TRUSTTIME ) ///< See ::NTP_REFCLK_CFG_TRUSTTIME /** @} anchor NTP_REFCLK_CFG_FLAGS_MASKS */ @@ -15765,7 +18654,7 @@ enum NTP_REFCLK_CFG_FLAGS /** * @brief NTP refclock configuration and supported refclock types * - * This structure can be used to set a NTP refclock's configuration + * This structure can be used to set an NTP refclock configuration * and get to know its overall supported refclocks. */ typedef struct @@ -15794,7 +18683,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_REFCLK_CFG_INFO info; } NTP_REFCLK_CFG_INFO_IDX; @@ -15807,6 +18696,19 @@ do \ } while ( 0 ) +enum NTP_SYMM_KEY_FLAGS +{ + NTP_SYMM_KEY_WHITELIST, ///< The device supports whitelisting for symmetric keys + N_NTP_SYMM_KEY_FLAGS +}; + + +enum NTP_SYMM_KEY_FLAG_MASKS +{ + NTP_SYMM_KEY_WHITELIST_MSK = ( 1UL << NTP_SYMM_KEY_WHITELIST ) ///< See ::NTP_SYMM_KEY_WHITELIST +}; + + /** * @brief Enumeration of NTP supported symmetric key hashing algorithms * @@ -15831,8 +18733,8 @@ enum NTP_SYMM_KEY_HASHES */ enum NTP_SYMM_KEY_HASH_MASKS { - NTP_SYMM_KEY_HASH_MSK_MD5 = ( 1UL << NTP_SYMM_KEY_HASH_MD5 ), ///< see ::NTP_SYMM_KEY_HASH_MD5 - NTP_SYMM_KEY_HASH_MSK_SHA1 = ( 1UL << NTP_SYMM_KEY_HASH_SHA1 ), ///< see ::NTP_SYMM_KEY_HASH_SHA1 + NTP_SYMM_KEY_HASH_MSK_MD5 = ( 1UL << NTP_SYMM_KEY_HASH_MD5 ), ///< See ::NTP_SYMM_KEY_HASH_MD5 + NTP_SYMM_KEY_HASH_MSK_SHA1 = ( 1UL << NTP_SYMM_KEY_HASH_SHA1 ), ///< See ::NTP_SYMM_KEY_HASH_SHA1 }; @@ -15859,7 +18761,7 @@ enum NTP_SYMM_KEY_HASH_MASKS typedef struct { uint16_t supp_hashes; ///< See ::NTP_SYMM_KEY_HASH_MASKS - uint16_t reserved_1; ///< Future use + uint16_t supp_flags; ///< See ::NTP_SYMM_KEY_FLAG_MASKS uint32_t reserved_2; ///< Future use uint32_t reserved_3; ///< Future use uint32_t reserved_4; ///< Future use @@ -15870,6 +18772,7 @@ typedef struct do \ { \ _mbg_swab16( &(_p)->supp_hashes ); \ + _mbg_swab16( &(_p)->supp_flags ); \ } while ( 0 ) @@ -15878,9 +18781,9 @@ do \ /// prepared for hash algorithms like SHA256, SH384, up to SHA512. #define N_NTP_SYMM_KEY_LEN 128 -/// Maximum number of ip addresses which can be assign to each key in -/// order to limit usage -#define N_NTP_SYMM_KEY_MAX_IP_ADDR 8 +/// Maximum number of whitelist entries which can be assigned to one key in +/// order to limit its usage +#define NTP_SYMM_KEY_WHITELIST_LEN 8 @@ -15891,17 +18794,19 @@ do \ */ typedef struct { - uint16_t id; ///< Configurable key id (1..65534) - uint8_t hash; ///< See ::NTP_SYMM_KEY_HASHES - uint8_t reserved_1; ///< Future use + uint16_t id; ///< Configurable key id (1..65534) + uint8_t hash; ///< See ::NTP_SYMM_KEY_HASHES + uint8_t reserved_1; ///< Future use - uint16_t reserved_2; ///< Future use - uint8_t num_ip_addr; ///< Number of configured ip addresses - uint8_t reserved_3; ///< Future use + uint16_t reserved_2; ///< Future use + uint8_t num_whitelist_entries; ///< Number of configured whitelist entries + ///< only valid if ::NTP_SYMM_KEY_WHITELIST_MSK is set in ::NTP_SYMM_KEY_LIMITS::supp_flags + uint8_t reserved_3; ///< Future use - uint8_t key[N_NTP_SYMM_KEY_LEN]; ///< Hashed phrase, see ::N_NTP_SYMM_KEY_LEN + uint8_t key[N_NTP_SYMM_KEY_LEN]; ///< Hashed phrase, see ::N_NTP_SYMM_KEY_LEN - MBG_IP_ADDR ip_addr[N_NTP_SYMM_KEY_MAX_IP_ADDR]; ///< Whitelist of ip addresses see ::N_NTP_SYMM_KEY_MAX_IP_ADDR + MBG_IP_ADDR whitelist_entries[NTP_SYMM_KEY_WHITELIST_LEN]; ///< Whitelist of ip addresses see ::NTP_SYMM_KEY_WHITELIST_LEN + ///< may only be used if ::NTP_SYMM_KEY_WHITELIST_MSK is set in ::NTP_SYMM_KEY_LIMITS::supp_flags } NTP_SYMM_KEY_SETTINGS; @@ -15912,8 +18817,8 @@ do \ \ _mbg_swab16( &(_p)->id ); \ \ - for ( i = 0; i < N_NTP_SYMM_KEY_MAX_IP_ADDR; ++i) \ - _mbg_swab_ip_addr( &(_p)->ip_addr[i] ); \ + for ( i = 0; i < NTP_SYMM_KEY_WHITELIST_LEN; ++i) \ + _mbg_swab_ip_addr( &(_p)->whitelist_entries[i] ); \ } while ( 0 ) @@ -15925,7 +18830,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_SYMM_KEY_SETTINGS settings; } NTP_SYMM_KEY_SETTINGS_IDX; @@ -15968,7 +18873,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_SYMM_KEY_INFO info; } NTP_SYMM_KEY_INFO_IDX; @@ -16008,7 +18913,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_TRUSTED_KEY_SETTINGS settings; } NTP_TRUSTED_KEY_SETTINGS_IDX; @@ -16050,7 +18955,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_TRUSTED_KEY_INFO info; } NTP_TRUSTED_KEY_INFO_IDX; @@ -16169,7 +19074,7 @@ typedef struct { uint8_t enable; ///< Generally enable / disable orphan mode uint8_t mode; ///< Stratum level when no ref source available - uint16_t reserved_1; ///< Future use + uint16_t wait_time; ///< Time until stratum is degraded (orphan mode active) in seconds uint32_t reserved_2; ///< Future use @@ -16178,6 +19083,9 @@ typedef struct #define _mbg_swab_ntp_misc_orphan_mode_settings( _p ) \ do \ { \ + _mbg_swab8( &(_p)->enable ); \ + _mbg_swab8( &(_p)->mode ); \ + _mbg_swab16( &(_p)->wait_time ); \ } while ( 0 ) @@ -16257,7 +19165,7 @@ do \ * * This structure can be used to determine possible NTP client settings and the current configuration */ -typedef struct +typedef struct ntp_clnt_mode_info_s { NTP_CLNT_MODE_SETTINGS settings; @@ -16390,9 +19298,9 @@ do \ * * @see ::NTP_PEER_SETTINGS */ -typedef struct +typedef struct ntp_peer_settings_idx_s { - uint32_t idx; + MBG_MSG_IDX_32 idx; NTP_PEER_SETTINGS peer_settings; } NTP_PEER_SETTINGS_IDX; @@ -16434,7 +19342,7 @@ do \ * * This structure should be used to query an NTP server configuration from a device */ -typedef struct +typedef struct ntp_srv_mode_info_s { NTP_SRV_MODE_SETTINGS settings; @@ -16821,17 +19729,17 @@ enum NTP_SYS_STATE_SUPP_FLAGS */ enum NTP_SYS_STATE_SUPP_FLAG_MASKS { - NTP_SYS_STATE_SUPP_STD_MSK = ( 1UL << NTP_SYS_STATE_SUPP_STD ), ///< see ::NTP_SYS_STATE_SUPP_STD - NTP_SYS_STATE_SUPP_EVENTS_MSK = ( 1UL << NTP_SYS_STATE_SUPP_EVENTS ), ///< see ::NTP_SYS_STATE_SUPP_EVENTS - NTP_SYS_STATE_SUPP_PRECISION_MSK = ( 1UL << NTP_SYS_STATE_SUPP_PRECISION ), ///< see ::NTP_SYS_STATE_SUPP_PRECISION - NTP_SYS_STATE_SUPP_ROOT_DELAY_MSK = ( 1UL << NTP_SYS_STATE_SUPP_ROOT_DELAY ), ///< see ::NTP_SYS_STATE_SUPP_ROOT_DELAY - NTP_SYS_STATE_SUPP_ROOT_DISP_MSK = ( 1UL << NTP_SYS_STATE_SUPP_ROOT_DISP ), ///< see ::NTP_SYS_STATE_SUPP_ROOT_DISP - NTP_SYS_STATE_SUPP_FREQ_MSK = ( 1UL << NTP_SYS_STATE_SUPP_FREQ ), ///< see ::NTP_SYS_STATE_SUPP_FREQ - NTP_SYS_STATE_SUPP_SYS_JITTER_MSK = ( 1UL << NTP_SYS_STATE_SUPP_SYS_JITTER ), ///< see ::NTP_SYS_STATE_SUPP_SYS_JITTER - NTP_SYS_STATE_SUPP_CLK_JITTER_MSK = ( 1UL << NTP_SYS_STATE_SUPP_CLK_JITTER ), ///< see ::NTP_SYS_STATE_SUPP_CLK_JITTER - NTP_SYS_STATE_SUPP_CLK_WANDER_MSK = ( 1UL << NTP_SYS_STATE_SUPP_CLK_WANDER ), ///< see ::NTP_SYS_STATE_SUPP_CLK_WANDER - NTP_SYS_STATE_SUPP_SYS_ASSOC_MSK = ( 1UL << NTP_SYS_STATE_SUPP_SYS_ASSOC ), ///< see ::NTP_SYS_STATE_SUPP_SYS_ASSOC - NTP_SYS_STATE_SUPP_SERVICE_STATE_MSK = ( 1UL << NTP_SYS_STATE_SUPP_SERVICE_STATE ) ///< see ::NTP_SYS_STATE_SUPP_SERVICE_STATE + NTP_SYS_STATE_SUPP_STD_MSK = ( 1UL << NTP_SYS_STATE_SUPP_STD ), ///< See ::NTP_SYS_STATE_SUPP_STD + NTP_SYS_STATE_SUPP_EVENTS_MSK = ( 1UL << NTP_SYS_STATE_SUPP_EVENTS ), ///< See ::NTP_SYS_STATE_SUPP_EVENTS + NTP_SYS_STATE_SUPP_PRECISION_MSK = ( 1UL << NTP_SYS_STATE_SUPP_PRECISION ), ///< See ::NTP_SYS_STATE_SUPP_PRECISION + NTP_SYS_STATE_SUPP_ROOT_DELAY_MSK = ( 1UL << NTP_SYS_STATE_SUPP_ROOT_DELAY ), ///< See ::NTP_SYS_STATE_SUPP_ROOT_DELAY + NTP_SYS_STATE_SUPP_ROOT_DISP_MSK = ( 1UL << NTP_SYS_STATE_SUPP_ROOT_DISP ), ///< See ::NTP_SYS_STATE_SUPP_ROOT_DISP + NTP_SYS_STATE_SUPP_FREQ_MSK = ( 1UL << NTP_SYS_STATE_SUPP_FREQ ), ///< See ::NTP_SYS_STATE_SUPP_FREQ + NTP_SYS_STATE_SUPP_SYS_JITTER_MSK = ( 1UL << NTP_SYS_STATE_SUPP_SYS_JITTER ), ///< See ::NTP_SYS_STATE_SUPP_SYS_JITTER + NTP_SYS_STATE_SUPP_CLK_JITTER_MSK = ( 1UL << NTP_SYS_STATE_SUPP_CLK_JITTER ), ///< See ::NTP_SYS_STATE_SUPP_CLK_JITTER + NTP_SYS_STATE_SUPP_CLK_WANDER_MSK = ( 1UL << NTP_SYS_STATE_SUPP_CLK_WANDER ), ///< See ::NTP_SYS_STATE_SUPP_CLK_WANDER + NTP_SYS_STATE_SUPP_SYS_ASSOC_MSK = ( 1UL << NTP_SYS_STATE_SUPP_SYS_ASSOC ), ///< See ::NTP_SYS_STATE_SUPP_SYS_ASSOC + NTP_SYS_STATE_SUPP_SERVICE_STATE_MSK = ( 1UL << NTP_SYS_STATE_SUPP_SERVICE_STATE ) ///< See ::NTP_SYS_STATE_SUPP_SERVICE_STATE }; @@ -16869,7 +19777,7 @@ enum MBG_NTP_SERVICE_STATES * * This structure can be requested from a monitoring program to determine the device system status */ -typedef struct +typedef struct ntp_sys_state_s { uint32_t supp_flags; ///< Supported NTP system state values, see ::NTP_SYS_STATE_SUPP_FLAG_MASKS @@ -17143,11 +20051,11 @@ enum NTP_PEER_STATUS_FLAGS */ enum NTP_PEER_STATUS_FLAG_MASKS { - NTP_PEER_STATUS_BCST_MSK = ( 1UL << NTP_PEER_STATUS_BCST ), ///< see ::NTP_PEER_STATUS_BCST - NTP_PEER_STATUS_REACH_MSK = ( 1UL << NTP_PEER_STATUS_REACH ), ///< see ::NTP_PEER_STATUS_REACH - NTP_PEER_STATUS_AUTHENB_MSK = ( 1UL << NTP_PEER_STATUS_AUTHENB ), ///< see ::NTP_PEER_STATUS_AUTHENB - NTP_PEER_STATUS_AUTH_MSK = ( 1UL << NTP_PEER_STATUS_AUTH ), ///< see ::NTP_PEER_STATUS_AUTH - NTP_PEER_STATUS_CONFIG_MSK = ( 1UL << NTP_PEER_STATUS_CONFIG ), ///< see ::NTP_PEER_STATUS_CONFIG + NTP_PEER_STATUS_BCST_MSK = ( 1UL << NTP_PEER_STATUS_BCST ), ///< See ::NTP_PEER_STATUS_BCST + NTP_PEER_STATUS_REACH_MSK = ( 1UL << NTP_PEER_STATUS_REACH ), ///< See ::NTP_PEER_STATUS_REACH + NTP_PEER_STATUS_AUTHENB_MSK = ( 1UL << NTP_PEER_STATUS_AUTHENB ), ///< See ::NTP_PEER_STATUS_AUTHENB + NTP_PEER_STATUS_AUTH_MSK = ( 1UL << NTP_PEER_STATUS_AUTH ), ///< See ::NTP_PEER_STATUS_AUTH + NTP_PEER_STATUS_CONFIG_MSK = ( 1UL << NTP_PEER_STATUS_CONFIG ), ///< See ::NTP_PEER_STATUS_CONFIG }; @@ -17283,19 +20191,19 @@ enum NTP_FLASH_STAT_FLAGS */ enum NTP_FLASH_STAT_FLAG_MASKS { - NTP_FLASH_STAT_PKT_DUP_MSK = ( 1UL << NTP_FLASH_STAT_PKT_DUP ), ///< see ::NTP_FLASH_STAT_PKT_DUP - NTP_FLASH_STAT_PKT_BOGUS_MSK = ( 1UL << NTP_FLASH_STAT_PKT_BOGUS ), ///< see ::NTP_FLASH_STAT_PKT_BOGUS - NTP_FLASH_STAT_PKT_UNSYNC_MSK = ( 1UL << NTP_FLASH_STAT_PKT_UNSYNC ), ///< see ::NTP_FLASH_STAT_PKT_UNSYNC - NTP_FLASH_STAT_PKT_DENIED_MSK = ( 1UL << NTP_FLASH_STAT_PKT_DENIED ), ///< see ::NTP_FLASH_STAT_PKT_DENIED - NTP_FLASH_STAT_PKT_AUTH_MSK = ( 1UL << NTP_FLASH_STAT_PKT_AUTH ), ///< see ::NTP_FLASH_STAT_PKT_AUTH - NTP_FLASH_STAT_PKT_STRATUM_MSK = ( 1UL << NTP_FLASH_STAT_PKT_STRATUM ), ///< see ::NTP_FLASH_STAT_PKT_STRATUM - NTP_FLASH_STAT_PKT_HEADER_MSK = ( 1UL << NTP_FLASH_STAT_PKT_HEADER ), ///< see ::NTP_FLASH_STAT_PKT_HEADER - NTP_FLASH_STAT_PKT_AUTOKEY_MSK = ( 1UL << NTP_FLASH_STAT_PKT_AUTOKEY ), ///< see ::NTP_FLASH_STAT_PKT_AUTOKEY - NTP_FLASH_STAT_PKT_CRYPTO_MSK = ( 1UL << NTP_FLASH_STAT_PKT_CRYPTO ), ///< see ::NTP_FLASH_STAT_PKT_CRYPTO - NTP_FLASH_STAT_PEER_STRATUM_MSK = ( 1UL << NTP_FLASH_STAT_PEER_STRATUM ), ///< see ::NTP_FLASH_STAT_PEER_STRATUM - NTP_FLASH_STAT_PEER_DIST_MSK = ( 1UL << NTP_FLASH_STAT_PEER_DIST ), ///< see ::NTP_FLASH_STAT_PEER_DIST - NTP_FLASH_STAT_PEER_LOOP_MSK = ( 1UL << NTP_FLASH_STAT_PEER_LOOP ), ///< see ::NTP_FLASH_STAT_PEER_LOOP - NTP_FLASH_STAT_PEER_UNREACH_MSK = ( 1UL << NTP_FLASH_STAT_PEER_UNREACH ), ///< see ::NTP_FLASH_STAT_PEER_UNREACH + NTP_FLASH_STAT_PKT_DUP_MSK = ( 1UL << NTP_FLASH_STAT_PKT_DUP ), ///< See ::NTP_FLASH_STAT_PKT_DUP + NTP_FLASH_STAT_PKT_BOGUS_MSK = ( 1UL << NTP_FLASH_STAT_PKT_BOGUS ), ///< See ::NTP_FLASH_STAT_PKT_BOGUS + NTP_FLASH_STAT_PKT_UNSYNC_MSK = ( 1UL << NTP_FLASH_STAT_PKT_UNSYNC ), ///< See ::NTP_FLASH_STAT_PKT_UNSYNC + NTP_FLASH_STAT_PKT_DENIED_MSK = ( 1UL << NTP_FLASH_STAT_PKT_DENIED ), ///< See ::NTP_FLASH_STAT_PKT_DENIED + NTP_FLASH_STAT_PKT_AUTH_MSK = ( 1UL << NTP_FLASH_STAT_PKT_AUTH ), ///< See ::NTP_FLASH_STAT_PKT_AUTH + NTP_FLASH_STAT_PKT_STRATUM_MSK = ( 1UL << NTP_FLASH_STAT_PKT_STRATUM ), ///< See ::NTP_FLASH_STAT_PKT_STRATUM + NTP_FLASH_STAT_PKT_HEADER_MSK = ( 1UL << NTP_FLASH_STAT_PKT_HEADER ), ///< See ::NTP_FLASH_STAT_PKT_HEADER + NTP_FLASH_STAT_PKT_AUTOKEY_MSK = ( 1UL << NTP_FLASH_STAT_PKT_AUTOKEY ), ///< See ::NTP_FLASH_STAT_PKT_AUTOKEY + NTP_FLASH_STAT_PKT_CRYPTO_MSK = ( 1UL << NTP_FLASH_STAT_PKT_CRYPTO ), ///< See ::NTP_FLASH_STAT_PKT_CRYPTO + NTP_FLASH_STAT_PEER_STRATUM_MSK = ( 1UL << NTP_FLASH_STAT_PEER_STRATUM ), ///< See ::NTP_FLASH_STAT_PEER_STRATUM + NTP_FLASH_STAT_PEER_DIST_MSK = ( 1UL << NTP_FLASH_STAT_PEER_DIST ), ///< See ::NTP_FLASH_STAT_PEER_DIST + NTP_FLASH_STAT_PEER_LOOP_MSK = ( 1UL << NTP_FLASH_STAT_PEER_LOOP ), ///< See ::NTP_FLASH_STAT_PEER_LOOP + NTP_FLASH_STAT_PEER_UNREACH_MSK = ( 1UL << NTP_FLASH_STAT_PEER_UNREACH ), ///< See ::NTP_FLASH_STAT_PEER_UNREACH }; @@ -17373,19 +20281,19 @@ enum NTP_PEER_STATE_SUPP_FLAGS */ enum NTP_PEER_STATE_SUPP_FLAG_MASKS { - NTP_PEER_STATE_SUPP_STD_MSK = ( 1UL << NTP_PEER_STATE_SUPP_STD ), ///< see ::NTP_PEER_STATE_SUPP_STD - NTP_PEER_STATE_SUPP_ASS_ID_MSK = ( 1UL << NTP_PEER_STATE_SUPP_ASS_ID ), ///< see ::NTP_PEER_STATE_SUPP_ASS_ID - NTP_PEER_STATE_SUPP_EVENTS_MSK = ( 1UL << NTP_PEER_STATE_SUPP_EVENTS ), ///< see ::NTP_PEER_STATE_SUPP_EVENTS - NTP_PEER_STATE_SUPP_REACH_STAT_MSK = ( 1UL << NTP_PEER_STATE_SUPP_REACH_STAT ), ///< see ::NTP_PEER_STATE_SUPP_REACH_STAT - NTP_PEER_STATE_SUPP_PRECISION_MSK = ( 1UL << NTP_PEER_STATE_SUPP_PRECISION ), ///< see ::NTP_PEER_STATE_SUPP_PRECISION - NTP_PEER_STATE_SUPP_ROOT_DELAY_MSK = ( 1UL << NTP_PEER_STATE_SUPP_ROOT_DELAY ), ///< see ::NTP_PEER_STATE_SUPP_ROOT_DELAY - NTP_PEER_STATE_SUPP_ROOT_DISP_MSK = ( 1UL << NTP_PEER_STATE_SUPP_ROOT_DISP ), ///< see ::NTP_PEER_STATE_SUPP_ROOT_DISP - NTP_PEER_STATE_SUPP_HEADWAY_MSK = ( 1UL << NTP_PEER_STATE_SUPP_HEADWAY ), ///< see ::NTP_PEER_STATE_SUPP_HEADWAY - NTP_PEER_STATE_SUPP_FLASH_STAT_MSK = ( 1UL << NTP_PEER_STATE_SUPP_FLASH_STAT ), ///< see ::NTP_PEER_STATE_SUPP_FLASH_STAT - NTP_PEER_STATE_SUPP_KEY_ID_MSK = ( 1UL << NTP_PEER_STATE_SUPP_KEY_ID ), ///< see ::NTP_PEER_STATE_SUPP_KEY_ID - NTP_PEER_STATE_SUPP_DISP_MSK = ( 1UL << NTP_PEER_STATE_SUPP_DISP ), ///< see ::NTP_PEER_STATE_SUPP_DISP - NTP_PEER_STATE_SUPP_JITTER_MSK = ( 1UL << NTP_PEER_STATE_SUPP_JITTER ), ///< see ::NTP_PEER_STATE_SUPP_JITTER - NTP_PEER_STATE_SUPP_XLEAVE_MSK = ( 1UL << NTP_PEER_STATE_SUPP_XLEAVE ), ///< see ::NTP_PEER_STATE_SUPP_XLEAVE + NTP_PEER_STATE_SUPP_STD_MSK = ( 1UL << NTP_PEER_STATE_SUPP_STD ), ///< See ::NTP_PEER_STATE_SUPP_STD + NTP_PEER_STATE_SUPP_ASS_ID_MSK = ( 1UL << NTP_PEER_STATE_SUPP_ASS_ID ), ///< See ::NTP_PEER_STATE_SUPP_ASS_ID + NTP_PEER_STATE_SUPP_EVENTS_MSK = ( 1UL << NTP_PEER_STATE_SUPP_EVENTS ), ///< See ::NTP_PEER_STATE_SUPP_EVENTS + NTP_PEER_STATE_SUPP_REACH_STAT_MSK = ( 1UL << NTP_PEER_STATE_SUPP_REACH_STAT ), ///< See ::NTP_PEER_STATE_SUPP_REACH_STAT + NTP_PEER_STATE_SUPP_PRECISION_MSK = ( 1UL << NTP_PEER_STATE_SUPP_PRECISION ), ///< See ::NTP_PEER_STATE_SUPP_PRECISION + NTP_PEER_STATE_SUPP_ROOT_DELAY_MSK = ( 1UL << NTP_PEER_STATE_SUPP_ROOT_DELAY ), ///< See ::NTP_PEER_STATE_SUPP_ROOT_DELAY + NTP_PEER_STATE_SUPP_ROOT_DISP_MSK = ( 1UL << NTP_PEER_STATE_SUPP_ROOT_DISP ), ///< See ::NTP_PEER_STATE_SUPP_ROOT_DISP + NTP_PEER_STATE_SUPP_HEADWAY_MSK = ( 1UL << NTP_PEER_STATE_SUPP_HEADWAY ), ///< See ::NTP_PEER_STATE_SUPP_HEADWAY + NTP_PEER_STATE_SUPP_FLASH_STAT_MSK = ( 1UL << NTP_PEER_STATE_SUPP_FLASH_STAT ), ///< See ::NTP_PEER_STATE_SUPP_FLASH_STAT + NTP_PEER_STATE_SUPP_KEY_ID_MSK = ( 1UL << NTP_PEER_STATE_SUPP_KEY_ID ), ///< See ::NTP_PEER_STATE_SUPP_KEY_ID + NTP_PEER_STATE_SUPP_DISP_MSK = ( 1UL << NTP_PEER_STATE_SUPP_DISP ), ///< See ::NTP_PEER_STATE_SUPP_DISP + NTP_PEER_STATE_SUPP_JITTER_MSK = ( 1UL << NTP_PEER_STATE_SUPP_JITTER ), ///< See ::NTP_PEER_STATE_SUPP_JITTER + NTP_PEER_STATE_SUPP_XLEAVE_MSK = ( 1UL << NTP_PEER_STATE_SUPP_XLEAVE ), ///< See ::NTP_PEER_STATE_SUPP_XLEAVE }; @@ -17397,7 +20305,7 @@ enum NTP_PEER_STATE_SUPP_FLAG_MASKS * * @see ::NTP_PEER_STATE_IDX */ -typedef struct +typedef struct ntp_peer_state_s { uint32_t supp_flags; ///< Supported NTP peer state values, see ::NTP_PEER_STATE_SUPP_FLAG_MASKS @@ -17536,9 +20444,9 @@ do \ * * @see ::NTP_PEER_STATE */ -typedef struct +typedef struct ntp_peer_state_idx_s { - uint32_t idx; ///< The index of the observed NTP peer + MBG_MSG_IDX_32 idx; ///< The index of the observed NTP peer NTP_PEER_STATE peer_state; ///< Peer state, see ::NTP_PEER_STATE } NTP_PEER_STATE_IDX, NTP_REFCLK_STATE_IDX; @@ -17700,7 +20608,7 @@ typedef struct NANO_TIME err_limit; ///< time difference limit above which an error is indicated NANO_TIME warn_limit; ///< time difference limit above which a warning is indicated uint32_t reserved; ///< reserved, currently always 0 - uint32_t flags; ///< see ::SHS_FLAG_MASKS + uint32_t flags; ///< See ::SHS_FLAG_MASKS } SHS_SETTINGS; @@ -17746,13 +20654,13 @@ do \ */ typedef struct { - NANO_TIME time_diff; ///< current time difference between the 2 clocks - TM_STATUS_EXT clk_status_1; ///< status of first clock - TM_STATUS_EXT clk_status_2; ///< status of second clock - uint8_t shs_state; ///< see ::SHS_STATES - uint8_t reserved_1; ///< reserved, currently always 0 - uint16_t reserved_2; ///< reserved, currently always 0 - uint32_t flags; ///< see ::SHS_FLAG_MASKS + NANO_TIME time_diff; ///< Current time difference between the 2 clocks. + TM_GPS_STATUS_EXT clk_status_1; ///< Status of first clock. + TM_GPS_STATUS_EXT clk_status_2; ///< Status of second clock. + uint8_t shs_state; ///< See ::SHS_STATES. + uint8_t reserved_1; ///< Reserved, currently always 0. + uint16_t reserved_2; ///< Reserved, currently always 0. + uint32_t flags; ///< See ::SHS_FLAG_MASKS. } SHS_STATUS; @@ -17813,9 +20721,9 @@ enum SHS_FLAG_BITS */ enum SHS_FLAG_MASKS { - SHS_FLAG_DISB_SERIAL = ( 1UL << SHS_FLAG_BIT_DISB_SERIAL ), ///< see ::SHS_FLAG_BIT_DISB_SERIAL - SHS_FLAG_DISB_PPS = ( 1UL << SHS_FLAG_BIT_DISB_PPS ), ///< see ::SHS_FLAG_BIT_DISB_PPS - SHS_FLAG_DISB_10MHZ = ( 1UL << SHS_FLAG_BIT_DISB_10MHZ ) ///< see ::SHS_FLAG_BIT_DISB_10MHZ + SHS_FLAG_DISB_SERIAL = ( 1UL << SHS_FLAG_BIT_DISB_SERIAL ), ///< See ::SHS_FLAG_BIT_DISB_SERIAL + SHS_FLAG_DISB_PPS = ( 1UL << SHS_FLAG_BIT_DISB_PPS ), ///< See ::SHS_FLAG_BIT_DISB_PPS + SHS_FLAG_DISB_10MHZ = ( 1UL << SHS_FLAG_BIT_DISB_10MHZ ) ///< See ::SHS_FLAG_BIT_DISB_10MHZ }; /** @} defgroup group_shs */ @@ -17858,7 +20766,7 @@ typedef uint8_t XBP_PORT; * * A generic scheme to address devices connected to cascaded controllers. */ -typedef struct +typedef struct xbp_addr_s { uint8_t hop_count; ///< Used as index to the addr array XBP_PORT addr[MAX_XBP_CASC_LVL]; ///< An array of port numbers on cascaded controllers @@ -17954,6 +20862,7 @@ enum XBP_DEVICE_STATES XBP_DEVICE_STATE_INITIALIZING, XBP_DEVICE_STATE_AVAILABLE, XBP_DEVICE_STATE_DISCONNECTED, + XBP_DEVICE_STATE_OUTDATED, N_XBP_DEVICE_STATES }; @@ -18003,11 +20912,12 @@ enum XBP_SLOT_TYPES * The number of instances supported by a device is specified * in ::XBP_NODE_LIMITS::node_count. */ -typedef struct +typedef struct xbp_node_info_s { XBP_ADDR addr; ///< The address of the specific node - /// ::RECEIVER_INFO of the device connected to this node. + /// @brief ::RECEIVER_INFO of the device connected to this node. + /// /// If no device is available then ::RECEIVER_INFO::model_code /// is set to ::GPS_MODEL_UNKNOWN (== 0). RECEIVER_INFO ri; @@ -18043,7 +20953,7 @@ do \ */ typedef struct { - uint32_t idx; ///< node index, 0..::XBP_NODE_LIMITS::node_count-1 + MBG_MSG_IDX_32 idx; ///< node index, 0..::XBP_NODE_LIMITS::node_count-1 XBP_NODE_INFO node_info; ///< ::RECEIVER_INFO of the device behind this node } XBP_NODE_INFO_IDX; @@ -18128,8 +21038,8 @@ enum MBG_TLV_FEAT_TYPES /// 2) ::MBG_TLV_TYPE_FILE => Firmware file as data blob MBG_TLV_FEAT_TYPE_FW_UPDATE, - /// If announce message's total bytes are 0, it is a diagnostics file - /// request. If its total bytes are not 0, TLV type ::MBG_TLV_TYPE_FILE + /// If the total bytes of aan announce message is 0, it is a diagnostics file + /// request. If the total bytes are not 0, TLV type ::MBG_TLV_TYPE_FILE /// is expected and it should contain a file as data blob. MBG_TLV_FEAT_TYPE_DIAG_FILE, @@ -18530,7 +21440,7 @@ typedef struct * * %UTC correction parameters basically as sent by the GPS satellites. * - * The csum field is only used by the card's firmware to check the + * The csum field is only used by the device firmware to check the * consistency of the structure in non-volatile memory. * * The field labeled valid indicates if the parameter set is valid, i.e. @@ -18563,17 +21473,26 @@ typedef struct */ typedef struct { - CSUM csum; ///< Checksum of the remaining bytes - int16_t valid; ///< Flag indicating %UTC parameters 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 [wn|sec] - double A0; ///< +- Clock Correction Coefficient 0 [sec] - double A1; ///< +- Clock Correction Coefficient 1 [sec/sec] + T_GPS t0t; ///< Reference Time of %UTC Parameters @a A0 and @a A1 [wn|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 a leap second occurs - 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] + GPS_WNUM WNlsf; ///< Week number of nearest leap second, originally + ///< truncated to 8 bit, so the extended number can be + ///< ambiguous unless @a #delta_tls and @a #delta_tlsf + ///< differ, indicating that a leap second is actually + ///< being announced. + + GPS_DNUM DNt; ///< The day-of-week at the end of which a leap second occurs. + ///< Transmitted numbers in the range 1..7 rather than 0..6. + + 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; @@ -18705,6 +21624,373 @@ typedef struct /** + * @defgroup group_sys_ref Reference system configuration + * + * System-wide reference configuration as replacement for XMR to provide an + * improved global API for new meinbergOS systems. + * + * This API is only supported if ::MBG_XFEATURE_SYS_REF is set. + */ + +typedef struct mbg_sys_ref_limits_s +{ + uint32_t num_ref_srcs; ///< Number of reference sources supported by the system, see ::MBG_SYS_REF_SRC_INFO_IDX + uint8_t max_prios; + uint8_t reserved_1[3]; + + uint32_t reserved_2[14]; ///< Reserved, currently always 0 + +} MBG_SYS_REF_LIMITS; + + +#define _mbg_swab_sys_ref_limits( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->num_ref_srcs ); \ + _mbg_swab32( &(_p)->supp_ref_types ); \ +} while ( 0 ) + + +enum MBG_SYS_REF_SRC_FLAGS +{ + SYS_REF_SRC_FLAG_XMR_STATS_SUPP, ///< Indicates, whether XMR stats are supported, read-only + SYS_REF_SRC_FLAG_XMR_ADV_METRICS_SUPP, ///< Indicates, whether advanced XMR metrics are supported, read-only + ///< Refers to the adv. metrics XMR feature, see ::XMR_EXT_SRC_FEAT_FLAG_BIT_ADV_METRICS + SYS_REF_SRC_FLAG_XMR_COASTING_SUPP, ///< Indicates, whether XMR coasting is supported, read-only + N_SYS_REF_SRC_FLAGS +}; + + +enum MBG_SYS_REF_SRC_MASKS +{ + SYS_REF_SRC_MASK_XMR_STATS_SUPP = ( 1UL << SYS_REF_SRC_FLAG_XMR_STATS_SUPP ), ///< See ::SYS_REF_SRC_FLAG_XMR_STATS_SUPP + SYS_REF_SRC_MASK_XMR_ADV_METRICS_SUPP = ( 1UL << SYS_REF_SRC_FLAG_XMR_ADV_METRICS_SUPP ), ///< See ::SYS_REF_SRC_FLAG_XMR_ADV_METRICS_SUPP + SYS_REF_SRC_MASK_XMR_COASTING_SUPP = ( 1UL << SYS_REF_SRC_FLAG_XMR_COASTING_SUPP ) ///< See ::SYS_REF_SRC_FLAG_XMR_COASTING_SUPP +}; + + +enum MBG_SYS_REF_SRC_TYPES +{ + SYS_REF_SRC_INTEGRATED, ///< Integrated reference source, i.e. an SMA or BNC port on the module itself + SYS_REF_SRC_PERIPHERAL, ///< Peripheral reference source, i.e. a port on an MRI (expansion) module + ///< Can only be used, if the equivalent ::SYS_REF_SRC_EXPANSION is equipped + SYS_REF_SRC_EXPANSION, ///< Expansion reference source announced by peripheral modules (i.e. MRI) + ///< Can only be used, if the equivalent ::SYS_REF_SRC_PERIPHERAL has been announced by the clock module + SYS_REF_SRC_AUTARKIC, ///< Autarkic reference source measuring a distinct offset, i.e. an ESI or a PTP (HPS) module + N_SYS_REF_SRC_TYPES +}; + + +#define SYS_REF_SRC_PRIO_UNUSED 0xFF +#define SYS_REF_SRC_INFO_STR_LEN 32 + +#define SYS_REF_SRC_PRQ_UNQUANTIFIED (-1) + +typedef struct mbg_sys_ref_src_settings_s +{ + uint8_t prio; ///< Priority for this reference + ///< must be 0 .. ::MBG_SYS_REF_LIMITS::num_ref_srcs or ::SYS_REF_SRC_PRIO_UNUSED + uint8_t itu_mask; ///< Used mask for ::XMR_METRICS, see ::MBG_SYS_REF_SRC_INFO::supp_itu_masks, only valid if + ///< ::SYS_REF_SRC_MASK_XMR_ADV_METRICS_SUPP is set in ::MBG_SYS_REF_SRC_INFO::supp_flags + uint8_t hysteresis; ///< Hysteresis (percent) between yellow and red alarm for ::XMR_METRICS, only valid if + ///< ::SYS_REF_SRC_MASK_XMR_ADV_METRICS_SUPP is set in ::MBG_SYS_REF_SRC_INFO::supp_flags + uint8_t reserved; ///< Reserved, currently always 0 + + uint32_t xmr_flags; ///< See ::XMR_SETTINGS_FLAG_MSKS + + NANO_TIME bias; ///< time bias, e.g. path delay + NANO_TIME precision; ///< precision of the time source + + uint32_t ro_uid; ///< Read-Only unique ref source identifier. We desperately + ///< need it to not be index dependent when sending settings. + ///< Layout from MSB to LSB: + ///< 8 bit chassis Id - 8 bit slot ID - 8 bit ref type (::MULTI_REF_TYPES) - 8 bit instance number (::XMULTI_REF_INSTANCES::n_inst[ref type]) + + int8_t quantifier; ///< Source precision quantifier (PRQ) to minimize clock switching operations, see ::SYS_REF_SRC_PRQ_UNQUANTIFIED. + ///< The smaller the value the more important is this source in relation to other sources (priorities). + uint8_t reserved_1[3]; + + uint32_t reserved_2[8]; ///< Reserved, currently always 0 + +} MBG_SYS_REF_SRC_SETTINGS; + + +/** + * @brief Default initializer for ::MBG_SYS_REF_SRC_SETTINGS::quantifier and the corresponding ::MULTI_REF_TYPES + * in ::XMULTI_REF_INSTANCES::n_inst. Keep them in sync! + */ +#define SYS_REF_SRC_QUANTIFIERS \ +{ \ + 0, 1, 1, SYS_REF_SRC_PRQ_UNQUANTIFIED, \ + 4, 6, 2, SYS_REF_SRC_PRQ_UNQUANTIFIED, \ + 1, 3, 3, SYS_REF_SRC_PRQ_UNQUANTIFIED, \ + 6, 6, 0, 3, \ + 5, 2, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, \ + SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, \ + SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, \ + SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED, SYS_REF_SRC_PRQ_UNQUANTIFIED \ +} + + +#define __to_sys_ref_ro_uid(c, s, t, i) \ + (((uint32_t)(c) << 24) | \ + ((uint32_t)(s) << 16) | \ + ((uint32_t)(t) << 8) | \ + ((uint32_t)(i))) + + +#define _mbg_swab_sys_ref_src_settings( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->xmr_flags ); \ + _mbg_swab_nano_time( &(_p)->bias ); \ + _mbg_swab_nano_time( &(_p)->precision ); \ + _mbg_swab32( &(_p)->ro_uid ); \ +} while ( 0 ) + + +typedef struct +{ + MBG_MSG_IDX_32 idx; + MBG_SYS_REF_SRC_SETTINGS settings; + +} MBG_SYS_REF_SRC_SETTINGS_IDX; + + +#define _mbg_swab_sys_ref_src_settings_idx( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_sys_ref_src_settings( &(_p)->settings ); \ +} while ( 0 ) + + +#define SYS_REF_SRC_PORT_UNKNOWN 0xFF + + +typedef struct mbg_sys_ref_src_info_s +{ + MBG_SYS_REF_SRC_SETTINGS settings; ///< See ::MBG_SYS_REF_SRC_SETTINGS + + uint8_t ref_type; ///< See ::MULTI_REF_TYPES + uint8_t conn_type; ///< See ::MBG_SYS_REF_SRC_TYPES + uint8_t clock_idx; ///< Index of the associated clock, if #conn_type is ::SYS_REF_SRC_PERIPHERAL, resp. ::SYS_REF_SRC_EXPANSION + uint8_t chassis_idx; ///< Index of the associated IMS chassis, or ::MBG_OWN_EVENT_CHASSIS + + uint8_t slot_type; ///< See ::XBP_NODE_INFO::slot_type, or ::MBG_OWN_EVENT_SLOT_TYPE + uint8_t slot_type_id; ///< See ::XBP_NODE_INFO::slot_type_id, or ::MBG_OWN_EVENT_SLOT_TYPE_ID + uint8_t port_idx; ///< Index of the associated physical port (I/O port), or ::SYS_REF_SRC_PORT_UNKNOWN. + uint8_t inst_num; ///< Instance number of ref_type in slot. See ::XMULTI_REF_INSTANCES::n_inst + + char str[SYS_REF_SRC_INFO_STR_LEN]; ///< String for reference identification + + uint32_t supp_xmr_flags; ///< See ::XMR_SETTINGS_FLAG_MSKS + uint32_t supp_flags; ///< See ::MBG_SYS_REF_SRC_INFO::supp_flags and ::MBG_SYS_REF_SRC_MASKS + uint32_t supp_itu_masks; ///< See ::ITU_LIMIT_MASKS + uint32_t reserved_2[7]; ///< Reserved, currently always 0 + +} MBG_SYS_REF_SRC_INFO; + + +#define _mbg_swab_sys_ref_src_info( _p ) \ +do \ +{ \ + _mbg_swab_sys_ref_src_settings( &(_p)->settings ); \ + _mbg_swab32( &(_p)->supp_xmr_flags ); \ + _mbg_swab32( &(_p)->supp_itu_masks ); \ +} while ( 0 ) + + +typedef struct +{ + MBG_MSG_IDX_32 idx; + MBG_SYS_REF_SRC_INFO info; + +} MBG_SYS_REF_SRC_INFO_IDX; + + +#define _mbg_swab_sys_ref_src_info_idx( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_sys_ref_src_info( &(_p)->info ); \ +} while ( 0 ) + + + +enum MBG_EST_TIME_QUALITY +{ + MBG_EST_TIME_QUALITY_RES_1, + MBG_EST_TIME_QUALITY_RES_2, + MBG_EST_TIME_QUALITY_RES_3, + MBG_EST_TIME_QUALITY_1ns, + MBG_EST_TIME_QUALITY_10ns, + MBG_EST_TIME_QUALITY_25ns, + MBG_EST_TIME_QUALITY_100ns, + MBG_EST_TIME_QUALITY_250ns, + MBG_EST_TIME_QUALITY_1us, + MBG_EST_TIME_QUALITY_2_5us, + MBG_EST_TIME_QUALITY_10us, + MBG_EST_TIME_QUALITY_25us, + MBG_EST_TIME_QUALITY_100us, + MBG_EST_TIME_QUALITY_250us, + MBG_EST_TIME_QUALITY_1ms, + MBG_EST_TIME_QUALITY_2_5ms, + MBG_EST_TIME_QUALITY_10ms, + MBG_EST_TIME_QUALITY_25ms, + MBG_EST_TIME_QUALITY_100ms, + MBG_EST_TIME_QUALITY_250ms, + MBG_EST_TIME_QUALITY_1s, + MBG_EST_TIME_QUALITY_10s, + MBG_EST_TIME_QUALITY_more_10s, + N_MBG_EST_TIME_QUALITYS +}; + + +#define MBG_EST_TIME_QUALITY_STRS \ +{ \ + "Unknown", \ + "Unknown", \ + "Unknown", \ + "1 ns", \ + "10 ns", \ + "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", \ + "> 10 s" \ +} + + +typedef struct mbg_sys_ref_glb_status_s +{ + uint32_t master_idx; ///< Index of currently used reference source, see ::MBG_SYS_REF_SRC_INFO_IDX::idx + uint8_t ref_type; ///< Reference type of the currently used clock, see ::MULTI_REF_TYPES + uint8_t reserved_1[3]; ///< Reserved, currently always 0 + + XMR_HOLDOVER_STATUS holdover_status; ///< See ::XMR_HOLDOVER_STATUS, holdover status of currently used reference source + + uint8_t clock_idx; ///< Index of the currently used clock starting with 0, depends on #master_idx + uint8_t osc_type; ///< Oscillator type of the currently selected clock, see ::GPS_OSC_TYPES + TM_GPS_STATUS tm_gps_status; ///< Status flags from ::TM_GPS of the currently used clock, see ::TM_GPS_STATUS_BIT_MASKS + + uint8_t est_time_quality; ///< Current estimated time quality of the used clock, see ::MBG_EST_TIME_QUALITY + uint8_t reserved_2[3]; ///< Reserved, currently always 0 + uint16_t scaled_log_variance; ///< Current variance of the clock, depending on the oscillator type as defined in IEEE1588 + uint16_t reserved_3; ///< Reserved, currently always 0 + + UTC utc_parms; ///< %UTC offset, leap second information, etc., see ::UTC, + ///< TODO!!! can this be used? contains doubles + + uint32_t reserved_4[8]; ///< Reserved, currently always 0 + +} MBG_SYS_REF_GLB_STATUS; + + +#define _mbg_swab_sys_ref_glb_status( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->master_idx ); \ + _mbg_swab_xmr_holdover_status( &(_p)->holdover_status ); \ + _mbg_swab_tm_gps_status( &(_p)->tm_gps_status ); \ + _mbg_swab32( &(_p)->est_time_quality ); \ + _mbg_swab16( &(_p)->scaled_log_variance ); \ + _mbg_swab_utc_parm( &(_p)->utc_parms ); \ +} while ( 0 ) + + +enum MBG_SYS_REF_SRC_STATUS_SUPP_FLAGS +{ + SYS_REF_SRC_STATUS_SUPP_SSM, ///< Indicates, that ::MBG_SYS_REF_SRC_STATUS::ssm holds a valid value + SYS_REF_SRC_STATUS_SUPP_OUTAGE_CNT, ///< Indicates, that ::MBG_SYS_REF_SRC_STATUS::outage_cnt holds a valid value + SYS_REF_SRC_STATUS_SUPP_XMR_HOLDOVER, ///< Indicates, that ::MBG_SYS_REF_SRC_STATUS::xmr_holdover holds valid values + SYS_REF_SRC_STATUS_SUPP_XMR_STATS, ///< Indicates, that ::MBG_SYS_REF_SRC_STATUS::xmr_stats holds valid values + SYS_REF_SRC_STATUS_SUPP_XMR_METRICS, ///< Indicates, that ::MBG_SYS_REF_SRC_STATUS::xmr_metrics holds valid values + N_SYS_REF_SRC_STATUS_SUPP_FLAGS +}; + + +enum MBG_SYS_REF_SRC_STATUS_SUPP_MASKS +{ + SYS_REF_SRC_STATUS_SUPP_SSM_MASK = ( 1UL << SYS_REF_SRC_STATUS_SUPP_SSM ), ///< See ::SYS_REF_SRC_STATUS_SUPP_SSM + SYS_REF_SRC_STATUS_SUPP_OUTAGE_CNT_MASK = ( 1UL << SYS_REF_SRC_STATUS_SUPP_OUTAGE_CNT ), ///< See ::SYS_REF_SRC_STATUS_SUPP_OUTAGE_CNT + SYS_REF_SRC_STATUS_SUPP_XMR_HOLDOVER_MASK = ( 1UL << SYS_REF_SRC_STATUS_SUPP_XMR_HOLDOVER ), ///< See ::SYS_REF_SRC_STATUS_SUPP_XMR_HOLDOVER + SYS_REF_SRC_STATUS_SUPP_XMR_STATS_MASK = ( 1UL << SYS_REF_SRC_STATUS_SUPP_XMR_STATS ), ///< See ::SYS_REF_SRC_STATUS_SUPP_XMR_STATS + SYS_REF_SRC_STATUS_SUPP_XMR_METRICS_MASK = ( 1UL << SYS_REF_SRC_STATUS_SUPP_XMR_METRICS ) ///< See ::SYS_REF_SRC_STATUS_SUPP_XMR_METRICS +}; + + +typedef struct mbg_sys_ref_src_status_s +{ + char str[SYS_REF_SRC_INFO_STR_LEN]; ///< String for reference identification + + uint32_t xmr_status; ///< See @ref XMR_REF_STATUS_BIT_MASKS + + NANO_TIME offset; ///< time offset from main time base + + uint8_t ssm; ///< synchronization status message, only valid if ::SYS_REF_SRC_STATUS_SUPP_SSM_MASK is set + uint8_t prio; ///< Priority for this reference + uint8_t reserved[2]; ///< Reserved, currently always 0 + + uint32_t outage_cnt; ///< signal outage counter, incremented on loss of signal, only valid if ::SYS_REF_SRC_STATUS_SUPP_OUTAGE_CNT_MASK is set + + XMR_HOLDOVER_STATUS xmr_holdover; ///< See ::XMR_HOLDOVER_STATUS, only valid if ::SYS_REF_SRC_STATUS_SUPP_XMR_HOLDOVER_MASK is set + XMR_STATS xmr_stats; ///< See ::XMR_STATS, only valid if ::SYS_REF_SRC_STATUS_SUPP_XMR_STATS_MASK is set + XMR_METRICS xmr_metrics; ///< See ::XMR_METRICS, only valid if ::SYS_REF_SRC_STATUS_SUPP_XMR_METRICS_MASK is set + + uint32_t supp_flags; ///< See ::MBG_SYS_REF_SRC_STATUS_SUPP_MASKS + + uint32_t reserved_4[8]; ///< Reserved, currently always 0 + +} MBG_SYS_REF_SRC_STATUS; + + +#define _mbg_swab_sys_ref_src_status( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->xmr_status ); \ + _mbg_swab_nano_time( &(_p)->offset ); \ + _mbg_swab32( &(_p)->outage_cnt ); \ + _mbg_swab_xmr_holdover_status( &(_p)->xmr_holdover ); \ + _mbg_swab_xmr_stats( &(_p)->xmr_stats ); \ + _mbg_swab_xmr_metrics( &(_p)->xmr_metrics ); \ + _mbg_swab32( &(_p)->supp_flags ); \ +} while ( 0 ) + + +typedef struct +{ + MBG_MSG_IDX_32 idx; + MBG_SYS_REF_SRC_STATUS status; + +} MBG_SYS_REF_SRC_STATUS_IDX; + + +#define _mbg_swab_sys_ref_src_status_idx( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_sys_ref_src_status( &(_p)->status ); \ +} while ( 0 ) + + +/** @} defgroup group_sys_ref */ + + +/** * @defgroup group_led_api Meinberg LED API definitions * * @note These structures and definitions are only supported by a device @@ -18771,10 +22057,10 @@ enum MBG_LED_MODES */ enum MBG_LED_MODE_MASKS { - MBG_LED_MODE_MASK_OFF = ( 1UL << MBG_LED_MODE_OFF ), ///< see ::MBG_LED_MODE_OFF - MBG_LED_MODE_MASK_ON = ( 1UL << MBG_LED_MODE_ON ), ///< see ::MBG_LED_MODE_ON - MBG_LED_MODE_MASK_FLASH = ( 1UL << MBG_LED_MODE_FLASH ), ///< see ::MBG_LED_MODE_FLASH - MBG_LED_MODE_MASK_FLASH_5S = ( 1UL << MBG_LED_MODE_FLASH_5S ) ///< see ::MBG_LED_MODE_FLASH_5S + MBG_LED_MODE_MASK_OFF = ( 1UL << MBG_LED_MODE_OFF ), ///< See ::MBG_LED_MODE_OFF + MBG_LED_MODE_MASK_ON = ( 1UL << MBG_LED_MODE_ON ), ///< See ::MBG_LED_MODE_ON + MBG_LED_MODE_MASK_FLASH = ( 1UL << MBG_LED_MODE_FLASH ), ///< See ::MBG_LED_MODE_FLASH + MBG_LED_MODE_MASK_FLASH_5S = ( 1UL << MBG_LED_MODE_FLASH_5S ) ///< See ::MBG_LED_MODE_FLASH_5S }; @@ -18824,10 +22110,10 @@ enum MBG_LED_COLORS */ enum MBG_LED_COLOR_MASKS { - MBG_LED_COLOR_MASK_GREEN = ( 1UL << MBG_LED_COLOR_GREEN ), ///< see ::MBG_LED_COLOR_GREEN - MBG_LED_COLOR_MASK_RED = ( 1UL << MBG_LED_COLOR_RED ), ///< see ::MBG_LED_COLOR_RED - MBG_LED_COLOR_MASK_YELLOW = ( 1UL << MBG_LED_COLOR_YELLOW ), ///< see ::MBG_LED_COLOR_YELLOW - MBG_LED_COLOR_MASK_BLUE = ( 1UL << MBG_LED_COLOR_BLUE ) ///< see ::MBG_LED_COLOR_BLUE + MBG_LED_COLOR_MASK_GREEN = ( 1UL << MBG_LED_COLOR_GREEN ), ///< See ::MBG_LED_COLOR_GREEN + MBG_LED_COLOR_MASK_RED = ( 1UL << MBG_LED_COLOR_RED ), ///< See ::MBG_LED_COLOR_RED + MBG_LED_COLOR_MASK_YELLOW = ( 1UL << MBG_LED_COLOR_YELLOW ), ///< See ::MBG_LED_COLOR_YELLOW + MBG_LED_COLOR_MASK_BLUE = ( 1UL << MBG_LED_COLOR_BLUE ) ///< See ::MBG_LED_COLOR_BLUE }; @@ -18882,8 +22168,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_LED_LIMITS::num_leds-1 - MBG_LED_SETTINGS settings; ///< LED settings + MBG_MSG_IDX idx; ///< 0..::MBG_LED_LIMITS::num_leds-1. + MBG_LED_SETTINGS settings; ///< LED settings. } MBG_LED_SETTINGS_IDX; @@ -18935,8 +22221,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_LED_LIMITS::num_leds-1 - MBG_LED_INFO info; ///< LED info + MBG_MSG_IDX idx; ///< 0..::MBG_LED_LIMITS::num_leds-1. + MBG_LED_INFO info; ///< LED info. } MBG_LED_INFO_IDX; @@ -19020,7 +22306,7 @@ enum MBG_LNE_FEAT_BITS */ enum MBG_LNE_FEAT_MASKS { - MBG_LNE_FEAT_MASK_SWITCH_PWR = ( 1UL << MBG_LNE_FEAT_BIT_SWITCH_PWR ) ///< see ::MBG_LNE_FEAT_BIT_SWITCH_PWR + MBG_LNE_FEAT_MASK_SWITCH_PWR = ( 1UL << MBG_LNE_FEAT_BIT_SWITCH_PWR ) ///< See ::MBG_LNE_FEAT_BIT_SWITCH_PWR }; #endif @@ -19060,8 +22346,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_LNE_LIMITS::num_ports-1 - MBG_LNE_PORT_SETTINGS settings; ///< LNE settings + MBG_MSG_IDX idx; ///< 0..::MBG_LNE_LIMITS::num_ports-1. + MBG_LNE_PORT_SETTINGS settings; ///< LNE settings. } MBG_LNE_PORT_SETTINGS_IDX; @@ -19090,7 +22376,7 @@ typedef struct uint32_t reserved_0; ///< currently reserved, unused, always 0 uint32_t reserved_1; ///< currently reserved, unused, always 0 uint32_t reserved_2; ///< currently reserved, unused, always 0 - uint32_t flags; ///< see ::LNE_PORT_FLAG_MASKS + uint32_t flags; ///< See ::LNE_PORT_FLAG_MASKS } MBG_LNE_PORT_INFO; @@ -19115,8 +22401,8 @@ do \ */ typedef struct { - uint16_t idx; ///< 0..::MBG_LED_LIMITS::num_leds-1 - MBG_LNE_PORT_INFO info; ///< LNE port info + MBG_MSG_IDX idx; ///< 0..::MBG_LED_LIMITS::num_leds-1. + MBG_LNE_PORT_INFO info; ///< LNE port info. } MBG_LNE_PORT_INFO_IDX; @@ -19153,7 +22439,7 @@ enum LNE_PORT_FLAG_BITS */ enum LNE_PORT_FLAG_MASKS { - LNE_PORT_FLAG_MASK_IS_SFP = ( 1UL << LNE_PORT_FLAG_BIT_IS_SFP ) ///< see ::LNE_PORT_FLAG_BIT_IS_SFP + LNE_PORT_FLAG_MASK_IS_SFP = ( 1UL << LNE_PORT_FLAG_BIT_IS_SFP ) ///< See ::LNE_PORT_FLAG_BIT_IS_SFP }; @@ -19187,11 +22473,11 @@ enum MBG_PWR_STATES /** * @brief Device power control * - * Used to change or retrieve a device's power state + * Used to change or retrieve the power state of a device. */ typedef struct { - uint8_t state; ///< see ::MBG_PWR_STATES + uint8_t state; ///< See ::MBG_PWR_STATES uint8_t reserved_0; ///< Currently reserved, unused, always 0 uint16_t reserved_1; ///< Currently reserved, unused, always 0 @@ -19236,6 +22522,9 @@ enum MBG_EXT_SYS_INFO_BITS MBG_EXT_SYS_INFO_BIT_STORAGE_SIZE, MBG_EXT_SYS_INFO_BIT_RELEASE_CANDIDATE, MBG_EXT_SYS_INFO_BIT_OS_TARGET, + MBG_EXT_SYS_INFO_BIT_STATUS, ///< Bit to announce ::MBG_EXT_SYS_STATUS support + MBG_EXT_SYS_INFO_BIT_COMMIT_HASH, + MBG_EXT_SYS_INFO_BIT_OS_NAME, N_MBG_EXT_SYS_INFO_BITS }; @@ -19248,16 +22537,19 @@ enum MBG_EXT_SYS_INFO_BITS */ enum MBG_EXT_SYS_INFO_MSKS { - MBG_EXT_SYS_INFO_MSK_SW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_SW_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_SW_REV - MBG_EXT_SYS_INFO_MSK_HW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_HW_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_HW_REV - MBG_EXT_SYS_INFO_MSK_OS_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_OS_REV - MBG_EXT_SYS_INFO_MSK_FPGA_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_FPGA_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_FPGA_REV - MBG_EXT_SYS_INFO_MSK_CORE_MOD_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV ), ///< see ::MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV - MBG_EXT_SYS_INFO_MSK_OS_TYPE = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_TYPE ), ///< see ::MBG_EXT_SYS_INFO_BIT_OS_TYPE - MBG_EXT_SYS_INFO_MSK_RAM_SIZE = ( 1UL << MBG_EXT_SYS_INFO_BIT_RAM_SIZE ), ///< see ::MBG_EXT_SYS_INFO_BIT_RAM_SIZE - MBG_EXT_SYS_INFO_MSK_STORAGE_SIZE = ( 1UL << MBG_EXT_SYS_INFO_BIT_STORAGE_SIZE ), ///< see ::MBG_EXT_SYS_INFO_BIT_STORAGE_SIZE - MBG_EXT_SYS_INFO_MSK_RELEASE_CANDIDATE = ( 1UL << MBG_EXT_SYS_INFO_BIT_RELEASE_CANDIDATE ), ///< see ::MBG_EXT_SYS_INFO_BIT_RELEASE_CANDIDATE - MBG_EXT_SYS_INFO_MSK_OS_TARGET = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_TARGET ) ///< see ::MBG_EXT_SYS_INFO_BIT_OS_TARGET + MBG_EXT_SYS_INFO_MSK_SW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_SW_REV ), ///< See ::MBG_EXT_SYS_INFO_BIT_SW_REV + MBG_EXT_SYS_INFO_MSK_HW_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_HW_REV ), ///< See ::MBG_EXT_SYS_INFO_BIT_HW_REV + MBG_EXT_SYS_INFO_MSK_OS_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_REV ), ///< See ::MBG_EXT_SYS_INFO_BIT_OS_REV + MBG_EXT_SYS_INFO_MSK_FPGA_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_FPGA_REV ), ///< See ::MBG_EXT_SYS_INFO_BIT_FPGA_REV + MBG_EXT_SYS_INFO_MSK_CORE_MOD_REV = ( 1UL << MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV ), ///< See ::MBG_EXT_SYS_INFO_BIT_CORE_MOD_REV + MBG_EXT_SYS_INFO_MSK_OS_TYPE = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_TYPE ), ///< See ::MBG_EXT_SYS_INFO_BIT_OS_TYPE + MBG_EXT_SYS_INFO_MSK_RAM_SIZE = ( 1UL << MBG_EXT_SYS_INFO_BIT_RAM_SIZE ), ///< See ::MBG_EXT_SYS_INFO_BIT_RAM_SIZE + MBG_EXT_SYS_INFO_MSK_STORAGE_SIZE = ( 1UL << MBG_EXT_SYS_INFO_BIT_STORAGE_SIZE ), ///< See ::MBG_EXT_SYS_INFO_BIT_STORAGE_SIZE + MBG_EXT_SYS_INFO_MSK_RELEASE_CANDIDATE = ( 1UL << MBG_EXT_SYS_INFO_BIT_RELEASE_CANDIDATE ), ///< See ::MBG_EXT_SYS_INFO_BIT_RELEASE_CANDIDATE + MBG_EXT_SYS_INFO_MSK_OS_TARGET = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_TARGET ), ///< See ::MBG_EXT_SYS_INFO_BIT_OS_TARGET + MBG_EXT_SYS_INFO_MSK_STATUS = ( 1UL << MBG_EXT_SYS_INFO_BIT_STATUS ), ///< See ::MBG_EXT_SYS_INFO_BIT_STATUS + MBG_EXT_SYS_INFO_MSK_COMMIT_HASH = ( 1UL << MBG_EXT_SYS_INFO_BIT_COMMIT_HASH ), ///< See ::MBG_EXT_SYS_INFO_BIT_COMMIT_HASH + MBG_EXT_SYS_INFO_MSK_OS_NAME = ( 1UL << MBG_EXT_SYS_INFO_BIT_OS_NAME ) ///< See ::MBG_EXT_SYS_INFO_BIT_OS_NAME }; @@ -19268,6 +22560,8 @@ enum MBG_EXT_SYS_INFO_PROC_TYPES MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_SAM3u, MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_SAM3s, MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_STM32F4, + MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_STM32F0, + MBG_EXT_SYS_INFO_PROC_TYPE_CORTEX_STM32F7, N_MBG_EXT_SYS_INFO_PROC_TYPES }; @@ -19277,7 +22571,9 @@ enum MBG_EXT_SYS_INFO_PROC_TYPES "Cortex A9", \ "Cortex SAM3u", \ "Cortex SAM3s", \ - "Cortex STM32F4" \ + "Cortex STM32F4", \ + "Cortex STM32F0", \ + "Cortex STM32F7" \ } enum MBG_EXT_SYS_INFO_FPGA_TYPES @@ -19350,6 +22646,16 @@ enum MBG_EXT_SYS_INFO_OS_TYPES "any" \ } +/* + * OS target information are only relevant for updates. The unique combination + * of CPU and GEN defines a specific update for this kind of hardware (FPGA) and CPU + * model. This means all microSync single boards (MSSB) do have the same + * update file as CPU and hardware (FPGA) are always equal. + * Several variants (power, telecom, etc...) do effect the real board layout + * (connectors, etc..) but never the update file as long as CPU and GEN are + * equal. The variant member only is informational. + */ + /// CPU mainline #define MBG_EXT_SYS_INFO_CPU_MSK 0xff @@ -19368,6 +22674,7 @@ enum MBG_EXT_SYS_INFO_CPUS MBG_EXT_SYS_INFO_CPU_UNKNOWN, MBG_EXT_SYS_INFO_CPU_HPS_USB_HOST, MBG_EXT_SYS_INFO_CPU_HPS_USB_DEVICE, + MBG_EXT_SYS_INFO_CPU_MSSB_USB_HOST, N_MBG_EXT_SYS_INFO_CPUS }; @@ -19375,7 +22682,8 @@ enum MBG_EXT_SYS_INFO_CPUS { \ "Unknown", \ "HPS USB host", \ - "HPS USB device" \ + "HPS USB device", \ + "microSync SB USB host" \ } #define __CPU_CODEC(cpu, gen, var) \ @@ -19383,25 +22691,75 @@ enum MBG_EXT_SYS_INFO_CPUS (((gen) & MBG_EXT_SYS_INFO_CPU_GEN_MSK) << 4) | \ ((var) & MBG_EXT_SYS_INFO_CPU_VAR_MSK) -/// CPU 1 : HPS USB host -/// Gen 1 : HPS100 -/// Var 0 : Base (4xLED, USB to serial, 2xSMA, SFP, RJ-45) -/// Product(s) : microSYNC HSXXX + +/** + * @defgroup group_os_target_codes OS target codes + * + * Status word, associated bit numbers and bit masks indicating + * whether certain data from the GPS satellites are + * available and valid. + * + * These bits defined are set in ::BVAR_STAT if the corresponding + * parameters are NOT valid and complete. + * + * @see ::MBG_EXT_SYS_INFO_CPUS + * @see ::MBG_OS_TARGET_CODE + * + * @{ */ + +/// - CPU 1 : HPS USB host +/// - Gen 1 : HPS100 +/// - Var 0 : Base (4 x LED, USB to serial, 2 x SMA, SFP, RJ-45) +/// - Product(s) : microSync HSXXX #define HPS_USB_HOST_G1_V0 __CPU_CODEC(MBG_EXT_SYS_INFO_CPU_HPS_USB_HOST, 1, 0) -/// CPU 2 : HPS USB device -/// Gen 1 : HPS100 -/// Var 0 : Base (4xLED, USB to serial, 2xSMA, SFP, RJ-45) -/// Product(s) : HPS100 +/// - CPU 2 : HPS USB device +/// - Gen 1 : HPS100 +/// - Var 0 : Base (4 x LED, USB to serial, 2 x SMA, SFP, RJ-45) +/// - Product(s) : HPS100 #define HPS_USB_DEVICE_G1_V0 __CPU_CODEC(MBG_EXT_SYS_INFO_CPU_HPS_USB_DEVICE, 1, 0) -/// CPU 2 : HPS USB device -/// Gen 1 : HPS100 -/// Var 1 : USB lock (4xLED, USB to serial, SMA, USB lock, SFP, RJ-45) -/// Product(s) : SSP100 +/// - CPU 2 : HPS USB device +/// - Gen 1 : HPS100 +/// - Var 1 : USB lock (4 x LED, USB to serial, SMA, USB lock, SFP, RJ-45) +/// - Product(s) : SSP100 #define HPS_USB_DEVICE_G1_V1 __CPU_CODEC(MBG_EXT_SYS_INFO_CPU_HPS_USB_DEVICE, 1, 1) -typedef struct +/// - CPU 3 : microSync SB USB host +/// - Gen 1 : MSSB100 +/// - Var 0 : Base (10 MHz in, PPS in, 10 MHz sine out, 10 MHz out, +/// 4 x LED, RS232, USB to serial, USB, 4 x SFP, 2 x DFK PPO, +/// 2 x Optocoupler) +/// - Product(s) : microSyncHR, microSyncRX +#define MSSB_USB_HOST_G1_V0 __CPU_CODEC(MBG_EXT_SYS_INFO_CPU_MSSB_USB_HOST, 1, 0) + +/** @} defgroup group_os_target_codes */ + + + +/** + * @brief Meinberg OS release year offset. + * + * If ::MBG_EXT_SYS_INFO_MSK_OS_TYPE is set in ::MBG_EXT_SYS_INFO::supp_members + * then ::MBG_OS_YEAR_CONSTANT needs to be added to the major version code of ::MBG_EXT_SYS_INFO::sw_rev + * to get the meinbergOS release year (4 digits), and its minor version represents the release month (2 digits). + */ +#define MBG_OS_YEAR_CONSTANT 2000 + + +/** + * @brief Bit-coded CPU type information. + * + * - Bits 0..3: CPU Type + * - Bits 4..7: CPU generation + * - Bits 8..15: CPU variant (currently unused) + * + * @see @ref group_os_target_codes + */ +typedef uint16_t MBG_OS_TARGET_CODE; + + +typedef struct mbg_ext_sys_info_s { uint32_t supp_members; ///< ::MBG_EXT_SYS_INFO_MSKS @@ -19422,21 +22780,14 @@ typedef struct uint8_t release_candidate;///< Release candidate number (0 = final release) - /* Reserved for future use, currently 0 */ + /// Reserved for future use, currently 0. uint8_t reserved_rev_3[3]; - /// Layout (see ::MBG_EXT_SYS_INFO_CPU_CODECS) - /// os_target:8 8 Bit CPU - /// os_target:4 4 Bit CPU generation - /// os_target:4 4 Bit CPU variant (currently unused) - uint16_t os_target; + MBG_OS_TARGET_CODE os_target; ///< See @ref group_os_target_codes uint16_t reserved_rev_4; - uint32_t reserved_rev_5; - uint32_t reserved_rev_6; - uint32_t reserved_rev_7; - uint32_t reserved_rev_8; - uint32_t reserved_rev_9; + uint32_t commit_hash; + char os_name[16]; } MBG_EXT_SYS_INFO; @@ -19472,6 +22823,97 @@ do \ } +#define MBG_REVISION_RC_DEVEL ((uint8_t)(-1)) +#define MBG_REVISION_RC_DEVEL_STR "devel" + + +/** + * @brief Bits used to define ::MBG_EXT_SYS_STATUS_MSKS + * + * @see ::MBG_EXT_SYS_STATUS_MSKS + */ +enum MBG_EXT_SYS_STATUS_BITS +{ + MBG_EXT_SYS_STATUS_BIT_UPTIME, + MBG_EXT_SYS_STATUS_BIT_FREE_RAM, + MBG_EXT_SYS_STATUS_BIT_LOAD, + MBG_EXT_SYS_STATUS_BIT_FLAGS, + N_MBG_EXT_SYS_STATUS_BITS +}; + +/** + * @brief Bit masks of supported status values in ::MBG_EXT_SYS_STATUS + * + * Used with ::MBG_EXT_SYS_STATUS::supp_members + * + * @see ::MBG_EXT_SYS_STATUS_BITS + */ +enum MBG_EXT_SYS_STATUS_MSKS +{ + MBG_EXT_SYS_STATUS_MSK_UPTIME = ( 1UL << MBG_EXT_SYS_STATUS_BIT_UPTIME ), ///< See ::MBG_EXT_SYS_STATUS_BIT_UPTIME + MBG_EXT_SYS_STATUS_MSK_FREE_RAM = ( 1UL << MBG_EXT_SYS_STATUS_BIT_FREE_RAM ), ///< See ::MBG_EXT_SYS_STATUS_BIT_FREE_RAM + MBG_EXT_SYS_STATUS_MSK_LOAD = ( 1UL << MBG_EXT_SYS_STATUS_BIT_LOAD ), ///< See ::MBG_EXT_SYS_STATUS_BIT_LOAD + MBG_EXT_SYS_STATUS_MSK_FLAGS = ( 1UL << MBG_EXT_SYS_STATUS_BIT_FLAGS ) ///< See ::MBG_EXT_SYS_STATUS_BIT_FLAGS +}; + +/** + * @brief Bits used to define ::MBG_EXT_SYS_STATUS_FLAGS_MSKS + * + * @see ::MBG_EXT_SYS_STATUS_FLAGS_MSKS + */ + +enum MBG_EXT_SYS_STATUS_FLAGS_BITS +{ + MBG_EXT_SYS_STATUS_FLAG_BIT_CONFIG_CHANGED, ///< Indicates if runtime config is different to startup config + N_MBG_EXT_SYS_STATUS_FLAGS_BITS +}; + +/** + * @brief Bit masks of supported status flags in ::MBG_EXT_SYS_STATUS + * + * Used with ::MBG_EXT_SYS_STATUS::supp_flags + * + * @see ::MBG_EXT_SYS_STATUS_FLAGS_BITS + */ + +enum MBG_EXT_SYS_STATUS_FLAGS_MSKS +{ + MBG_EXT_SYS_STATUS_FLAG_MSK_CONFIG_CHANGED = ( 1UL << MBG_EXT_SYS_STATUS_FLAG_BIT_CONFIG_CHANGED ) ///< See ::MBG_EXT_SYS_STATUS_FLAG_BIT_CONFIG_CHANGED +}; + + +typedef struct mbg_ext_sys_status_s +{ + uint32_t supp_members; ///< Indicates, which members of this struct are supported, see ::MBG_EXT_SYS_STATUS_MSKS + uint32_t uptime; ///< Seconds since boot + + uint32_t free_ram; ///< Free RAM in MB + + uint16_t supp_flags; ///< Indicates, which flags are supported see ::MBG_EXT_SYS_STATUS_FLAGS_MSKS + uint16_t flags; ///< See ::MBG_EXT_SYS_STATUS_FLAGS_MSKS + + uint16_t load_1m; ///< Multiplied by 100 since original value is a double + uint16_t load_5m; ///< Multiplied by 100 since original value is a double + uint16_t load_15m; ///< Multiplied by 100 since original value is a double + uint16_t reserved_2; + + uint32_t reserved_3[10]; + +} MBG_EXT_SYS_STATUS; + +#define _mbg_swab_ext_sys_status( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->supp_members ); \ + _mbg_swab32( &(_p)->uptime ); \ + _mbg_swab32( &(_p)->free_ram ); \ + _mbg_swab16( &(_p)->load_1m ); \ + _mbg_swab16( &(_p)->load_5m ); \ + _mbg_swab16( &(_p)->load_15m ); \ +} while ( 0 ) + + + /** @} defgroup group_ext_sys_info */ @@ -19619,7 +23061,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_LICENSE_PTPV2 license; } MBG_LICENSE_PTPV2_IDX; @@ -19686,7 +23128,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_LICENSE_NTP license; } MBG_LICENSE_NTP_IDX; @@ -19751,7 +23193,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_LICENSE_PTPV1 license; } MBG_LICENSE_PTPV1_IDX; @@ -19821,7 +23263,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_LICENSE_TIME_MONITOR license; } MBG_LICENSE_TIME_MONITOR_IDX; @@ -20025,6 +23467,34 @@ enum MBG_TRANSACTION_TYPES */ MBG_TRANSACTION_TYPE_DATABASE, + /* + * PTP next gen transaction is supported, + * if ::MBG_XFEATURE_PTP_NG is set in ::MBG_XFEATURE_BUFFER and + * (if used in a save function) requires at least and as first command: + * ::GPS_PTP_NG_GLB_INFO + * + * Other commands in any order + * + * - ::GPS_PTP_NG_GLB_INFO + * - ::GPS_PTP_NG_TSTAMPER_INFO_IDX + * - ::GPS_PTP_NG_INSTC_INFO_IDX + * - ::GPS_PTP_NG_INSTC_STATUS_IDX + * - ::GPS_PTP_NG_UC_MASTER_INFO_IDX + * - ::GPS_PTP_NG_UC_SLAVE_STATUS_IDX + */ + MBG_TRANSACTION_TYPE_PTP_NG, + + /* + * Sys ref API is supported, if ::MBG_XFEATURE_SYS_REF is set + * in ::MBG_XFEATURE_BUFFER and supports the following commands: + * + * - ::GPS_SYS_REF_LIMITS + * - ::GPS_SYS_REF_GLB_STATUS + * - ::GPS_SYS_REF_SRC_INFO_IDX + * - ::GPS_SYS_REF_SRC_STATUS_IDX + */ + MBG_TRANSACTION_TYPE_SYS_REF, + MAX_MBG_TRANSACTION_TYPES }; @@ -20063,12 +23533,15 @@ enum MBG_IO_PORT_TYPES MBG_IO_PORT_TYPE_MULTI, MBG_IO_PORT_TYPE_POUT, MBG_IO_PORT_TYPE_SWITCH, - MBG_IO_PORT_TYPE_TIMECODE, ///< e.g. IRIG AM/DC, see ::MBG_IO_PORT_SHAPE_LEVELS + MBG_IO_PORT_TYPE_TIMECODE, ///< e.g. IRIG AM/DC, see ::MBG_IO_PORT_SHAPE_LEVELS MBG_IO_PORT_TYPE_LIGHT, MBG_IO_PORT_TYPE_ANTENNA, MBG_IO_PORT_TYPE_UART, MBG_IO_PORT_TYPE_DCF77, MBG_IO_PORT_TYPE_POWER, + MBG_IO_PORT_TYPE_SPST_RELAY, ///< Single-Pole Single-Throw Relay, two terminals which can be connected or disconnected + MBG_IO_PORT_TYPE_SPDT_RELAY, ///< Single-Pole Double-Throw Relay, common terminal connects to either of two others, never connecting to both at the same time + MBG_IO_PORT_TYPE_SYNTHESIZER, N_MBG_IO_PORT_TYPES }; @@ -20105,7 +23578,10 @@ enum MBG_IO_PORT_TYPES "Antenna", \ "UART", \ "DCF77", \ - "Power" \ + "Power", \ + "SPST Relay", \ + "SPDT Relay", \ + "Synthesizer" \ } @@ -20258,6 +23734,7 @@ enum MBG_IO_PORT_CONN_TYPES MBG_IO_PORT_CONN_TYPE_LED_BUTTON, MBG_IO_PORT_CONN_TYPE_QUAD_LED, MBG_IO_PORT_CONN_TYPE_5_PIN_DFK, + MBG_IO_PORT_CONN_TYPE_SINGLE_LED, N_MBG_IO_PORT_CONN_TYPES }; @@ -20289,6 +23766,7 @@ enum MBG_IO_PORT_CONN_TYPES 1, \ 1, \ 4, \ + 1, \ 1 \ } @@ -20322,7 +23800,8 @@ enum MBG_IO_PORT_CONN_TYPES "XHE SPI", \ "LED Button", \ "Quad LED", \ - "DFK 5-Pin" \ + "DFK 5-Pin", \ + "Single LED" \ } @@ -20551,31 +24030,28 @@ enum MBG_IO_PORT_GRP_ROLE_MSKS /** - * @brief Supported members in ::MBG_IO_PORT_ANTENNA_INFO and ::MBG_IO_PORT_ANTENNA_SETTINGS + * @brief Supported members in ::MBG_IO_PORT_ANT_INFO and ::MBG_IO_PORT_ANT_SETTINGS * - * Used with ::MBG_IO_PORT_ANTENNA_INFO::supp_members + * Used with ::MBG_IO_PORT_ANT_INFO::supp_members * */ enum MBG_IO_PORT_ANT_MEMBERS { - /// Supports ::MBG_IO_PORT_ANT_INFO::gnss_info and ::MBG_IO_PORT_ANT_SETTINGS::gnss_settings - MBG_IO_PORT_ANT_MEMBER_GNSS, - /// Supports ::MBG_IO_PORT_ANT_SETTINGS::ant_cab_len - MBG_IO_PORT_ANT_MEMBER_CAB_LEN, - /// Supports ::MBG_IO_PORT_ANT_SETTINGS::ignore_lock - MBG_IO_PORT_ANT_MEMBER_IGN_LOCK, - /// Supports ::MBG_IO_PORT_ANT_SETTINGS::tr_dist - MBG_IO_PORT_ANT_MEMBER_TR_DIST, + MBG_IO_PORT_ANT_MEMBER_GNSS, ///< Supports ::MBG_IO_PORT_ANT_INFO::gnss_info + ///< and ::MBG_IO_PORT_ANT_SETTINGS::gnss_settings. + MBG_IO_PORT_ANT_MEMBER_CAB_LEN, ///< Supports ::MBG_IO_PORT_ANT_SETTINGS::ant_cab_len. + MBG_IO_PORT_ANT_MEMBER_IGN_LOCK, ///< Supports ::MBG_IO_PORT_ANT_SETTINGS::ignore_lock. + MBG_IO_PORT_ANT_MEMBER_TR_DIST, ///< Supports ::MBG_IO_PORT_ANT_SETTINGS::tr_dist. N_MBG_IO_PORT_ANT_MEMBERS }; enum MBG_IO_PORT_ANT_MEMBER_MSKS { - MBG_IO_PORT_ANT_MEMBER_MSK_GNSS = (1UL << MBG_IO_PORT_ANT_MEMBER_GNSS), /// See ::MBG_IO_PORT_ANT_MEMBER_GNSS - MBG_IO_PORT_ANT_MEMBER_MSK_CAB_LEN = (1UL << MBG_IO_PORT_ANT_MEMBER_CAB_LEN), /// See ::MBG_IO_PORT_ANT_MEMBER_CAB_LEN - MBG_IO_PORT_ANT_MEMBER_MSK_IGN_LOCK = (1UL << MBG_IO_PORT_ANT_MEMBER_IGN_LOCK), /// See ::MBG_IO_PORT_ANT_MEMBER_IGN_LOCK - MBG_IO_PORT_ANT_MEMBER_MSK_TR_DIST = (1UL << MBG_IO_PORT_ANT_MEMBER_TR_DIST) /// See ::MBG_IO_PORT_ANT_MEMBER_TR_DIST + MBG_IO_PORT_ANT_MEMBER_MSK_GNSS = ( 1UL << MBG_IO_PORT_ANT_MEMBER_GNSS ), ///< See ::MBG_IO_PORT_ANT_MEMBER_GNSS + MBG_IO_PORT_ANT_MEMBER_MSK_CAB_LEN = ( 1UL << MBG_IO_PORT_ANT_MEMBER_CAB_LEN ), ///< See ::MBG_IO_PORT_ANT_MEMBER_CAB_LEN + MBG_IO_PORT_ANT_MEMBER_MSK_IGN_LOCK = ( 1UL << MBG_IO_PORT_ANT_MEMBER_IGN_LOCK ), ///< See ::MBG_IO_PORT_ANT_MEMBER_IGN_LOCK + MBG_IO_PORT_ANT_MEMBER_MSK_TR_DIST = ( 1UL << MBG_IO_PORT_ANT_MEMBER_TR_DIST ) ///< See ::MBG_IO_PORT_ANT_MEMBER_TR_DIST }; @@ -20613,6 +24089,33 @@ do \ } while ( 0 ) +typedef struct +{ + IRIG_INFO irig_info; + +} MBG_IO_PORT_TIMECODE_INFO; + +#define _mbg_swab_io_port_timecode_info( _p ) \ +do \ +{ \ + _mbg_swab_irig_info( &(_p)->irig_info ); \ +} while ( 0 ) + +typedef struct +{ + IRIG_SETTINGS irig_settings; + MBG_REF_OFFS ref_offs; ///< Fix %UTC offset of incoming IRIG codde, only for inputs. + +} MBG_IO_PORT_TIMECODE_SETTINGS; + +#define _mbg_swab_io_port_timecode_settings( _p ) \ +do \ +{ \ + _mbg_swab_irig_settings( &(_p)->irig_settings ); \ + _mbg_swab_mbg_ref_offs( &(_p)->ref_offs ); \ +} while ( 0 ) + + /** * @brief IO Port Settings Union * @@ -20631,41 +24134,46 @@ typedef union { MBG_GPIO_SETTINGS gpio_settings; POUT_SETTINGS pout_settings; - IRIG_SETTINGS irig_settings; + MBG_IO_PORT_TIMECODE_SETTINGS timecode_settings; MBG_IO_PORT_ANT_SETTINGS ant_settings; PORT_SETTINGS uart_settings; + SYNTH synth_settings; } MBG_IO_PORT_SETTINGS_U; -#define _mbg_swab_io_port_settings_u( _type, _p, _recv ) \ -do \ -{ \ - switch ( (_type) ) \ - { \ - case MBG_IO_PORT_TYPE_GPIO: \ - _mbg_swab_mbg_gpio_settings( &(_p)->gpio_settings, (_recv) ); \ - break; \ - \ - case MBG_IO_PORT_TYPE_POUT: \ - if ( _recv ) \ - _mbg_swab_pout_settings_on_get( &(_p)->pout_settings ); \ - else _mbg_swab_pout_settings_on_set( &(_p)->pout_settings ); \ - break; \ - \ - case MBG_IO_PORT_TYPE_TIMECODE: \ - _mbg_swab_irig_settings( &(_p)->irig_settings ); \ - break; \ - \ - case MBG_IO_PORT_TYPE_ANTENNA: \ - _mbg_swab_io_port_ant_settings( &(_p)->ant_settings ); \ - break; \ - \ - case MBG_IO_PORT_TYPE_UART: \ - _mbg_swab_port_settings( &(_p)->uart_settings ); \ - break; \ - \ - default: break; \ - } \ +#define _mbg_swab_io_port_settings_u( _type, _p, _recv ) \ +do \ +{ \ + switch ( (_type) ) \ + { \ + case MBG_IO_PORT_TYPE_GPIO: \ + _mbg_swab_mbg_gpio_settings( &(_p)->gpio_settings, (_recv) ); \ + break; \ + \ + case MBG_IO_PORT_TYPE_POUT: \ + if ( _recv ) \ + _mbg_swab_pout_settings_on_get( &(_p)->pout_settings ); \ + else _mbg_swab_pout_settings_on_set( &(_p)->pout_settings ); \ + break; \ + \ + case MBG_IO_PORT_TYPE_TIMECODE: \ + _mbg_swab_io_port_timecode_settings( &(_p)->timecode_settings ); \ + break; \ + \ + case MBG_IO_PORT_TYPE_ANTENNA: \ + _mbg_swab_io_port_ant_settings( &(_p)->ant_settings ); \ + break; \ + \ + case MBG_IO_PORT_TYPE_UART: \ + _mbg_swab_port_settings( &(_p)->uart_settings ); \ + break; \ + \ + case MBG_IO_PORT_TYPE_SYNTHESIZER: \ + _mbg_swab_synth( &(_p)->synth_settings ); \ + break; \ + \ + default: break; \ + } \ } while ( 0 ) @@ -20737,7 +24245,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_IO_PORT_SETTINGS settings; } MBG_IO_PORT_SETTINGS_IDX; @@ -20753,35 +24261,43 @@ do \ #define MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE (MBG_IO_PORT_SETTINGS_MIN_SIZE + sizeof( uint32_t )) -#define MBG_IO_PORT_SETTINGS_IDX_SIZES \ -{ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_PPS */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_10MHz */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_2048KHz */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( MBG_GPIO_SETTINGS ), /* MBG_IO_PORT_TYPE_GPIO */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_ETHERNET */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_TERMINAL */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_MULTI */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( POUT_SETTINGS ), /* MBG_IO_PORT_TYPE_POUT */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SWITCH */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( IRIG_SETTINGS ), /* MBG_IO_PORT_TYPE_TIMECODE */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_LIGHT */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_ANT_SETTINGS ), /* MBG_IO_PORT_TYPE_ANTENNA */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( PORT_SETTINGS ), /* MBG_IO_PORT_TYPE_UART */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_DCF77 */ \ - MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE /* MBG_IO_PORT_TYPE_POWER */ \ +#define MBG_IO_PORT_SETTINGS_IDX_SIZES \ +{ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_PPS */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_10MHz */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_2048KHz */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( MBG_GPIO_SETTINGS ), /* MBG_IO_PORT_TYPE_GPIO */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_ETHERNET */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_TERMINAL */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_MULTI */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( POUT_SETTINGS ), /* MBG_IO_PORT_TYPE_POUT */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SWITCH */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_TIMECODE_SETTINGS ), /* MBG_IO_PORT_TYPE_TIMECODE */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_LIGHT */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_ANT_SETTINGS ), /* MBG_IO_PORT_TYPE_ANTENNA */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( PORT_SETTINGS ), /* MBG_IO_PORT_TYPE_UART */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_DCF77 */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_POWER */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SPST_RELAY */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SPDT_RELAY */ \ + MBG_IO_PORT_SETTINGS_IDX_MIN_SIZE + sizeof( SYNTH ) /* MBG_IO_PORT_TYPE_SYNTHESIZER */ \ } enum MBG_IO_PORT_INFO_BITS { - MBG_IO_PORT_INFO_BIT_IS_ALIGNED ///< Indicates, that this port shall be optically aligned to ::MBG_IO_PORT_INFO::align_rule_idx + MBG_IO_PORT_INFO_BIT_IS_ALIGNED, ///< Indicates, that this port shall be optically aligned to ::MBG_IO_PORT_INFO::align_rule_idx + MBG_IO_PORT_INFO_BIT_PASSED_THROUGH_CFG_NOT_SUPP ///< Indicates, that the output signal of this port (defined in (::MBG_IO_PORT_SETTINGS::data) + ///< can not be configured, if ::MBG_IO_PORT_SETTINGS::op_mode is set to ::MBG_IO_PORT_OP_MODE_PASSTHROUGH + }; enum MBG_IO_PORT_INFO_MASKS { - MBG_IO_PORT_INFO_MASK_IS_ALIGNED = ( 1UL << MBG_IO_PORT_INFO_BIT_IS_ALIGNED ) ///< see ::MBG_IO_PORT_INFO_BIT_IS_ALIGNED + MBG_IO_PORT_INFO_MASK_IS_ALIGNED = ( 1UL << MBG_IO_PORT_INFO_BIT_IS_ALIGNED ), ///< See ::MBG_IO_PORT_INFO_BIT_IS_ALIGNED + MBG_IO_PORT_INFO_MASK_PASSED_THROUGH_CFG_NOT_SUPP = ( 1UL << MBG_IO_PORT_INFO_BIT_PASSED_THROUGH_CFG_NOT_SUPP ) ///< See ::MBG_IO_PORT_INFO_BIT_PASSED_THROUGH_CFG_NOT_SUPP + }; @@ -20815,7 +24331,7 @@ typedef struct uint8_t pos_col; ///< Column position of this port uint8_t pos_row; ///< Row position of this port uint8_t rear; ///< Indicates, whether the port is on the front or rear side - uint32_t pols; ///< Pols which are used by this IO port, only if @p conn_type has more than 1 variable pol + uint32_t pols; ///< Pols which are used by this IO port, only if #conn_type has more than 1 variable pol uint32_t flags; ///< Flags, see ::MBG_IO_PORT_INFO_MASKS uint32_t reserved_2[2]; ///< Future use and padding, currently 0 char use_str[MBG_IO_PORT_STR_SIZE]; ///< Informational string for user interface, i.e. "NTP Status LED" @@ -20861,7 +24377,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_IO_PORT_INFO info; } MBG_IO_PORT_INFO_IDX; @@ -20878,23 +24394,26 @@ do \ #define MBG_IO_PORT_INFO_IDX_MIN_SIZE (MBG_IO_PORT_INFO_MIN_SIZE + sizeof( uint32_t )) -#define MBG_IO_PORT_INFO_IDX_SIZES \ -{ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_PPS */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_10MHz */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_2048KHz */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( MBG_GPIO_SETTINGS ), /* MBG_IO_PORT_TYPE_GPIO */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_ETHERNET */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_TERMINAL */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_MULTI */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( POUT_SETTINGS ), /* MBG_IO_PORT_TYPE_POUT */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SWITCH */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( IRIG_SETTINGS ), /* MBG_IO_PORT_TYPE_TIMECODE */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_LIGHT */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_ANT_SETTINGS ), /* MBG_IO_PORT_TYPE_ANTENNA */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( PORT_SETTINGS ), /* MBG_IO_PORT_TYPE_UART */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_DCF77 */ \ - MBG_IO_PORT_INFO_IDX_MIN_SIZE /* MBG_IO_PORT_TYPE_POWER */ \ +#define MBG_IO_PORT_INFO_IDX_SIZES \ +{ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_PPS */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_10MHz */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_2048KHz */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( MBG_GPIO_SETTINGS ), /* MBG_IO_PORT_TYPE_GPIO */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_ETHERNET */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_TERMINAL */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_MULTI */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( POUT_SETTINGS ), /* MBG_IO_PORT_TYPE_POUT */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SWITCH */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_TIMECODE_SETTINGS ), /* MBG_IO_PORT_TYPE_TIMECODE */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_LIGHT */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_ANT_SETTINGS ), /* MBG_IO_PORT_TYPE_ANTENNA */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( PORT_SETTINGS ), /* MBG_IO_PORT_TYPE_UART */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_DCF77 */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_POWER */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SPST_RELAY */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SPDT_RELAY */ \ + MBG_IO_PORT_INFO_IDX_MIN_SIZE + sizeof( SYNTH ) /* MBG_IO_PORT_TYPE_SYNTHESIZER */ \ } @@ -20917,7 +24436,7 @@ typedef union { MBG_GPIO_LIMITS gpio_limits; POUT_INFO pout_info; - IRIG_INFO irig_info; + MBG_IO_PORT_TIMECODE_INFO timecode_info; PORT_INFO uart_info; MBG_IO_PORT_ANT_INFO ant_info; @@ -20937,7 +24456,7 @@ do \ break; \ \ case MBG_IO_PORT_TYPE_TIMECODE: \ - _mbg_swab_irig_info( &(_p)->irig_info ); \ + _mbg_swab_io_port_timecode_info( &(_p)->timecode_info ); \ break; \ \ case MBG_IO_PORT_TYPE_ANTENNA: \ @@ -20976,7 +24495,8 @@ typedef struct uint16_t port_type; ///< See ::MBG_IO_PORT_TYPES uint16_t reserved_1; ///< Future use and padding, currently 0 uint8_t supp_dirs; ///< See ::MBG_IO_PORT_DIR_MSKS - uint8_t pt_idx; ///< index of the port types (e.g. 0 for PPO0, 1 for PPO1, ...) + uint8_t pt_idx; ///< Index for this specific port type (e.g. 0 for PPO0, 1 for PPO1) + ///< especially interesting for passed through ports uint8_t shape_level; ///< Signal shape/level, see ::MBG_IO_PORT_SHAPE_LEVELS uint8_t reserved_2[1]; ///< Future use and padding, currently 0 uint32_t supp_srcs; ///< See ::MBG_IO_PORT_SRC_MSKS @@ -21006,23 +24526,26 @@ do \ #define MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE (MBG_IO_PORT_TYPE_INFO_MIN_SIZE + 2 * sizeof( uint32_t )) -#define MBG_IO_PORT_TYPE_INFO_IDX_SIZES \ -{ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_PPS */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_10MHz */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_2048KHz */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( MBG_GPIO_LIMITS ), /* MBG_IO_PORT_TYPE_GPIO */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_ETHERNET */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_TERMINAL */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_MULTI */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( POUT_INFO ), /* MBG_IO_PORT_TYPE_POUT */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SWITCH */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( IRIG_INFO ), /* MBG_IO_PORT_TYPE_TIMECODE */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_LIGHT */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_ANT_INFO ), /* MBG_IO_PORT_TYPE_ANTENNA */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( PORT_INFO ), /* MBG_IO_PORT_TYPE_UART */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_DCF77 */ \ - MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE /* MBG_IO_PORT_TYPE_POWER */ \ +#define MBG_IO_PORT_TYPE_INFO_IDX_SIZES \ +{ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_PPS */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_10MHz */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_2048KHz */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( MBG_GPIO_LIMITS ), /* MBG_IO_PORT_TYPE_GPIO */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_ETHERNET */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_TERMINAL */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_MULTI */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( POUT_INFO ), /* MBG_IO_PORT_TYPE_POUT */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SWITCH */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_TIMECODE_INFO ), /* MBG_IO_PORT_TYPE_TIMECODE */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_LIGHT */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( MBG_IO_PORT_ANT_INFO ), /* MBG_IO_PORT_TYPE_ANTENNA */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE + sizeof( PORT_INFO ), /* MBG_IO_PORT_TYPE_UART */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_DCF77 */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_POWER */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SPST_RELAY */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE, /* MBG_IO_PORT_TYPE_SPDT_RELAY */ \ + MBG_IO_PORT_TYPE_INFO_IDX_MIN_SIZE /* MBG_IO_PORT_TYPE_SYNTHESIZER */ \ } @@ -21065,13 +24588,13 @@ do \ /** - * @brief Port Type Status Bits + * @brief Port Status Bits * */ enum MBG_IO_PORT_STATUS_BITS { MBG_IO_PORT_STATUS_BIT_DISABLED, ///< See ::MBG_IO_PORT_OP_MODE_DISABLED. Other bits should be 0 in this case - MBG_IO_PORT_STATUS_BIT_CARRIER_DETECTED, ///< Port has physical carrier connection (e.g. BNC cable in BPE's case) + MBG_IO_PORT_STATUS_BIT_CARRIER_DETECTED, ///< Port has physical carrier connection (e.g. BNC cable in case of BPE) MBG_IO_PORT_STATUS_BIT_INPUT_SIGNAL_NEVER_AVAIL, ///< Input signal has NEVER been avail MBG_IO_PORT_STATUS_BIT_INPUT_SIGNAL_AVAIL, ///< Input signal is avail right now MBG_IO_PORT_STATUS_BIT_INPUT_SIGNAL_LOST, ///< Input signal is currently not avail, but has been avail before @@ -21080,6 +24603,8 @@ enum MBG_IO_PORT_STATUS_BITS MBG_IO_PORT_STATUS_BIT_LIGHT_GREEN, ///< LED shows green light MBG_IO_PORT_STATUS_BIT_LIGHT_BLUE, ///< LED shows blue light MBG_IO_PORT_STATUS_BIT_LIGHT_YELLOW, ///< LED shows yellow light + MBG_IO_PORT_STATUS_BIT_TIME_VERIFYING, ///< Received time gets verified + MBG_IO_PORT_STATUS_BIT_TELEGRAM_INCONSISTENT, ///< Received time telegram is inconsistent N_MBG_IO_PORT_STATUS_BITS }; @@ -21103,7 +24628,9 @@ enum MBG_IO_PORT_STATUS_BITS "Red", \ "Green", \ "Blue", \ - "Yellow" \ + "Yellow", \ + "Time gets verified", \ + "Telegram inconsistent" \ } @@ -21129,7 +24656,7 @@ enum MBG_IO_PORT_STATUS_BITS * @see ::_set_io_port_status_bit * @see ::check_feat_supp_byte_array */ -typedef struct +typedef struct mbg_io_port_status_buffer_s { uint8_t b[MAX_IO_PORT_STATUS_BYTES]; @@ -21167,7 +24694,7 @@ typedef struct /** - * @brief IO Port Type Status + * @brief IO Port Status * * @see @ref group_io_ports * @see ::MBG_IO_PORT_SETTINGS_U @@ -21206,7 +24733,7 @@ do \ /** - * @brief IO Port Type Status + * @brief IO Port Status * * @see @ref group_io_ports * @see ::MBG_IO_PORT_SETTINGS_U @@ -21218,13 +24745,13 @@ do \ * @see ::MBG_IO_PORT_TYPE_INFO_IDX * @see ::MBG_IO_PORT_STATUS * - * Indexes from 0..::MBG_IO_PORT_INFO::num_types - 1 are used + * Indexes from 0..::MBG_IO_PORT_LIMITS::num_ports - 1 are used * to query ::MBG_IO_PORT_TYPE_INFO wrapped in ::MBG_IO_PORT_TYPE_INFO_IDX. * */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_IO_PORT_STATUS status; } MBG_IO_PORT_STATUS_IDX; @@ -21259,6 +24786,7 @@ enum MBG_MONITORING_TYPES MBG_MONITORING_TYPE_SNMP, MBG_MONITORING_TYPE_EMAIL, MBG_MONITORING_TYPE_SYSLOG, + MBG_MONITORING_TYPE_EVENTS, N_MBG_MONITORING_TYPES }; @@ -21266,14 +24794,16 @@ enum MBG_MONITORING_TYPES { \ "SNMP", \ "Email", \ - "Syslog" \ + "Syslog", \ + "Events" \ } enum MBG_MONITORING_TYPE_MSKS { MBG_MONITORING_TYPE_MSK_SNMP = (1UL << MBG_MONITORING_TYPE_SNMP), MBG_MONITORING_TYPE_MSK_EMAIL = (1UL << MBG_MONITORING_TYPE_EMAIL), - MBG_MONITORING_TYPE_MSK_SYSLOG = (1UL << MBG_MONITORING_TYPE_SYSLOG) + MBG_MONITORING_TYPE_MSK_SYSLOG = (1UL << MBG_MONITORING_TYPE_SYSLOG), + MBG_MONITORING_TYPE_MSK_EVENTS = (1UL << MBG_MONITORING_TYPE_EVENTS) }; @@ -21281,7 +24811,7 @@ enum MBG_MONITORING_TYPE_MSKS typedef struct { uint16_t supp_types; ///< See ::MBG_MONITORING_TYPE_MSKS - uint16_t supp_num_events; ///< Supported number of events. See ::MBG_EVENT_TYPES + uint16_t reserved_1; uint32_t reserved_2[3]; } MBG_MONITORING_LIMITS; @@ -21290,7 +24820,6 @@ typedef struct do \ { \ _mbg_swab16( &(_p)->supp_types ); \ - _mbg_swab16( &(_p)->supp_num_events ); \ } while ( 0 ) @@ -21324,6 +24853,7 @@ enum MBG_SNMP_FLAGS { MBG_SNMP_SYSTEM_USER, MBG_SNMP_ADD_CONF, ///< Supports additional SNMP configuration (i.e. via script) + MBG_SNMP_READ_ONLY, ///< Read/Write is not supported, SNMP can be used for monitoring, only N_MBG_SNMP_FLAGS }; @@ -21331,14 +24861,16 @@ enum MBG_SNMP_FLAGS #define MBG_SNMP_FLAG_STRS \ { \ "System user", \ - "Additional config" \ + "Additional config", \ + "Read-Only" \ } enum MBG_SNMP_FLAG_MSKS { MBG_SNMP_SYSTEM_USER_MSK = ( 1UL << MBG_SNMP_SYSTEM_USER ), - MBG_SNMP_ADD_CONF_MSK = ( 1UL << MBG_SNMP_ADD_CONF ) ///< see ::MBG_SNMP_ADD_CONF + MBG_SNMP_ADD_CONF_MSK = ( 1UL << MBG_SNMP_ADD_CONF ), ///< See ::MBG_SNMP_ADD_CONF + MBG_SNMP_READ_ONLY_MSK = ( 1UL << MBG_SNMP_READ_ONLY ) ///< See ::MBG_SNMP_READ_ONLY }; @@ -21374,7 +24906,7 @@ do \ -typedef struct +typedef struct mbg_snmp_glb_info_s { MBG_SNMP_GLB_SETTINGS settings; uint8_t supp_versions; ///< See ::MBG_SNMP_VERSION_MSKS @@ -21383,8 +24915,7 @@ typedef struct uint8_t max_v12_trap_receivers; ///< Only valid if ::MBG_SNMP_GLB_INFO::supp_versions contains ::MBG_SNMP_VERSION_MSK_V1 or ::MBG_SNMP_VERSION_MSK_V2c uint8_t max_v3_trap_receivers; ///< Only valid if ::MBG_SNMP_GLB_INFO::supp_versions contains ::MBG_SNMP_VERSION_MSK_V3 uint8_t reserved_1[1]; - uint16_t supp_flags; ///< See ::MBG_SNMP_FLAG_MSKS - /// MBG_SNMP_SYSTEM_USER_MSK is only relevant for SNMPv3 + uint16_t supp_flags; ///< See ::MBG_SNMP_FLAG_MSKS. ::MBG_SNMP_SYSTEM_USER_MSK is only relevant for SNMPv3. uint32_t reserved_2[2]; } MBG_SNMP_GLB_INFO; @@ -21433,7 +24964,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V12_SETTINGS settings; } MBG_SNMP_V12_SETTINGS_IDX; @@ -21447,7 +24978,7 @@ do \ -typedef struct +typedef struct mbg_snmp_v12_info_s { MBG_SNMP_V12_SETTINGS settings; uint32_t reserved_1[4]; @@ -21464,7 +24995,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V12_INFO info; } MBG_SNMP_V12_INFO_IDX; @@ -21504,7 +25035,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V12_TRAP_SETTINGS settings; } MBG_SNMP_V12_TRAP_SETTINGS_IDX; @@ -21518,7 +25049,7 @@ do \ -typedef struct +typedef struct mbg_snmp_v12_trap_info_s { MBG_SNMP_V12_TRAP_SETTINGS settings; uint32_t reserved_1[4]; @@ -21535,7 +25066,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V12_TRAP_INFO info; } MBG_SNMP_V12_TRAP_INFO_IDX; @@ -21636,7 +25167,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V3_SETTINGS settings; } MBG_SNMP_V3_SETTINGS_IDX; @@ -21650,7 +25181,7 @@ do \ -typedef struct +typedef struct mbg_snmp_v3_info_s { MBG_SNMP_V3_SETTINGS settings; uint32_t reserved_1[4]; @@ -21667,7 +25198,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V3_INFO info; } MBG_SNMP_V3_INFO_IDX; @@ -21705,7 +25236,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V3_TRAP_SETTINGS settings; } MBG_SNMP_V3_TRAP_SETTINGS_IDX; @@ -21719,7 +25250,7 @@ do \ -typedef struct +typedef struct mbg_snmp_v3_trap_info_s { MBG_SNMP_V3_TRAP_SETTINGS settings; uint32_t reserved_1[4]; @@ -21736,7 +25267,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SNMP_V3_TRAP_INFO info; } MBG_SNMP_V3_TRAP_INFO_IDX; @@ -21750,19 +25281,149 @@ do \ +/* If ::MBG_MONITORING_TYPE_MSK_EVENTS is set in ::MBG_MONITORING_LIMITS::supp_types */ + + +enum MBG_EVENT_STR_FMTS +{ + MBG_EVENT_STR_FMT_JSON, + N_MBG_EVENT_STR_FMTS +}; + + +enum MBG_EVENT_STR_FMT_MSKS +{ + MBG_EVENT_STR_FMT_JSON_MSK = (1UL << MBG_EVENT_STR_FMT_JSON) +}; + + +#define MBG_EVENT_STR_FMT_STRS \ +{ \ + "JSON" \ +} + + +enum MBG_EVENT_DEV_IDS +{ + MBG_EVENT_DEV_ID_NONE, ///< No identifier added to the events + MBG_EVENT_DEV_ID_ALIAS, ///< Add alias from MBG_EVENT_GLB_SETTINGS as identifier to all events + MBG_EVENT_DEV_ID_SERNUM, ///< Add serial number as identifier to all events + N_MBG_EVENT_DEV_IDS +}; + + +enum MBG_EVENT_DEV_ID_MSKS +{ + MBG_EVENT_DEV_ID_NONE_MSK = ( 1UL << MBG_EVENT_DEV_ID_NONE ), ///< See ::MBG_EVENT_DEV_ID_NONE + MBG_EVENT_DEV_ID_ALIAS_MSK = ( 1UL << MBG_EVENT_DEV_ID_ALIAS ), ///< See ::MBG_EVENT_DEV_ID_ALIAS + MBG_EVENT_DEV_ID_SERNUM_MSK = ( 1UL << MBG_EVENT_DEV_ID_SERNUM ) ///< See ::MBG_EVENT_DEV_ID_SERNUM +}; + + +#define MBG_EVENT_DEV_ID_STRS \ +{ \ + "None", \ + "Alias", \ + "Serial Number" \ +} + + +enum MBG_EVENT_GLB_FLAGS +{ + MBG_EVENT_GLB_FLAG_FUE, ///< Forward unknown events. This is not relevant for mbgdevman + ///< that always gets all events. It's important for syslog, SNMP, email, etc.. + ///< to avoid that alarming systems react furious to unknown events. + N_MBG_EVENT_GLB_FLAGS +}; + + +enum MBG_EVENT_GLB_FLAG_MSKS +{ + MBG_EVENT_GLB_FLAG_FUE_MSK = ( 1UL << MBG_EVENT_GLB_FLAG_FUE ) ///< See ::MBG_EVENT_GLB_FLAG_FUE +}; + + +typedef struct +{ + uint8_t format; ///< See ::MBG_EVENT_STR_FMTS + uint8_t dev_id; ///< See ::MBG_EVENT_DEV_IDS + uint8_t flags; ///< See ::MBG_EVENT_GLB_FLAG_MSKS + uint8_t reserved_1[5]; + + char alias[16]; ///< Alias of this device, see ::MBG_EVENT_DEV_ID_ALIAS + + uint32_t reserved_3[4]; + +} MBG_EVENT_GLB_SETTINGS; + +#define _mbg_swab_event_glb_settings( _p ) \ +do \ +{ \ +} while ( 0 ) + + +typedef struct mbg_event_glb_info_s +{ + MBG_EVENT_GLB_SETTINGS settings; ///< See ::MBG_EVENT_GLB_SETTINGS + + uint16_t num_events; ///< Supported number of events. See ::MBG_EVENT_TYPES + uint16_t supp_formats; ///< Supported format (::MBG_EVENT_STR_FMTS) in ::MBG_EVENT_STATUS::data + uint16_t supp_dev_ids; ///< Supported dev ids (::MBG_EVENT_DEV_IDS) that can be added to each ::MBG_EVENT_STATUS::data + uint8_t supp_flags; ///< Supported global settings flags. See ::MBG_EVENT_GLB_FLAG_MSKS + uint8_t reserved_1; + + uint32_t reserved_2[3]; + +} MBG_EVENT_GLB_INFO; + +#define _mbg_swab_event_glb_info( _p ) \ +do \ +{ \ + _mbg_swab_event_glb_settings( (_p) ); \ + _mbg_swab16( &(_p)->num_events ); \ + _mbg_swab16( &(_p)->supp_formats ); \ + _mbg_swab16( &(_p)->supp_dev_ids ); \ +} while ( 0 ) + + + enum MBG_EVENT_TYPES { MBG_EVENT_TYPE_NTP_STATE, MBG_EVENT_TYPE_HEARTBEAT, MBG_EVENT_TYPE_RECEIVER_STATE, + MBG_EVENT_TYPE_LEAP_SECOND, + MBG_EVENT_TYPE_PTP_STATE, + MBG_EVENT_TYPE_SYSREF_MASTER_REF, + MBG_EVENT_TYPE_PS_STATE, + MBG_EVENT_TYPE_REBOOT, + MBG_EVENT_TYPE_MEMORY, + MBG_EVENT_TYPE_CPU_LOAD, + MBG_EVENT_TYPE_TEMPERATURE, + MBG_EVENT_TYPE_NW_LINK, + MBG_EVENT_TYPE_CONFIG, + MBG_EVENT_TYPE_LOGIN, + MBG_EVENT_TYPE_WATCHDOG, N_MBG_EVENT_TYPES }; -#define MBG_EVENT_TYPE_STRS \ -{ \ - "NTP state", \ - "Heartbeat", \ - "Receiver state" \ +#define MBG_EVENT_TYPE_STRS \ +{ \ + "NTP state", \ + "Heartbeat", \ + "Receiver state", \ + "Leap second", \ + "PTP state", \ + "Master reference changed", \ + "Power supply state", \ + "Reboot", \ + "Memory", \ + "CPU load", \ + "Temperature", \ + "Network link", \ + "Configuration", \ + "Login", \ + "Watchdog" \ } @@ -21811,7 +25472,7 @@ do \ */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_EVENT_SETTINGS settings; } MBG_EVENT_SETTINGS_IDX; @@ -21864,28 +25525,31 @@ enum MBG_EVENT_SUPP_FLAG_MSKS #define MBG_OWN_EVENT_SLOT_TYPE 0xFF ///< See ::MBG_EVENT_INFO::slot_type #define MBG_OWN_EVENT_SLOT_TYPE_ID 0xFF ///< See ::MBG_EVENT_INFO::slot_type_id #define MBG_INV_EVENT_PORT 0xFF ///< See ::MBG_EVENT_INFO::port_idx +#define MBG_INV_EVENT_INST 0xFF ///< See ::MBG_EVENT_INFO::inst_idx /** @} defgroup group_mbg_event_info_indexes */ - typedef struct { - MBG_EVENT_SETTINGS settings; ///< See ::MBG_EVENT_SETTINGS - uint16_t type; ///< See ::MBG_EVENT_TYPES - uint8_t chassis_idx; ///< Index of the associated IMS chassis, or ::MBG_OWN_EVENT_CHASSIS - uint8_t slot_type; ///< See ::XBP_NODE_INFO::slot_type, or ::MBG_OWN_EVENT_SLOT_TYPE - uint8_t port_idx; ///< Index of the associated IO port, or ::MBG_INV_EVENT_PORT - uint8_t value_type; ///< See ::MBG_EVENT_VALUE_TYPES - uint16_t value_dict_entries; ///< Number of entries in value dictionary, see ::MBG_EVENT_VALUE_IDX + MBG_EVENT_SETTINGS settings; ///< See ::MBG_EVENT_SETTINGS + uint16_t type; ///< See ::MBG_EVENT_TYPES + uint8_t chassis_idx; ///< Index of the associated IMS chassis, or ::MBG_OWN_EVENT_CHASSIS + uint8_t slot_type; ///< See ::XBP_NODE_INFO::slot_type, or ::MBG_OWN_EVENT_SLOT_TYPE + uint8_t port_idx; ///< Index of the associated IO port, or ::MBG_INV_EVENT_PORT + uint8_t reserved_1; + uint16_t reserved_2; - uint8_t slot_type_id; ///< See ::XBP_NODE_INFO::slot_type_id, or ::MBG_OWN_EVENT_SLOT_TYPE_ID - uint8_t reserved_1; ///< Future use - uint16_t supp_flags; ///< See ::MBG_EVENT_SUPP_FLAG_MSKS - uint16_t supp_triggers; ///< See ::MBG_MONITORING_TYPE_MSKS - uint16_t reserved_2; ///< Future use + uint8_t slot_type_id; ///< See ::XBP_NODE_INFO::slot_type_id, or ::MBG_OWN_EVENT_SLOT_TYPE_ID + uint8_t inst_idx; ///< Instance index since one port might have multiple instances of the same type. + ///< For example, PTP is hopefully capable to do so one day. + ///< Use ::MBG_INV_EVENT_INST to not show the instance number explicitly, + ///< e.g. you only have got one instance. + uint16_t supp_flags; ///< See ::MBG_EVENT_SUPP_FLAG_MSKS + uint16_t supp_triggers; ///< See ::MBG_MONITORING_TYPE_MSKS + uint16_t reserved_3; ///< Future use - uint32_t reserved_3[6]; + uint32_t reserved_4[8]; } MBG_EVENT_INFO; @@ -21897,7 +25561,6 @@ do \ _mbg_swab16( &(_p)->value_dict_entries ); \ _mbg_swab16( &(_p)->supp_flags ); \ _mbg_swab16( &(_p)->supp_triggers ); \ - _mbg_swab16( &(_p)->flags ); \ } while ( 0 ) @@ -21907,14 +25570,14 @@ do \ * * @note idx represents the event type, see ::MBG_EVENT_TYPES * Before requesting the struct, its availability should be checked - * in ::MBG_MONITORING_LIMITS::supp_num_events. + * in ::MBG_EVENT_GLB_INFO::num_events. * * @see ::MBG_EVENT_TYPES - * @see ::MBG_MONITORING_LIMITS + * @see ::MBG_EVENT_GLB_INFO */ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_EVENT_INFO info; } MBG_EVENT_INFO_IDX; @@ -21927,187 +25590,39 @@ do \ } while ( 0 ) -enum MBG_EVENT_VALUE_TYPES -{ - MBG_EVENT_VALUE_TYPE_NONE, ///< Sounds stupid but think of heartbeat - MBG_EVENT_VALUE_TYPE_INTEGER32, - MBG_EVENT_VALUE_TYPE_UNSIGNED32, - MBG_EVENT_VALUE_TYPE_STRING, - MBG_EVENT_VALUE_TYPE_IRANGE, - MBG_EVENT_VALUE_TYPE_URANGE, - MBG_EVENT_VALUE_TYPE_SELECTION, - N_MBG_EVENT_VALUE_TYPES -}; - - - -#define MBG_EVENT_VALUE_TYPE_STRS \ -{ \ - "None", \ - "Signed32", \ - "Unsigned32", \ - "String", \ - "Signed range", \ - "Unsigned range", \ - "Selection" \ -} - - - -typedef char MBG_EVENT_STR[64]; - - - -typedef struct -{ - int32_t value; - MBG_EVENT_STR string; - -} MBG_EVENT_VALUE_SELECTION; - -#define _mbg_swab_event_value_selection( _p ) \ -do \ -{ \ - _mbg_swab32( &(_p)->value ); \ -} while ( 0 ) - - - -typedef struct -{ - int32_t min; - int32_t max; - -} MBG_EVENT_VALUE_IRANGE; - -#define _mbg_swab_event_value_irange( _p ) \ -do \ -{ \ - _mbg_swab32( &(_p)->min ); \ - _mbg_swab32( &(_p)->max ); \ -} while ( 0 ) - - - -typedef struct -{ - uint32_t min; - uint32_t max; - -} MBG_EVENT_VALUE_URANGE; - -#define _mbg_swab_event_value_urange( _p ) \ -do \ -{ \ - _mbg_swab32( &(_p)->min ); \ - _mbg_swab32( &(_p)->max ); \ -} while ( 0 ) - - -/* - * Maximum size is limited to 68 bytes -> MBG_EVENT_VALUE_SELECTION - * Don't enlarge it due to compatibility reasons!! - */ -typedef union -{ - MBG_EVENT_VALUE_SELECTION selection; - MBG_EVENT_VALUE_IRANGE irange; - MBG_EVENT_VALUE_URANGE urange; - -} MBG_EVENT_VALUE; - -#define _mbg_swab_event_value( _p, _type ) \ -do \ -{ \ - switch ( (_type) ) \ - { \ - case MBG_EVENT_VALUE_TYPE_SELECTION: \ - _mbg_swab_event_value_selection( &(_p)->selection ); \ - break; \ - \ - case MBG_EVENT_VALUE_TYPE_IRANGE: \ - _mbg_swab_event_value_irange( &(_p)->irange ); \ - break; \ - \ - case MBG_EVENT_VALUE_TYPE_URANGE: \ - _mbg_swab_event_value_urange( &(_p)->urange ); \ - break; \ - \ - default: \ - break; \ - } \ -} while ( 0 ) - - +#define MBG_EVT_ST_MAX_DATA_LEN 480 typedef struct { - uint32_t idx; - MBG_EVENT_VALUE value; + uint32_t last_changed; ///< Unix timestamp when this event state has been changed + uint32_t reserved_1[2]; ///< Future use + uint8_t severity; ///< See ::MBG_EVENT_SEVERITIES + uint8_t reserved_2[3]; ///< Future use -} MBG_EVENT_VALUE_IDX; - -#define _mbg_swab_event_value_idx( _p, _type ) \ -do \ -{ \ - _mbg_swab32( &(_p)->idx ); \ - _mbg_swab_event_value( &(_p)->value, (_type) ); \ -} while ( 0 ) - - -/* - * Maximum union size is limited to 64 bytes -> MBG_EVENT_STR - * Don't enlarge the union due to compatibility reasons!! - */ -typedef struct -{ - uint32_t last_changed; ///< Unix timestamp when this event state has been changed - uint32_t reserved_1[3]; ///< Future use - uint8_t severity; ///< See ::MBG_EVENT_SEVERITIES - uint8_t reserved_2[3]; ///< Future use - union - { - int32_t i32; - uint32_t u32; - MBG_EVENT_STR string; - - } u; + uint8_t data[MBG_EVT_ST_MAX_DATA_LEN]; ///< The event value in the configured format, see ::MBG_EVENT_GLB_SETTINGS::format } MBG_EVENT_STATUS; -#define _mbg_swab_event_status( _p, _type ) \ -do \ -{ \ - _mbg_swab32( &(_p)->last_changed ); \ - switch ( (_type) ) \ - { \ - case MBG_EVENT_VALUE_TYPE_INTEGER32: \ - _mbg_swab32( &(_p)->u.i32 ); \ - break; \ - \ - case MBG_EVENT_VALUE_TYPE_UNSIGNED32: \ - _mbg_swab32( &(_p)->u.u32 ); \ - break; \ - \ - default: \ - break; \ - } \ +#define _mbg_swab_event_status( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->last_changed ); \ } while ( 0 ) typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_EVENT_STATUS status; } MBG_EVENT_STATUS_IDX; -#define _mbg_swab_event_status_idx( _p, _type ) \ -do \ -{ \ - _mbg_swab32( &(_p)->idx ); \ - _mbg_swab_event_status( &(_p)->status, (_type) ); \ +#define _mbg_swab_event_status_idx( _p ) \ +do \ +{ \ + _mbg_swab32( &(_p)->idx ); \ + _mbg_swab_event_status( &(_p)->status ); \ } while ( 0 ) @@ -22160,7 +25675,7 @@ do \ } while ( 0 ) -typedef struct +typedef struct mbg_syslog_glb_info_s { MBG_SYSLOG_GLB_SETTINGS settings; ///< MBG_SYSLOG_GLB_SETTINGS @@ -22204,7 +25719,7 @@ do \ typedef struct { MBG_SYSLOG_SETTINGS settings; - uint32_t idx; + MBG_MSG_IDX_32 idx; } MBG_SYSLOG_SETTINGS_IDX; @@ -22233,7 +25748,7 @@ do \ typedef struct { MBG_SYSLOG_INFO info; ///< See ::MBG_SYSLOG_INFO - uint32_t idx; + MBG_MSG_IDX_32 idx; } MBG_SYSLOG_INFO_IDX; @@ -22254,11 +25769,11 @@ do \ * @note This structure and its definitions are only supported by a device * if ::MBG_XFEATURE_TAINTED_CFG is set in the extended device features. * Feature has a list of configuration counters for several sub-features. - * Each time a sub-feature's config changes, its counter in this structure - * is increased to indicate a config change. Thus, software can read this - * structure and request the changed config. Also use it for push notifications. + * Each time the config of a sub-feature changes, its counter in this structure + * is increased to indicate the config change. Thus, software can read this + * structure and request the changed config. Also used for push notifications. * - * TODO: Add proper Doxygen documentation + * TODO Add proper Doxygen documentation * * @{ */ @@ -22298,6 +25813,9 @@ enum MBG_TAINTED_CFGS MBG_TAINTED_CFG_TZDL, MBG_TAINTED_CFG_CABLE_LENGTH, MBG_TAINTED_CFG_DATABASE, + MBG_TAINTED_CFG_PTP_NG, + MBG_TAINTED_CFG_SYS_REF, + MBG_TAINTED_CFG_TR_DIST, N_MBG_TAINTED_CFGS }; @@ -22367,7 +25885,7 @@ do \ * * @{ */ -typedef enum +typedef enum _mbg_user_perms { USER_PERM_SYSTEM, ///< permission to read/write system related structures ///< ::GPS_SCU_STAT @@ -22404,6 +25922,10 @@ typedef enum ///< ::GPS_XMR_HOLDOVER_STATUS ///< ::GPS_XMR_STATS_IDX ///< ::GPS_XMR_METRICS_IDX + ///< ::GPS_SYS_REF_LIMITS + ///< ::GPS_SYS_REF_GLB_STATUS + ///< ::GPS_SYS_REF_SRC_INFO_IDX + ///< ::GPS_SYS_REF_SRC_STATUS_IDX USER_PERM_SERIAL, ///< permission to read/write serial port related structures ///< ::GPS_PORT_INFO_IDX ///< ::GPS_STR_TYPE_INFO_IDX @@ -22440,7 +25962,6 @@ typedef enum ///< ::GPS_SNMP_V3_TRAP_IDX ///< ::GPS_EVENT_IDX ///< ::GPS_EVENT_STAT_IDX - ///< ::GPS_EVENT_VALUE_IDX ///< ::GPS_NUM_EVT_LOG_ENTRIES ///< ::GPS_FIRST_EVT_LOG_ENTRY ///< ::GPS_NEXT_EVT_LOG_ENTRY @@ -22492,6 +26013,11 @@ typedef enum ///< ::GPS_PTP_V1_PARENT_DS ///< ::GPS_PTP_V1_TIME_PROP_DS ///< ::GPS_PTP_V1_PORT_DS_IDX + ///< ::GPS_PTP_NG_GLB_INFO + ///< ::GPS_PTP_NG_TSTAMPER_INFO_IDX + ///< ::GPS_PTP_NG_INSTC_INFO_IDX + ///< ::GPS_PTP_NG_INSTC_STATUS_IDX + ///< ::GPS_PTP_NG_UC_MASTER_INFO_IDX USER_PERM_FDM, ///< permission to read/write FDM related structures ///< ::GPS_FDM_LIMITS ///< ::GPS_FDM_INFO @@ -22521,10 +26047,10 @@ typedef enum ///< ::MBG_TLV_FEAT_TYPE_UFU ///< ::MBG_TLV_FEAT_TYPE_FW_ROLLBACK USER_PERM_SERVICE, ///< permission to read/write service related structures - ///< ::GPS_SRV_MGMT_INFO - ///< ::GPS_SRV_INFO_IDX - ///< ::GPS_SRV_STATUS_IDX - ///< ::GPS_SRV_CTL_IDX + ///< ::GPS_SVC_MGMT_INFO + ///< ::GPS_SVC_INFO_IDX + ///< ::GPS_SVC_STATUS_IDX + ///< ::GPS_SVC_CTL_IDX USER_PERM_DATABASE, ///< permission to read/write database related structures ///< ::GPS_DATABASE_GLB_INFO ///< ::GPS_DATABASE_INFO_IDX @@ -22559,7 +26085,7 @@ typedef enum } -typedef enum +typedef enum _mbg_user_scopes { USER_SCOPE_STATUS_READ, USER_SCOPE_CONFIG_READ, @@ -22571,12 +26097,19 @@ typedef enum typedef enum { - USER_SCOPE_STATUS_READ_MSK = ( 1UL << USER_SCOPE_STATUS_READ ), ///< see ::USER_SCOPE_STATUS_READ - USER_SCOPE_CONFIG_READ_MSK = ( 1UL << USER_SCOPE_CONFIG_READ ), ///< see ::USER_SCOPE_CONFIG_READ - USER_SCOPE_CONFIG_WRITE_MSK = ( 1UL << USER_SCOPE_CONFIG_WRITE ) ///< see ::USER_SCOPE_CONFIG_WRITE + USER_SCOPE_STATUS_READ_MSK = ( 1UL << USER_SCOPE_STATUS_READ ), ///< See ::USER_SCOPE_STATUS_READ + USER_SCOPE_CONFIG_READ_MSK = ( 1UL << USER_SCOPE_CONFIG_READ ), ///< See ::USER_SCOPE_CONFIG_READ + USER_SCOPE_CONFIG_WRITE_MSK = ( 1UL << USER_SCOPE_CONFIG_WRITE ) ///< See ::USER_SCOPE_CONFIG_WRITE } MBG_USER_SCOPE_MSKS; +/// @brief a combined permission mask to read configuration or status. +/// +/// In most cases the permission to read the configuration includes +/// the permission to read the status, anyway. +#define USER_SCOPE_CONFIG_OR_STATUS_READ_MSK \ + ( USER_SCOPE_CONFIG_READ_MSK | USER_SCOPE_STATUS_READ_MSK ) + #define MAX_USER_PERM_BYTES 64 #define MAX_USER_PERM_BITS MAX_USER_PERM_BYTES * 8 @@ -22624,7 +26157,7 @@ typedef enum * @see ::_set_user_perm * @see ::_check_user_perm */ -typedef struct +typedef struct mbg_user_perm_buf_s { uint8_t b[MAX_USER_PERM_BYTES]; ///< buffer for user permissions, see ::_set_user_perm and ::_check_user_perm @@ -22718,8 +26251,8 @@ typedef enum typedef enum { - USER_MNGMNT_SUPP_USER_CFG_MASK = ( 1UL << USER_MNGMNT_SUPP_USER_CFG ), ///< see ::USER_MNGMNT_SUPP_USER_CFG - USER_MNGMNT_SUPP_USER_LEVEL_CFG_MASK = ( 1UL << USER_MNGMNT_SUPP_USER_LEVEL_CFG ) ///< see ::USER_MNGMNT_SUPP_USER_LEVEL_CFG + USER_MNGMNT_SUPP_USER_CFG_MASK = ( 1UL << USER_MNGMNT_SUPP_USER_CFG ), ///< See ::USER_MNGMNT_SUPP_USER_CFG + USER_MNGMNT_SUPP_USER_LEVEL_CFG_MASK = ( 1UL << USER_MNGMNT_SUPP_USER_LEVEL_CFG ) ///< See ::USER_MNGMNT_SUPP_USER_LEVEL_CFG } MBG_USER_MNGMNT_FLAG_MASKS; @@ -22793,6 +26326,8 @@ typedef enum USER_CFG_FORCE_DISABLE_ON_EXP, ///< user account will immediately be disabled on password expiration, if this flags is not set, ///< the user shall be forced to change the password on the next login attempt USER_CFG_PASSWORD_CHANGED, ///< Indicates, that the password has been changed and needs to be crypted + USER_CFG_CAN_SHELL_SUDO, ///< The user is allowed to increase the privilege level by using sudo tool. + ///< Only relevant if user is allowed to use shell channel. N_USER_CFG_FLAGS } MBG_USER_CFG_FLAGS; @@ -22800,19 +26335,20 @@ typedef enum typedef enum { - USER_CFG_CAN_LOGIN_MASK = ( 1UL << USER_CFG_CAN_LOGIN ), ///< see ::USER_CFG_CAN_LOGIN - USER_CFG_CAN_REMOVE_MASK = ( 1UL << USER_CFG_CAN_REMOVE ), ///< see ::USER_CFG_CAN_REMOVE - USER_CFG_CAN_DISABLE_ON_FAILS_MASK = ( 1UL << USER_CFG_CAN_DISABLE_ON_FAILS ), ///< see ::USER_CFG_CAN_DISABLE_ON_FAILS - USER_CFG_MULTI_SESSION_MASK = ( 1UL << USER_CFG_MULTI_SESSION ), ///< see ::USER_CFG_MULTI_SESSION - USER_CFG_FORCE_CHANGE_ON_WARN_MASK = ( 1UL << USER_CFG_FORCE_CHANGE_ON_WARN ), ///< see ::USER_CFG_FORCE_CHANGE_ON_WARN - USER_CFG_FORCE_DISABLE_ON_EXP_MASK = ( 1UL << USER_CFG_FORCE_DISABLE_ON_EXP ), ///< see ::USER_CFG_FORCE_DISABLE_ON_EXP - USER_CFG_PASSWORD_CHANGED_MASK = ( 1UL << USER_CFG_PASSWORD_CHANGED ) ///< see ::USER_CFG_PASSWORD_CHANGED + USER_CFG_CAN_LOGIN_MASK = ( 1UL << USER_CFG_CAN_LOGIN ), ///< See ::USER_CFG_CAN_LOGIN + USER_CFG_CAN_REMOVE_MASK = ( 1UL << USER_CFG_CAN_REMOVE ), ///< See ::USER_CFG_CAN_REMOVE + USER_CFG_CAN_DISABLE_ON_FAILS_MASK = ( 1UL << USER_CFG_CAN_DISABLE_ON_FAILS ), ///< See ::USER_CFG_CAN_DISABLE_ON_FAILS + USER_CFG_MULTI_SESSION_MASK = ( 1UL << USER_CFG_MULTI_SESSION ), ///< See ::USER_CFG_MULTI_SESSION + USER_CFG_FORCE_CHANGE_ON_WARN_MASK = ( 1UL << USER_CFG_FORCE_CHANGE_ON_WARN ), ///< See ::USER_CFG_FORCE_CHANGE_ON_WARN + USER_CFG_FORCE_DISABLE_ON_EXP_MASK = ( 1UL << USER_CFG_FORCE_DISABLE_ON_EXP ), ///< See ::USER_CFG_FORCE_DISABLE_ON_EXP + USER_CFG_PASSWORD_CHANGED_MASK = ( 1UL << USER_CFG_PASSWORD_CHANGED ), ///< See ::USER_CFG_PASSWORD_CHANGED + USER_CFG_CAN_SHELL_SUDO_MASK = ( 1UL << USER_CFG_CAN_SHELL_SUDO ) ///< See ::USER_CFG_CAN_SHELL_SUDO } MBG_USER_CFG_FLAG_MASKS; -#define MBG_MAX_USER_NAME_LEN 32 /// See manpage useradd -#define MBG_MAX_USER_PASSWORD_LEN 32 +#define MBG_MAX_USER_NAME_LEN 32 ///< See man page for 'useradd'. +#define MBG_MAX_USER_PASSWORD_LEN 128 typedef struct @@ -22835,7 +26371,7 @@ typedef struct MBG_USER_PERM_BUF cfg_read_perm; ///< config read permission configuration, see ::MBG_USER_PERM_BUF and ::MBG_USER_PERMS MBG_USER_PERM_BUF cfg_write_perm; ///< config write permission configuration, see ::MBG_USER_PERM_BUF and ::MBG_USER_PERMS - uint32_t reserved[16]; ///< reserved, currently always 0 + uint32_t reserved[8]; ///< reserved, currently always 0 } MBG_USER_SETTINGS; @@ -22852,8 +26388,8 @@ do \ typedef struct { - uint32_t idx; ///< the index of the user - MBG_USER_SETTINGS settings; ///< settings, see ::MBG_USER_SETTINGS + MBG_MSG_IDX_32 idx; ///< The index of the user. + MBG_USER_SETTINGS settings; ///< Settings, see ::MBG_USER_SETTINGS. } MBG_USER_SETTINGS_IDX; @@ -22880,7 +26416,7 @@ typedef struct uint32_t password_doc; ///< time of last password change (days since 1970) uint32_t supp_flags; ///< supported flags, see ::MBG_USER_CFG_FLAG_MASKS - uint32_t reserved_3[16]; ///< reserved, currently always 0 + uint32_t reserved_3[8]; ///< reserved, currently always 0 } MBG_USER_INFO; @@ -22898,7 +26434,7 @@ do \ typedef struct { - uint32_t idx; ///< the index of the user + MBG_MSG_IDX_32 idx; ///< the index of the user MBG_USER_INFO info; ///< info, see ::MBG_USER_INFO } MBG_USER_INFO_IDX; @@ -22925,10 +26461,10 @@ typedef enum typedef enum { - USER_STAT_PASSWORD_WARN_MASK = ( 1UL << USER_STAT_PASSWORD_WARN ), ///< see ::USER_STAT_PASSWORD_WARN - USER_STAT_PASSWORD_EXP_MASK = ( 1UL << USER_STAT_PASSWORD_EXP ), ///< see ::USER_STAT_PASSWORD_EXP - USER_STAT_DISABLED_ON_EXP_MASK = ( 1UL << USER_STAT_DISABLED_ON_EXP ), ///< see ::USER_STAT_DISABLED_ON_EXP - USER_STAT_DISABLED_ON_MAX_FAILS_MASK = ( 1UL << USER_STAT_DISABLED_ON_MAX_FAILS ) ///< see ::USER_STAT_DISABLED_ON_MAX_FAILS + USER_STAT_PASSWORD_WARN_MASK = ( 1UL << USER_STAT_PASSWORD_WARN ), ///< See ::USER_STAT_PASSWORD_WARN + USER_STAT_PASSWORD_EXP_MASK = ( 1UL << USER_STAT_PASSWORD_EXP ), ///< See ::USER_STAT_PASSWORD_EXP + USER_STAT_DISABLED_ON_EXP_MASK = ( 1UL << USER_STAT_DISABLED_ON_EXP ), ///< See ::USER_STAT_DISABLED_ON_EXP + USER_STAT_DISABLED_ON_MAX_FAILS_MASK = ( 1UL << USER_STAT_DISABLED_ON_MAX_FAILS ) ///< See ::USER_STAT_DISABLED_ON_MAX_FAILS } MBG_USER_STAT_FLAG_MASKS; @@ -22959,7 +26495,7 @@ do \ typedef struct { - uint32_t idx; ///< the index of the user + MBG_MSG_IDX_32 idx; ///< the index of the user MBG_USER_STATUS status; ///< status, see ::MBG_USER_STATUS } MBG_USER_STATUS_IDX; @@ -23070,7 +26606,7 @@ typedef struct typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SERVICE_SETTINGS settings; } MBG_SERVICE_SETTINGS_IDX; @@ -23122,7 +26658,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SERVICE_INFO info; } MBG_SERVICE_INFO_IDX; @@ -23150,7 +26686,7 @@ typedef struct typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_SERVICE_STATUS status; } MBG_SERVICE_STATUS_IDX; @@ -23178,13 +26714,30 @@ do \ * @{ */ +enum MBG_FW_GLB_FLAGS +{ + MBG_FW_GLB_FLAG_CAN_SET_OSV, ///< OSV is settable/changeable + N_MBG_FW_GLB_FLAGS +}; + + +enum MBG_FW_GLB_MSKS +{ + MBG_FW_GLB_MSK_CAN_SET_OSV = ( 1UL << MBG_FW_GLB_FLAG_CAN_SET_OSV ) ///< See ::MBG_FW_GLB_FLAG_CAN_SET_OSV +}; + + typedef struct { uint8_t max_fws; ///< Maximum installable firmwares uint8_t installed_fws; ///< Currently installed firmwares uint8_t active_fw; ///< Index of currently active firmware uint8_t osv_fw; ///< Index of OSV firmware - uint32_t reserved_1[15]; + + uint8_t reserved_1[2]; + uint16_t flags; ///< See ::MBG_FW_GLB_MSKS + + uint32_t reserved_2[14]; } MBG_FW_GLB_INFO; @@ -23286,7 +26839,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_FW_INFO info; } MBG_FW_INFO_IDX; @@ -23358,7 +26911,7 @@ enum MBG_FW_UFU_FLASH_CMDS /// ::MBG_FW_UFU_FLASH_CMD::model_code must be set. /// Find the newest firmware version for specific devices identified by - /// the firmware's model code and flash that firmware to all suitable devices. + /// the model code of the firmware, and flash that firmware to all suitable devices. MBG_FW_UFU_FLASH_CMD_TYPE, /// Find the newest firmware version for each single device and flash @@ -23369,16 +26922,20 @@ enum MBG_FW_UFU_FLASH_CMDS }; +/** + * @brief Data used with UFU firmware flash command. + * + * @note Please note that, depending on the command, specific members in + * ::MBG_FW_UFU_FLASH_CMD are valid, all others should be zero and be ignored. + */ typedef struct { - /// Please be aware that, depending on the command, specific members in - /// ::MBG_FW_UFU_FLASH_CMD are valid, all others should be zero and be ignored. uint8_t cmd; ///< See ::MBG_FW_UFU_FLASH_CMDS uint8_t reserved_1; ///< Future use uint16_t ufu_idx; ///< See ::MBG_FW_UFU_FLASH_CMD_DEVICE_UFU XBP_ADDR xbp_addr; ///< See ::MBG_FW_UFU_FLASH_CMD_DEVICE_UFU or ///< ::MBG_FW_UFU_FLASH_CMD_DEVICE - uint16_t model_code; ///< see ::MBG_FW_UFU_FLASH_CMD_TYPE + uint16_t model_code; ///< See ::MBG_FW_UFU_FLASH_CMD_TYPE uint16_t reserved_3; ///< Future use uint32_t reserved_4[4]; ///< Future use @@ -23460,21 +27017,22 @@ enum MBG_DATABASE_SETTINGS_FLAG_MSKS typedef struct { - uint16_t flags; ///< See ::MBG_DATABASE_SETTINGS_FLAG_MSKS - uint16_t port; ///< Remote host port + uint16_t flags; ///< See ::MBG_DATABASE_SETTINGS_FLAG_MSKS. + uint16_t port; ///< Remote host port. uint32_t reserved_2[7]; - char user[MBG_DATABASE_MAX_STR]; ///< Database username - char password[MBG_DATABASE_MAX_STR]; ///< Database password - - /// ::MBG_DATABASE_SETTINGS::host can be set to a remote database server - /// (MySQL, PostgreSQL, etc...) or even to a local file path - /// in case of a SQLite database. In case of a local file database - /// ::MBG_DATABASE_INFO_FLAG_MSK_LOCAL_FILE should be set in ::MBG_DATABASE_INFO::flags - /// to announce its path. Thus, a capable piece of software can fetch it via - /// TLV API. + char user[MBG_DATABASE_MAX_STR]; ///< Database username. + char password[MBG_DATABASE_MAX_STR]; ///< Database password. + + /// @brief Database host. + /// + /// Can be set to a remote database server (MySQL, PostgreSQL, etc.) + /// or even to a local file path in case of a SQLite database. + /// In case of a local file database, ::MBG_DATABASE_INFO_FLAG_MSK_LOCAL_FILE + /// should be set in ::MBG_DATABASE_INFO::flags to announce its path, + /// so a capable piece of software can fetch it via the TLV API. char host[MBG_MAX_HOSTNAME_LEN]; - char dbname[MBG_DATABASE_MAX_STR]; ///< Database name + char dbname[MBG_DATABASE_MAX_STR]; ///< Database name. char reserved_3[MBG_DATABASE_MAX_STR]; char reserved_4[MBG_DATABASE_MAX_STR]; @@ -23490,7 +27048,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_DATABASE_SETTINGS settings; } MBG_DATABASE_SETTINGS_IDX; @@ -23513,7 +27071,7 @@ enum MBG_DATABASE_INFO_FLAGS enum MBG_DATABASE_INFO_FLAG_MSKS { - /// See ::MBG_DATABASE_INFO_FLAG_LOCAL_FILE + /// @brief See ::MBG_DATABASE_INFO_FLAG_LOCAL_FILE MBG_DATABASE_INFO_FLAG_MSK_LOCAL_FILE = ( 1UL << MBG_DATABASE_INFO_FLAG_LOCAL_FILE ) }; @@ -23547,18 +27105,20 @@ typedef struct uint8_t type; ///< See ::MBG_DATABASE_TYPES uint8_t flags; ///< See ::MBG_DATABASE_INFO_FLAG_MSKS - /// Flag field which ::MBG_DATABASE_MEMBER_MSKS are valid. + /// @brief Flag field indicating which ::MBG_DATABASE_MEMBER_MSKS are valid. uint16_t supp_members; - /// Flag field which ::MBG_DATABASE_MEMBER_MSKS are configurable. + /// @brief Flag field which ::MBG_DATABASE_MEMBER_MSKS are configurable. + /// /// Subset of ::MBG_DATABASE_INFO::supp_members. - uint16_t supp_cfgs; + /// @brief Supported settings flags. + /// /// If ::MBG_DATABASE_MEMBER_MSK_FLAGS is set in ::MBG_DATABASE_INFO::supp_members /// and ::MBG_DATABASE_MEMBER_MSK_FLAGS is set in ::MBG_DATABASE_INFO::supp_cfgs, /// this is the flag field of supported ::MBG_DATABASE_SETTINGS_FLAG_MSKS in - /// ::MBG_DATABASE_SETTINGS::flags + /// ::MBG_DATABASE_SETTINGS::flags. uint16_t supp_settings_flags; uint32_t reserved_3[2]; @@ -23577,7 +27137,7 @@ do \ typedef struct { - uint32_t idx; + MBG_MSG_IDX_32 idx; MBG_DATABASE_INFO info; } MBG_DATABASE_INFO_IDX; @@ -23620,6 +27180,309 @@ do \ +/** + * @defgroup group_fcu_api FCU API + * + * @note These structures and definitions allow configuration + * and status monitoring of multiple power supplies and fans. + * Only supported if ::MBG_XFEATURE_FCU_API is set. + * The legacy device FCU_01 does ***not*** support this API. + * + * @{ */ + + +/** + * @brief The maximum number of power supply modules supported by the API. + * + * This is limited e.g. by the number of bits available + * in ::MBG_FCU_SETTINGS::installed_power_supplies. + * Existing FCU modules normally only support a much smaller + * number of power supplies. + */ +#define FCU_MAX_PSU_MODULES 16 +// NOTE Changing the numeric value breaks API compatibility. + + +/** + * @brief The maximum number of fan control modules supported by the API. + * + * This is limited e.g. by the number of bits available + * in ::MBG_FCU_SETTINGS::fan_units_to_disable. + * The number of fan modules supported by a particular FCU module + * is usually smaller. + */ +#define FCU_MAX_FAN_MODULES 16 +// NOTE Changing the numeric value breaks API compatibility. + + +/** + * @brief The maximum number of fan control lines per fan module. + * + * This is an arbitrary maximum number. + * Existing FCU modules normally only support a much smaller + * number of fan modules, e.g. 1 or 4, depending on the fan + * module hardware and the FCU model. + */ +#define FCU_MAX_FANS_CTRL_PER_MODULE 8 +// NOTE Changing the numeric value breaks API compatibility. + + + +/** + * @brief Configuration settings to be sent to an FCU module. + */ +typedef struct +{ + /// @brief Bit mask used to tell the FCU module which slot(s) + /// are known to have a power supply module is physically installed. + /// + /// This tells the FCU that power should be available from those slots, + /// and thus affects the status reported for a power supply slot, + /// i.e. "not available" vs. "OK" or "faulty". + uint16_t installed_power_supplies; + + /// @brief Bit mask of fan modules to be ***disabled*** by the FCU. + /// + /// By default, all fan modules are anyway enabled after + /// power-up, so the control program can explicitly disable + /// selected modules later, if preferred for some reason. + uint16_t fan_units_to_disable; + + uint16_t reserved_0; ///< Currently not used, should be set to 0. + uint16_t reserved_1; ///< Currently not used, should be set to 0. + + uint16_t reserved_2; ///< Currently not used, should be set to 0. + uint16_t reserved_3; ///< Currently not used, should be set to 0. + uint16_t reserved_4; ///< Currently not used, should be set to 0. + uint16_t reserved_5; ///< Currently not used, should be set to 0. + +} MBG_FCU_SETTINGS; + +#define _mbg_swab_fcu_settings( _p ) \ +do \ +{ \ + _mbg_swab16( &(_p)->installed_power_supplies ); \ + _mbg_swab16( &(_p)->fan_units_to_disable ); \ + _mbg_swab16( &(_p)->reserved_0 ); \ + _mbg_swab16( &(_p)->reserved_1 ); \ + _mbg_swab16( &(_p)->reserved_2 ); \ + _mbg_swab16( &(_p)->reserved_3 ); \ + _mbg_swab16( &(_p)->reserved_4 ); \ + _mbg_swab16( &(_p)->reserved_5 ); \ +} while ( 0 ) + + + +/** + * @brief Info and current settings to be retrieved from an FCU module. + */ +typedef struct +{ + MBG_FCU_SETTINGS fcu_settings; ///< Current settings. + + /// @brief The number of power supply modules that can be + /// monitored by the particular FCU module. + /// + /// Must not exceed ::FCU_MAX_PSU_MODULES. + uint8_t n_psu_modules; + + /// @brief The number of fan modules that can be monitored + /// by the particular FCU module. + /// + /// Must no exceed ::FCU_MAX_FAN_MODULES. + uint8_t n_fan_modules; + + uint8_t reserved_0; ///< Currently not used, reserved. + uint8_t reserved_1; ///< Currently not used, reserved. + + uint32_t reserved_2; ///< Currently not used, reserved. + + /// @brief The number of fan control lines for each fan module. + /// + /// Some module types may have 1 fan with 1 control line, + /// there may be modules with several fans, each of which + /// has its own control line, and finally there may be modules + /// with several fans that share a single summary control line. + /// The FCU firmware can determine and report these values + /// depending on the hardware it is running on. + uint8_t fan_ctrls_per_module[FCU_MAX_FAN_MODULES]; + + uint32_t reserved_3; ///< Currently not used, reserved. + uint32_t reserved_4; ///< Currently not used, reserved. + uint32_t reserved_5; ///< Currently not used, reserved. + uint32_t reserved_6; ///< Currently not used, reserved. + +} MBG_FCU_INFO; + +#define _mbg_swab_fcu_info( _p ) \ +do \ +{ \ + _mbg_swab_fcu_settings( &(_p)->fcu_settings ); \ + _mbg_swab8( &(_p)->n_psu_modules ); \ + _mbg_swab8( &(_p)->n_fan_modules ); \ + _mbg_swab8( &(_p)->reserved_0 ); \ + _mbg_swab8( &(_p)->reserved_1 ); \ + _mbg_swab32( &(_p)->reserved_2 ); \ + _mbg_swab32( &(_p)->reserved_3 ); \ + _mbg_swab32( &(_p)->reserved_4 ); \ + _mbg_swab32( &(_p)->reserved_5 ); \ + _mbg_swab32( &(_p)->reserved_6 ); \ +} while ( 0 ) + + + +/** + * @brief Power supply status information to be retrieved from an FCU module. + * + * ::MBG_FCU_INFO::n_psu_modules are supported by the FCU module, + * but how many and which power supply modules are actually + * monitored depends on the bit mask ::MBG_FCU_SETTINGS::installed_power_supplies + * that has been sent to the FCU module. + */ +typedef struct +{ + uint8_t status; ///< The status, see ::FCU_PSU_STAT_CODES. + uint8_t reserved_0; ///< Currently unused, reserved. + uint16_t reserved_1; ///< Currently unused, reserved. + +} MBG_FCU_PSU_STAT; + +#define _mbg_swab_fcu_psu_stat( _p ) \ +do \ +{ \ + _mbg_swab8( &(_p)->status ); \ + _mbg_swab8( &(_p)->reserved_0 ); \ + _mbg_swab16( &(_p)->reserved_1 ); \ +} while ( 0 ) + + + +/** + * @brief Power supply status codes used with ::MBG_FCU_PSU_STAT::status. + */ +enum FCU_PSU_STAT_CODES +{ + /// The bit mask in ::MBG_FCU_SETTINGS::installed_power_supplies + /// indicates there is no PSU module expected in this slot, and + /// the associated voltage sense line is low, es expected. + FCU_PSU_STAT_CODE_NOT_AVAIL, + + /// The bit mask in ::MBG_FCU_SETTINGS::installed_power_supplies + /// indicates there is no PSU module expected in this slot, but + /// the associated voltage sense line is anyway high, so obviously + /// a PSU module is installed which has not yet been registered. + FCU_PSU_STAT_CODE_UNREGISTERED, + + /// The bit mask in ::MBG_FCU_SETTINGS::installed_power_supplies + /// indicates there is a PSU module installed in this slot, and + /// the associated voltage sense line is high, so the PSU works + /// properly. + FCU_PSU_STAT_CODE_OK, + + /// The bit mask in ::MBG_FCU_SETTINGS::installed_power_supplies + /// indicates there is a PSU module installed in this slot, but + /// the associated voltage sense line is low, so the PSU is faulty + /// or has been removed. + FCU_PSU_STAT_CODE_FAIL, + + N_FCU_PSU_STAT_CODE ///< The number of known status codes. +}; + + + +/** + * @brief Power supply status information plus module index. + * + * Monitoring software should poll index 0...::MBG_FCU_INFO::n_psu_modules-1. + */ +typedef struct +{ + MBG_MSG_IDX idx; ///< 0...::MBG_FCU_INFO::n_psu_modules-1. + MBG_FCU_PSU_STAT psu_stat; + +} MBG_FCU_PSU_STAT_IDX; + +#define _mbg_swab_fcu_psu_stat_idx( _p ) \ +do \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_fcu_psu_stat( &(_p)->psu_stat ); \ +} while ( 0 ) + + + +/** + * @brief Fan status information to be retrieved from an FCU module. + * + * ::MBG_FCU_INFO::n_fan_modules are supported by the FCU module, + * but how many fan modules with one or more control lines each + * are actually monitored depends on the FCU device and fan hardware. + */ +typedef struct +{ + /// @brief Indicates how many control lines are checked + /// + /// for the specified module, i.e. how many items + /// of @a #status contain relevant status information. + /// Should correspond to ::MBG_FCU_INFO::fan_ctrls_per_module. + uint8_t n_ctrls; + + uint8_t reserved_0; ///< Currently unused, reserved. + uint16_t reserved_1; ///< Currently unused, reserved. + + uint8_t status[FCU_MAX_FANS_CTRL_PER_MODULE]; ///< See ::FCU_FAN_STAT_CODES. + +} MBG_FCU_FAN_STAT; + +#define _mbg_swab_fcu_fan_stat( _p ) \ +do \ +{ \ + _mbg_swab8( &(_p)->n_ctrls ); \ + _mbg_swab8( &(_p)->reserved_0 ); \ + _mbg_swab16( &(_p)->reserved_1 ); \ +} while ( 0 ) + + + +/** + * @brief Fan status codes used with ::MBG_FCU_FAN_STAT::status. + */ +enum FCU_FAN_STAT_CODES +{ + FCU_FAN_STAT_CODE_NOT_AVAIL, ///< No fan installed at the control line of this unit. + FCU_FAN_STAT_CODE_DISABLED, ///< Fan installed but disabled. + FCU_FAN_STAT_CODE_OK, ///< Fan installed and working OK. + FCU_FAN_STAT_CODE_TURNED_OFF, ///< Fan turned off by frontpanel switch. + FCU_FAN_STAT_CODE_FAULTY, ///< Fan installed but fails. + N_FCU_FAN_STAT_CODE ///< The number of known status codes. +}; + + + +/** + * @brief Fan status information plus module index. + * + * Monitoring software should poll index 0...::MBG_FCU_INFO::n_fan_modules-1. + */ +typedef struct +{ + MBG_MSG_IDX idx; ///< 0...::MBG_FCU_INFO::n_fan_modules-1. + MBG_FCU_FAN_STAT fan_stat; + +} MBG_FCU_FAN_STAT_IDX; + +#define _mbg_swab_fcu_fan_stat_idx( _p ) \ +do \ +{ \ + _mbg_swab16( &(_p)->idx ); \ + _mbg_swab_fcu_fan_stat( &(_p)->fan_stat ); \ +} while ( 0 ) + + +/** @} defgroup group_fcu_api */ + + + #if defined( _USING_BYTE_ALIGNMENT ) #pragma pack() // set default alignment #undef _USING_BYTE_ALIGNMENT diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h index a6044a1..36faf5a 100755 --- a/mbglib/common/mbg_tgt.h +++ b/mbglib/common/mbg_tgt.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_tgt.h 1.46 2019/08/28 12:52:02 martin REL_M $ + * $Id: mbg_tgt.h 1.52 2021/10/05 09:10:44 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,6 +11,20 @@ * * ----------------------------------------------------------------------- * $Log: mbg_tgt.h $ + * Revision 1.52 2021/10/05 09:10:44 martin + * Clean up definitions _MBG_API_ATTR_EXPORT and _MBG_API_ATTR_IMPORT. + * Revision 1.51 2021/09/13 08:59:55 martin + * New definitions _MBG_API_ATTR_EXPORT and _MBG_API_ATTR_IMPORT. + * Required if variables that are exported by a DLL are to be + * imported into a different DLL. + * Revision 1.50 2021/03/18 11:08:51 martin + * Updated some comments. + * Revision 1.49 2021/03/12 11:51:37 martin + * Corrected the wording of some comments. + * Revision 1.48 2021/02/10 13:34:35 martin + * Defined MBG_TGT_MISSING_STRUCT_TIMESPEC for CVI. + * Revision 1.47 2019/11/12 15:33:59 martin + * Added some doxygen comments. * Revision 1.46 2019/08/28 12:52:02 martin * Changes for mingw. * Revision 1.45 2019/02/11 09:53:02Z martin @@ -40,7 +54,7 @@ * MBG_TGT_HAS_DEV_FN is supported on Windows, but * MBG_TGT_HAS_DEV_FN_BASE is not supported. * Enhanced debug support for Windows kernel drivers. - * Include limits.h under Windows. + * Include limits.h on Windows. * Defined MBG_TGT_MISSING_STRUCT_TIMESPEC for Borland C. * Defined __func__ for BC 5 and for DOS, and provide a * common default declaration.. @@ -95,7 +109,7 @@ * Always include unistd.h for MBG_TGT_POSIX. * Define empty __attribute__ macro for non-gcc environments. * Revision 1.29 2013/02/01 14:50:46 martin - * Fixed a typo which caused an error under Borland CBuilder 5. + * Fixed a typo which caused an error with Borland CBuilder 5. * Revision 1.28 2012/12/12 10:03:16Z martin * Fix for Borland C 3.1. * Revision 1.27 2012/11/29 12:03:14Z martin @@ -140,7 +154,7 @@ * Revision 1.13 2008/01/30 15:52:22 martin * Modified checking for availability of wchar_t. * Revision 1.13 2008/01/29 15:18:07Z martin - * Recognize DOS target under Watcom compilers. + * Recognize DOS target with Watcom compilers. * Flag Watcom C always supports wchar_t. * Revision 1.12 2008/01/17 09:38:50Z daniel * Added macros to determine whether C language extensions @@ -154,7 +168,7 @@ * Added MBG_PORT_HANDLE type for serial ports. * Added macros for unified inline code syntax. * Revision 1.9 2006/12/08 12:45:54Z martin - * Under Windows include ntddk.h rather than windows.h + * On Windows include ntddk.h rather than windows.h * if building kernel driver . * Revision 1.8 2006/10/25 12:20:45Z martin * Initial support for FreeBSD, NetBSD, and OpenBSD. @@ -621,7 +635,7 @@ extern "C" { #endif // "struct timespec" is supported only since VS2015 - // If it is then also the symbol TIME_UTC should be defined. + // If it is, also the symbol TIME_UTC should be defined. // Functions to read the current time as struct timespec // are timespec_get() and friends, which are also only provided // by VS2015 and later. @@ -635,7 +649,7 @@ extern "C" { #endif #endif - #if ( _MSC_VER >= 1600 ) // TODO Eventually even 1600 doesn't support this. + #if ( _MSC_VER >= 1600 ) // TODO Even 1600 probably doesn't support this. #include <stdint.h> #include <inttypes.h> #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1 @@ -864,10 +878,10 @@ extern "C" { // If the build environment doesn't provide an inttypes.h file -// with print format specifiers for 64 bit fixed size types -// then MBG_PRI_64_PREFIX should be defined, which is used -// to define our own C99 compatible format specifiers. -// Eventually, similar definitions are required for 32, 16, +// with print format specifiers for 64 bit fixed size types, +// MBG_PRI_64_PREFIX should be defined, which is used to +// define our own C99 compatible format specifiers. +// Maybe similar definitions are required for 32, 16, // and 8 bit fixed size types. #if defined( MBG_PRI_64_PREFIX ) #define PRIi64 MBG_PRI_64_PREFIX "i" @@ -929,12 +943,15 @@ extern "C" { // CVI uses an own set of functions to support serial ports typedef int MBG_PORT_HANDLE; #define MBG_INVALID_PORT_HANDLE -1 + + // At least CVI 13.02 doesn't provide a declaration of struct timespec. + #define MBG_TGT_MISSING_STRUCT_TIMESPEC 1 #else typedef HANDLE MBG_PORT_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 + // with VC6. However, if the SDK is installed, 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 ) @@ -951,12 +968,25 @@ extern "C" { #endif - #if !defined( MBG_TGT_MINGW ) // not required for MinGW - #if defined( MBG_LIB_EXPORT ) - #define _MBG_API_ATTR __declspec( dllexport ) - #elif !defined( MBGSVCTL_STATIC_LIB ) - #define _MBG_API_ATTR __declspec( dllimport ) - #endif + #if !defined( MBG_TGT_MINGW ) // Not required for MinGW + // The definitions below have to be used if a variable + // is exported from one DLL, and imported by a different + // DLL. It has to be used in the header file with the _ext + // symbol, depending on whether the file is included by + // its "parent" .c or .cpp file which implements the + // variable, or by a different file which just references + // the exported variable. + #define _MBG_API_ATTR_EXPORT __declspec( dllexport ) + #define _MBG_API_ATTR_IMPORT __declspec( dllimport ) + #endif + + // The old code below works well when exporting functions + // from a DLL, but fails if a variable is exported from + // one DLL, and imported by a different DLL. + #if defined( MBG_LIB_EXPORT ) + #define _MBG_API_ATTR _MBG_API_ATTR_EXPORT + #else + #define _MBG_API_ATTR _MBG_API_ATTR_IMPORT #endif #elif defined( MBG_TGT_POSIX ) @@ -981,12 +1011,14 @@ extern "C" { /** - * @brief A socket file descriptor type + * @brief A portable socket descriptor type returned by socket(). + * + * @see ::MBG_INVALID_SOCK_FD for the value returned in case of error. */ #if defined( MBG_TGT_WIN32 ) // && !defined( MBG_TGT_MINGW ) #if !defined( MBG_TGT_KERNEL ) // we don't need this in kernel space - // usually evaluates to UINT_PTR, which in turn evaluates - // to (unsigned int), or (unsigned __int64). + /// On Windows usually evaluates to @a UINT_PTR, which in turn + /// evaluates to <em>(unsigned int)</em>, or <em>(unsigned __int64)</em>. typedef SOCKET MBG_SOCK_FD; #endif #elif defined( MBG_TGT_POSIX ) @@ -997,7 +1029,17 @@ extern "C" { /** - * @brief A value to mark an ::MBG_SOCK_FD as invalid + * @brief The value returned by the socket() function in case of error. + * + * On Windows usually evaluates to (SOCKET)(~0), + * since the SOCKET type is unsigned. + * For POSIX systems the value is usually -1. + * + * If the @a socket() call returns this value, + * call ::mbg_get_last_socket_error to retrieve + * one of the portable @ref MBG_ERROR_CODES. + * + * @see ::MBG_SOCK_FD for a portable socket descriptor type. */ #if defined( MBG_TGT_WIN32 ) #define MBG_INVALID_SOCK_FD INVALID_SOCKET // usually evaluates to (SOCKET)(~0) since SOCKET is unsigned @@ -1008,7 +1050,10 @@ extern "C" { /** - * @brief The return code of socket functions in case of error + * @brief The return code of networking functions in case of error. + * + * The code is returned by functions like @a select(), + * @a recv(), etc. in case of error. */ #if defined( MBG_TGT_WIN32 ) #define MBG_SOCKET_ERR_RETVAL SOCKET_ERROR // usually evaluates to -1 @@ -1026,6 +1071,14 @@ extern "C" { #define _MBG_API_ATTR #endif +#if !defined( _MBG_API_ATTR_EXPORT ) + #define _MBG_API_ATTR_EXPORT +#endif + +#if !defined( _MBG_API_ATTR_IMPORT ) + #define _MBG_API_ATTR_IMPORT +#endif + #if !defined( _NO_MBG_API ) #define _NO_MBG_API #endif diff --git a/mbglib/common/mbgerror.c b/mbglib/common/mbgerror.c index f4bbafa..c3e19e3 100755 --- a/mbglib/common/mbgerror.c +++ b/mbglib/common/mbgerror.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgerror.c 1.9 2019/08/26 15:15:10 martin REL_M $ + * $Id: mbgerror.c 1.12 2021/03/16 12:20:57 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,12 @@ * * ----------------------------------------------------------------------- * $Log: mbgerror.c $ + * Revision 1.12 2021/03/16 12:20:57 martin + * Updated some comments. + * Revision 1.11 2021/03/12 12:32:15 martin + * Updated some comments. + * Revision 1.10 2019/11/11 09:43:41 martin + * Tiny doxygen change. * Revision 1.9 2019/08/26 15:15:10 martin * Translate POSIX ENODATA to MBG_ERR_NO_DATA. * Revision 1.8 2019/08/20 08:22:51 martin @@ -162,7 +168,7 @@ typedef struct #if defined( _MBG_TGT_HAS_POSIX_ERRNO ) /** - * @brief Mappings between Meinberg error codes and POSIX error codes + * @brief Mappings between Meinberg error codes and POSIX error codes. * * Always refer to the symbolic names only. The numeric codes listed * in the comments below are just for a quick reference, and may vary @@ -190,7 +196,7 @@ static ERRNO_CNV_ENTRY posix_errno_table[] = { ENOMEM, MBG_ERR_NO_MEM }, // 12, Out of memory (can't allocate memory). { EACCES, MBG_ERR_ACCESS }, // 13, Permission denied (e.g. when trying to access a device without sufficient permissions). { EFAULT, MBG_ERR_BAD_ADDRESS }, // 14, Bad address (e.g. invalid address in a function argument). - // { ENOTBLK, }, // 15, Block device required (eventually no POSIX error, but supported in Linux and *BSD). + // { ENOTBLK, }, // 15, Block device required (possibly not a POSIX error, but supported on Linux and *BSD). { EBUSY, MBG_ERR_BUSY }, // 16, Device or resource busy. { EEXIST, MBG_ERR_EXIST }, // 17, File exists. // { EXDEV, }, // 18, Cross-device link. @@ -223,10 +229,10 @@ static ERRNO_CNV_ENTRY posix_errno_table[] = { ENOTSOCK, MBG_ERR_NOT_A_SOCKET }, // 88, Socket operation on non-socket (file descriptor is not a socket). #endif #if defined( ECONNRESET ) - { ECONNRESET, MBG_ERR_CONN_RESET }, // 104, Connection reset by peer + { ECONNRESET, MBG_ERR_CONN_RESET }, // 104, Connection reset by peer. #endif #if defined( ETIMEDOUT ) - { ETIMEDOUT, MBG_ERR_TIMEOUT }, // 110, Connection timed out + { ETIMEDOUT, MBG_ERR_TIMEOUT }, // 110, Connection timed out. #endif { 0, 0 } // end-of-table identifier @@ -241,10 +247,10 @@ static ERRNO_CNV_ENTRY posix_errno_table[] = static ERRNO_CNV_ENTRY posix_h_errno_table[] = { // POSIX codes taken from Linux netdb.h - { HOST_NOT_FOUND, MBG_ERR_HOST_NOT_FOUND }, // The specified host is unknown - // { NO_ADDRESS, }, // Usually same numeric value as NO_DATA - // { NO_DATA, }, // The requested name is valid but does not have an IP address - // { NO_RECOVERY, }, // A nonrecoverable name server error occurred + { HOST_NOT_FOUND, MBG_ERR_HOST_NOT_FOUND }, // The specified host is unknown. + // { NO_ADDRESS, }, // Usually same numeric value as NO_DATA. + // { NO_DATA, }, // The requested name is valid but does not have an IP address. + // { NO_RECOVERY, }, // A nonrecoverable name server error occurred. // { TRY_AGAIN, }, // A temporary error occurred on an authoritative name server. Try again later. { 0, 0 } // end-of-table identifier @@ -320,7 +326,7 @@ static ERRNO_CNV_ENTRY cvi_rs232_error_table[] = #if defined( MBG_TGT_KERNEL ) /** - * @brief Mappings of some NTSTATUS codes to Meinberg error codes + * @brief Mappings of some NTSTATUS codes to Meinberg error codes. * * Kernel space Windows APIs use NTSTATUS codes as return values, * which consist of several bit fields which also provide some severity @@ -410,8 +416,8 @@ static ERRNO_CNV_ENTRY win32_kernel_status_table[] = * - The user space function uses ::win32_sys_err_table to convert this * to a Meinberg error code, which again yields ::MBG_ERR_INV_PARM. * - * @note Eventually it would be possible to defined custom NTSTATUS codes - * in kernel space, e.g. ((NTSTATUS) (0xC0000000 | 0x20000000 | 31)). + * @note It is possible to define custom NTSTATUS codes in kernel space, + * e.g. ((NTSTATUS) (0xC0000000 | 0x20000000 | 31)). * Apparently, such custom error status codes are passed up to user space, * and GetLastError() after the ioctl() call then returns a negative number, * i.e. -31 for the example here. @@ -444,7 +450,7 @@ static ERRNO_CNV_ENTRY mbg_ioctl_to_ntstatus_table[] = #else // Windows user space /** - * @brief Mappings of WIN32 error codes to Meinberg error codes + * @brief Mappings of WIN32 error codes to Meinberg error codes. * * If a WIN32 user space API function encounters an error, * the Windows GetLastError() function has to be called in @@ -500,7 +506,7 @@ static ERRNO_CNV_ENTRY win32_sys_err_table[] = /** - * @brief Mappings of Winsock error codes to Meinberg error codes + * @brief Mappings of Winsock error codes to Meinberg error codes. * * If a Windows socket (Winsock) function encounters an error, * the Windows WSAGetLastError() function has to be called in @@ -597,10 +603,10 @@ static ERRNO_CNV_ENTRY win32_wsa_err_table[] = static /*HDR*/ /** - * @brief Lookup some error code in a conversion table + * @brief Lookup some error code in a conversion table. * - * @param[in] srch_errno The error number to be looked up in the conversion table - * @param[in] tbl A conversion table + * @param[in] srch_errno The error number to be looked up in the conversion table. + * @param[in] tbl A conversion table. * @param[in] dflt_val The code to be returned if no table entry was found. * * @return @ref MBG_ERROR_CODES associated with the original error code, @@ -623,13 +629,13 @@ int lookup_tbl_errno( int srch_errno, const ERRNO_CNV_ENTRY tbl[], int dflt_val /*HDR*/ /** - * @brief Convert one of the @ref MBG_ERROR_CODES to an OS-specific format + * @brief Convert one of the @ref MBG_ERROR_CODES to an OS-specific format. * * @param[in] err_no One of the @ref MBG_ERROR_CODES. * * @see @ref MBG_ERROR_CODES * - * @return An OS-specific error code + * @return An OS-specific error code. */ int mbg_errno_to_os( int err_no ) { @@ -684,11 +690,12 @@ int mbg_errno_to_os( int err_no ) /*HDR*/ /** - * @brief Return an error string associated with the @ref MBG_ERROR_CODES + * @brief Return an error string associated with the @ref MBG_ERROR_CODES. * - * @param[in] mbg_errno One of the @ref MBG_ERROR_CODES + * @param[in] mbg_errno One of the @ref MBG_ERROR_CODES. * - * @return A constant string describing the error, or NULL for unknown error codes + * @return A constant string describing the error, or a generic string + * "Unknown error" for unknown error codes. */ const char *mbg_strerror( int mbg_errno ) { @@ -712,12 +719,12 @@ const char *mbg_strerror( int mbg_errno ) /*HDR*/ /** - * @brief Check if a value is an error code and print an associated error message + * @brief Check if a value is an error code and print an associated error message. * - * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES - * @param[in] what A string indicated what failed + * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES. + * @param[in] what A string indicated what failed. * - * @return true if rc represented an error code, and a message has been printed, else false + * @return @a true if @p rc represented an error code and a message has been printed, else @a false. */ bool mbg_cond_err_msg( int rc, const char *what ) { @@ -729,23 +736,22 @@ bool mbg_cond_err_msg( int rc, const char *what ) /*HDR*/ /** - * @brief Check if a value is an general or a "not supported" error code and print an associated message + * @brief Check if a value is a general or a "not supported" error code, and print an associated message. * - * If rc contains an error code then an error message is printed, and true is returned. + * If @p rc contains an error code, an error message is printed. * - * If the optional parameter string info2 is not NULL then it should contain - * the name of a feature which has been tested before. In this case, if the error - * code is the specific error ::MBG_ERR_NOT_SUPP_BY_DEV then a "not supported" message - * is printed using info2. + * If the error code is ::MBG_ERR_NOT_SUPP_BY_DEV and the optional parameter + * string @p info is not @a NULL, a specific error message is generated. * - * If info2 is NULL, or the error code is not ::MBG_ERR_NOT_SUPP_BY_DEV then the standard - * error message is printed anyway. + * If @p rc contains a different error code, or the optional parameter + * string @p info is @a NULL, a generic error message is generated that + * includes the string from parameter @p what. * - * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES - * @param[in] what A string indicated what failed - * @param[in] info An optional informational string telling what is not supported (may be NULL). + * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES. + * @param[in] what A string indicated what failed. + * @param[in] info An optional informational string telling what is not supported (may be @a NULL). * - * @return true if rc represented an error code, and a message has been printed, else false + * @return @a true if @p rc represented any error code, and a message has been printed, else @a false. */ bool mbg_cond_err_msg_info( int rc, const char *what, const char *info ) { @@ -771,12 +777,12 @@ bool mbg_cond_err_msg_info( int rc, const char *what, const char *info ) /*HDR*/ /** - * @brief Translate an error code from the Labwindows/CVI RS-232 library to one of the @ref MBG_ERROR_CODES + * @brief Translate an error code from the Labwindows/CVI RS-232 library to one of the @ref MBG_ERROR_CODES. * - * @param[in] cvi_rc An error code returned by a CVI RS-232 library function - * @param[in] info An optional informational text string, or NULL + * @param[in] cvi_rc An error code returned by a CVI RS-232 library function. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. * * @see http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvirs232_error_conditions/ */ @@ -803,12 +809,12 @@ int mbg_cvi_rs232_error_to_mbg( int cvi_rc, const char *info ) /*HDR*/ /** - * @brief Translate a Windows NTSTATUS code to one of the @ref MBG_ERROR_CODES + * @brief Translate a Windows NTSTATUS code to one of the @ref MBG_ERROR_CODES. * - * @param[in] st One of the NTSTATUS codes defined in ntstatus.h - * @param[in] info An optional informational text string, or NULL + * @param[in] st One of the NTSTATUS codes defined in ntstatus.h. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_win32_ntstatus_to_mbg( NTSTATUS st, const char *info ) { @@ -828,12 +834,12 @@ int mbg_win32_ntstatus_to_mbg( NTSTATUS st, const char *info ) /*HDR*/ /** - * @brief Translate a Windows non-socket API return code to one of the @ref MBG_RETURN_CODES + * @brief Translate a Windows non-socket API return code to one of the @ref MBG_RETURN_CODES. * - * @param[in] win32_sys_rc A Windows non-socket API error code as returned by GetLastError(), or ERROR_SUCCESS. - * @param[in] info An optional informational text string, or NULL. + * @param[in] win32_sys_rc A Windows non-socket API error code as returned by @a GetLastError, or @a ERROR_SUCCESS. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_RETURN_CODES + * @return One of the @ref MBG_RETURN_CODES. */ int mbg_win32_sys_err_to_mbg( DWORD win32_sys_rc, const char *info ) { @@ -858,9 +864,9 @@ int mbg_win32_sys_err_to_mbg( DWORD win32_sys_rc, const char *info ) if ( rc < 0 ) { - // If the error code is negative then this is a user-defined - // error code e.g. returned by an IOCTL call. In this case we - // assume it's one of the + // If the error code is negative, this is a user-defined + // error code e.g. returned by an IOCTL call. In this case + // we assume it's one of the ... goto out; } #endif @@ -885,12 +891,12 @@ out: /*HDR*/ /** - * @brief Translate a Windows socket API error code to one of the @ref MBG_ERROR_CODES + * @brief Translate a Windows socket API error code to one of the @ref MBG_ERROR_CODES. * - * @param[in] wsa_err A Windows socket API error code as returned by WSAGetLastError() - * @param[in] info An optional informational text string, or NULL + * @param[in] wsa_err A Windows socket API error code as returned by @a WSAGetLastError. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_win32_wsa_err_to_mbg( int wsa_err, const char *info ) { @@ -918,12 +924,12 @@ int mbg_win32_wsa_err_to_mbg( int wsa_err, const char *info ) /*HDR*/ /** - * @brief Translate a POSIX errno error code to one of the @ref MBG_ERROR_CODES + * @brief Translate a POSIX errno error code to one of the @ref MBG_ERROR_CODES. * - * @param[in] posix_errno A POSIX error code as usually defined in errno.h - * @param[in] info An optional informational text string, or NULL + * @param[in] posix_errno A POSIX error code as usually defined in errno.h. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_posix_errno_to_mbg( int posix_errno, const char *info ) { @@ -947,19 +953,19 @@ int mbg_posix_errno_to_mbg( int posix_errno, const char *info ) /*HDR*/ /** - * @brief Translate a POSIX h_errno error code to one of the @ref MBG_ERROR_CODES + * @brief Translate a POSIX h_errno error code to one of the @ref MBG_ERROR_CODES. * * This function is specific to translate error codes returned by - * gethostbyname() and gethostbyaddr(). In case of error these functions - * don't set errno but h_errno to a specific value. + * @a gethostbyname and @a gethostbyaddr. In case of error these functions + * don't set @a errno but @a h_errno to a specific value. * - * The functions gethostbyname() and gethostbyaddr() are obsolete, - * and getaddressinfo() should be used preferably. + * The functions @a gethostbyname and @a gethostbyaddr are obsolete, + * and @a getaddressinfo should be used preferably. * - * @param[in] posix_h_errno An error code as usually defined in netdb.h - * @param[in] info An optional informational text string, or NULL + * @param[in] posix_h_errno An error code as usually defined in netdb.h. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info ) { @@ -983,26 +989,26 @@ int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info ) /*HDR*/ /** - * @brief Get and translate last error after non-socket function call + * @brief Get and translate last error after non-socket function call. * * Retrieve the "last error" code after a non-socket function has been called * and translate to one of the @ref MBG_ERROR_CODES. * - * On POSIX systems the "last error" code is always stored in errno, but - * e.g. under Windows the "last error" code after a socket function - * has to be retrieved by calling WSAGetLastError(), whereas the "last error" + * On POSIX systems the "last error" code is always stored in @a errno, but + * e.g. on Windows the "last error" code after a socket function + * has to be retrieved by calling @a WSAGetLastError, whereas the "last error" * code from non-socket POSIX-like functions has to be retrieved - * by calling GetLastError(). + * by calling @a GetLastError. * - * @param[in] info An optional informational text string, or NULL + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_get_last_error( const char *info ) { #if defined( MBG_TGT_WIN32 ) - // Under Windows the "last error" code after a non-socket function + // On Windows the "last error" code after a non-socket function // ("Windows System Errors") has to be retrieved by calling GetLastError(), // whereas the "last error" code from POSIX-like socket functions // ("Windows Sockets Error Codes") has to be retrieved by calling @@ -1029,19 +1035,19 @@ int mbg_get_last_error( const char *info ) /*HDR*/ /** - * @brief Get and translate last error after socket function call + * @brief Get and translate last error after socket function call. * * Retrieve the "last error" code after a socket function has been called * and translate to one of the @ref MBG_ERROR_CODES. * - * On POSIX systems the "last error" code is always stored in errno, but - * e.g. under Windows the "last error" code after a socket function - * has to be retrieved by calling WSAGetLastError, whereas the "last error" - * code from non-socket POSIX-like functions is stored in errno as usual. + * On POSIX systems the "last error" code is always stored in @a errno, but + * e.g. on Windows the "last error" code after a socket function + * has to be retrieved by calling @a WSAGetLastError, whereas the "last error" + * code from non-socket POSIX-like functions is stored in @a errno as usual. * - * @param[in] info An optional informational text string, or NULL + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_get_last_socket_error( const char *info ) { @@ -1053,7 +1059,7 @@ int mbg_get_last_socket_error( const char *info ) #elif defined( MBG_TGT_WIN32 ) #if !defined( MBG_TGT_KERNEL ) - // Under Windows the "last error" code after a POSIX-like socket + // On Windows the "last error" code after a POSIX-like socket // function ("Windows Sockets Error Code") has to be retrieved // by calling WSAGetLastError(), whereas the "last error" code // after a non-socket function ("Windows System Errors") has @@ -1080,20 +1086,20 @@ int mbg_get_last_socket_error( const char *info ) /*HDR*/ /** - * @brief Retrieve and convert last error after gethostbyname() + * @brief Retrieve and convert last error after gethostbyname(). * * This function is specific to retrieve and translate error codes - * returned by gethostbyname() and gethostbyaddr(). In case of error - * these functions don't set errno but h_errno on POSIX systems, but - * under Windows the error code can be retrieved by WSAGetLastError() + * returned by @a gethostbyname and @a gethostbyaddr. In case of error + * these functions don't set @a errno but @a h_errno on POSIX systems, + * but on Windows the error code can be retrieved by @a WSAGetLastError * as usual. * - * The functions gethostbyname() and gethostbyaddr() are obsolete, - * and getaddressinfo() should be used preferably. + * The functions @a gethostbyname and @a gethostbyaddr are obsolete, + * and @a getaddressinfo should be used preferably. * - * @param[in] info An optional informational text string, or NULL + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_get_gethostbyname_error( const char *info ) { @@ -1165,14 +1171,14 @@ int mbg_gai_error( int rc, const char *info ) /*HDR*/ /** - * @brief Retrieve and convert last zlib internal error code + * @brief Retrieve and convert last zlib internal error code. * - * @param[in] zlib_error zlib internal error code - * @param[in] info An optional informational text string, or NULL - * @param[in] msg An optional zlib specific error msg, or NULL. - * Struct z_stream contains member msg. + * @param[in] zlib_error zlib internal error code. + * @param[in] info An optional informational text string, or @a NULL. + * @param[in] msg An optional zlib specific error msg, or @a NULL. + * Struct @a z_stream contains member msg. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_zlib_error_to_mbg( int zlib_error, const char *info, const char *msg ) { diff --git a/mbglib/common/mbgerror.h b/mbglib/common/mbgerror.h index 05a8999..df87c4a 100755 --- a/mbglib/common/mbgerror.h +++ b/mbglib/common/mbgerror.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgerror.h 1.24 2019/08/28 08:02:56 philipp REL_M $ + * $Id: mbgerror.h 1.33 2021/11/03 16:57:02 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,6 +11,25 @@ * * ----------------------------------------------------------------------- * $Log: mbgerror.h $ + * Revision 1.33 2021/11/03 16:57:02 martin.burnicki + * Added MBG_ERR_NOT_SUPP_BY_DRVR. + * Revision 1.32 2021/04/13 08:27:01 martin + * Updated some comments. + * Revision 1.31 2021/03/16 12:21:53 martin + * Updated some comments. + * Revision 1.30 2021/03/12 12:32:05 martin + * Updated some comments. + * Revision 1.29 2020/05/27 11:30:40 martin + * New NTP exit codes MBG_NTP_EXIT_FAIL_MEM and MBG_NTP_EXIT_FAIL_CRYPTO_API. + * Revision 1.28 2020/05/25 20:52:12 martin + * New NTP exit code MBG_NTP_EXIT_FAIL_TIMEOUT. + * Revision 1.27 2019/12/02 09:26:17 philipp + * Added MBG_ERR_NAME error code + * Revision 1.26 2019/11/11 10:10:10 martin + * Moved exit codes here that are used by NTP tools. + * Should be merged with other exit codes later. + * Revision 1.25 2019/10/09 09:31:04 philipp + * Added MBG_ERR_INV_USER and MBG_ERR_INV_GROUP * Revision 1.24 2019/08/28 08:02:56 philipp * Added error code MBG_ERR_IN_PROGRESS * Revision 1.23 2019/08/26 15:14:34 martin @@ -50,7 +69,7 @@ * Changed message text for MBG_ERR_NO_ENTITY. * Replaced old _mbg_err_to_os() macro by new inline functions * mbg_errno_to_os() and mbg_ret_val_to_os(). - * Fixed build under Windows. + * Fixed build on Windows. * Updated doxygen comments. * Updated function prototypes. * Revision 1.14 2017/05/10 15:21:39 martin @@ -113,27 +132,27 @@ #if defined( MBG_TGT_KERNEL ) - #define MBG_TGT_MISSING_DWORD 1 // missing even in kernel space. - #define MBG_TGT_MISSING_NTSTATUS 0 // available in kernel space + #define MBG_TGT_MISSING_DWORD 1 // Missing even in kernel space. + #define MBG_TGT_MISSING_NTSTATUS 0 // Available in kernel space #else // Windows user space - #define MBG_TGT_MISSING_DWORD 0 // available in user space + #define MBG_TGT_MISSING_DWORD 0 // Available in user space. // Some (but not all) Windows build environments provide a // bcrypt.h file which has a definition for NTSTATUS, so we - // use.that if available to avoid duplicate / mismatching + // use that if available to avoid duplicate / mismatching // definitions in case an application uses bcrypt.h anyway. - #if !defined( MBG_TGT_HAS_BCRYPT_H ) // unless already defined elsewhere - #if defined( _MSC_VER ) && ( _MSC_VER >= 1500 ) // at least VS2008 has it + #if !defined( MBG_TGT_HAS_BCRYPT_H ) // Unless already defined elsewhere. + #if defined( _MSC_VER ) && ( _MSC_VER >= 1500 ) // At least VS2008 has it. #define MBG_TGT_HAS_BCRYPT_H 1 #endif - #if defined( MBG_TGT_MINGW ) // older versions may not have it, though + #if defined( MBG_TGT_MINGW ) // Mingw has it, too. #define MBG_TGT_HAS_BCRYPT_H 1 #endif - #if !defined( MBG_TGT_HAS_BCRYPT_H ) + #if !defined( MBG_TGT_HAS_BCRYPT_H ) // Other build environments may not have it. #define MBG_TGT_HAS_BCRYPT_H 0 #endif #endif @@ -147,7 +166,7 @@ #endif -#else // non-Windows targets +#else // Non-Windows targets. #define MBG_TGT_MISSING_DWORD 1 #define MBG_TGT_MISSING_NTSTATUS 1 @@ -248,16 +267,16 @@ extern "C" { /** - * @brief Error codes used with Meinberg devices and drivers + * @defgroup MBG_RETURN_CODES Return codes used with Meinberg devices and drivers * * Appropriate error strings can be retrieved via the ::mbg_strerror function. * * @see ::MBG_ERR_STR_TABLE_ENG * - * @anchor MBG_RETURN_CODES @{ */ + * @{ */ -/* ### TODO FIXME - * Under Windows, some message strings are provided as resources appended +/* FIXME TODO + * On Windows, some message strings are provided as resources appended * to the mbgctrl DLL, but the codes specified here have to be translated * to Windows-specific message IDs before the appropriate resource string * can be retrieved. Actually this is done by taking the absolute number @@ -270,16 +289,20 @@ extern "C" { // and returned by the firmware of bus-level devices, so the definitions // must *not* be renumbered. -#define MBG_SUCCESS 0 ///< No error, has to match ::PCPS_SUCCESS +#define MBG_SUCCESS 0 ///< No error, has to match ::PCPS_SUCCESS. - /** @anchor MBG_ERROR_CODES @{ */ -// Other codes which have to match codes defined in pcpsdefs.h returned by bus-level devices -#define MBG_ERR_STIME -1 ///< Tried to write invalid date/time/status to device, has to match ::PCPS_ERR_STIME -#define MBG_ERR_CFG -2 ///< Tried to write invalid configuration parameters to device, has to match ::PCPS_ERR_CFG (see also ::MBG_ERR_INV_CFG) +/** + * @defgroup MBG_ERROR_CODES Error codes used with Meinberg devices and drivers + * + * @{ */ + +// Other codes which have to match codes defined in pcpsdefs.h returned by bus-level devices. +#define MBG_ERR_STIME -1 ///< Tried to write invalid date/time/status to device, has to match ::PCPS_ERR_STIME. +#define MBG_ERR_CFG -2 ///< Tried to write invalid configuration parameters to device, has to match ::PCPS_ERR_CFG (see also ::MBG_ERR_INV_CFG). -// Codes returned by low level functions of the bus-level device driver +// Codes returned by low level functions of the bus-level device driver. #define MBG_ERR_GENERIC -19 ///< Generic error. #define MBG_ERR_TIMEOUT -20 ///< Timeout accessing the device. #define MBG_ERR_FW_ID -21 ///< Invalid firmware ID. @@ -298,12 +321,12 @@ extern "C" { #define MBG_ERR_DEV_NOT_SUPP -29 ///< Device type not supported by driver. #define MBG_ERR_INV_DEV_REQUEST -30 ///< IOCTL call not supported by driver. #define MBG_ERR_NOT_SUPP_BY_DEV -31 ///< Command or feature not supported by device. -// #define MBG_ERR_USB_ACCESS -32 ///< USB access failed (FIXME TODO this is B.S., we should return *why*) +// #define MBG_ERR_USB_ACCESS -32 ///< USB access failed (TODO This is B.S., we should return ***why***). #define MBG_ERR_CYCLIC_TIMEOUT -33 ///< Cyclic event (IRQ, etc.) didn't occur in time. #define MBG_ERR_NOT_SUPP_ON_OS -34 ///< Function is not supported on this operating system. #define MBG_ERR_LIB_NOT_COMPATIBLE -35 ///< Installed shared library version not compatible with version used at build time. -#define MBG_ERR_N_COM_EXCEEDS_SUPP -36 ///< Num. COM ports of the device exceeds max. supp. by driver. -#define MBG_ERR_N_STR_EXCEEDS_SUPP -37 ///< Num. string formats of the device exceeds max. supp. by driver. +#define MBG_ERR_N_COM_EXCEEDS_SUPP -36 ///< Number of COM ports of the device exceeds max. supported by driver. +#define MBG_ERR_N_STR_EXCEEDS_SUPP -37 ///< Number of string formats of the device exceeds max. supp. by driver. #define MBG_ERR_IRQ_UNSAFE -38 ///< Enabled IRQ of bus-level device is unsafe with this firmware/ASIC version. #define MBG_ERR_N_POUT_EXCEEDS_SUPP -39 ///< Num. prog. outputs of the device exceeds max. supp. by driver. @@ -402,6 +425,11 @@ extern "C" { #define MBG_ERR_BAD_ADDRESS -119 ///< Bad Address (like POSIX EFAULT) #define MBG_ERR_IN_PROGRESS -120 ///< Long lasting operation in progress +#define MBG_ERR_INV_USER -121 ///< Invalid user +#define MBG_ERR_INV_GROUP -122 ///< Invalid group +#define MBG_ERR_NAME -123 ///< Invalid name + +#define MBG_ERR_NOT_SUPP_BY_DRVR -124 ///< Requested feature is not supported by the driver // NOTE: New codes have to be appended to this list, and the sequence of codes must not // be changed. Whenever new codes have been defined, appropriate entries have to be added @@ -506,7 +534,11 @@ extern "C" { { MBG_ERR_BUFFER_TOO_SMALL, "Data buffer too small" }, \ { MBG_ERR_OUTDATED, "Software/Module is too old/outdated. Please update!" }, \ { MBG_ERR_STR_SUBSTR, "Invalid substring in string" }, \ - { MBG_ERR_IN_PROGRESS, "Long lasting operation in progress" } + { MBG_ERR_IN_PROGRESS, "Long lasting operation in progress" }, \ + { MBG_ERR_INV_USER, "Invalid user" }, \ + { MBG_ERR_INV_GROUP, "Invalid group" }, \ + { MBG_ERR_NAME, "Invalid name" }, \ + { MBG_ERR_NOT_SUPP_BY_DRVR, "Not supported by the driver" } /** @@ -642,6 +674,11 @@ bool mbg_rc_is_success_or_err_perm( int rc ) /** * @brief Predefined exit codes returned by some tools. + * + * Should be merged with ::MBG_NTP_EXIT_CODES. + * + * @see ::MBG_NTP_EXIT_CODES + * @see ::MBG_NTP_EXIT_CODE_STRS */ enum MBG_EXIT_CODES { @@ -655,193 +692,248 @@ enum MBG_EXIT_CODES +/** + * @brief Predefined exit codes returned by some NTP tools. + * + * Should be merged with ::MBG_EXIT_CODES. + * + * @see ::MBG_NTP_EXIT_CODE_STRS + * @see ::MBG_EXIT_CODES + */ +enum MBG_NTP_EXIT_CODES +{ + MBG_NTP_EXIT_SUCCESS, // Success. + MBG_NTP_EXIT_FAIL_USAGE, // Usage printed, invalid parameter? + MBG_NTP_EXIT_FAIL_GENERIC, // General failure, unspecified. + MBG_NTP_EXIT_FAIL_DNS, // Host name lookup failed. + MBG_NTP_EXIT_FAIL_SOCKET, // Failed to open socket. + MBG_NTP_EXIT_FAIL_SEND, // Failed to send packet. + MBG_NTP_EXIT_FAIL_RECEIVE, // Failed to receive packet. + MBG_NTP_EXIT_FAIL_ENCRYPT, // Failed to encrypt a packet. + MBG_NTP_EXIT_FAIL_DECRYPT, // Failed to decrypt an encrypted packet. + MBG_NTP_EXIT_FAIL_CRYPT_NACK, // Failed because received a crypto NACK. + MBG_NTP_EXIT_FAIL_BIND, // Failed to bind to specific address or port. + MBG_NTP_EXIT_FAIL_TIMEOUT, // Timeout that shouldn't occur unless running at full speed. + MBG_NTP_EXIT_FAIL_MEM, // Out of memory. + MBG_NTP_EXIT_FAIL_CRYPTO_API, // Some crypto API call failed for unspecified reason. + N_MBG_NTP_EXIT_CODES +}; + + +/** + * @brief Info strings associated with predefined NTP tool exit codes. + * + * Should be merged with ::MBG_EXIT_CODES. + * + * @see ::MBG_NTP_EXIT_CODES + */ + +#define MBG_NTP_EXIT_CODE_STRS \ +{ \ + "Success", /* MBG_NTP_EXIT_OK */ \ + "Usage printed, e.g. invalid parameter.", /* MBG_NTP_EXIT_FAIL_USAGE */ \ + "Unspecified error.", /* MBG_NTP_EXIT_FAIL_GENERIC */ \ + "Host name lookup failed.", /* MBG_NTP_EXIT_FAIL_DNS */ \ + "Failed to open socket.", /* MBG_NTP_EXIT_FAIL_SOCKET */ \ + "Failed to send packet.", /* MBG_NTP_EXIT_FAIL_SEND */ \ + "Failed to receive packet.", /* MBG_NTP_EXIT_FAIL_RECEIVE */ \ + "Failed to encrypt a packet.", /* MBG_NTP_EXIT_FAIL_ENCRYPT */ \ + "Failed to decrypt an encrypted packet.", /* MBG_NTP_EXIT_FAIL_DECRYPT */ \ + "Received a crypto NACK.", /* MBG_NTP_EXIT_FAIL_CRYPT_NACK */ \ + "Failed to bind to specific address or port.", /* MBG_NTP_EXIT_FAIL_BIND */ \ + "Timeout.", /* MBG_NTP_EXIT_FAIL_TIMEOUT */ \ + "Unspecified crypto API error." /* MBG_NTP_EXIT_FAIL_CRYPTO_API */ \ +} + + + /* ----- function prototypes begin ----- */ /* This section was generated automatically */ /* by MAKEHDR, do not remove the comments. */ /** - * @brief Convert one of the @ref MBG_ERROR_CODES to an OS-specific format + * @brief Convert one of the @ref MBG_ERROR_CODES to an OS-specific format. * * @param[in] err_no One of the @ref MBG_ERROR_CODES. * * @see @ref MBG_ERROR_CODES * - * @return An OS-specific error code + * @return An OS-specific error code. */ int mbg_errno_to_os( int err_no ) ; /** - * @brief Return an error string associated with the @ref MBG_ERROR_CODES + * @brief Return an error string associated with the @ref MBG_ERROR_CODES. * - * @param[in] mbg_errno One of the @ref MBG_ERROR_CODES + * @param[in] mbg_errno One of the @ref MBG_ERROR_CODES. * - * @return A constant string describing the error, or NULL for unknown error codes + * @return A constant string describing the error, or a generic string + * "Unknown error" for unknown error codes. */ const char *mbg_strerror( int mbg_errno ) ; /** - * @brief Check if a value is an error code and print an associated error message + * @brief Check if a value is an error code and print an associated error message. * - * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES - * @param[in] what A string indicated what failed + * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES. + * @param[in] what A string indicated what failed. * - * @return true if rc represented an error code, and a message has been printed, else false + * @return @a true if @p rc represented an error code and a message has been printed, else @a false. */ bool mbg_cond_err_msg( int rc, const char *what ) ; /** - * @brief Check if a value is an general or a "not supported" error code and print an associated message + * @brief Check if a value is a general or a "not supported" error code, and print an associated message. * - * If rc contains an error code then an error message is printed, and true is returned. + * If @p rc contains an error code, an error message is printed. * - * If the optional parameter string info2 is not NULL then it should contain - * the name of a feature which has been tested before. In this case, if the error - * code is the specific error ::MBG_ERR_NOT_SUPP_BY_DEV then a "not supported" message - * is printed using info2. + * If the error code is ::MBG_ERR_NOT_SUPP_BY_DEV and the optional parameter + * string @p info is not @a NULL, a specific error message is generated. * - * If info2 is NULL, or the error code is not ::MBG_ERR_NOT_SUPP_BY_DEV then the standard - * error message is printed anyway. + * If @p rc contains a different error code, or the optional parameter + * string @p info is @a NULL, a generic error message is generated that + * includes the string from parameter @p what. * - * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES - * @param[in] what A string indicated what failed - * @param[in] info An optional informational string telling what is not supported (may be NULL). + * @param[in] rc A positive number including ::MBG_SUCCESS, or one of the @ref MBG_ERROR_CODES. + * @param[in] what A string indicated what failed. + * @param[in] info An optional informational string telling what is not supported (may be @a NULL). * - * @return true if rc represented an error code, and a message has been printed, else false + * @return @a true if @p rc represented any error code, and a message has been printed, else @a false. */ bool mbg_cond_err_msg_info( int rc, const char *what, const char *info ) ; /** - * @brief Translate an error code from the Labwindows/CVI RS-232 library to one of the @ref MBG_ERROR_CODES + * @brief Translate an error code from the Labwindows/CVI RS-232 library to one of the @ref MBG_ERROR_CODES. * - * @param[in] cvi_rc An error code returned by a CVI RS-232 library function - * @param[in] info An optional informational text string, or NULL + * @param[in] cvi_rc An error code returned by a CVI RS-232 library function. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. * * @see http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cvirs232_error_conditions/ */ int mbg_cvi_rs232_error_to_mbg( int cvi_rc, const char *info ) ; /** - * @brief Translate a Windows NTSTATUS code to one of the @ref MBG_ERROR_CODES + * @brief Translate a Windows NTSTATUS code to one of the @ref MBG_ERROR_CODES. * - * @param[in] st One of the NTSTATUS codes defined in ntstatus.h - * @param[in] info An optional informational text string, or NULL + * @param[in] st One of the NTSTATUS codes defined in ntstatus.h. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_win32_ntstatus_to_mbg( NTSTATUS st, const char *info ) ; /** - * @brief Translate a Windows non-socket API return code to one of the @ref MBG_RETURN_CODES + * @brief Translate a Windows non-socket API return code to one of the @ref MBG_RETURN_CODES. * - * @param[in] win32_sys_rc A Windows non-socket API error code as returned by GetLastError(), or ERROR_SUCCESS. - * @param[in] info An optional informational text string, or NULL. + * @param[in] win32_sys_rc A Windows non-socket API error code as returned by @a GetLastError, or @a ERROR_SUCCESS. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_RETURN_CODES + * @return One of the @ref MBG_RETURN_CODES. */ int mbg_win32_sys_err_to_mbg( DWORD win32_sys_rc, const char *info ) ; /** - * @brief Translate a Windows socket API error code to one of the @ref MBG_ERROR_CODES + * @brief Translate a Windows socket API error code to one of the @ref MBG_ERROR_CODES. * - * @param[in] wsa_err A Windows socket API error code as returned by WSAGetLastError() - * @param[in] info An optional informational text string, or NULL + * @param[in] wsa_err A Windows socket API error code as returned by @a WSAGetLastError. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_win32_wsa_err_to_mbg( int wsa_err, const char *info ) ; /** - * @brief Translate a POSIX errno error code to one of the @ref MBG_ERROR_CODES + * @brief Translate a POSIX errno error code to one of the @ref MBG_ERROR_CODES. * - * @param[in] posix_errno A POSIX error code as usually defined in errno.h - * @param[in] info An optional informational text string, or NULL + * @param[in] posix_errno A POSIX error code as usually defined in errno.h. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_posix_errno_to_mbg( int posix_errno, const char *info ) ; /** - * @brief Translate a POSIX h_errno error code to one of the @ref MBG_ERROR_CODES + * @brief Translate a POSIX h_errno error code to one of the @ref MBG_ERROR_CODES. * * This function is specific to translate error codes returned by - * gethostbyname() and gethostbyaddr(). In case of error these functions - * don't set errno but h_errno to a specific value. + * @a gethostbyname and @a gethostbyaddr. In case of error these functions + * don't set @a errno but @a h_errno to a specific value. * - * The functions gethostbyname() and gethostbyaddr() are obsolete, - * and getaddressinfo() should be used preferably. + * The functions @a gethostbyname and @a gethostbyaddr are obsolete, + * and @a getaddressinfo should be used preferably. * - * @param[in] posix_h_errno An error code as usually defined in netdb.h - * @param[in] info An optional informational text string, or NULL + * @param[in] posix_h_errno An error code as usually defined in netdb.h. + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_posix_h_errno_to_mbg( int posix_h_errno, const char *info ) ; /** - * @brief Get and translate last error after non-socket function call + * @brief Get and translate last error after non-socket function call. * * Retrieve the "last error" code after a non-socket function has been called * and translate to one of the @ref MBG_ERROR_CODES. * - * On POSIX systems the "last error" code is always stored in errno, but - * e.g. under Windows the "last error" code after a socket function - * has to be retrieved by calling WSAGetLastError(), whereas the "last error" + * On POSIX systems the "last error" code is always stored in @a errno, but + * e.g. on Windows the "last error" code after a socket function + * has to be retrieved by calling @a WSAGetLastError, whereas the "last error" * code from non-socket POSIX-like functions has to be retrieved - * by calling GetLastError(). + * by calling @a GetLastError. * - * @param[in] info An optional informational text string, or NULL + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_get_last_error( const char *info ) ; /** - * @brief Get and translate last error after socket function call + * @brief Get and translate last error after socket function call. * * Retrieve the "last error" code after a socket function has been called * and translate to one of the @ref MBG_ERROR_CODES. * - * On POSIX systems the "last error" code is always stored in errno, but - * e.g. under Windows the "last error" code after a socket function - * has to be retrieved by calling WSAGetLastError, whereas the "last error" - * code from non-socket POSIX-like functions is stored in errno as usual. + * On POSIX systems the "last error" code is always stored in @a errno, but + * e.g. on Windows the "last error" code after a socket function + * has to be retrieved by calling @a WSAGetLastError, whereas the "last error" + * code from non-socket POSIX-like functions is stored in @a errno as usual. * - * @param[in] info An optional informational text string, or NULL + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_get_last_socket_error( const char *info ) ; /** - * @brief Retrieve and convert last error after gethostbyname() + * @brief Retrieve and convert last error after gethostbyname(). * * This function is specific to retrieve and translate error codes - * returned by gethostbyname() and gethostbyaddr(). In case of error - * these functions don't set errno but h_errno on POSIX systems, but - * under Windows the error code can be retrieved by WSAGetLastError() + * returned by @a gethostbyname and @a gethostbyaddr. In case of error + * these functions don't set @a errno but @a h_errno on POSIX systems, + * but on Windows the error code can be retrieved by @a WSAGetLastError * as usual. * - * The functions gethostbyname() and gethostbyaddr() are obsolete, - * and getaddressinfo() should be used preferably. + * The functions @a gethostbyname and @a gethostbyaddr are obsolete, + * and @a getaddressinfo should be used preferably. * - * @param[in] info An optional informational text string, or NULL + * @param[in] info An optional informational text string, or @a NULL. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_get_gethostbyname_error( const char *info ) ; /** - * @brief Retrieve and convert last zlib internal error code + * @brief Retrieve and convert last zlib internal error code. * - * @param[in] zlib_error zlib internal error code - * @param[in] info An optional informational text string, or NULL - * @param[in] msg An optional zlib specific error msg, or NULL. - * Struct z_stream contains member msg. + * @param[in] zlib_error zlib internal error code. + * @param[in] info An optional informational text string, or @a NULL. + * @param[in] msg An optional zlib specific error msg, or @a NULL. + * Struct @a z_stream contains member msg. * - * @return One of the @ref MBG_ERROR_CODES + * @return One of the @ref MBG_ERROR_CODES. */ int mbg_zlib_error_to_mbg( int zlib_error, const char *info, const char *msg ) ; diff --git a/mbglib/common/mbgtime.h b/mbglib/common/mbgtime.h index b6064a8..f0ce77f 100755 --- a/mbglib/common/mbgtime.h +++ b/mbglib/common/mbgtime.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgtime.h 1.37 2019/08/28 13:19:40 martin REL_M $ + * $Id: mbgtime.h 1.46 2021/03/16 12:20:48 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,33 @@ * * ----------------------------------------------------------------------- * $Log: mbgtime.h $ + * Revision 1.46 2021/03/16 12:20:48 martin + * Updated some comments. + * Revision 1.45 2021/03/12 12:32:51 martin + * Updated some comments. + * Revision 1.44 2021/03/11 16:08:01 martin + * Fixed some doxygen comments. + * Revision 1.43 2020/09/01 14:48:56 martin + * Fixed build with Borland C. + * Revision 1.42 2020/08/10 16:31:30Z martin + * Fixed 'long long' suffix for Windows builds. + * Revision 1.41 2019/11/27 11:21:39Z martin + * Renamed function n_days() to n_days_since_year_0() + * to make clearer what the function returns, and provided + * a backward-compatible inline function n_days(). + * Updated some doxygen comments. + * Revision 1.40 2019/11/27 11:14:39 martin + * Added definition POSIX_1970_INITIAL_DAY. + * Revision 1.39 2019/11/27 11:09:58 martin + * Added definitions of SMPTE epoch offsets from GPS epoch. + * Revision 1.38 2019/09/27 14:53:20 martin + * New define MONTHS_PER_YEAR. + * New types MBG_TIME32_T MBG_TIME32U_T. + * New inline function mbg_exp_year(). + * New inline functions normalize_gps_wn_dn() and de_normalize_gps_wn_dn(). + * New definitions for different types of leap second tables. + * New function is_valid_leap_second_date() and variants thereof. + * Updated function prototypes. * Revision 1.37 2019/08/28 13:19:40 martin * New structures MBG_TZ_INFO and MBG_LS_INFO which * are used by some new functions in new module mbgtimex.c. @@ -64,7 +91,7 @@ * Added some useful macros. * Revision 1.18 2012/10/02 18:51:11 martin * Include <time.h> for WIN32 target and firmware only - * Fixed build under QNX, DOS, and FreeBSD. + * Fixed build on QNX, DOS, and FreeBSD. * Revision 1.17 2010/08/06 13:03:03 martin * Removed obsolete code. * Revision 1.16 2010/07/16 10:22:07Z martin @@ -131,32 +158,174 @@ extern "C" { /* Start of header body */ /** - * @brief A POSIX-like timestamp which is always 64 bits wide. + * @defgroup leap_second_fncs Meinberg leap second support functions + * + * By default, the date and time ***at the end of a leap second*** + * is referred to as <em>leap second date</em>. This is because: + * + * - At this point in time a new TAI offset comes into effect. + * + * - This is precise both in case of an inserted leap second (when the + * numbered seconds are counted 59, 60, 0) as well as for a deleted + * leap second (when the numbered seconds jump from 58 to 0, and + * there is no second numbered 59). + * + * - This complies with the leap second tables published by the + * International Earth Rotation and Reference Systems Service (IERS). + * + * So, for example, instead of 2016-12-31 23:59:59 we expect + * 2017-01-01 00:00:00 as a valid leap second date. + */ + +/** + * @defgroup leap_date_valid_fncs Meinberg functions that check if a leap second date is valid + * @ingroup leap_second_fncs + * + * For detailed hints, see @ref leap_second_fncs. + * + * Actually, only dates at the beginning of January or or July are + * considered valid leap second dates. There are several functions: + * + * @see ::is_valid_leap_second_date_tm A check function that expects a <em>struct tm</em> parameter. + * @see ::is_valid_leap_second_date_tm_gps A check function that expects a ::TM_GPS parameter. + * @see ::is_valid_leap_second_date A generic check function that expects day of month and month. + * + * @see @ref leap_second_fncs + */ + +/** + * @defgroup group_true_gps_wn_fncs Functions to determine a true leap second week number + * @ingroup leap_second_fncs + * + * The ::UTC::WNlsf field originally transmitted by the GPS satellites + * contains only the 8 LSBs of the full leap second week number, covering + * only a range of +/- ~128 weeks from the current week number. + * + * GPS receivers try to derive a full extended week number + * from this truncated week number. + * + * If the %UTC offset fields ::UTC::delta_tls and ::UTC::delta_tlsf + * are different, this means that a leap second is currently being + * announced, and thus the leap second week number is indeed in + * the range of +/- ~128 week of the current week, which means + * the week number can be unambiguously extended by the receiver. + * + * However, if ::UTC::delta_tls and ::UTC::delta_tlsf are the + * same, no leap second is announced, and it's not clear in + * which 256-week cycle the last leap second really occurred. + * These functions can be used to try to resolve this ambiguity, + * and, if possible, determine the true extended week number. + * + * The approach implemented here is based on a suggestion by + * Tom van Baak [[tvb@leapsecond.com]] on the leap seconds mailing + * list, and the fact that previous leap seconds were inserted only + * at the end of June/beginning of July, or end of December/beginning + * of January, and there are no plans to change this in the foreseeable + * future. + * + * The truncated week number is expanded for subsequent 256-week + * cycles, and if the extended week number and given day number + * yield a date that matches one of these well-known leap second + * dates, we have found the correct extended week number. + * + * A test has shown that there are unique results for 25 256-week + * cycles from 1980, i.e. until year 2099, if only leap seconds + * at the beginning of January or July are accepted. If the number of + * 256-week cycles is extended beyond 25 / year 2099, or if leap + * dates at the beginning of April or October are in addition taken + * into account, the results can be ambiguous, i.e. there + * can be more than one match. + * + * For example, both week numbers 1929 (0x0789, real week number) + * and 2185 (0x0889, off by 256 weeks) with correct day 7 yield + * the real leap second date 2017-01-01. + * + * @see ::mbg_find_true_gps_wn_lsf + * @see ::mbg_find_true_gps_wn_lsf_ex + * @see ::find_past_gps_wn_lsf_from_table + */ + + + +/** + * @defgroup group_timestamp_types Data types to store timestamps. * * Depending on the build and target environment, the original - * POSIX time_t may be only 32 bits wide, and thus will roll over - * in year 2038. Using this type for time conversion functions - * which also support this avoid the rollover on such systems. + * POSIX @a time_t type is usually 32 bits or 64 bits wide. + * If it is only 32 bits wide, timestamps will overflow in 2038. + * + * Using 64 bit types and associated time conversion functions + * avoid a rollover in 2038. + * + * Using a distinct 32 bit type can be useful for API calls which + * return 32 bit timestamps only, which may need to be mapped to + * an extended 64 bit range. + */ + +/** + * @brief A POSIX-like timestamp, 64 bits wide, signed. + * + * Negative numbers can represent times before the epoch. + * + * @ingroup group_timestamp_types + * @see @ref group_timestamp_types */ typedef int64_t MBG_TIME64_T; +/** + * @brief A POSIX-like timestamp, 32 bits wide, signed. + * + * Negative numbers can represent times before the epoch, + * but rolls over earlier than the unsigned type ::MBG_TIME32U_T. + * + * @ingroup group_timestamp_types + * @see @ref group_timestamp_types + */ +typedef int32_t MBG_TIME32_T; + /** - * @brief The number of days from 0000-01-01 until GPS epoch + * @brief A POSIX-like timestamp, 32 bits wide, unsigned. * - * The number of days as computed by ::n_days for the date - * of the GPS epoch, 1980-01-06. + * No negative numbers, so times before the epoch + * can't be represented, but rolls over later + * than the signed type ::MBG_TIME32_T. * - * @see ::n_days + * @ingroup group_timestamp_types + * @see @ref group_timestamp_types + */ +typedef uint32_t MBG_TIME32U_T; + + + +/** + * @brief The number of days from 0000-01-01 until POSIX epoch 1970-01-01. + * + * The number of days as computed by ::n_days_since_year_0 for the + * POSIX time_t epoch, 1970-01-01, which was a Thursday. + * + * @see ::n_days_since_year_0 + */ +#define POSIX_1970_INITIAL_DAY 719162L + + + +/** + * @brief The number of days from 0000-01-01 until GPS epoch. + * + * The number of days as computed by ::n_days_since_year_0 for the + * date of the GPS epoch, 1980-01-06, which was a Sunday. + * + * @see ::n_days_since_year_0 */ #define GPS_INITIAL_DAY 722819L /** - * @brief GPS epoch bias from ordinary time_t epoch + * @brief GPS epoch bias from ordinary POSIX time_t epoch. * - * The Unix time_t epoch is usually 1970-01-01 00:00 whereas + * The POSIX time_t epoch is usually 1970-01-01 00:00:00, whereas * the GPS epoch 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), so:<br> @@ -167,10 +336,10 @@ typedef int64_t MBG_TIME64_T; /** - * @brief NTP epoch bias from ordinary time_t epoch + * @brief NTP epoch bias from ordinary POSIX time_t epoch. * - * The Unix time_t epoch is usually 1970-01-01 00:00 whereas - * the NTP epoch is 1900-01-01 00:00, so the difference is + * The POSIX time_t epoch is usually 1970-01-01 00:00:00, whereas + * the NTP epoch is 1900-01-01 00:00:00, so the difference is * a constant number of seconds:<br> * * time_t t = ntp_time - ::NTP_SEC_BIAS @@ -183,24 +352,112 @@ typedef int64_t MBG_TIME64_T; -// Modified Julian Day (MJD) numbers for some commonly used epochs. -// To compute the MJD for a given date just compute the days since epoch -// and add the constant number of days according to the epoch, e.g.: -// current_unix_mjd = ( time( NULL ) / SECS_PER_DAY ) + MJD_AT_UNIX_EPOCH; -#define MJD_AT_GPS_EPOCH 44244UL // MJD at 1980-01-06 -#define MJD_AT_UNIX_EPOCH 40587UL // MJD at 1970-01-01 -#define MJD_AT_NTP_EPOCH 40587UL // MJD at 1900-01-01 +/** + * @defgroup group_smpte_epoch_offsets_gps Predefined SMPTE epoch offsets from GPS epoch + * + * With these constants, timestamps of the GPS time scale + * can be converted to a particular time scale used by SMPTE, + * e.g. to calculate a specific video frame number. + * + * @anchor MBG_SMPTE_EPOCH_OFFSETS + * @see ::MBG_GPIO_VIDEO_EPOCHS + * + * @{ */ -// The constant below defines the Windows FILETIME number (100 ns intervals -// since 1601-01-01) for 1970-01-01, which is usually the epoch for the time_t -// type used by the standard C library. +/** + * @brief SMPTE epoch offset from GPS to 1970-01-01T00:00:00 TAI. + * + * The total offset consists of the difference between GPS epoch + * and POSIX/UTC epoch (::GPS_SEC_BIAS), plus the constant offset + * between GPS time scale and TAI (::GPS_TAI_OFFSET). + * + * @note This is the standard epoch referred to + * by the PTP/IEEE1588 SMPTE extension. + * + * @see ::SMPTE_TAI_EPOCH_1970 + */ +#define SMPTE_GPS_OFFSET_TAI_1970 ( GPS_SEC_BIAS + GPS_TAI_OFFSET ) + + +/** + * @brief SMPTE epoch offset from GPS to 1958-01-01T00:00:00 TAI. + * + * The total offset consists of the difference between GPS epoch + * and POSIX/UTC epoch (::GPS_SEC_BIAS), plus 12 years since 1958, + * 3 of which were leap years that had an additional day, plus the + * constant offset between GPS time scale and TAI (::GPS_TAI_OFFSET). + * + * @note The TAI time scale didn't exist in 1958, and time scales were + * shifted/adjusted/aligned between 1958 and 1972, so this offset is just + * a hypothetic extrapolation into the past, which may be defined or + * implemented in different ways by different manufacturers or projects. + * + * @see ::SMPTE_TAI_EPOCH_1958 + */ +#define SMPTE_GPS_OFFSET_TAI_1958 ( GPS_SEC_BIAS + ( ( 12 * 365 + 3 ) * SECS_PER_DAY ) + GPS_TAI_OFFSET ) + + +/** + * @brief SMPTE epoch offset from GPS to 1972-01-01T00:00:00 UTC. + * + * The total offset consists of the difference between GPS epoch + * and POSIX/UTC epoch (::GPS_SEC_BIAS), minus 2 years until 1972, + * none of which were leap years that had an additional day. + * + * @see ::SMPTE_UTC_EPOCH_1972 + */ +#define SMPTE_GPS_OFFSET_UTC_1972 ( GPS_SEC_BIAS - ( ( 2 * 365 + 0 ) * SECS_PER_DAY ) ) + + +/** + * @brief SMPTE epoch offset from GPS to 1980-06-01T00:00:00 GPS. + * + * In this case the SMPTE epoch is the same as the GPS epoch, + * so the offset is 0. + * + * @see ::SMPTE_GPS_EPOCH_1980 + */ +#define SMPTE_GPS_OFFSET_GPS_1980 ( 0 ) + + +/** @} defgroup group_ptp_smpte_epoch_offsets_gps */ + + + +/** + * @defgroup group_mjd_numbers Modified Julian Day (MJD) numbers for some commonly used epochs + * + * To compute the MJD for a given date just compute the days since epoch + * and add the constant number of days according to the epoch, e.g. for POSIX: + * + * current_unix_mjd = ( time( NULL ) / SECS_PER_DAY ) + MJD_AT_POSIX_EPOCH; + * + * @anchor MBG_MJD_NUMBERS + * + * @{ */ + +#define MJD_AT_GPS_EPOCH 44244UL ///< MJD at 1980-01-06, see @ref MBG_MJD_NUMBERS +#define MJD_AT_POSIX_EPOCH 40587UL ///< MJD at 1970-01-01, see @ref MBG_MJD_NUMBERS +#define MJD_AT_NTP_EPOCH 40587UL ///< MJD at 1900-01-01, see @ref MBG_MJD_NUMBERS + +/** @} defgroup group_mjd_numbers */ + + + +/** + * @brief The Windows FILETIME value at the usual POSIX epoch. + * + * The Windows @a FILETIME counts the number of 100 ns intervals + * since 1601-01-01, while the POSIX @a time_t epoch is usually + * (but not necessarily) 1970-01-01. + */ #if !defined( FILETIME_1970 ) // FILETIME represents a 64 bit number, so we need to defined the // constant with an appendix depending on the compiler. #if MBG_TGT_C99 || defined( __GNUC__ ) // syntax introduced by C99 standard - #define FILETIME_1970 0x019db1ded53e8000ULL // Epoch offset from FILETIME to UNIX + #define FILETIME_1970 0x019db1ded53e8000ULL #elif defined( MBG_TGT_WIN32 ) // MSC-specific syntax #define FILETIME_1970 0x019db1ded53e8000ui64 @@ -265,6 +522,7 @@ typedef struct } TIMEOUT; +#define MONTHS_PER_YEAR 12 #define DAYS_PER_WEEK 7 @@ -401,7 +659,7 @@ _ext DAYS_OF_MONTH_TABLE days_of_month // simplify call to n_days with structures #define _n_days( _s ) \ - n_days( (_s)->mday, (_s)->month, (_s)->year ) + n_days_since_year_0( (_s)->mday, (_s)->month, (_s)->year ) #define _is_leap_year( _y ) \ @@ -413,6 +671,95 @@ _ext DAYS_OF_MONTH_TABLE days_of_month +static __mbg_inline /*HDR*/ +/** + * @brief Expand a 2-digit year-of-the-century to a full 4-digit year number. + * + * The resulting year number includes the century and is + * in the range [year_lim ... ( year_lim + 99 )]. + * + * @param[in] year The 2-digit year-of-the-century to be converted. + * + * @param[in] year_lim The smallest 4-digit year number to be returned. + * + * @return The resulting 4 digit year number including century. + */ +int mbg_exp_year( int year, int year_lim ) +{ + int lyear = year + year_lim - ( year_lim % 100 ); + + if ( lyear < year_lim ) + lyear += 100; + + return lyear; + +} // mbg_exp_year + + + +static __mbg_inline /*HDR*/ +/** + * @brief Normalize a GPS week number / day number pair. + * + * GPS navigation data may contain week number / day number pairs where + * the day number is in the range 1..7 rather than 0..6. For example, + * a known leap second date was sent with 1929|7 instead of 1930|0. + * + * To resolve this ambiguity in computations, this function can be used + * to normalize the wn|dn pair. + * + * The complementary function ::de_normalize_gps_wn_dn can be used + * to convert a wn|dn pair back to the common wn|dn format where the + * day number is in the range 1..7. + * + * @param[in,out] p_wn Address of a variable containing the week number. + * @param[in,out] p_dn Address of a variable containing the day number. + * + * @see ::de_normalize_gps_wn_dn + */ +void normalize_gps_wn_dn( GPS_WNUM *p_wn, GPS_DNUM *p_dn ) +{ + if ( *p_dn == 7 ) + { + *p_dn = 0; + (*p_wn)++; + } + +} // normalize_gps_wn_dn + + + +static __mbg_inline /*HDR*/ +/** + * @brief De-normalize a GPS week number / day number pair. + * + * GPS navigation data may contain week number / day number pairs where + * the day number is in the range 1..7 rather than 0..6. For example, + * a known leap second date was sent with 1929|7 instead of 1930|0. + * + * However, the function ::normalize_gps_wn_dn may have been called before + * to normalize the wn|dn pair to simplify computations. + * + * This function can be used to convert a wn|dn pair back to the common + * wn|dn format where the day number is in the range 1..7. + * + * @param[in,out] p_wn Address of a variable containing the week number. + * @param[in,out] p_dn Address of a variable containing the day number. + * + * @see ::normalize_gps_wn_dn + */ +void de_normalize_gps_wn_dn( GPS_WNUM *p_wn, GPS_DNUM *p_dn ) +{ + if ( *p_dn == 0 ) + { + *p_dn = 7; + (*p_wn)--; + } + +} // de_normalize_gps_wn_dn + + + #if !defined( MBG_TGT_KERNEL ) /** @@ -455,7 +802,7 @@ _ext DAYS_OF_MONTH_TABLE days_of_month * also need to be updated whenever a leap second event occurrs. * * @see ::mbg_set_tz_info_for_year - * @see ::mbg_set_tz_info_for_utc_time_t + * @see ::mbg_set_tz_info_for_utc_time64_t * @see ::mbg_tz_info_to_tai */ typedef struct @@ -485,12 +832,12 @@ typedef struct { /// @brief Time of the nearest leap second, if available, in %UTC time scale. /// Should match %UTC midnight at the end of the last day in June or December of a given year. - MBG_TIME64_T t_ls_utc; + MBG_TIME64_T t64_ls_utc; /// @brief Time of the nearest leap second, if available, in TAI time scale. - /// Should be ahead of @a #t_ls_utc by a number of leap seconds (~37 s in year 2019) + /// Should be ahead of @a #t64_ls_utc by a number of leap seconds (~37 s in year 2019) /// that have already been inserted in the past. - MBG_TIME64_T t_ls_tai; + MBG_TIME64_T t64_ls_tai; /// @brief Number of seconds to be inserted into the %UTC time scale at the leap second transition. /// This is 0 as long as no leap second announcement is currently available, +1 for a leap @@ -508,6 +855,282 @@ typedef struct /** + * @brief Entry of a leap second table providing timestamps and %UTC/TAI offsets. + * + * There are initializers that can be used to instantiate a table of entries. + * + * @see ::KNOWN_LEAP_SECOND_INFO_NTP + * @see ::KNOWN_LEAP_SECOND_INFO_POSIX + * @see ::LS_TABLE_ENTRY_GPS + */ +typedef struct +{ + /// Timestamp associated with ***the end*** of the leap second, + /// e.g. 2017-01-01 00:00:00 instead of 2016-12-31 23:59:59. + MBG_TIME64_T t_ls; + + /// Number of seconds that %UTC is ***behind*** TAI + /// after the given time. + int utc_tai_offs; + +} LS_TABLE_ENTRY; + + + +/** + * @brief Entry of a leap second table providing GPS timestamps and %UTC/GPS offsets. + * + * There is an initializer that can be used to instantiate a table of entries. + * + * ***Please note*** the table contains normalized wn|dn pairs like 1930|0, + * while the ::UTC info sent by the satellites could be 1929|7. So the wn|dn + * pairs from a GPS receiver should be normalized before being compared. + * + * @see ::KNOWN_LEAP_SECOND_INFO_GPS + * @see ::LS_TABLE_ENTRY + */ +typedef struct +{ + /// Extended GPS week number during which a leap second occurs. + GPS_WNUM wn; + + /// A day-of-week indicating when the leap second occurs. + /// Associated with ***the end*** of the leap second, + /// e.g. 2017-01-01 00:00:00 instead of 2016-12-31 23:59:59. + GPS_DNUM dn; + + /// Number of seconds that %UTC is ***behind*** GPS + /// after the given time. + int gps_tai_offs; + +} LS_TABLE_ENTRY_GPS; + + +#if defined( MBG_TGT_WIN32 ) && ( defined( _MSC_VER ) || defined( __BORLANDC__ ) ) + #define _ls_ntp_ts( _x ) ( _x ## i64 ) +#else + #define _ls_ntp_ts( _x ) ( _x ## LL ) +#endif + + +/** + * @brief Initializer for a table of known leap seconds, with NTP times. + * + * Can be used to initialize a table of ::LS_TABLE_ENTRY entries. + * Values have been copied and can be updated from an NTP leap second file. + * + * The table can be incomplete after another leap second has been scheduled, + * unless this initializer is updated. + * + * The first value is the number of seconds since the NTP epoch, 1900-01-01, + * and the second value indicates how many seconds %UTC is ***behind TAI*** + * after the given date. + * + * There is also an initializer which uses a POSIX time_t for the date, and + * another one where the date is specified by a GPS week number plus day number. + * + * @see ::LS_TABLE_ENTRY + * @see ::KNOWN_LEAP_SECOND_INFO_POSIX + * @see ::KNOWN_LEAP_SECOND_INFO_GPS + */ +#define KNOWN_LEAP_SECOND_INFO_NTP \ +{ \ + { _ls_ntp_ts( 2272060800 ), 10 }, /* 1 Jan 1972 */ \ + { _ls_ntp_ts( 2287785600 ), 11 }, /* 1 Jul 1972 */ \ + { _ls_ntp_ts( 2303683200 ), 12 }, /* 1 Jan 1973 */ \ + { _ls_ntp_ts( 2335219200 ), 13 }, /* 1 Jan 1974 */ \ + { _ls_ntp_ts( 2366755200 ), 14 }, /* 1 Jan 1975 */ \ + { _ls_ntp_ts( 2398291200 ), 15 }, /* 1 Jan 1976 */ \ + { _ls_ntp_ts( 2429913600 ), 16 }, /* 1 Jan 1977 */ \ + { _ls_ntp_ts( 2461449600 ), 17 }, /* 1 Jan 1978 */ \ + { _ls_ntp_ts( 2492985600 ), 18 }, /* 1 Jan 1979 */ \ + { _ls_ntp_ts( 2524521600 ), 19 }, /* 1 Jan 1980 */ \ + { _ls_ntp_ts( 2571782400 ), 20 }, /* 1 Jul 1981 */ \ + { _ls_ntp_ts( 2603318400 ), 21 }, /* 1 Jul 1982 */ \ + { _ls_ntp_ts( 2634854400 ), 22 }, /* 1 Jul 1983 */ \ + { _ls_ntp_ts( 2698012800 ), 23 }, /* 1 Jul 1985 */ \ + { _ls_ntp_ts( 2776982400 ), 24 }, /* 1 Jan 1988 */ \ + { _ls_ntp_ts( 2840140800 ), 25 }, /* 1 Jan 1990 */ \ + { _ls_ntp_ts( 2871676800 ), 26 }, /* 1 Jan 1991 */ \ + { _ls_ntp_ts( 2918937600 ), 27 }, /* 1 Jul 1992 */ \ + { _ls_ntp_ts( 2950473600 ), 28 }, /* 1 Jul 1993 */ \ + { _ls_ntp_ts( 2982009600 ), 29 }, /* 1 Jul 1994 */ \ + { _ls_ntp_ts( 3029443200 ), 30 }, /* 1 Jan 1996 */ \ + { _ls_ntp_ts( 3076704000 ), 31 }, /* 1 Jul 1997 */ \ + { _ls_ntp_ts( 3124137600 ), 32 }, /* 1 Jan 1999 */ \ + { _ls_ntp_ts( 3345062400 ), 33 }, /* 1 Jan 2006 */ \ + { _ls_ntp_ts( 3439756800 ), 34 }, /* 1 Jan 2009 */ \ + { _ls_ntp_ts( 3550089600 ), 35 }, /* 1 Jul 2012 */ \ + { _ls_ntp_ts( 3644697600 ), 36 }, /* 1 Jul 2015 */ \ + { _ls_ntp_ts( 3692217600 ), 37 }, /* 1 Jan 2017 */ \ + /* =============================== */ \ + /* If a new entry is added, don't */ \ + /* forget to update the tables */ \ + /* KNOWN_LEAP_SECOND_INFO_POSIX */ \ + /* and KNOWN_LEAP_SECOND_INFO_GPS */ \ + /* accordingly. */ \ + /* =============================== */ \ + { 0, 0 } /* end-of-table */ \ +} + + + +#define _ls_ntp_to_posix( _x ) ( _ls_ntp_ts( _x ) - NTP_SEC_BIAS ) + +/** + * @brief Initializer for a table of known leap seconds, with POSIX times. + * + * Can be used to initialize a table of ::LS_TABLE_ENTRY entries. Numeric + * values have been copied and can be updated from an NTP leap second file, + * and an appropriate macro is used to convert the NTP times to POSIX. + * + * The table can be incomplete after another leap second has been scheduled, + * unless this initializer is updated. + * + * The resulting first value is the number of seconds since the POSIX epoch, + * 1970-01-01, and the second value indicates how many seconds %UTC is + * ***behind TAI*** after the given date. + * + * There is also an initializer which uses an NTP time for the date, and + * another one where the date is specified by a GPS week number + * plus day number. + * + * @see ::LS_TABLE_ENTRY + * @see ::KNOWN_LEAP_SECOND_INFO_NTP + * @see ::KNOWN_LEAP_SECOND_INFO_GPS + */ +#define KNOWN_LEAP_SECOND_INFO_POSIX \ +{ \ + { _ls_ntp_to_posix( 2272060800 ), 10 }, /* 1 Jan 1972 */ \ + { _ls_ntp_to_posix( 2287785600 ), 11 }, /* 1 Jul 1972 */ \ + { _ls_ntp_to_posix( 2303683200 ), 12 }, /* 1 Jan 1973 */ \ + { _ls_ntp_to_posix( 2335219200 ), 13 }, /* 1 Jan 1974 */ \ + { _ls_ntp_to_posix( 2366755200 ), 14 }, /* 1 Jan 1975 */ \ + { _ls_ntp_to_posix( 2398291200 ), 15 }, /* 1 Jan 1976 */ \ + { _ls_ntp_to_posix( 2429913600 ), 16 }, /* 1 Jan 1977 */ \ + { _ls_ntp_to_posix( 2461449600 ), 17 }, /* 1 Jan 1978 */ \ + { _ls_ntp_to_posix( 2492985600 ), 18 }, /* 1 Jan 1979 */ \ + { _ls_ntp_to_posix( 2524521600 ), 19 }, /* 1 Jan 1980 */ \ + { _ls_ntp_to_posix( 2571782400 ), 20 }, /* 1 Jul 1981 */ \ + { _ls_ntp_to_posix( 2603318400 ), 21 }, /* 1 Jul 1982 */ \ + { _ls_ntp_to_posix( 2634854400 ), 22 }, /* 1 Jul 1983 */ \ + { _ls_ntp_to_posix( 2698012800 ), 23 }, /* 1 Jul 1985 */ \ + { _ls_ntp_to_posix( 2776982400 ), 24 }, /* 1 Jan 1988 */ \ + { _ls_ntp_to_posix( 2840140800 ), 25 }, /* 1 Jan 1990 */ \ + { _ls_ntp_to_posix( 2871676800 ), 26 }, /* 1 Jan 1991 */ \ + { _ls_ntp_to_posix( 2918937600 ), 27 }, /* 1 Jul 1992 */ \ + { _ls_ntp_to_posix( 2950473600 ), 28 }, /* 1 Jul 1993 */ \ + { _ls_ntp_to_posix( 2982009600 ), 29 }, /* 1 Jul 1994 */ \ + { _ls_ntp_to_posix( 3029443200 ), 30 }, /* 1 Jan 1996 */ \ + { _ls_ntp_to_posix( 3076704000 ), 31 }, /* 1 Jul 1997 */ \ + { _ls_ntp_to_posix( 3124137600 ), 32 }, /* 1 Jan 1999 */ \ + { _ls_ntp_to_posix( 3345062400 ), 33 }, /* 1 Jan 2006 */ \ + { _ls_ntp_to_posix( 3439756800 ), 34 }, /* 1 Jan 2009 */ \ + { _ls_ntp_to_posix( 3550089600 ), 35 }, /* 1 Jul 2012 */ \ + { _ls_ntp_to_posix( 3644697600 ), 36 }, /* 1 Jul 2015 */ \ + { _ls_ntp_to_posix( 3692217600 ), 37 }, /* 1 Jan 2017 */ \ + /* =================================================== */ \ + /* If a new entry is added, don't forget to update */ \ + /* the tables KNOWN_LEAP_SECOND_INFO_NTP and */ \ + /* KNOWN_LEAP_SECOND_INFO_GPS accordingly. */ \ + /* =================================================== */ \ + { 0, 0 } /* end-of-table */ \ +} + + + +#define _ls_ntp_to_gps( _x ) \ + ( ( _ls_ntp_ts( _x ) - NTP_SEC_BIAS - GPS_SEC_BIAS ) / SECS_PER_WEEK ), \ + ( ( ( _ls_ntp_ts( _x ) - NTP_SEC_BIAS - GPS_SEC_BIAS ) % SECS_PER_WEEK ) / SECS_PER_DAY ) + +#define _ls_utc_offs_to_gps( _x ) ( (_x) - GPS_TAI_OFFSET ) + +/** + * @brief Initializer for a table of known leap seconds, with GPS times. + * + * Can be used to initialize a table of ::LS_TABLE_ENTRY_GPS entries. Numeric + * values have been copied and can be updated from an NTP leap second file, + * and appropriate macros are used to convert the NTP times to GPS time. + * + * The table can be incomplete after another leap second has been scheduled, + * unless this initializer is updated. + * + * The resulting first value is an extended GPS week number, the second value + * is a day-of-week number, and the third value indicates how many seconds %UTC + * is ***behind GPS*** after the given date. + * + * ***Please note*** the resulting table does not include leap seconds before + * the GPS epoch, and it contains normalized wn|dn pairs like 1930|0, while + * the ::UTC info sent by the satellites could be 1929|7. So the dates from + * a GPS receiver should be normalized before being compared. + * + * There is also an initializer which uses an NTP time for the date, and + * another one where the date is specified by a POSIX time_t value. + * + * @see ::LS_TABLE_ENTRY + * @see ::KNOWN_LEAP_SECOND_INFO_NTP + * @see ::KNOWN_LEAP_SECOND_INFO_POSIX + */ +#define KNOWN_LEAP_SECOND_INFO_GPS \ +{ \ + { _ls_ntp_to_gps( 2571782400 ), _ls_utc_offs_to_gps( 20 ) }, /* 1 Jul 1981 */ \ + { _ls_ntp_to_gps( 2603318400 ), _ls_utc_offs_to_gps( 21 ) }, /* 1 Jul 1982 */ \ + { _ls_ntp_to_gps( 2634854400 ), _ls_utc_offs_to_gps( 22 ) }, /* 1 Jul 1983 */ \ + { _ls_ntp_to_gps( 2698012800 ), _ls_utc_offs_to_gps( 23 ) }, /* 1 Jul 1985 */ \ + { _ls_ntp_to_gps( 2776982400 ), _ls_utc_offs_to_gps( 24 ) }, /* 1 Jan 1988 */ \ + { _ls_ntp_to_gps( 2840140800 ), _ls_utc_offs_to_gps( 25 ) }, /* 1 Jan 1990 */ \ + { _ls_ntp_to_gps( 2871676800 ), _ls_utc_offs_to_gps( 26 ) }, /* 1 Jan 1991 */ \ + { _ls_ntp_to_gps( 2918937600 ), _ls_utc_offs_to_gps( 27 ) }, /* 1 Jul 1992 */ \ + { _ls_ntp_to_gps( 2950473600 ), _ls_utc_offs_to_gps( 28 ) }, /* 1 Jul 1993 */ \ + { _ls_ntp_to_gps( 2982009600 ), _ls_utc_offs_to_gps( 29 ) }, /* 1 Jul 1994 */ \ + { _ls_ntp_to_gps( 3029443200 ), _ls_utc_offs_to_gps( 30 ) }, /* 1 Jan 1996 */ \ + { _ls_ntp_to_gps( 3076704000 ), _ls_utc_offs_to_gps( 31 ) }, /* 1 Jul 1997 */ \ + { _ls_ntp_to_gps( 3124137600 ), _ls_utc_offs_to_gps( 32 ) }, /* 1 Jan 1999 */ \ + { _ls_ntp_to_gps( 3345062400 ), _ls_utc_offs_to_gps( 33 ) }, /* 1 Jan 2006 */ \ + { _ls_ntp_to_gps( 3439756800 ), _ls_utc_offs_to_gps( 34 ) }, /* 1 Jan 2009 */ \ + { _ls_ntp_to_gps( 3550089600 ), _ls_utc_offs_to_gps( 35 ) }, /* 1 Jul 2012 */ \ + { _ls_ntp_to_gps( 3644697600 ), _ls_utc_offs_to_gps( 36 ) }, /* 1 Jul 2015 */ \ + { _ls_ntp_to_gps( 3692217600 ), _ls_utc_offs_to_gps( 37 ) }, /* 1 Jan 2017 */ \ + /* ======================================================================== */ \ + /* If a new entry is added, don't forget to update the tables */ \ + /* KNOWN_LEAP_SECOND_INFO_NTP and KNOWN_LEAP_SECOND_INFO_POSIX */ \ + /* accordingly. */ \ + /* ======================================================================== */ \ + { 0, 0, 0 } /* end-of-tbl */ \ +} + + + +/** + * @brief Number of 256-week-cycles to check for true leap second week number. + * + * The number of 256-week-cycles to check in ::mbg_find_true_gps_wn_lsf + * or find_true_gps_wn_lsf (firmware version of the function), or when trying + * to resolve the ambiguity of the 8 bit truncated week number in ::UTC::WNlsf. + * + * According to some tests, the results are not ambiguous for 25 + * 256-week cycles after 1980 (i.e. until year 2099), if only + * leap second dates at the end of June / beginning of July or + * end of December / beginning of January are taken into account. + * + * @see ::mbg_find_true_gps_wn_lsf (Meinberg API) + * @see find_true_gps_wn_lsf (firmware version of ::mbg_find_true_gps_wn_lsf) + * @see ::ACCEPT_LS_APR_OCT + */ +#define N_GPS_WN_EPOCH 25 + + +#if !defined( ACCEPT_LS_APR_OCT ) + #define ACCEPT_LS_APR_OCT 0 + ///< Should be 0, otherwise ::mbg_find_true_gps_wn_lsf or + ///< find_true_gps_wn_lsf (firmware version of the function) + ///< may fail. + ///< See also ::N_GPS_WN_EPOCH +#endif + + + +/** * @brief Convert a 16 bit binary fraction to a scaled decimal * * @param[in] bin The binary fraction @@ -519,7 +1142,7 @@ typedef struct * @see ::dec_frac_to_bin_frac_32 * @see ::bin_frac_32_to_dec_frac */ -static __mbg_inline +static __mbg_inline /*HDR*/ uint32_t bin_frac_16_to_dec_frac( uint16_t bin, uint32_t scale ) { return (uint32_t) ( (MBG_FRAC32_CONVERSION_TYPE) bin * scale @@ -541,7 +1164,7 @@ uint32_t bin_frac_16_to_dec_frac( uint16_t bin, uint32_t scale ) * @see ::dec_frac_to_bin_frac_16 * @see ::bin_frac_16_to_dec_frac */ -static __mbg_inline +static __mbg_inline /*HDR*/ uint32_t bin_frac_32_to_dec_frac( uint32_t bin, uint32_t scale ) { return (uint32_t) ( (MBG_FRAC32_CONVERSION_TYPE) bin * scale @@ -560,7 +1183,7 @@ uint32_t bin_frac_32_to_dec_frac( uint32_t bin, uint32_t scale ) // This could probably be fixed by a different way of // casting, at least for a partial expression. -static __mbg_inline +static __mbg_inline /*HDR*/ uint16_t dec_frac_to_bin_frac_16( MBG_FRAC32_CONVERSION_TYPE dec, uint32_t scale ) { return (uint16_t) ( ( ( dec * 0x20000 / scale ) + 1 ) >> 1 ); @@ -568,7 +1191,7 @@ uint16_t dec_frac_to_bin_frac_16( MBG_FRAC32_CONVERSION_TYPE dec, uint32_t scale } // dec_frac_to_bin_frac_16 -static __mbg_inline +static __mbg_inline /*HDR*/ uint32_t dec_frac_to_bin_frac_32( MBG_FRAC32_CONVERSION_TYPE dec, uint32_t scale ) { return (uint32_t) ( ( ( dec * MBG_FRAC32_UNITS_PER_SEC * 2 / scale ) + 1 ) >> 1 ); @@ -615,7 +1238,7 @@ uint32_t dec_frac_to_bin_frac_32( MBG_FRAC32_CONVERSION_TYPE dec, uint32_t scale * * @see ::bin_frac_32_to_dec_frac */ -static __mbg_inline +static __mbg_inline /*HDR*/ uint32_t frac_sec_from_bin( uint32_t b, uint32_t scale ) { return bin_frac_32_to_dec_frac( b, scale ); @@ -640,13 +1263,107 @@ uint32_t frac_sec_from_bin( uint32_t b, uint32_t scale ) * * @see ::MBG_FRAC32_UNITS_PER_SEC */ -static __mbg_inline +static __mbg_inline /*HDR*/ double dfrac_sec_from_bin( uint32_t b ) { return (double) b / (double) MBG_FRAC32_UNITS_PER_SEC; } // dfrac_sec_from_bin + + +static __mbg_inline /*HDR*/ +/** + * @brief Check if a particular date is a valid leap second date. + * + * This generic function expects a day of month, and a month. + * + * @param[in] mday The day of month of the date to be checked, range [1..31]. + * @param[in] month The month of the date to be checked, range [1..12]. + * + * @return @a true if considered valid, else @a false. + * + * @ingroup leap_date_valid_fncs + * @see @ref leap_date_valid_fncs + * @see ::is_valid_leap_second_date_tm_gps + * @see ::is_valid_leap_second_date_tm + */ +bool is_valid_leap_second_date( int mday, int month ) +{ + if ( mday != 1 ) + return false; + + if ( ( month == 1 ) || ( month == 7 ) ) // 1st of January or July + return true; + + #if ACCEPT_LS_APR_OCT + if ( ( month == 4 ) || ( month == 10 ) ) // 1st of April or October + return true; + #endif + + return false; + +} // is_valid_leap_second_date + + + +static __mbg_inline /*HDR*/ +/** + * @brief Check if a particular date in ::TM_GPS format is a valid leap second date. + * + * For detailed hints see @ref leap_date_valid_fncs and @ref leap_date_valid_fncs. + * + * This function expects a ::TM_GPS parameter and calls + * a generic function to actually check the date. + * + * @param[in] p_tm_gps The date to be checked, in ::TM_GPS format. + * + * @return @a true if considered valid, else @a false. + * + * @ingroup leap_date_valid_fncs + * @see @ref leap_date_valid_fncs + * @see ::is_valid_leap_second_date_tm + * @see ::is_valid_leap_second_date + */ +bool is_valid_leap_second_date_tm_gps( const TM_GPS *p_tm_gps ) +{ + return is_valid_leap_second_date( p_tm_gps->mday, p_tm_gps->month ); + +} // is_valid_leap_second_date_tm_gps + + + +static __mbg_inline /*HDR*/ +/** + * @brief Check if a particular date in <em>struct tm</em> format is a valid leap second date. + * + * We expect the date and time immediately ***after*** a leap second, + * i.e. when a new TAI offset becomes valid. For example, we expect + * 2017-01-01 00:00:00 instead of 2016-12-31 23:59:59. + * This should work for both inserted and deleted leap seconds. + * + * By default, only dates at the beginning of January or or July are + * considered valid. + * + * This function expects a <em>struct tm</em> parameter and calls + * a generic function to actually check the date. + * + * @param[in] p_tm The date to be checked, in <em>struct tm</em> format. + * + * @return @a true if considered valid, else @a false. + * + * @ingroup leap_date_valid_fncs + * @see @ref leap_date_valid_fncs + * @see ::is_valid_leap_second_date_tm_gps + * @see ::is_valid_leap_second_date + */ +bool is_valid_leap_second_date_tm( const struct tm *p_tm ) +{ + return is_valid_leap_second_date( p_tm->tm_mday, p_tm->tm_mon + 1 ); + +} // is_valid_leap_second_date_tm + + #endif // !defined( MBG_TGT_KERNEL ) @@ -760,7 +1477,7 @@ double dfrac_sec_from_bin( uint32_t b ) * @param[in] day_num Number of days from the beginning of that year, may be negative * @param[out] tm Address of a ::TM_GPS structure which takes the computed results */ - void date_of_year ( int year, int day_num, TM_GPS *tm ) ; + void date_of_year( int year, int day_num, TM_GPS *tm ) ; /** * @brief Compute day-of-week for a given date. @@ -778,7 +1495,7 @@ double dfrac_sec_from_bin( uint32_t b ) * @return The computed day-of-week, 0..6, 0 = Monday (!) * * @see ::day_of_week_sun06 - * @see ::n_days + * @see ::n_days_since_year_0 */ int day_of_week( int day, int month, int year ) ; @@ -794,7 +1511,7 @@ double dfrac_sec_from_bin( uint32_t b ) * * @return The computed day-of-week, 0..6, with 0 = Sunday. * - * @see ::n_days + * @see ::n_days_since_year_0 * @see ::wsec_to_tm */ int day_of_week_sun06( int day, int month, int year ) ; @@ -812,15 +1529,27 @@ double dfrac_sec_from_bin( uint32_t b ) /** * @brief Compute number of days after Jan 1, 0000 for a given date * - * @param[in] mday The day-of-month - * @param[in] month The month - * @param[in] year The full year number + * @param[in] mday The day-of-month, [1..31] + * @param[in] month The month, [1..12]. + * @param[in] year The full year number, starting from year 0. * * @return The computed number of days * * @see ::day_of_week */ - long n_days( ushort mday, ushort month, ushort year ) ; + long n_days_since_year_0( int mday, int month, int year ) ; + + /** + * @brief Search a table of known past leap second dates for a specific week and day number. + * + * Optionally we return the latest week number we + * have found in the table, so an application can + * start there searching there for future potential + * leap second dates. + * + * @ingroup group_true_gps_wn_fncs + */ + int find_past_gps_wn_lsf_from_table( GPS_WNUM *p_wn, GPS_DNUM dn_t, int srch_all, GPS_WNUM *p_wn_last ) ; /** * @brief Print time with hours, minutes, seconds to a string @@ -882,6 +1611,28 @@ double dfrac_sec_from_bin( uint32_t b ) /* ----- function prototypes end ----- */ +static __mbg_inline /*HDR*/ +/** + * @brief Compute number of days after Jan 1, 0000 for a given date. + * + * @deprecated This function is deprecated. Use ::n_days_since_year_0 + * instead, which has a more meaningful name to avoid usage problems. + * + * @param[in] mday The day-of-month, [1..31] + * @param[in] month The month, [1..12]. + * @param[in] year The full year number, starting from year 0. + * + * @return The computed number of days + * + * @see ::day_of_week + */ +long _DEPRECATED_BY( "n_days_since_year_0" ) n_days( int mday, int month, int year ) +{ + return n_days_since_year_0( mday, month, year ); + +} // n_days + + /* End of header body */ diff --git a/mbglib/common/str_util.c b/mbglib/common/str_util.c index 859b5e3..16241cd 100755 --- a/mbglib/common/str_util.c +++ b/mbglib/common/str_util.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: str_util.c 1.6 2019/07/31 15:42:38 martin REL_M $ + * $Id: str_util.c 1.11 2021/03/22 11:28:52 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,16 @@ * * ----------------------------------------------------------------------- * $Log: str_util.c $ + * Revision 1.11 2021/03/22 11:28:52 martin + * Updated some comments. + * Revision 1.10 2021/03/16 12:20:37 martin + * Updated some comments. + * Revision 1.9 2021/03/12 12:32:24 martin + * Updated some comments. + * Revision 1.8 2021/03/12 11:00:26 martin + * Updated some doxygen comments. + * Revision 1.7 2019/11/27 10:37:33 martin + * Tiny code style fixes. * Revision 1.6 2019/07/31 15:42:38 martin * Doxygen changes. * Revision 1.5 2018/08/23 13:07:16 martin @@ -50,15 +60,15 @@ #if defined( MBG_TGT_DOS ) static /*HDR*/ -// Under DOS we use the Borland C/C++ v3.1 compiler by default, which +// On DOS, we use the Borland C/C++ v3.1 compiler by default, which // doesn't provide a vsnprintf() function, so we use a simple replacement // here. Since we share most of the source code between several target -// systems we assume that if our code works properly for other targets -// which really provide a vsnprintf() function then it also works properly -// under DOS. ;-) +// systems, we assume that if our code works properly for other targets +// which really provide a vsnprintf() function, it also works properly +// on DOS. ;-) int vsnprintf( char *s, size_t max_len, const char *fmt, va_list args ) { - (void) max_len; // quiet compiler warning "not used" + (void) max_len; // Quiet compiler warning "not used". return vsprintf( s, fmt, args ); @@ -70,15 +80,15 @@ int vsnprintf( char *s, size_t max_len, const char *fmt, va_list args ) /*HDR*/ /** - * @brief A portable, safe implementation of vsnprintf() + * @brief A portable, safe implementation of vsnprintf(). * - * Unfortunately the behaviour of vsnprintf() and thus snprintf() - * differs in detail across various build environments and run time - * libraries. + * Unfortunately, the behavior of @a vsnprintf and therefore also that + * of @a snprintf differs in detail in different build environments + * and runtime libraries. * - * If the output exceeds the buffer size and thus is truncated then:<br> + * If the output exceeds the buffer size and thus is truncated, then:<br> * - * - Under Windows a negative value is returned and eventually ***no*** + * - On Windows, a negative value is returned and maybe ***no*** * terminating 0 is written to the output buffer, so the output string * may not be terminated properly. * @@ -89,8 +99,10 @@ int vsnprintf( char *s, size_t max_len, const char *fmt, va_list args ) * * So subsequent calls like * - * n = snprintf( s, max_len, ... ); - * n += snprintf( &s[n], max_len - n, ... ); + * @code{.c} + n = snprintf( s, max_len, ... ); + n += snprintf( &s[n], max_len - n, ... ); + * @endcode * * may always work properly, or fail with buffer overruns or stack * corruption depending on the build environment. @@ -99,20 +111,21 @@ int vsnprintf( char *s, size_t max_len, const char *fmt, va_list args ) * characters really written to the string buffer, excluding the * terminating 0. * - * @note The "size_t" type parameter used to specify the buffer size - * can be larger (e.g. "unsigned long") than the "int" type returned - * by mostly all functions of the printf() family. So if a very large + * @note The @a size_t type parameter used to specify the buffer size + * can be larger (e.g. @a unsigned_long) than the @a int type returned + * by mostly all functions of the @a printf family. So if a very large * buffer is specified, and a large number of characters (more than - * MAXINT) are written to that buffer then how can an "int" type + * @a MAXINT) are written to that buffer, how can an @a int type * return the large number of characters written to the buffer? * We also try to workaround this here. * - * @param[out] s The string buffer to be filled - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] fmt Format string according to subsequent parameters - * @param[in] args Variable argument list in va_list format + * @param[out] s The string buffer to be filled. + * @param[in] max_len Size of the output buffer for a 0-terminated string. + * @param[in] fmt Format string according to subsequent parameters. + * @param[in] args Variable argument list in @a va_list format. * - * @return Number of characters written to the output buffer, except the terminating 0 + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::snprintf_safe * @see ::strncpy_safe @@ -125,7 +138,7 @@ int vsnprintf_safe( char *s, size_t max_len, const char *fmt, va_list args ) size_t n; if ( !mbg_buffer_specs_valid( s, max_len ) ) - return 0; // nothing to do anyway + return 0; // Nothing to do anyway. n = mbg_vsnprintf( s, max_len, fmt, args ); @@ -138,16 +151,17 @@ int vsnprintf_safe( char *s, size_t max_len, const char *fmt, va_list args ) /*HDR*/ /** - * @brief A portable, safe implementation of snprintf() + * @brief A portable, safe implementation of snprintf(). * - * For a detailed description see ::vsnprintf_safe + * For a detailed description see ::vsnprintf_safe. * - * @param[out] s The string buffer to be filled - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] fmt Format string according to subsequent parameters - * @param[in] ... Variable argument list according to the format string + * @param[out] s The string buffer to be filled. + * @param[in] max_len Size of the output buffer for a 0-terminated string. + * @param[in] fmt Format string according to subsequent parameters. + * @param[in] ... Variable argument list according to the format string. * - * @return Number of characters written to the output buffer, except the terminating 0 + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::strncpy_safe @@ -155,7 +169,7 @@ int vsnprintf_safe( char *s, size_t max_len, const char *fmt, va_list args ) * @see ::sn_cpy_char_safe */ __attribute__( ( format( printf, 3, 4 ) ) ) -int snprintf_safe( char *s, size_t max_len, const char * fmt, ... ) +int snprintf_safe( char *s, size_t max_len, const char *fmt, ... ) { va_list args; int len; @@ -170,21 +184,22 @@ int snprintf_safe( char *s, size_t max_len, const char * fmt, ... ) -static __mbg_inline +static __mbg_inline /*HDR*/ /* (explicitly excluded from doxygen) - * @brief A portable, safe implementation of a copy function + * @brief A portable, safe implementation of a copy function. * * This is the basic function used to implemment ::strncpy_safe and * ::sn_cpy_safe. This function takes care that the copied string * is always terminated by 0, but any remaining buffer space * is ***not*** filled up with '0' characters. * - * @param[out] dst Pointer to the output buffer - * @param[in] src Pointer to the input buffer - * @param[in] n Number of characters to copy at most - * @param[in,out] p_i Pointer to a counter variable + * @param[out] dst Pointer to the output buffer. + * @param[in] src Pointer to the input buffer. + * @param[in] n Number of characters to copy at most. + * @param[in,out] p_i Pointer to a counter variable. * - * @return The number of characters copied. + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -203,15 +218,15 @@ size_t do_str_copy_safe( char *dst, const char *src, size_t n ) *dst = *src; if ( *dst == 0 ) - break; // just copied the terminating 0, done + break; // Just copied the terminating 0, done. - if ( --n == 0 ) // no more space left in buffer + if ( --n == 0 ) // No more space left in buffer. { - *dst = 0; // force terminating 0 + *dst = 0; // Force terminating 0. break; } - i++; // count normal characters + i++; // Count normal characters. src++; dst++; } @@ -225,21 +240,21 @@ size_t do_str_copy_safe( char *dst, const char *src, size_t n ) /*HDR*/ /** - * @brief A portable, safe implementation of strncpy() + * @brief A portable, safe implementation of strncpy(). * - * In the original implementation of strncpy(), if the length of the + * In the original implementation of @a strncpy, if the length of the * string to be copied into the destination buffer exceeds the specified - * buffer length then the string in the output buffer is not 0-terminated. + * buffer length, the string in the output buffer is not 0-terminated. * * Our implementation always forces a proper termination by 0, but unlike - * the original implementation of strncpy() it does ***not*** fill the whole + * the original implementation of @a strncpy, it does ***not*** fill the whole * remaining buffer space with '0' characters. * - * @param[out] dst Pointer to the output buffer - * @param[in] src Pointer to the input buffer - * @param[in] max_len Size of the output buffer for 0-terminated string + * @param[out] dst Pointer to the output buffer. + * @param[in] src Pointer to the input buffer. + * @param[in] max_len Size of the output buffer for 0-terminated string. * - * @return Pointer to the destination buffer + * @return Pointer to the destination buffer. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -258,17 +273,18 @@ char *strncpy_safe( char *dst, const char *src, size_t max_len ) /*HDR*/ /** - * @brief A function to copy a string safely, returning the number of characters copied + * @brief A function to copy a string safely, returning the number of characters copied. * * This basically works like ::strncpy_safe but instead of a pointer to * the destination buffer it returns the number of characters copied * to the destination buffer. * - * @param[out] dst Pointer to the output buffer - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] src Pointer to the input buffer + * @param[out] dst Pointer to the output buffer. + * @param[in] max_len Size of the output buffer for 0-terminated string. + * @param[in] src Pointer to the input buffer. * - * @return Number of characters copied to the destination buffer + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -287,18 +303,19 @@ int sn_cpy_str_safe( char *dst, size_t max_len, const char *src ) /*HDR*/ /** - * @brief A function to copy a character safely to a string buffer + * @brief A function to copy a character safely to a string buffer. * * This basically works like ::sn_cpy_str_safe but expects a character * to be copied to the destination buffer. Appends a terminating 0 to * the string buffer and returns the number of characters copied to * the destination buffer, usually 0 or 1. * - * @param[out] dst Pointer to the output buffer - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] c Character to be copied to the destination buffer + * @param[out] dst Pointer to the output buffer. + * @param[in] max_len Size of the output buffer for 0-terminated string. + * @param[in] c Character to be copied to the destination buffer. * - * @return Number of characters copied to the destination buffer, without the terminating 0 + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -323,15 +340,15 @@ int sn_cpy_char_safe( char *dst, size_t max_len, char c ) /*HDR*/ /** - * @brief Trim whitespace at the end of a string + * @brief Trim whitespace at the end of a string. * - * @param[in,out] s The string to be trimmed + * @param[in,out] s The string to be trimmed. */ void trim_trailing_whitespace( char *s ) { char *cp; - // set all trailing spaces to 0 + // Set all trailing spaces to 0. for ( cp = &s[strlen( s )]; cp > s; ) { --cp; @@ -348,9 +365,9 @@ void trim_trailing_whitespace( char *s ) /*HDR*/ /** - * @brief Trim whitespace at the beginning of a string + * @brief Trim whitespace at the beginning of a string. * - * @param[in,out] s The string to be trimmed + * @param[in,out] s The string to be trimmed. */ void trim_leading_whitespace( char *s ) { @@ -362,7 +379,7 @@ void trim_leading_whitespace( char *s ) if ( *srcp > ' ' ) break; - // If there are leading spaces then srcp now + // If there are leading spaces, srcp now // points behind the beginning of the string, // otherwise there's nothing to do. if ( srcp > s ) @@ -382,9 +399,9 @@ void trim_leading_whitespace( char *s ) /*HDR*/ /** - * @brief Trim both leading and trailing whitespace from a string + * @brief Trim both leading and trailing whitespace from a string. * - * @param[in,out] s The string to be trimmed + * @param[in,out] s The string to be trimmed. */ void trim_whitespace( char *s ) { @@ -397,17 +414,17 @@ void trim_whitespace( char *s ) /*HDR*/ /** - * @brief Copy array of bytes starting at beginning of buffer + * @brief Copy array of bytes starting at beginning of buffer. * * Can be used if the destination address is in the same buffer * in front of the source address. Even though you would expect - * that memcpy() would also work for this properly, we have seen - * cases where it didn't, and only memmove() worked correctly. - * Anyway, we try to avoid the overhead of memmove(). + * that @a memcpy would also work for this properly, we have seen + * cases where it didn't, and only @a memmove worked correctly. + * Anyway, we try to avoid the overhead of @a memmove. * - * @param[out] dst Destination address behind the source address - * @param[in] src Source address - * @param[in] n_bytes Number of bytes to copy + * @param[out] dst Destination address behind the source address. + * @param[in] src Source address. + * @param[in] n_bytes Number of bytes to copy. * * @see ::mbg_memcpy_reversed */ @@ -425,21 +442,21 @@ void mbg_memcpy( void *dst, const void *src, size_t n_bytes ) /*HDR*/ /** - * @brief Copy an array of bytes in reversed order, starting at end of buffer + * @brief Copy an array of bytes in reversed order, starting at end of buffer. * * Can be used if the destination address is in the same buffer * behind the source address, so the source address would be - * overwritten by a normal memcpy(). + * overwritten by a normal @a memcpy. * - * @param[out] dst Destination address behind the source address - * @param[in] src Source address - * @param[in] n_bytes Number of bytes to copy + * @param[out] dst Destination address behind the source address. + * @param[in] src Source address. + * @param[in] n_bytes Number of bytes to copy. * * @see ::mbg_memcpy */ void mbg_memcpy_reversed( void *dst, const void *src, size_t n_bytes ) { - if ( n_bytes ) // just to be sure it isn't 0 + if ( n_bytes ) // Just to be sure it isn't 0. { uint8_t *dstp = ( (uint8_t *) dst ) + n_bytes; uint8_t *srcp = ( (uint8_t *) src ) + n_bytes; diff --git a/mbglib/common/str_util.h b/mbglib/common/str_util.h index cdc0be6..2d5c8eb 100755 --- a/mbglib/common/str_util.h +++ b/mbglib/common/str_util.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: str_util.h 1.7 2019/07/31 15:42:39 martin REL_M $ + * $Id: str_util.h 1.12 2021/03/22 11:27:45 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,16 @@ * * ----------------------------------------------------------------------- * $Log: str_util.h $ + * Revision 1.12 2021/03/22 11:27:45 martin + * Updated some comments. + * Revision 1.11 2021/03/16 12:21:51 martin + * Updated some comments. + * Revision 1.10 2021/03/12 11:00:28 martin + * Updated some doxygen comments. + * Revision 1.9 2020/10/15 13:38:44 martin + * Fixed build on FreeBSD. + * Revision 1.8 2020/02/27 13:57:12 martin + * Updated function prototypes. * Revision 1.7 2019/07/31 15:42:39 martin * Doxygen changes. * Revision 1.6 2018/08/23 13:10:26 martin @@ -42,6 +52,10 @@ #if defined( MBG_TGT_KERNEL ) #include <mbgddmsg.h> + + #if defined( MBG_TGT_FREEBSD ) + #include <sys/stddef.h> // NULL + #endif #else #include <stdlib.h> #include <stdarg.h> @@ -79,13 +93,13 @@ static __mbg_inline /*HDR*/ * passed to another function to specify an output buffer to be filled. * * If no buffer has been specified, or the size of the buffer which - * eventually remains after a previous operation is 0 or even less than 0 - * then no data can be placed in the buffer. + * may remain after a previous operation is 0 or even less than 0, + * no data can be placed in the buffer. * - * @param[in] s The address of the specified buffer + * @param[in] s The address of the specified buffer. * @param[in] max_len The size of the specified buffer. * - * @return true if the buffer address is not NULL and the size is > 0, else false. + * @return @a true if the buffer address is not @a NULL and the size is > 0, else @a false. */ bool mbg_buffer_specs_valid( char *s, size_t max_len ) { @@ -99,22 +113,22 @@ static __mbg_inline /*HDR*/ /** * @brief Check the results of an snprintf()-like function. * - * Implementations of snprintf()-like functions may behave differently + * Implementations of <em>snprintf</em>-like functions may behave differently * and badly if the specified output buffer is too small. * The exact behavior depends on the runtime library shipped with a * specific build environment for a specific operating system, * the version of that runtime library, and may even differ depending * on whether kernel mode or user mode code is compiled. * - * This function can be called after any snprintf()-like function + * This function can be called after any <em>snprintf</em>-like function * to make sure that a valid buffer is always 0-terminated, and the - * number returned to indicate how many bytes have been written to the - * buffer is never less than 0, and never exceeds the real size + * number returned to indicate how many bytes have been written to + * the buffer is never less than 0, and never exceeds the real size * of the buffer. * - * @param[in] n The return code from an snprintf()-like function that has been called before. - * @param[in] s The address of the buffer that had been passed to the snprintf()-like function. - * @param[in] max_len The size of the specified buffer that had been passed to the snprintf()-like function. + * @param[in] n The return code from an <em>snprintf</em>-like function that has been called before. + * @param[in] s The address of the buffer that had been passed to the <em>snprintf</em>-like function. + * @param[in] max_len The size of the specified buffer that had been passed to the <em>snprintf</em>-like function. * * @return The real number of bytes that had been written to the buffer. * @@ -160,15 +174,15 @@ out: /* by MAKEHDR, do not remove the comments. */ /** - * @brief A portable, safe implementation of vsnprintf() + * @brief A portable, safe implementation of vsnprintf(). * - * Unfortunately the behaviour of vsnprintf() and thus snprintf() - * differs in detail across various build environments and run time - * libraries. + * Unfortunately, the behavior of @a vsnprintf and therefore also that + * of @a snprintf differs in detail in different build environments + * and runtime libraries. * - * If the output exceeds the buffer size and thus is truncated then:<br> + * If the output exceeds the buffer size and thus is truncated, then:<br> * - * - Under Windows a negative value is returned and eventually ***no*** + * - On Windows, a negative value is returned and maybe ***no*** * terminating 0 is written to the output buffer, so the output string * may not be terminated properly. * @@ -179,8 +193,10 @@ out: * * So subsequent calls like * - * n = snprintf( s, max_len, ... ); - * n += snprintf( &s[n], max_len - n, ... ); + * @code{.c} + n = snprintf( s, max_len, ... ); + n += snprintf( &s[n], max_len - n, ... ); + * @endcode * * may always work properly, or fail with buffer overruns or stack * corruption depending on the build environment. @@ -189,20 +205,21 @@ out: * characters really written to the string buffer, excluding the * terminating 0. * - * @note The "size_t" type parameter used to specify the buffer size - * can be larger (e.g. "unsigned long") than the "int" type returned - * by mostly all functions of the printf() family. So if a very large + * @note The @a size_t type parameter used to specify the buffer size + * can be larger (e.g. @a unsigned_long) than the @a int type returned + * by mostly all functions of the @a printf family. So if a very large * buffer is specified, and a large number of characters (more than - * MAXINT) are written to that buffer then how can an "int" type + * @a MAXINT) are written to that buffer, how can an @a int type * return the large number of characters written to the buffer? * We also try to workaround this here. * - * @param[out] s The string buffer to be filled - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] fmt Format string according to subsequent parameters - * @param[in] args Variable argument list in va_list format + * @param[out] s The string buffer to be filled. + * @param[in] max_len Size of the output buffer for a 0-terminated string. + * @param[in] fmt Format string according to subsequent parameters. + * @param[in] args Variable argument list in @a va_list format. * - * @return Number of characters written to the output buffer, except the terminating 0 + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::snprintf_safe * @see ::strncpy_safe @@ -212,40 +229,41 @@ out: __attribute__( ( format( printf, 3, 0 ) ) ) int vsnprintf_safe( char *s, size_t max_len, const char *fmt, va_list args ) ; /** - * @brief A portable, safe implementation of snprintf() + * @brief A portable, safe implementation of snprintf(). * - * For a detailed description see ::vsnprintf_safe + * For a detailed description see ::vsnprintf_safe. * - * @param[out] s The string buffer to be filled - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] fmt Format string according to subsequent parameters - * @param[in] ... Variable argument list according to the format string + * @param[out] s The string buffer to be filled. + * @param[in] max_len Size of the output buffer for a 0-terminated string. + * @param[in] fmt Format string according to subsequent parameters. + * @param[in] ... Variable argument list according to the format string. * - * @return Number of characters written to the output buffer, except the terminating 0 + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::strncpy_safe * @see ::sn_cpy_str_safe * @see ::sn_cpy_char_safe */ - __attribute__( ( format( printf, 3, 4 ) ) ) int snprintf_safe( char *s, size_t max_len, const char * fmt, ... ) ; + __attribute__( ( format( printf, 3, 4 ) ) ) int snprintf_safe( char *s, size_t max_len, const char *fmt, ... ) ; /** - * @brief A portable, safe implementation of strncpy() + * @brief A portable, safe implementation of strncpy(). * - * In the original implementation of strncpy(), if the length of the + * In the original implementation of @a strncpy, if the length of the * string to be copied into the destination buffer exceeds the specified - * buffer length then the string in the output buffer is not 0-terminated. + * buffer length, the string in the output buffer is not 0-terminated. * * Our implementation always forces a proper termination by 0, but unlike - * the original implementation of strncpy() it does ***not*** fill the whole + * the original implementation of @a strncpy, it does ***not*** fill the whole * remaining buffer space with '0' characters. * - * @param[out] dst Pointer to the output buffer - * @param[in] src Pointer to the input buffer - * @param[in] max_len Size of the output buffer for 0-terminated string + * @param[out] dst Pointer to the output buffer. + * @param[in] src Pointer to the input buffer. + * @param[in] max_len Size of the output buffer for 0-terminated string. * - * @return Pointer to the destination buffer + * @return Pointer to the destination buffer. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -255,17 +273,18 @@ out: char *strncpy_safe( char *dst, const char *src, size_t max_len ) ; /** - * @brief A function to copy a string safely, returning the number of characters copied + * @brief A function to copy a string safely, returning the number of characters copied. * * This basically works like ::strncpy_safe but instead of a pointer to * the destination buffer it returns the number of characters copied * to the destination buffer. * - * @param[out] dst Pointer to the output buffer - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] src Pointer to the input buffer + * @param[out] dst Pointer to the output buffer. + * @param[in] max_len Size of the output buffer for 0-terminated string. + * @param[in] src Pointer to the input buffer. * - * @return Number of characters copied to the destination buffer + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -275,18 +294,19 @@ out: int sn_cpy_str_safe( char *dst, size_t max_len, const char *src ) ; /** - * @brief A function to copy a character safely to a string buffer + * @brief A function to copy a character safely to a string buffer. * * This basically works like ::sn_cpy_str_safe but expects a character * to be copied to the destination buffer. Appends a terminating 0 to * the string buffer and returns the number of characters copied to * the destination buffer, usually 0 or 1. * - * @param[out] dst Pointer to the output buffer - * @param[in] max_len Size of the output buffer for 0-terminated string - * @param[in] c Character to be copied to the destination buffer + * @param[out] dst Pointer to the output buffer. + * @param[in] max_len Size of the output buffer for 0-terminated string. + * @param[in] c Character to be copied to the destination buffer. * - * @return Number of characters copied to the destination buffer, without the terminating 0 + * @return The number of characters written to the output buffer, + * except the terminating 0. * * @see ::vsnprintf_safe * @see ::snprintf_safe @@ -296,53 +316,53 @@ out: int sn_cpy_char_safe( char *dst, size_t max_len, char c ) ; /** - * @brief Trim whitespace at the end of a string + * @brief Trim whitespace at the end of a string. * - * @param[in,out] s The string to be trimmed + * @param[in,out] s The string to be trimmed. */ void trim_trailing_whitespace( char *s ) ; /** - * @brief Trim whitespace at the beginning of a string + * @brief Trim whitespace at the beginning of a string. * - * @param[in,out] s The string to be trimmed + * @param[in,out] s The string to be trimmed. */ void trim_leading_whitespace( char *s ) ; /** - * @brief Trim both leading and trailing whitespace from a string + * @brief Trim both leading and trailing whitespace from a string. * - * @param[in,out] s The string to be trimmed + * @param[in,out] s The string to be trimmed. */ void trim_whitespace( char *s ) ; /** - * @brief Copy array of bytes starting at beginning of buffer + * @brief Copy array of bytes starting at beginning of buffer. * * Can be used if the destination address is in the same buffer * in front of the source address. Even though you would expect - * that memcpy() would also work for this properly, we have seen - * cases where it didn't, and only memmove() worked correctly. - * Anyway, we try to avoid the overhead of memmove(). + * that @a memcpy would also work for this properly, we have seen + * cases where it didn't, and only @a memmove worked correctly. + * Anyway, we try to avoid the overhead of @a memmove. * - * @param[out] dst Destination address behind the source address - * @param[in] src Source address - * @param[in] n_bytes Number of bytes to copy + * @param[out] dst Destination address behind the source address. + * @param[in] src Source address. + * @param[in] n_bytes Number of bytes to copy. * * @see ::mbg_memcpy_reversed */ void mbg_memcpy( void *dst, const void *src, size_t n_bytes ) ; /** - * @brief Copy an array of bytes in reversed order, starting at end of buffer + * @brief Copy an array of bytes in reversed order, starting at end of buffer. * * Can be used if the destination address is in the same buffer * behind the source address, so the source address would be - * overwritten by a normal memcpy(). + * overwritten by a normal @a memcpy. * - * @param[out] dst Destination address behind the source address - * @param[in] src Source address - * @param[in] n_bytes Number of bytes to copy + * @param[out] dst Destination address behind the source address. + * @param[in] src Source address. + * @param[in] n_bytes Number of bytes to copy. * * @see ::mbg_memcpy */ diff --git a/mbglib/common/timeutil.c b/mbglib/common/timeutil.c index 0c525f9..4bf34bd 100755 --- a/mbglib/common/timeutil.c +++ b/mbglib/common/timeutil.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: timeutil.c 1.11 2019/07/19 14:20:52 martin REL_M $ + * $Id: timeutil.c 1.15 2021/03/22 11:52:30 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,14 @@ * * ----------------------------------------------------------------------- * $Log: timeutil.c $ + * Revision 1.15 2021/03/22 11:52:30 martin + * Updated some comments. + * Revision 1.14 2021/03/12 12:32:18 martin + * Updated some comments. + * Revision 1.13 2019/09/27 15:22:30 martin + * Fixed naming of some variables, and updated some comments. + * Revision 1.12 2019/09/10 13:13:23 martin + * Fixed doxygen comments. * Revision 1.11 2019/07/19 14:20:52 martin * Cleaned up mbg_clock_gettime() and mbg_clock_settime(), * and let them set an appropriate POSIX error code on error. @@ -32,7 +40,7 @@ * Revision 1.4 2017/11/16 11:33:28 philipp * Added functions to print a time_t to ISO format * Revision 1.3 2017/08/24 13:51:48 martin - * Fixed a xcompiler warning under Windows (x64). + * Fixed a xcompiler warning on Windows (x64). * Revision 1.2 2017/07/05 07:10:48Z martin * Added mbg_clock_gettime(), mbg_clock_settime(), * and check_precise_time_api() for Windows. @@ -82,12 +90,12 @@ int snprint_gmtime_error( char *s, size_t max_len, int mbg_errno, time_t t, cons /*HDR*/ /** - * @brief A Windows implementation for POSIX clock_gettime(). + * @brief A Windows implementation for POSIX @a clock_gettime. * * @param[in] clock_id Identifier of a specific clock, e.g. - * CLOCK_REALTIME, CLOCK_MONOTONIC, etc. - * @param[out] tp Address of a struct timespec to take up - * the current time. + * @a CLOCK_REALTIME, @a CLOCK_MONOTONIC, etc. + * @param[out] tp Address of a <em>struct timespec</em> + * to take up the current time. * * @return 0 on success, -1 on error, just like the POSIX function. * In case of an error the POSIX errno variable is set @@ -100,21 +108,23 @@ int mbg_clock_gettime( clockid_t clock_id, struct timespec *tp ) case CLOCK_REALTIME: case CLOCK_MONOTONIC: // FIXME TODO CLOCK_MONOTONIC should be implemented separately, - // e.g. using QPC, + // e.g. using QPC. { #if defined( TIME_UTC ) // C11 / VS2015+ if ( timespec_get( tp, TIME_UTC ) == 0 ) goto fail; // error #else FILETIME ft; - uint64_t tmp; + uint64_t u64; gstaft_fnc( &ft ); // Always succeeds. - tmp = ( (uint64_t) ft.dwHighDateTime << 32 ) | ft.dwLowDateTime; - tmp -= FILETIME_1970; // convert to Unix epoch - tmp *= 100; // convert to nanoseconds - tp->tv_sec = (time_t) ( tmp / NSEC_PER_SEC ); - tp->tv_nsec = (long) ( tmp % NSEC_PER_SEC ); + u64 = ( ( (uint64_t) ft.dwHighDateTime ) << 32 ) | ft.dwLowDateTime; + u64 -= FILETIME_1970; // Convert to Unix epoch. + u64 *= 100; // Convert to nanoseconds. + // 'time_t' is 64 bits wide on Windows, if using + // Visual Studio 2005 or newer. + tp->tv_sec = (time_t) ( u64 / NSEC_PER_SEC ); + tp->tv_nsec = (long) ( u64 % NSEC_PER_SEC ); #endif } break; @@ -129,7 +139,7 @@ fail: // The specified clock_id is not supported. // Set the POSIX errno variable appropriately // and return -1 just like clock_gettime() - // does.in case of error. + // does in case of error. errno = EINVAL; return -1; @@ -139,10 +149,10 @@ fail: /*HDR*/ /** - * @brief A Windows implementation for POSIX clock_settime(). + * @brief A Windows implementation for POSIX @a clock_settime. * * @param[in] clock_id Identifier of a specific clock, i.e. - * CLOCK_REALTIME which is the only clock + * @a CLOCK_REALTIME which is the only clock * supported by this call. * @param[in] tp Pointer to a struct timespec providing * the time to be set. @@ -179,7 +189,7 @@ int mbg_clock_settime( clockid_t clock_id, const struct timespec *tp ) // Just like POSIX clock_settime(), we return 0 on success. return 0; -} + } fail: // One of the Windows API calls above failed, so the @@ -187,7 +197,7 @@ fail: // Anyway, we try to find an appropriate POSIX error // code, set the POSIX errno variable accordingly, and // return -1 just like POSIX clock_settime() does - //.in case of error. + // in case of error. dw = GetLastError(); @@ -217,7 +227,7 @@ void check_precise_time_api( void ) GSTAFT_FNC tmp_fnc; HINSTANCE h = LoadLibrary( "kernel32.dll" ); - if ( h == NULL ) // TODO error msg + if ( h == NULL ) // TODO Error msg. { info = "Precise system time may not be supported; failed to get handle for kernel32.dll."; goto out; @@ -251,16 +261,17 @@ out: /*HDR*/ /** - * @brief Print a UTC offset into a string + * @brief Print a %UTC offset into a string. * * Format of the string is "[info]+hh[:mm[:ss]]h" * * @param[out] s Address of a string buffer to be filled. * @param[in] max_len Size of the string buffer. - * @param[in] info An optional info string to be prepended, may be NULL. - * @param[in] utc_offs The UTC offset to be printed, in [s]. + * @param[in] info An optional info string to be prepended, may be @a NULL. + * @param[in] utc_offs The %UTC offset to be printed, in [s]. * - * @return The number of characters written to the output buffer, except the terminating 0. + * @return The number of characters written to the string buffer, + * except the terminating 0. */ int snprint_utc_offs( char *s, size_t max_len, const char *info, long utc_offs ) { diff --git a/mbglib/common/timeutil.h b/mbglib/common/timeutil.h index c2390cd..96183fb 100755 --- a/mbglib/common/timeutil.h +++ b/mbglib/common/timeutil.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: timeutil.h 1.12 2019/08/07 09:05:44 martin REL_M $ + * $Id: timeutil.h 1.16 2021/04/22 08:37:50 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,16 @@ * * ----------------------------------------------------------------------- * $Log: timeutil.h $ + * Revision 1.16 2021/04/22 08:37:50 martin + * Avoid some compiler warnings. + * Revision 1.15 2021/03/22 11:52:33 martin + * Updated some comments. + * Revision 1.14 2019/09/27 15:26:27 martin + * New inline functions mbg_exp_time_t_to_time64_t() and + * mbg_trnc_time64_t_to_time_t(). + * Updated function prototypes and doxygen comments. + * Revision 1.13 2019/09/10 13:10:25 martin + * Fixed doxygen comments. * Revision 1.12 2019/08/07 09:05:44 martin * New inline function mbg_gmtime64(). * Updated doxygen comments. @@ -53,6 +63,7 @@ #include <time.h> #include <stddef.h> +#include <assert.h> #ifdef _TIMEUTIL @@ -70,8 +81,8 @@ extern "C" { #endif -// exclude for MinGW #if defined( MBG_TGT_WIN32 ) || defined( MBG_TGT_DOS ) + // We don't need this with MinGW. #if !defined( MBG_TGT_MINGW ) typedef int clockid_t; #define clockid_t clockid_t @@ -91,10 +102,11 @@ extern "C" { #define __const__ const /** - * @brief A pointer to a function returning the system time as FILETIME + * @brief A pointer to a function returning the system time as @a FILETIME. * - * This can be e.g. the standard Windows API call GetSystemTimeAsFileTime() - * or the GetSystemTimeAsPreciseFileTime() API call introduced with Windows 8. + * This can be e.g. the standard Windows API call @a GetSystemTimeAsFileTime + * or the @a GetSystemTimeAsPreciseFileTime API call available on Windows 8 + * and later Windows versions. */ typedef VOID (WINAPI *GSTAFT_FNC)(LPFILETIME lpSystemTimeAsFileTime); @@ -109,45 +121,167 @@ _ext GSTAFT_FNC gstaft_fnc #if !defined( MBG_TGT_MISSING_64_BIT_TYPES ) - typedef int64_t mbg_time_t; // we try to always use 64 bit types + typedef int64_t mbg_time_t; // We try to always use 64 bit types. #else - typedef time_t mbg_time_t; // fall back to the default + typedef time_t mbg_time_t; // Fall back to the default. #endif -static __mbg_inline + +static __mbg_inline /*HDR*/ time_t cvt_to_time_t( mbg_time_t t ) { - // Eventually we can do some epoch check / conversion here. + // Maybe we can do some epoch check / conversion here. return (time_t) t; } // cvt_to_time_t -static __mbg_inline +static __mbg_inline /*HDR*/ +int mbg_exp_time_t_to_time64_t( MBG_TIME64_T *p_t64, const time_t *p_t ) +{ + if ( sizeof( time_t ) == sizeof( MBG_TIME64_T ) ) + { + // No conversion required. + *p_t64 = *p_t; + return MBG_SUCCESS; + } + + // 'time_t' has 32 bits only. + + *p_t64 = (MBG_TIME64_T) (*p_t); + // FIXME TODO Maybe we should do some + // epoch conversion / range mapping here. + + return MBG_SUCCESS; + +} // mbg_exp_time_t_to_time64_t + + + +static __mbg_inline /*HDR*/ +int mbg_trnc_time64_t_to_time_t( time_t *p_t, const MBG_TIME64_T *p_t64 ) +{ + int rc = MBG_SUCCESS; + + if ( sizeof( time_t ) == sizeof( MBG_TIME64_T ) ) + goto done; // No range check required. + + + if ( sizeof( time_t ) == sizeof( MBG_TIME32_T ) ) + { + // Must check if result in in range. + MBG_TIME64_T t64 = *p_t64; + int64_t upper_limit; + int64_t lower_limit; + + if ( ( (time_t) -1 ) > 0 ) // time_t is unsigned. + { + upper_limit = 0xFFFFFFFFUL; + lower_limit = 0; + } + else // time_t is signed. + { + upper_limit = 0x7FFFFFFFL; + lower_limit = 0x8000000L; + } + + if ( ( t64 > upper_limit ) || ( t64 < lower_limit ) ) + rc = MBG_ERR_OVERFLOW; + + goto done; + } + + rc = MBG_ERR_NOT_SUPP_ON_OS; + goto out; + + +done: + *p_t = (time_t) (*p_t64); + +out: + return rc; + +} // mbg_trnc_time64_t_to_time_t + + + +static __mbg_inline /*HDR*/ +int mbg_cvt_time32_t_to_time64_t( MBG_TIME64_T *p_t64, const MBG_TIME32_T *p_t32 ) +{ + // FIXME TODO Move the checks below to an extra inline function + // which does an epoch conversion, if required. + + // Avoid warnings "never used". + (void) p_t64; + (void) p_t32; + +#if 0 + // time_t should be at least 4 bytes + assert( sizeof( time_t ) >= 4 ); + + if ( sizeof( time_t ) == 4 ) + { + // 32 bit *signed* time_t will roll over after 2038-01-19 03:14:07 + // when the number of seconds reaches 0x7FFFFFFF, so we don't try + // conversions for 2038 or later, though 32 bit *unsigned* time_t + // may still work after year 2100. + if ( year < 70 || year > 137 ) + { + rc = MBG_ERR_RANGE; + goto out; + } + } + else + if ( sizeof( time_t ) == 8 ) + { + // 64 bit time_t will work for million years. However, it's not + // clear what happens for dates before 1970-01-01T00:00:00 if time_t + // is *unsigned*. + if ( year < 70 ) + { + rc = MBG_ERR_RANGE; + goto out; // TODO Maybe we can handle this ... + } + } + else + { + rc = MBG_ERR_NOT_SUPP_ON_OS; + goto out; + } +#endif + + return MBG_SUCCESS; + +} // mbg_cvt_time32_t_to_time64_t + + + + +static __mbg_inline /*HDR*/ /** - * @brief A replacement function for POSIX gmtime(). + * @brief A replacement function for POSIX @a gmtime. * - * This function calls the original gmtime() function, but unlike gmtime() - * it expects the address of a struct tm variable which is only filled - * if gmtime() completed successfully. An appropriate return code - * is provided, indicating if the conversion succeeded, or not. + * This function calls the original @a gmtime function, but unlike @a gmtime, + * it expects the address of a <em>struct tm</em> variable which is only filled + * if @a gmtime completed successfully. An appropriate return code + * is provided, indicating whether the conversion succeeded, or not. * - * The original gmtime() function returns a NULL pointer if the conversion + * The original @a gmtime function returns a @a NULL pointer if the conversion * fails, so a programs which just uses the pointer without checking it first * may trap if the conversion fails. This can't happen with this function. * - * This variant expects the address of a generic time_t variable. A time_t can + * This variant expects the address of a generic @a time_t variable. A @a time_t can * be 32 bit or 64 bit wide, depending on the build environment and target system. - * Systems with 32 bit time_t will suffer from the Y2038 problem. + * Systems with 32 bit @a time_t will <b>suffer from the Y2038 problem</b>. * * There is also the ::mbg_gmtime64 variant, which expects a pointer to an * ::MBG_TIME64_T variable to be converted, which is always 64 bits, even * on 32 bit systems. * - * @param[out] p_tm Address of a struct tm variable to take the conversion result. - * @param[in] p_t Address of a time_t variable to be converted. + * @param[out] p_tm Address of a <em>struct tm</em> variable to take the conversion result. + * @param[in] p_t Address of a @a time_t variable to be converted. * * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES * @@ -168,31 +302,33 @@ int mbg_gmtime( struct tm *p_tm, const time_t *p_t ) -static __mbg_inline +static __mbg_inline /*HDR*/ /** - * @brief A replacement function for POSIX gmtime(). + * @brief A replacement function for POSIX @a gmtime. * * This variant of ::mbg_gmtime expects a pointer to an ::MBG_TIME64_T variable * to be converted, which is always 64 bits, even on 32 bit systems. * - * Actually, the ::MBG_TIME64_T value is truncated to a native time_t, which can + * Actually, the ::MBG_TIME64_T value is truncated to a native @a time_t, which can * be 32 bit or 64 bit wide, depending on the build environment and target system. - * So this "just works" on systems with 64 bit time_t, but systems with 32 bit time_t - * will anyway suffer from the Y2038 problem, unless the gmtime() call is replaced - * by a function that does a 64 bit conversion even on systems with 32 bit time_t. + * So this "just works" on systems with 64 bit @a time_t, but systems with 32 bit @a time_t + * will anyway suffer from the Y2038 problem, unless the @a gmtime call is replaced + * by a function that does a 64 bit conversion even on systems with 32 bit @a time_t. * - * @param[out] p_tm Address of a struct tm variable to take the conversion result. - * @param[in] p_t Address of an ::MBG_TIME64_T variable to be converted. + * @param[out] p_tm Address of a <em>struct tm</em> variable to take the conversion result. + * @param[in] p_t64 Pointer to an ::MBG_TIME64_T providing the timestamp to be converted. * * @return ::MBG_SUCCESS on success, else one of the @ref MBG_ERROR_CODES * * @see ::mbg_gmtime */ -int mbg_gmtime64( struct tm *p_tm, const MBG_TIME64_T *p_t ) +int mbg_gmtime64( struct tm *p_tm, const MBG_TIME64_T *p_t64 ) { struct tm *p_tm_tmp; - time_t t = (time_t) (*p_t); + time_t t = cvt_to_time_t( *p_t64 ); + // FIXME TODO Need to implement gmtime64() + // which always works with 64 bit timestamps. p_tm_tmp = gmtime( &t ); if ( p_tm_tmp == NULL ) // Conversion failed. @@ -322,12 +458,12 @@ int64_t delta_timespec_ll_ns( const struct timespec *ts, int snprint_gmtime_error( char *s, size_t max_len, int mbg_errno, time_t t, const char *calling_fnc ) ; /** - * @brief A Windows implementation for POSIX clock_gettime(). + * @brief A Windows implementation for POSIX @a clock_gettime. * * @param[in] clock_id Identifier of a specific clock, e.g. - * CLOCK_REALTIME, CLOCK_MONOTONIC, etc. - * @param[out] tp Address of a struct timespec to take up - * the current time. + * @a CLOCK_REALTIME, @a CLOCK_MONOTONIC, etc. + * @param[out] tp Address of a <em>struct timespec</em> + * to take up the current time. * * @return 0 on success, -1 on error, just like the POSIX function. * In case of an error the POSIX errno variable is set @@ -336,10 +472,10 @@ int64_t delta_timespec_ll_ns( const struct timespec *ts, int mbg_clock_gettime( clockid_t clock_id, struct timespec *tp ) ; /** - * @brief A Windows implementation for POSIX clock_settime(). + * @brief A Windows implementation for POSIX @a clock_settime. * * @param[in] clock_id Identifier of a specific clock, i.e. - * CLOCK_REALTIME which is the only clock + * @a CLOCK_REALTIME which is the only clock * supported by this call. * @param[in] tp Pointer to a struct timespec providing * the time to be set. @@ -352,16 +488,17 @@ int64_t delta_timespec_ll_ns( const struct timespec *ts, void check_precise_time_api( void ) ; /** - * @brief Print a UTC offset into a string + * @brief Print a %UTC offset into a string. * * Format of the string is "[info]+hh[:mm[:ss]]h" * * @param[out] s Address of a string buffer to be filled. * @param[in] max_len Size of the string buffer. - * @param[in] info An optional info string to be prepended, may be NULL. - * @param[in] utc_offs The UTC offset to be printed, in [s]. + * @param[in] info An optional info string to be prepended, may be @a NULL. + * @param[in] utc_offs The %UTC offset to be printed, in [s]. * - * @return The number of characters written to the output buffer, except the terminating 0. + * @return The number of characters written to the string buffer, + * except the terminating 0. */ int snprint_utc_offs( char *s, size_t max_len, const char *info, long utc_offs ) ; diff --git a/mbglib/common/words.h b/mbglib/common/words.h index cf6dee7..319b41f 100755 --- a/mbglib/common/words.h +++ b/mbglib/common/words.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: words.h 1.48 2019/06/17 08:38:59 thomas-b REL_M $ + * $Id: words.h 1.52 2021/03/18 11:08:31 martin REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,14 @@ * * ----------------------------------------------------------------------- * $Log: words.h $ + * Revision 1.52 2021/03/18 11:08:31 martin + * Updated some comments. + * Revision 1.51 2021/03/16 12:20:31 martin + * Updated some comments. + * Revision 1.50 2021/03/12 10:48:34 martin + * Corrected the wording of a comment. + * Revision 1.49 2019/10/23 08:31:48 thomas-b + * Added struct name for NANO_TIME_64 * Revision 1.48 2019/06/17 08:38:59 thomas-b * Renamed structs according to Meinberg naming convention * Revision 1.47 2019/06/06 12:17:14 thomas-b @@ -185,7 +193,7 @@ #if defined( _C166 ) \ || defined( _CC51 ) - #define _BIT_DEFINED 1 // these compilers natively support the "bit" type + #define _BIT_DEFINED 1 // These compilers natively support the "bit" type. #define USE_LONG_FOR_INT32 1 #endif @@ -195,7 +203,7 @@ #if defined( MBG_TGT_HAS_INT_8_16_32 ) - // Define C99 exact size types using non-standard exact-size types + // Define C99 exact size types using non-standard exact-size types. typedef __int8 int8_t; typedef unsigned __int8 uint8_t; @@ -374,7 +382,7 @@ typedef int bool; #endif - // Eventually provoke a build error if the build + // Try to provoke a build error if the build // environment unexpectedly supports "bool" natively. #define bool bool #define true 1 @@ -396,7 +404,7 @@ // and should be fine if it's supported natively. // // However, if "bool" has been substituted above - // by "int"then this is just a hack which may yield + // by "int", this is just a hack which may yield // unexpected results with code like: // return (bit) ( val & 0x10 ); // A safe way of coding would be: @@ -414,7 +422,7 @@ // clang / FreeBSD user space and kernel typedef bool bit; - // Eventually provoke a build error if the build + // Try to provoke a build error if the build // environment unexpectedly supports "bit" natively. #define bit bit @@ -439,27 +447,29 @@ #define HI_WORD( _x ) ( (uint16_t ) ( (_x) >> 16 ) ) #define LO_WORD( _x ) ( (uint16_t ) ( (_x) & 0xFFFF ) ) -// the macros below assume little endianess -// these macros expect the name of a variable + +// The macros below assume little endianess. + +// 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) ) #define FBYTE_OF( _v, _n ) *( ( (uint8_t far *) &(_v) ) + (_n) ) #define FWORD_OF( _v, _n ) *( ( (uint16_t far *) &(_v) ) + (_n) ) -// same as above, but taking pointers +// 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 +// A macro to swap the byte order of a 16 bit value. #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 +// A macro to swap the byte order of a 32 bit value. #define _bswap32( _x ) \ ( \ ( ( ( (uint32_t) (_x) ) & 0x000000FFUL ) << 24 ) | \ @@ -468,7 +478,7 @@ ( ( ( (uint32_t) (_x) ) & 0xFF000000UL ) >> 24 ) \ ) -// a macro to swap the word order of a 32 bit value +// A macro to swap the word order of a 32 bit value. #define _wswap32( _x ) \ ( \ ( ( ( (uint32_t) (_x) ) & 0x0000FFFFUL ) << 16 ) | \ @@ -479,7 +489,7 @@ #define _var_bswap32( _v ) (_v) = _bswap32( _v ) -// The C51 compiler is big-endian, that means the most +// The C51 compiler is big-endian, this means the most // significant byte of a 16 or 32 bit value is stored in // the lowest memory location. Most other systems are // little-endian, so we must use macros to adjust the @@ -541,16 +551,16 @@ typedef struct } MBG_CODE_NAME_TABLE_ENTRY; /** - * @brief A macro defining a ::MBG_CODE_NAME_TABLE_ENTRY + * @brief A macro defining a ::MBG_CODE_NAME_TABLE_ENTRY. * * The stringified parameter is used for the name. * - * @param _n The symbolic name of the numeric code + * @param[in] _n The symbolic name of the numeric code. */ #define _mbg_cn_table_entry( _n ) { _n, #_n } /** - * @brief A macro defining an empty ::MBG_CODE_NAME_TABLE_ENTRY + * @brief A macro defining an empty ::MBG_CODE_NAME_TABLE_ENTRY. * * This is used to terminate a table. */ @@ -559,18 +569,18 @@ typedef struct /** - * @brief A timestamp with nanosecond resolution + * @brief A timestamp with nanosecond resolution. * - * @note If the structure is to represent a negative value then both the - * fields nano_secs and secs have to be set to the negative values. + * @note If the structure is to represent a negative value, both the + * fields @p nano_secs and @p secs have to be set to the negative values. * Otherwise the sign of the represented number was ambiguous if either - * of the fields was accidentally 0, and only the other field was not 0. + * of the fields was 0 by accident, and only the other field was not 0. * The macro ::_nano_time_negative should always be used to determine * if the sign of the represented value is negative, or not. * - * @note The secs field will roll over on 2038-01-19 03:14:07 + * @note The @p secs field will roll over on 2038-01-19 03:14:07 * if used for the number of seconds since 1970-01-01, just like - * 32 bit POSIX time_t. + * 32 bit POSIX @a time_t. * * @see ::_nano_time_negative * @see ::_nano_time_zero @@ -579,11 +589,11 @@ typedef struct typedef struct nano_time_s { // ATTENTION: - // This structure is and has has been used in public API calls for a long time, + // This structure is and has been used in public API calls for a long time, // so even though the order of member fields is different than in NANO_TIME_64 // this must *NOT* be changed, or API compatibility will get lost! - int32_t nano_secs; ///< [nanoseconds] - int32_t secs; ///< [seconds], usually since 1970-01-01 00:00:00 + int32_t nano_secs; ///< [nanoseconds]. + int32_t secs; ///< [seconds], usually since 1970-01-01 00:00:00. } NANO_TIME; @@ -595,13 +605,13 @@ do \ } while ( 0 ) /** - * Check if the value of the ::NANO_TIME structure _nt is negative + * @brief Check if the value of the ::NANO_TIME structure _nt is negative. */ #define _nano_time_negative( _nt ) \ ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) ) /** - * Check if the value of the ::NANO_TIME structure _nt is 0 + * @brief Check if the value of the ::NANO_TIME structure _nt is 0. */ #define _nano_time_zero( _nt ) \ ( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) ) @@ -609,12 +619,12 @@ do \ /** - * @brief A timestamp with nanosecond resolution, but 64 bit size + * @brief A timestamp with nanosecond resolution, but 64 bit size. * - * @note If the structure is to represent a negative value then both the - * fields nano_secs and secs have to be set to the negative values. + * @note If the structure is to represent a negative value, both the + * fields @p nano_secs and @p secs have to be set to the negative values. * Otherwise the sign of the represented number was ambiguous if either - * of the fields was accidentally 0, and only the other field was not 0. + * of the fields was 0 by accident, and only the other field was not 0. * The macro ::_nano_time_64_negative should always be used to determine * if the sign of the represented value is negative, or not. * @@ -622,14 +632,14 @@ do \ * @see ::_nano_time_64_zero * @see ::NANO_TIME */ -typedef struct +typedef struct nano_time_64_s { // ATTENTION: // This structure is and has been used in public API calls for a long time, - // so even though the order of member fields is different than in NANO_TIME + // so even though the order of member fields is different than in ::NANO_TIME, // this must *NOT* be changed, or API compatibility will get lost! - int64_t secs; ///< [seconds], usually since 1970-01-01 00:00:00 - int64_t nano_secs; ///< [nanoseconds] + int64_t secs; ///< [seconds], usually since 1970-01-01 00:00:00. + int64_t nano_secs; ///< [nanoseconds]. } NANO_TIME_64; @@ -641,20 +651,20 @@ do \ } while ( 0 ) /** - * Check if the value of the ::NANO_TIME_64 structure _nt is negative + * @brief Check if the value of the ::NANO_TIME_64 structure _nt is negative. */ #define _nano_time_64_negative( _nt ) \ ( ( (_nt)->secs < 0 ) || ( (_nt)->nano_secs < 0 ) ) /** - * Check if the value of the ::NANO_TIME_64 structure _nt is 0 + * @brief Check if the value of the ::NANO_TIME_64 structure _nt is 0. */ #define _nano_time_64_zero( _nt ) \ ( ( (_nt)->secs == 0 ) && ( (_nt)->nano_secs == 0 ) ) -// The size_t type can eventually be larger than an int type. +// The size_t type may be larger than an int type. // However, some snprintf-like functions expect a size_t value // to specify the buffer size, but just return an int value. // So we take care that at least the return value is limited @@ -669,7 +679,7 @@ do \ /** - * @brief A helper macro to implement ::STRINGIFY correctly + * @brief A helper macro to implement ::STRINGIFY correctly. * * This just a helper macro which must be defined before * ::STRINGIFY to work correctly, and should not be used alone. @@ -680,20 +690,20 @@ do \ /** - * @brief Make a string from a constant definition + * @brief Make a string from a constant definition. * * This macro can be used e.g. to define a constant string on the * compiler's command line, e.g. like -DVERSION_STRING="v1.0 BETA". * Source code like * @code{.c} - const char version_string[] = VERSION_STRING; + const char version_string[] = VERSION_STRING; * @endcode * * may not work for every compiler since the double quotes * in VERSION_STRING may be removed when the definition is evaluated. * A proper solution is to use the STRINGIFY() macro defined here: * @code{.c} - const char version_string[] = STRINGIFY( VERSION_STRING ); + const char version_string[] = STRINGIFY( VERSION_STRING ); * @endcode */ #define STRINGIFY(x) XSTRINGIFY(x) |