AM263Px MCU+ SDK: icss_timeSync_init.h Source File

| AM263Px MCU+ SDK 26.00.00 |

icss_timeSync_init.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2024 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
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40
41
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 #include "icss_timeSync.h"
55 #include "icss_timeSyncApi.h"
56 #include "icss_timeSync_osal.h"
57
62 #define TS_LEAP_61_INDEX 0
63
67 #define TS_LEAP_59_INDEX 1
68
72 #define TS_UTC_REASONABLE_INDEX 2
73
78 #define TS_PTP_TIMESCALE_INDEX 3
79
84 #define TS_TIME_TRACEABLE_INDEX 4
85
90 #define TS_FREQ_TRACEABLE_INDEX 5
91
96 #define TS_ALTERNATE_MASTER_INDEX 6
97
102 #define TS_PTP_TWO_STEP_INDEX 7
103
108 #define TS_PTP_UNICAST 8
109
115 #define TS_PROFILE_SPECIFIC_1_INDEX 9
116
122 #define TS_PROFILE_SPECIFIC_2_INDEX 10
123
128 #define TS_PTP_SECURITY_INDEX 11
129
130 /*------------Flag masks for different frames as per standard--------*/
131 /* These are derived indirectly from Table 20 of the standard*/
137 #define TS_SYNC_BYTE0_MASK 0xFF
138
143 #define TS_ANNOUNCE_BYTE0_MASK 0xFD
144
150 #define TS_FOLLOW_UP_BYTE0_MASK 0xFD
151
156 #define TS_PDELAY_RESP_BYTE0_MASK 0xFE
157
162 #define TS_DELAY_RESP_BYTE0_MASK 0xFD
163
169 #define TS_OTHER_FRAMES_BYTE0_MASK 0xFC
170
176 #define TIMESYNC_PDELAY_BUF_SIZE 68
177
182 #define TIMESYNC_SYNC_BUF_ANNEX_F_SIZE 58
183
188 #define TIMESYNC_FOLLOW_UP_BUF_ANNEX_F_SIZE 63
189
194 #define TIMESYNC_ANNOUNCE_BUF_ANNEX_F_SIZE 78
195
200 #define TIMESYNC_SYNC_BUF_ANNEX_E_SIZE 86
201
206 #define TIMESYNC_FOLLOW_UP_BUF_ANNEX_E_SIZE 86
207
212 #define TIMESYNC_ANNOUNCE_BUF_ANNEX_E_SIZE 106
213
218 #define TIMESYNC_DELAY_REQ_BUF_SIZE 86
219
220 /*-----------------Default PTP Master init params-------------------*/
221
222 /* These are used in BMCA*/
226 #define TIMESYNC_DEFAULT_PRIO_1 128
227
230 #define TIMESYNC_DEFAULT_PRIO_2 128
231
234 #define TIMESYNC_DEFAULT_CLOCK_ACCURACY 0x31
235
238 #define TIMESYNC_DEFAULT_CLOCK_CLASS 248
239
242 #define TIMESYNC_DEFAULT_CLOCK_VARIANCE 0
243
246 #define TIMESYNC_DEFAULT_STEPS_REMOVED 0
247
250 #define TIMESYNC_UTC_OFFSET 0
251
254 #define TIMESYNC_DEFAULT_TIME_SOURCE 0xa0
255
256
260 #define TIMESYNC_OFFSET_STABLE_ALGO_THRESHOLD 15
261
262 /* ========================================================================== */
263 /* Function Declarations */
264 /* ========================================================================== */
265
271 int8_t TimeSync_drvInit(TimeSync_ParamsHandle_t timeSyncHandle);
272
278 int8_t TimeSync_alloc_PktBuffer(TimeSync_ParamsHandle_t timeSyncHandle);
279
284 void TimeSync_unAlloc_PktBuffer(TimeSync_ParamsHandle_t timeSyncHandle);
285
290 void TimeSync_drvEnable(TimeSync_ParamsHandle_t timeSyncHandle);
291
296 void TimeSync_drvDisable(TimeSync_ParamsHandle_t timeSyncHandle);
297
302 void TimeSync_dramInit(TimeSync_ParamsHandle_t timeSyncHandle);
303
304
311 void TimeSync_setDefaultValue(TimeSync_ParamsHandle_t timeSyncHandle);
312
318 void TimeSync_formatPTPFrames(TimeSync_ParamsHandle_t timeSyncHandle,
319 uint8_t *ifMacID);
325 void TimeSync_initializeFollowUp(TimeSync_ParamsHandle_t timeSyncHandle);
326
332 void TimeSync_addIP(TimeSync_ParamsHandle_t timeSyncHandle, uint32_t IP);
333
337 #ifdef __cplusplus
338 }
339 #endif
340
341 #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:985
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.