AM243x MCU+ SDK  09.00.00
gptpbasetypes.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
58 #ifndef GPTPBASETYPES_H_
59 #define GPTPBASETYPES_H_
60 
61 #include <string.h>
63 
73 #define MAX_PATH_TRACE_N 179
74 
78 #define CLOCK_IDENTITY_LENGTH 8
79 
81 
97 typedef uint8_t Nibble;
98 typedef uint8_t Octet;
99 typedef uint8_t Octet2[2];
100 typedef uint8_t Octet3[3];
101 typedef uint8_t Octet4[4];
102 typedef uint8_t Enumeration2;
103 typedef uint8_t Enumeration4;
104 typedef uint8_t Enumeration8;
105 typedef uint16_t Enumeration16;
106 typedef uint32_t Enumeration24;
107 typedef uint8_t UInteger4;
108 
113 typedef struct PortIdentity {
115  uint16_t portIndex;
116 } PortIdentity;
117 
121 typedef struct ClockQuality {
122  uint8_t clockClass;
125 } ClockQuality;
126 
130 typedef struct UInteger48 {
131  uint32_t lsb;
132  uint16_t msb;
133 } UInteger48;
137 typedef struct UInteger48m32 {
138  uint16_t lsb;
139  uint32_t msb;
140 } UInteger48m32;
141 
145 typedef struct UInteger112 {
146  uint8_t priority1;
147  uint8_t clockClass;
148  uint8_t clockAccuracy;
150  uint8_t priority2;
152 } __attribute__((packed, aligned(1))) UInteger112;
153 
158 typedef struct UInteger224 {
160  uint16_t stepsRemoved;
162  uint16_t portNumber;
163 } __attribute__((packed, aligned(1))) UInteger224;
164 
169 typedef struct ScaledNs {
170  uint16_t subns;
171  int64_t nsec;
172  int16_t nsec_msb;
173 } ScaledNs;
174 
184 typedef struct UScaledNs {
185  uint16_t subns;
186  uint64_t nsec;
187  uint16_t nsec_msb;
188 } UScaledNs;
189 
190 /*
191  * @brief 2^-16 ns scaling multiplier
192  */
193 #define SCALEDNS_FACTOR 0x10000
194 
195 /*
196  * @brief The TimeInterval type represents time intervals, in units of 2^-16 ns
197  * @verbatim Example to express ns@endverbatim
198  * @code
199  * 2.5 ns expressed as below
200  * 0x0000 0000 0002 8000
201  * @endcode
202  *
203  */
204 typedef struct TimeInterval {
206 } TimeInterval;
207 
216 typedef struct Timestamp {
217  uint32_t nanoseconds;
219 } Timestamp;
220 
231 typedef struct ExtendedTimestamp {
235 
236 #define VALUE_DISABLED 0u
237 #define VALUE_ENABLED 1u
238 
242 typedef enum {
243  ATOMIC_CLOCK = 0x10,
244  GPS = 0x20,
246  PTP = 0x40,
247  NTP = 0x50,
248  HAND_SET = 0x60,
249  OTHER = 0x90,
251 } TimeSource;
252 
253 // 14.8.3 portState, (from IEEE 1588 Table-8)
261 typedef enum {
266 } PTPPortState;
267 
268 typedef enum {
273 
274 #endif
275 
ScaledNs::nsec_msb
int16_t nsec_msb
Definition: gptpbasetypes.h:172
SlavePort
@ SlavePort
Definition: gptpbasetypes.h:265
UInteger112::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: gptpbasetypes.h:149
UInteger224::portNumber
uint16_t portNumber
Definition: gptpbasetypes.h:162
ExtendedTimestamp
The ExtendTimestamp type represents a positive time with respect to the epoch. The fractionalNanoseco...
Definition: gptpbasetypes.h:231
PortIdentity
The portIdentity identifies a port of a time-aware system.
Definition: gptpbasetypes.h:113
UScaledNs::nsec_msb
uint16_t nsec_msb
Definition: gptpbasetypes.h:187
Enumeration4
uint8_t Enumeration4
Definition: gptpbasetypes.h:103
PassivePort
@ PassivePort
Definition: gptpbasetypes.h:264
UInteger224
UInteger224 (802.1AS, 10.3.4 time-synchronization spanning tree priority vectors )
Definition: gptpbasetypes.h:158
UInteger4
uint8_t UInteger4
Definition: gptpbasetypes.h:107
UInteger112::priority1
uint8_t priority1
Definition: gptpbasetypes.h:146
PortIdentity::portIndex
uint16_t portIndex
Definition: gptpbasetypes.h:115
Enumeration2
uint8_t Enumeration2
Definition: gptpbasetypes.h:102
Timestamp::seconds
UInteger48 seconds
Definition: gptpbasetypes.h:218
ScaledNs
The ScaledNs type represents signed values of time and time interval in units of 2e-16 ns.
Definition: gptpbasetypes.h:169
ClockQuality::clockAccuracy
Enumeration8 clockAccuracy
Definition: gptpbasetypes.h:123
MasterPort
@ MasterPort
Definition: gptpbasetypes.h:263
UInteger224::sourcePortIdentity
PortIdentity sourcePortIdentity
Definition: gptpbasetypes.h:161
GMSYNC_SYNC
@ GMSYNC_SYNC
Definition: gptpbasetypes.h:270
UInteger224::stepsRemoved
uint16_t stepsRemoved
Definition: gptpbasetypes.h:160
Octet4
uint8_t Octet4[4]
Definition: gptpbasetypes.h:101
ClockQuality::clockClass
uint8_t clockClass
Definition: gptpbasetypes.h:122
UScaledNs::subns
uint16_t subns
Definition: gptpbasetypes.h:185
ExtendedTimestamp::fractionalNanoseconds
UInteger48m32 fractionalNanoseconds
Definition: gptpbasetypes.h:232
UScaledNs::nsec
uint64_t nsec
Definition: gptpbasetypes.h:186
DisabledPort
@ DisabledPort
Definition: gptpbasetypes.h:262
OTHER
@ OTHER
Definition: gptpbasetypes.h:249
TimeInterval::scaledNanoseconds
int64_t scaledNanoseconds
Definition: gptpbasetypes.h:205
tsn_data.h
ClockQuality
The clock quality represents quality of clock.
Definition: gptpbasetypes.h:121
Octet3
uint8_t Octet3[3]
Definition: gptpbasetypes.h:100
Octet
uint8_t Octet
Definition: gptpbasetypes.h:98
GMSYNC_SYNC_STABLE
@ GMSYNC_SYNC_STABLE
Definition: gptpbasetypes.h:271
UInteger112::clockIdentity
ClockIdentity clockIdentity
Definition: gptpbasetypes.h:151
UInteger48::msb
uint16_t msb
Definition: gptpbasetypes.h:132
Nibble
uint8_t Nibble
Primitive data types specifications for IEEE 802.1AS. All non-primitive data types are derived from t...
Definition: gptpbasetypes.h:97
Timestamp::nanoseconds
uint32_t nanoseconds
Definition: gptpbasetypes.h:217
__attribute__
struct UInteger112 __attribute__((packed, aligned(1))) UInteger112
UInteger112 (802.1AS, 10.3.2 systemIdentity)
GPS
@ GPS
Definition: gptpbasetypes.h:244
HAND_SET
@ HAND_SET
Definition: gptpbasetypes.h:248
gmsync_status_t
gmsync_status_t
Definition: gptpbasetypes.h:268
INTERNAL_OSCILLATOR
@ INTERNAL_OSCILLATOR
Definition: gptpbasetypes.h:250
ExtendedTimestamp::seconds
UInteger48 seconds
Definition: gptpbasetypes.h:233
ATOMIC_CLOCK
@ ATOMIC_CLOCK
Definition: gptpbasetypes.h:243
Enumeration24
uint32_t Enumeration24
Definition: gptpbasetypes.h:106
UInteger48::lsb
uint32_t lsb
Definition: gptpbasetypes.h:131
UInteger48
48bit variable, lsb is 32 bits
Definition: gptpbasetypes.h:130
PTP
@ PTP
Definition: gptpbasetypes.h:246
UScaledNs
The ScaledNs type represents unsigned values of time and time interval in units of 2^-16 ns.
Definition: gptpbasetypes.h:184
UInteger112::clockAccuracy
uint8_t clockAccuracy
Definition: gptpbasetypes.h:148
PTPPortState
PTPPortState
value of the port state (802.1AS 14.8.3 portState)
Definition: gptpbasetypes.h:261
UInteger48m32::msb
uint32_t msb
Definition: gptpbasetypes.h:139
UInteger112
UInteger112 (802.1AS, 10.3.2 systemIdentity)
Definition: gptpbasetypes.h:145
UInteger48m32
48bit variable, msb is 32 bits
Definition: gptpbasetypes.h:137
ScaledNs::nsec
int64_t nsec
Definition: gptpbasetypes.h:171
CLOCK_IDENTITY_LENGTH
#define CLOCK_IDENTITY_LENGTH
Macro which defines Clock Identity Length.
Definition: gptpbasetypes.h:78
NTP
@ NTP
Definition: gptpbasetypes.h:247
GMSYNC_UNSYNC
@ GMSYNC_UNSYNC
Definition: gptpbasetypes.h:269
UInteger112::clockClass
uint8_t clockClass
Definition: gptpbasetypes.h:147
Enumeration16
uint16_t Enumeration16
Definition: gptpbasetypes.h:105
TimeSource
TimeSource
the type of source of time used by a ClockMaster(802.1AS, 8.6.2.7 timeSource)
Definition: gptpbasetypes.h:242
UInteger48m32::lsb
uint16_t lsb
Definition: gptpbasetypes.h:138
Octet2
uint8_t Octet2[2]
Definition: gptpbasetypes.h:99
PortIdentity::clockIdentity
ClockIdentity clockIdentity
Definition: gptpbasetypes.h:114
TimeInterval
Definition: gptpbasetypes.h:204
UInteger112::priority2
uint8_t priority2
Definition: gptpbasetypes.h:150
Enumeration8
uint8_t Enumeration8
Definition: gptpbasetypes.h:104
UInteger224::rootSystemIdentity
UInteger112 rootSystemIdentity
Definition: gptpbasetypes.h:159
ClockIdentity
uint8_t ClockIdentity[CLOCK_IDENTITY_LENGTH]
Definition: gptpbasetypes.h:80
TERRESTRIAL_RADIO
@ TERRESTRIAL_RADIO
Definition: gptpbasetypes.h:245
Timestamp
The Timestamp type represents a positive time with respect to the epoch.
Definition: gptpbasetypes.h:216
ClockQuality::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: gptpbasetypes.h:124
ScaledNs::subns
uint16_t subns
Definition: gptpbasetypes.h:170