Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /* * Copyright (c) 2018 Intel Corporation. * * SPDX-License-Identifier: Apache-2.0 */ /** * @file * @brief Public functions for the Precision Time Protocol time specification. * */ #ifndef ZEPHYR_INCLUDE_NET_PTP_TIME_H_ #define ZEPHYR_INCLUDE_NET_PTP_TIME_H_ /** * @brief Precision Time Protocol time specification * @defgroup ptp_time PTP time * @ingroup networking * @{ */ #include <net/net_core.h> #include <toolchain.h> #ifdef __cplusplus extern "C" { #endif /** * @brief Precision Time Protocol Timestamp format. * * This structure represents a timestamp according * to the Precision Time Protocol standard. * * Seconds are encoded as a 48 bits unsigned integer. * Nanoseconds are encoded as a 32 bits unsigned integer. */ struct net_ptp_time { /** Seconds encoded on 48 bits. */ union { struct { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ u32_t low; u16_t high; u16_t unused; #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ u16_t unused; u16_t high; u32_t low; #else #error "Unknown byte order" #endif } _sec; u64_t second; }; /** Nanoseconds. */ u32_t nanosecond; }; #ifdef __cplusplus } #endif /** * @brief Precision Time Protocol Extended Timestamp format. * * This structure represents an extended timestamp according * to the Precision Time Protocol standard. * * Seconds are encoded as 48 bits unsigned integer. * Fractional nanoseconds are encoded as 48 bits, their unit * is 2*(-16) ns. */ struct net_ptp_extended_time { /** Seconds encoded on 48 bits. */ union { struct { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ u32_t low; u16_t high; u16_t unused; #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ u16_t unused; u16_t high; u32_t low; #else #error "Unknown byte order" #endif } _sec; u64_t second; }; /** Fractional nanoseconds on 48 bits. */ union { struct { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ u32_t low; u16_t high; u16_t unused; #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ u16_t unused; u16_t high; u32_t low; #else #error "Unknown byte order" #endif } _fns; u64_t fract_nsecond; }; } __packed; /** * @} */ #endif /* ZEPHYR_INCLUDE_NET_PTP_TIME_H_ */ |