AM263Px MCU+ SDK: lldtsync.h Source File

| AM263Px MCU+ SDK 26.00.00 |

lldtsync.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 */
56 #ifndef LLDTSYNC_H_
57 #define LLDTSYNC_H_
58
59 #include "lldtype.h"
60
64 typedef struct {
68 uint32_t enetType;
72 uint32_t instId;
73 } LLDTSyncCfg_t;
74
75 typedef enum
76 {
77 LLDTSYNC_TS_SOURCE_INVALID = 0,
78 LLDTSYNC_TS_SOURCE_CPTS,
79 LLDTSYNC_TS_SOURCE_PHY,
80 }LLDTsyncTsSource;
81
85 typedef struct LLDTSync LLDTSync_t;
86
91 void LLDTSyncCfgInit(LLDTSyncCfg_t *cfg);
92
99 LLDTSync_t *LLDTSyncOpen(LLDTSyncCfg_t *cfg, LLDTsyncTsSource tsSource);
100
105 void LLDTSyncClose(LLDTSync_t *hTSync);
106
117 int LLDTSyncGetRxTime(LLDTSync_t *hTSync, uint8_t rxPort, int msgType,
118 uint16_t seqId, uint8_t domain, uint64_t *ts);
119
130 int LLDTSyncGetTxTime(LLDTSync_t *hTSync, uint8_t txPort, int msgType,
131 uint16_t seqId, uint8_t domain, uint64_t *ts);
132
139 int LLDTSyncAdjFreq(LLDTSync_t *hTSync, int ppb);
140
147 int LLDTSyncSetTime(LLDTSync_t *hTSync, uint64_t ts);
148
155 int LLDTSyncGetTime(LLDTSync_t *hTSync, uint64_t *ts);
156
164 int LLDTSyncEnableTsEvent(LLDTSync_t *hTSync, uint32_t ports[], uint32_t numPorts);
165
172 int LLDTSyncShiftTime(LLDTSync_t *hTSync, int64_t offset);
173
183 int LLDTsyncPhyWaitTxTs(LLDTSync_t *hTSync, uint8_t txPort, int msgType,
184 uint16_t seqId, uint8_t domain);
185
195 int LLDTSyncProcPhyStatusFrame(void* hEnet, uint8_t coreId , uint8_t txPort,
196 uint8_t* frame, uint32_t size);
197
198
199 #endif //LLDTSYNC_H_
200
LLDTsyncPhyWaitTxTs
int LLDTsyncPhyWaitTxTs(LLDTSync_t *hTSync, uint8_t txPort, int msgType, uint16_t seqId, uint8_t domain)
Put the TX packet in the wait list.
LLDTSyncGetRxTime
int LLDTSyncGetRxTime(LLDTSync_t *hTSync, uint8_t rxPort, int msgType, uint16_t seqId, uint8_t domain, uint64_t *ts)
Retrieves the PTP RX timestamp for a specific message.
LLDTSyncCfgInit
void LLDTSyncCfgInit(LLDTSyncCfg_t *cfg)
Initializes the LLDTSyncCfg_t configuration structure.
LLDTSyncAdjFreq
int LLDTSyncAdjFreq(LLDTSync_t *hTSync, int ppb)
Adjusts the frequency of the PTP clock.
LLDTSyncCfg_t::enetType
uint32_t enetType
Definition: lldtsync.h:68
LLDTSYNC_TS_SOURCE_CPTS
@ LLDTSYNC_TS_SOURCE_CPTS
Definition: lldtsync.h:78
LLDTSyncSetTime
int LLDTSyncSetTime(LLDTSync_t *hTSync, uint64_t ts)
Sets the time for the PTP clock.
LLDTSyncEnableTsEvent
int LLDTSyncEnableTsEvent(LLDTSync_t *hTSync, uint32_t ports[], uint32_t numPorts)
Enables PTP timestamp events for specified ports.
LLDTSyncClose
void LLDTSyncClose(LLDTSync_t *hTSync)
Closes the LLDTSync instance.
lldtype.h
Data types and macros for TI Enet LLD abstract APIs.
LLDTSyncCfg_t::instId
uint32_t instId
Definition: lldtsync.h:72
LLDTSyncGetTime
int LLDTSyncGetTime(LLDTSync_t *hTSync, uint64_t *ts)
Retrieves the current time from the PTP clock.
LLDTSyncShiftTime
int LLDTSyncShiftTime(LLDTSync_t *hTSync, int64_t offset)
Shift the time of the PTP clock by offset nsec.
LLDTSyncCfg_t
Configuration structure for LLDTSync.
Definition: lldtsync.h:64
LLDTSyncOpen
LLDTSync_t * LLDTSyncOpen(LLDTSyncCfg_t *cfg, LLDTsyncTsSource tsSource)
Opens a new LLDTSync instance to access the PTP clock.
LLDTSYNC_TS_SOURCE_INVALID
@ LLDTSYNC_TS_SOURCE_INVALID
Definition: lldtsync.h:77
LLDTsyncTsSource
LLDTsyncTsSource
Definition: lldtsync.h:76
LLDTSync_t
struct LLDTSync LLDTSync_t
Structure representing the LLDTSync instance.
Definition: lldtsync.h:85
LLDTSyncProcPhyStatusFrame
int LLDTSyncProcPhyStatusFrame(void *hEnet, uint8_t coreId, uint8_t txPort, uint8_t *frame, uint32_t size)
Process the status frame.
LLDTSYNC_TS_SOURCE_PHY
@ LLDTSYNC_TS_SOURCE_PHY
Definition: lldtsync.h:79
LLDTSyncGetTxTime
int LLDTSyncGetTxTime(LLDTSync_t *hTSync, uint8_t txPort, int msgType, uint16_t seqId, uint8_t domain, uint64_t *ts)
Retrieves the PTP TX timestamp for a specific message.