AM64x MCU+ SDK  08.02.00
icss_timeSync_init.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef ICSS_TIMESYNC_INIT_H_
34 #define ICSS_TIMESYNC_INIT_H_
35 
45 /* ========================================================================== */
46 /* Include Files */
47 /* ========================================================================== */
48 #include "icss_timeSync.h"
49 #include "icss_timeSyncApi.h"
50 #include "icss_timeSync_osal.h"
51 
56 #define TS_LEAP_61_INDEX 0
57 
61 #define TS_LEAP_59_INDEX 1
62 
66 #define TS_UTC_REASONABLE_INDEX 2
67 
72 #define TS_PTP_TIMESCALE_INDEX 3
73 
78 #define TS_TIME_TRACEABLE_INDEX 4
79 
84 #define TS_FREQ_TRACEABLE_INDEX 5
85 
90 #define TS_ALTERNATE_MASTER_INDEX 6
91 
96 #define TS_PTP_TWO_STEP_INDEX 7
97 
102 #define TS_PTP_UNICAST 8
103 
109 #define TS_PROFILE_SPECIFIC_1_INDEX 9
110 
116 #define TS_PROFILE_SPECIFIC_2_INDEX 10
117 
122 #define TS_PTP_SECURITY_INDEX 11
123 
124 /*------------Flag masks for different frames as per standard--------*/
125 /* These are derived indirectly from Table 20 of the standard*/
131 #define TS_SYNC_BYTE0_MASK 0xFF
132 
137 #define TS_ANNOUNCE_BYTE0_MASK 0xFD
138 
144 #define TS_FOLLOW_UP_BYTE0_MASK 0xFD
145 
150 #define TS_PDELAY_RESP_BYTE0_MASK 0xFE
151 
156 #define TS_DELAY_RESP_BYTE0_MASK 0xFD
157 
163 #define TS_OTHER_FRAMES_BYTE0_MASK 0xFC
164 
170 #define TIMESYNC_PDELAY_BUF_SIZE 68
171 
176 #define TIMESYNC_SYNC_BUF_ANNEX_F_SIZE 58
177 
182 #define TIMESYNC_FOLLOW_UP_BUF_ANNEX_F_SIZE 63
183 
188 #define TIMESYNC_ANNOUNCE_BUF_ANNEX_F_SIZE 78
189 
194 #define TIMESYNC_SYNC_BUF_ANNEX_E_SIZE 86
195 
200 #define TIMESYNC_FOLLOW_UP_BUF_ANNEX_E_SIZE 86
201 
206 #define TIMESYNC_ANNOUNCE_BUF_ANNEX_E_SIZE 106
207 
212 #define TIMESYNC_DELAY_REQ_BUF_SIZE 86
213 
214 /*-----------------Default PTP Master init params-------------------*/
215 
216 /* These are used in BMCA*/
220 #define TIMESYNC_DEFAULT_PRIO_1 128
221 
224 #define TIMESYNC_DEFAULT_PRIO_2 128
225 
228 #define TIMESYNC_DEFAULT_CLOCK_ACCURACY 0x31
229 
232 #define TIMESYNC_DEFAULT_CLOCK_CLASS 248
233 
236 #define TIMESYNC_DEFAULT_CLOCK_VARIANCE 0
237 
240 #define TIMESYNC_DEFAULT_STEPS_REMOVED 0
241 
244 #define TIMESYNC_UTC_OFFSET 0
245 
248 #define TIMESYNC_DEFAULT_TIME_SOURCE 0xa0
249 
250 
254 #define TIMESYNC_OFFSET_STABLE_ALGO_THRESHOLD 15
255 
256 /* ========================================================================== */
257 /* Function Declarations */
258 /* ========================================================================== */
259 
266 
273 
279 
285 
291 
297 
298 
306 
313  uint8_t *ifMacID);
320 
326 void TimeSync_addIP(TimeSync_ParamsHandle_t timeSyncHandle, uint32_t IP);
327 
330 #endif /* ICSS_TIMESYNC_INIT_H_ */
TimeSync_unAlloc_PktBuffer
void TimeSync_unAlloc_PktBuffer(TimeSync_ParamsHandle_t timeSyncHandle)
Unallocate Rx and Tx buffers for frames like Sync, Announce etc.
TimeSync_formatPTPFrames
void TimeSync_formatPTPFrames(TimeSync_ParamsHandle_t timeSyncHandle, uint8_t *ifMacID)
Prepare PTP frames with fields, mac addresses etc.
icss_timeSync.h
TimeSync_drvDisable
void TimeSync_drvDisable(TimeSync_ParamsHandle_t timeSyncHandle)
Disable PTP firmware.
TimeSync_setDefaultValue
void TimeSync_setDefaultValue(TimeSync_ParamsHandle_t timeSyncHandle)
Set Default values for the PTP Object based on clock type.
TimeSync_drvEnable
void TimeSync_drvEnable(TimeSync_ParamsHandle_t timeSyncHandle)
Enable PTP firmware.
TimeSync_initializeFollowUp
void TimeSync_initializeFollowUp(TimeSync_ParamsHandle_t timeSyncHandle)
Populate MAC ID, clock identity etc in Follow Up frame. Should be called everytime we change to Maste...
icss_timeSyncApi.h
TimeSync_addIP
void TimeSync_addIP(TimeSync_ParamsHandle_t timeSyncHandle, uint32_t IP)
Update IP and Modify checksum whenever IP is assigned or changed.
TimeSync_ParamsHandle_t
struct TimeSync_ParamsHandle_s * TimeSync_ParamsHandle_t
Definition: icss_timeSyncApi.h:1016
TimeSync_alloc_PktBuffer
int8_t TimeSync_alloc_PktBuffer(TimeSync_ParamsHandle_t timeSyncHandle)
Allocate Rx and Tx buffers for frames like Sync, Announce etc.
TimeSync_drvInit
int8_t TimeSync_drvInit(TimeSync_ParamsHandle_t timeSyncHandle)
Initializes variables and timers & clocks, call once at the beginning.
TimeSync_dramInit
void TimeSync_dramInit(TimeSync_ParamsHandle_t timeSyncHandle)
Initialize PTP stored variables in the DRAM.