AM64x MCU+ SDK  08.06.00
iPtcpDrv.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 IPTCPDRV_H_
34 #define IPTCPDRV_H_
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 
42 /* ========================================================================== */
43 /* Doxygen */
44 /* ========================================================================== */
50 /* ========================================================================== */
51 /* Include Files */
52 /* ========================================================================== */
53 
54 #include <drivers/pruicss.h>
55 
56 /* ========================================================================== */
57 /* Macros & Typedefs */
58 /* ========================================================================== */
59 
66 typedef enum
67 {
68  disable = 0,
69  enable = 1
71 
72 
77 typedef enum
78 {
84 
85 /* ========================================================================== */
86 /* Structure Declarations */
87 /* ========================================================================== */
88 
93 typedef struct ptcpTimes
94 {
95  uint32_t rxDelayLocal;
96  uint32_t txDelayLocal;
97  uint32_t rxDelayRemote;
98  uint32_t txDelayRemote;
99  uint32_t cableDelay;
101 
106 typedef struct
107 {
109  uint8_t masterSA[6];
110  uint8_t subdomainUUID[16];
112 
117 typedef struct
118 {
119  uint16_t Status;
120  uint16_t SecondsHigh;
121  uint32_t SecondsLow;
122  uint32_t Nanoseconds;
124 
129 typedef struct
130 {
131  uint32_t TorgSec;
132  uint32_t TorgNsec;
133  uint32_t TDelay;
134 
135  uint32_t IEP_count_tS;
136  uint32_t IEP_count_tL_R;
137  uint32_t IEP_count_tL_F;
138  uint32_t IEP_count_fn;
139 
140  uint64_t tick_S;
141  uint64_t tick_L;
142  uint64_t tick_fn;
143 } LatchVars;
144 
145 /* ========================================================================== */
146 /* Function Declarations */
147 /* ========================================================================== */
148 
157 typedef void (*ptcpCallBack_t)(uint32_t arg, uint32_t arg2);
158 
168  ptcpCallBack_t callBack);
169 
179  ptcpCallBack_t callBack);
180 
189  uint8_t portNum);
190 
199 void PN_PTCP_getLocalDelayValues(PN_Handle pnHandle, uint8_t portNum,
200  uint32_t *outRxDelay, uint32_t *outTxDelay);
201 
210 void PN_PTCP_getRemoteDelayValues(PN_Handle pnHandle, uint8_t portNum,
211  uint32_t *outRxDelay, uint32_t *outTxDelay);
212 
219 void PN_PTCP_getSyncInfo(PN_Handle pnHandle, ptcpSyncInfo_t *syncInfo);
220 
227 void PN_PTCP_getSyncMasterAddress(PN_Handle pnHandle, uint8_t *addr);
228 
238 void PN_PTCP_setPllWindow(PN_Handle pnHandle, uint32_t pllWindowSize);
239 
249  uint32_t syncTimeoutFactor);
250 
260  uint32_t takeoverTimeoutFactor);
261 
268 void PN_PTCP_setSyncUUID(PN_Handle pnHandle, uint8_t *subdomainUUID);
269 
276 void PN_PTCP_configureSyncFwd(PRUICSS_HwAttrs const *pruicssHwAttrs,
278 
287 void PN_PTCP_configureDelayMeasurement(PN_Handle pnHandle, uint8_t portNum,
289 
298 void PN_PTCP_configureDelayResp(PRUICSS_HwAttrs const *pruicssHwAttrs,
299  uint8_t portNum,
321  PNIO_TimeStamp *p_PNIO_TimeStamp, int32_t LatchEn);
322 
323 
325 
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif /* IPTCPDRV_H_ */
ptcpPortDelayVal_t::cableDelay
uint32_t cableDelay
Definition: iPtcpDrv.h:99
PNIO_TimeStamp::Status
uint16_t Status
Definition: iPtcpDrv.h:119
disable
@ disable
Definition: iPtcpDrv.h:68
PN_Handle
struct PN_Config_s * PN_Handle
Alias for Profinet Handle containing base addresses and modules.
Definition: PN_Handle.h:102
LatchVars::IEP_count_tL_R
uint32_t IEP_count_tL_R
Definition: iPtcpDrv.h:136
LatchVars::TorgSec
uint32_t TorgSec
Definition: iPtcpDrv.h:131
PN_PTCP_getSyncMasterAddress
void PN_PTCP_getSyncMasterAddress(PN_Handle pnHandle, uint8_t *addr)
Get the sync Master address (MAC)
PN_PTCP_configureSyncFwd
void PN_PTCP_configureSyncFwd(PRUICSS_HwAttrs const *pruicssHwAttrs, ptcpPortStatus_t state)
Controls(enable/disable) the sync forwarding; by default it is enabled.
pruicss.h
TAKEOVER_TIMEOUT
@ TAKEOVER_TIMEOUT
Definition: iPtcpDrv.h:81
ptcpPortDelayVal_t::rxDelayLocal
uint32_t rxDelayLocal
Definition: iPtcpDrv.h:95
SYNC_TIMEOUT
@ SYNC_TIMEOUT
Definition: iPtcpDrv.h:82
ptcpPortDelayVal_t
Structure containing the port delay values of the local and remote.
Definition: iPtcpDrv.h:94
state
uint8_t state
Definition: tisci_pm_clock.h:3
PN_PTCP_getDelayValues
void PN_PTCP_getDelayValues(PN_Handle pnHandle, ptcpPortDelayVal_t *portDelays, uint8_t portNum)
Returns the current cable delay related values.
ptcpPortDelayVal_t::rxDelayRemote
uint32_t rxDelayRemote
Definition: iPtcpDrv.h:97
PNIO_TimeStamp::Nanoseconds
uint32_t Nanoseconds
Definition: iPtcpDrv.h:122
addr
uint64_t addr
Definition: csl_udmap_tr.h:3
PN_PTCP_registerDelayUpdateCall
void PN_PTCP_registerDelayUpdateCall(PN_Handle pnHandle, ptcpCallBack_t callBack)
Registers the callback function for getting notifications about new cable delay measurement.
IN_SYNC
@ IN_SYNC
Definition: iPtcpDrv.h:80
PNIO_TimeStamp::SecondsLow
uint32_t SecondsLow
Definition: iPtcpDrv.h:121
LatchVars::tick_S
uint64_t tick_S
Definition: iPtcpDrv.h:140
ptcpSyncInfo_t::syncState
syncState_t syncState
Definition: iPtcpDrv.h:108
PRUICSS_HwAttrs
PRUICSS Hardware Attributes.
Definition: pruicss/g_v0/pruicss.h:334
PN_PTCP_getRemoteDelayValues
void PN_PTCP_getRemoteDelayValues(PN_Handle pnHandle, uint8_t portNum, uint32_t *outRxDelay, uint32_t *outTxDelay)
Get the remote port delay values.
PN_PTCP_setTakeoverTimeoutFactor
void PN_PTCP_setTakeoverTimeoutFactor(PN_Handle pnHandle, uint32_t takeoverTimeoutFactor)
Sets the takeover timeout factor.
PN_PTCP_setSyncUUID
void PN_PTCP_setSyncUUID(PN_Handle pnHandle, uint8_t *subdomainUUID)
Sets the sync UUID for the device. Application is also notified about the current sync status....
PN_PTCP_registerSyncStatusCall
void PN_PTCP_registerSyncStatusCall(PN_Handle pnHandle, ptcpCallBack_t callBack)
Registers the callback function for getting notifications about change in sync state.
PN_PTCP_setSyncTimeoutFactor
void PN_PTCP_setSyncTimeoutFactor(PN_Handle pnHandle, uint32_t syncTimeoutFactor)
Sets the Sync timeout factor.
LatchVars::tick_L
uint64_t tick_L
Definition: iPtcpDrv.h:141
LatchVars
Definition: iPtcpDrv.h:130
LatchVars::IEP_count_fn
uint32_t IEP_count_fn
Definition: iPtcpDrv.h:138
LatchVars::TDelay
uint32_t TDelay
Definition: iPtcpDrv.h:133
PNIO_TimeStamp
Definition: iPtcpDrv.h:118
PNIO_TimeStamp::SecondsHigh
uint16_t SecondsHigh
Definition: iPtcpDrv.h:120
LatchVars::tick_fn
uint64_t tick_fn
Definition: iPtcpDrv.h:142
PN_PTCP_getSyncInfo
void PN_PTCP_getSyncInfo(PN_Handle pnHandle, ptcpSyncInfo_t *syncInfo)
Returns current sync status and other sync related info.
PN_PTCP_configureDelayResp
void PN_PTCP_configureDelayResp(PRUICSS_HwAttrs const *pruicssHwAttrs, uint8_t portNum, ptcpPortStatus_t state)
ptcpPortDelayVal_t::txDelayRemote
uint32_t txDelayRemote
Definition: iPtcpDrv.h:98
ptcpPortDelayVal_t::txDelayLocal
uint32_t txDelayLocal
Definition: iPtcpDrv.h:96
OUT_OF_SYNC
@ OUT_OF_SYNC
Definition: iPtcpDrv.h:79
LatchVars::IEP_count_tL_F
uint32_t IEP_count_tL_F
Definition: iPtcpDrv.h:137
PN_PTCP_latchInit
void PN_PTCP_latchInit(PN_Handle pnHandle)
LatchVars::TorgNsec
uint32_t TorgNsec
Definition: iPtcpDrv.h:132
ptcpSyncInfo_t
Structure containing current sync info.
Definition: iPtcpDrv.h:107
syncState_t
syncState_t
Enum for the various sync states.
Definition: iPtcpDrv.h:78
PN_PTCP_setPllWindow
void PN_PTCP_setPllWindow(PN_Handle pnHandle, uint32_t pllWindowSize)
Sets the PLL window for sync handling.
PN_PTCP_getAbsoluteTime
int32_t PN_PTCP_getAbsoluteTime(PN_Handle pnHandle, PNIO_TimeStamp *p_PNIO_TimeStamp, int32_t LatchEn)
API to return absolute PTCP time.
PN_PTCP_configureDelayMeasurement
void PN_PTCP_configureDelayMeasurement(PN_Handle pnHandle, uint8_t portNum, ptcpPortStatus_t state)
Controls(enable/disable) the delay measurement process on a particular port. By default,...
LatchVars::IEP_count_tS
uint32_t IEP_count_tS
Definition: iPtcpDrv.h:135
PN_PTCP_getLocalDelayValues
void PN_PTCP_getLocalDelayValues(PN_Handle pnHandle, uint8_t portNum, uint32_t *outRxDelay, uint32_t *outTxDelay)
Get the local port delay values.
ptcpPortStatus_t
ptcpPortStatus_t
Enum for enable/disable states.
Definition: iPtcpDrv.h:67
ptcpCallBack_t
void(* ptcpCallBack_t)(uint32_t arg, uint32_t arg2)
Definition: iPtcpDrv.h:157
enable
@ enable
Definition: iPtcpDrv.h:69