AM261x MCU+ SDK: gptpbasetypes.h Source File

| AM261x MCU+ SDK 26.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 */
63 #ifndef GPTPBASETYPES_H_
64 #define GPTPBASETYPES_H_
65
66 #include <string.h>
67
77 #define MAX_PATH_TRACE_N 179
78
82 #define CLOCK_IDENTITY_LENGTH 8
83
84 typedef uint8_t ClockIdentity[CLOCK_IDENTITY_LENGTH];
85
101 typedef uint8_t Nibble;
102 typedef uint8_t Octet;
103 typedef uint8_t Octet2[2];
104 typedef uint8_t Octet3[3];
105 typedef uint8_t Octet4[4];
106 typedef uint8_t Enumeration2;
107 typedef uint8_t Enumeration4;
108 typedef uint8_t Enumeration8;
109 typedef uint16_t Enumeration16;
110 typedef uint32_t Enumeration24;
111 typedef uint8_t UInteger4;
112
117 typedef struct PortIdentity {
118 ClockIdentity clockIdentity;
119 uint16_t portIndex;
120 } PortIdentity;
121
125 typedef struct ClockQuality {
126 uint8_t clockClass;
127 Enumeration8 clockAccuracy;
128 uint16_t offsetScaledLogVariance;
129 } ClockQuality;
130
134 typedef struct UInteger48 {
135 uint32_t lsb;
136 uint16_t msb;
137 } UInteger48;
141 typedef struct UInteger48m32 {
142 uint16_t lsb;
143 uint32_t msb;
144 } UInteger48m32;
145
149 typedef struct UInteger112 {
150 uint8_t priority1;
151 uint8_t clockClass;
152 uint8_t clockAccuracy;
153 uint16_t offsetScaledLogVariance;
154 uint8_t priority2;
155 ClockIdentity clockIdentity;
156 } UInteger112;
157
162 typedef struct UInteger224 {
163 UInteger112 rootSystemIdentity;
164 uint16_t stepsRemoved;
165 PortIdentity sourcePortIdentity;
166 uint16_t portNumber;
167 } UInteger224;
168
173 typedef struct ScaledNs {
174 uint16_t subns;
175 int64_t nsec;
176 int16_t nsec_msb;
177 } ScaledNs;
178
188 typedef struct UScaledNs {
189 uint16_t subns;
190 uint64_t nsec;
191 uint16_t nsec_msb;
192 } UScaledNs;
193
194 /*
195 * @brief 2^-16 ns scaling multiplier
196 */
197 #define SCALEDNS_FACTOR 0x10000
198
199 /*
200 * @brief The TimeInterval type represents time intervals, in units of 2^-16 ns
201 * @verbatim Example to express ns@endverbatim
202 * @code
203 * 2.5 ns expressed as below
204 * 0x0000 0000 0002 8000
205 * @endcode
206 *
207 */
208 typedef struct TimeInterval {
209 int64_t scaledNanoseconds;
210 } TimeInterval;
211
220 typedef struct Timestamp {
221 uint32_t nanoseconds;
222 UInteger48 seconds;
223 } Timestamp;
224
235 typedef struct ExtendedTimestamp {
236 UInteger48m32 fractionalNanoseconds;
237 UInteger48 seconds;
238 } ExtendedTimestamp;
239
240 #define VALUE_DISABLED 0u
241 #define VALUE_ENABLED 1u
242
246 typedef enum {
247 ATOMIC_CLOCK = 0x10,
248 GPS = 0x20,
249 TERRESTRIAL_RADIO = 0x30,
250 PTP = 0x40,
251 NTP = 0x50,
252 HAND_SET = 0x60,
253 OTHER = 0x90,
254 INTERNAL_OSCILLATOR = 0xA0,
255 } TimeSource;
256
257 // 14.8.3 portState, (from IEEE 1588 Table-8)
265 typedef enum {
266 DisabledPort = 3,
267 MasterPort = 6,
268 PassivePort = 7,
269 SlavePort = 9,
270 } PTPPortState;
271
272 typedef enum {
273 GMSYNC_UNSYNC=0,
274 GMSYNC_SYNC,
275 GMSYNC_SYNC_STABLE,
276 } gmsync_status_t;
277
278 #endif
279
ScaledNs::nsec_msb
int16_t nsec_msb
Definition: gptpbasetypes.h:176
SlavePort
@ SlavePort
Definition: gptpbasetypes.h:269
UInteger112::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: gptpbasetypes.h:153
UInteger224::portNumber
uint16_t portNumber
Definition: gptpbasetypes.h:166
ExtendedTimestamp
The ExtendTimestamp type represents a positive time with respect to the epoch. The fractionalNanoseco...
Definition: gptpbasetypes.h:235
PortIdentity
The portIdentity identifies a port of a time-aware system.
Definition: gptpbasetypes.h:117
UScaledNs::nsec_msb
uint16_t nsec_msb
Definition: gptpbasetypes.h:191
Enumeration4
uint8_t Enumeration4
Definition: gptpbasetypes.h:107
PassivePort
@ PassivePort
Definition: gptpbasetypes.h:268
UInteger224
UInteger224 (802.1AS, 10.3.4 time-synchronization spanning tree priority vectors )
Definition: gptpbasetypes.h:162
UInteger4
uint8_t UInteger4
Definition: gptpbasetypes.h:111
UInteger112::priority1
uint8_t priority1
Definition: gptpbasetypes.h:150
PortIdentity::portIndex
uint16_t portIndex
Definition: gptpbasetypes.h:119
Enumeration2
uint8_t Enumeration2
Definition: gptpbasetypes.h:106
Timestamp::seconds
UInteger48 seconds
Definition: gptpbasetypes.h:222
ScaledNs
The ScaledNs type represents signed values of time and time interval in units of 2e-16 ns.
Definition: gptpbasetypes.h:173
ClockQuality::clockAccuracy
Enumeration8 clockAccuracy
Definition: gptpbasetypes.h:127
MasterPort
@ MasterPort
Definition: gptpbasetypes.h:267
UInteger224::sourcePortIdentity
PortIdentity sourcePortIdentity
Definition: gptpbasetypes.h:165
GMSYNC_SYNC
@ GMSYNC_SYNC
Definition: gptpbasetypes.h:274
UInteger224::stepsRemoved
uint16_t stepsRemoved
Definition: gptpbasetypes.h:164
Octet4
uint8_t Octet4[4]
Definition: gptpbasetypes.h:105
ClockQuality::clockClass
uint8_t clockClass
Definition: gptpbasetypes.h:126
UScaledNs::subns
uint16_t subns
Definition: gptpbasetypes.h:189
ExtendedTimestamp::fractionalNanoseconds
UInteger48m32 fractionalNanoseconds
Definition: gptpbasetypes.h:236
UScaledNs::nsec
uint64_t nsec
Definition: gptpbasetypes.h:190
DisabledPort
@ DisabledPort
Definition: gptpbasetypes.h:266
OTHER
@ OTHER
Definition: gptpbasetypes.h:253
TimeInterval::scaledNanoseconds
int64_t scaledNanoseconds
Definition: gptpbasetypes.h:209
ClockQuality
The clock quality represents quality of clock.
Definition: gptpbasetypes.h:125
Octet3
uint8_t Octet3[3]
Definition: gptpbasetypes.h:104
Octet
uint8_t Octet
Definition: gptpbasetypes.h:102
GMSYNC_SYNC_STABLE
@ GMSYNC_SYNC_STABLE
Definition: gptpbasetypes.h:275
UInteger112::clockIdentity
ClockIdentity clockIdentity
Definition: gptpbasetypes.h:155
UInteger48::msb
uint16_t msb
Definition: gptpbasetypes.h:136
Nibble
uint8_t Nibble
Primitive data types specifications for IEEE 802.1AS. All non-primitive data types are derived from t...
Definition: gptpbasetypes.h:101
Timestamp::nanoseconds
uint32_t nanoseconds
Definition: gptpbasetypes.h:221
GPS
@ GPS
Definition: gptpbasetypes.h:248
HAND_SET
@ HAND_SET
Definition: gptpbasetypes.h:252
gmsync_status_t
gmsync_status_t
Definition: gptpbasetypes.h:272
INTERNAL_OSCILLATOR
@ INTERNAL_OSCILLATOR
Definition: gptpbasetypes.h:254
ExtendedTimestamp::seconds
UInteger48 seconds
Definition: gptpbasetypes.h:237
ATOMIC_CLOCK
@ ATOMIC_CLOCK
Definition: gptpbasetypes.h:247
Enumeration24
uint32_t Enumeration24
Definition: gptpbasetypes.h:110
UInteger48::lsb
uint32_t lsb
Definition: gptpbasetypes.h:135
UInteger48
48bit variable, lsb is 32 bits
Definition: gptpbasetypes.h:134
PTP
@ PTP
Definition: gptpbasetypes.h:250
UScaledNs
The ScaledNs type represents unsigned values of time and time interval in units of 2^-16 ns.
Definition: gptpbasetypes.h:188
UInteger112::clockAccuracy
uint8_t clockAccuracy
Definition: gptpbasetypes.h:152
PTPPortState
PTPPortState
value of the port state (802.1AS 14.8.3 portState)
Definition: gptpbasetypes.h:265
UInteger48m32::msb
uint32_t msb
Definition: gptpbasetypes.h:143
UInteger112
UInteger112 (802.1AS, 10.3.2 systemIdentity)
Definition: gptpbasetypes.h:149
UInteger48m32
48bit variable, msb is 32 bits
Definition: gptpbasetypes.h:141
ScaledNs::nsec
int64_t nsec
Definition: gptpbasetypes.h:175
CLOCK_IDENTITY_LENGTH
#define CLOCK_IDENTITY_LENGTH
Macro which defines Clock Identity Length.
Definition: gptpbasetypes.h:82
NTP
@ NTP
Definition: gptpbasetypes.h:251
GMSYNC_UNSYNC
@ GMSYNC_UNSYNC
Definition: gptpbasetypes.h:273
UInteger112::clockClass
uint8_t clockClass
Definition: gptpbasetypes.h:151
Enumeration16
uint16_t Enumeration16
Definition: gptpbasetypes.h:109
TimeSource
TimeSource
the type of source of time used by a ClockMaster(802.1AS, 8.6.2.7 timeSource)
Definition: gptpbasetypes.h:246
UInteger48m32::lsb
uint16_t lsb
Definition: gptpbasetypes.h:142
Octet2
uint8_t Octet2[2]
Definition: gptpbasetypes.h:103
PortIdentity::clockIdentity
ClockIdentity clockIdentity
Definition: gptpbasetypes.h:118
TimeInterval
Definition: gptpbasetypes.h:208
UInteger112::priority2
uint8_t priority2
Definition: gptpbasetypes.h:154
Enumeration8
uint8_t Enumeration8
Definition: gptpbasetypes.h:108
UInteger224::rootSystemIdentity
UInteger112 rootSystemIdentity
Definition: gptpbasetypes.h:163
ClockIdentity
uint8_t ClockIdentity[CLOCK_IDENTITY_LENGTH]
Definition: gptpbasetypes.h:84
TERRESTRIAL_RADIO
@ TERRESTRIAL_RADIO
Definition: gptpbasetypes.h:249
Timestamp
The Timestamp type represents a positive time with respect to the epoch.
Definition: gptpbasetypes.h:220
ClockQuality::offsetScaledLogVariance
uint16_t offsetScaledLogVariance
Definition: gptpbasetypes.h:128
ScaledNs::subns
uint16_t subns
Definition: gptpbasetypes.h:174