AM64x MCU+ SDK  08.02.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 /* ========================================================================== */
37 /* Doxygen */
38 /* ========================================================================== */
44 /* ========================================================================== */
45 /* Include Files */
46 /* ========================================================================== */
47 
48 #include <drivers/pruicss.h>
49 
50 /* ========================================================================== */
51 /* Macros & Typedefs */
52 /* ========================================================================== */
53 
60 typedef enum
61 {
62  disable = 0,
63  enable = 1
65 
66 
71 typedef enum
72 {
78 
79 /* ========================================================================== */
80 /* Structure Declarations */
81 /* ========================================================================== */
82 
87 typedef struct ptcpTimes
88 {
89  uint32_t rxDelayLocal;
90  uint32_t txDelayLocal;
91  uint32_t rxDelayRemote;
92  uint32_t txDelayRemote;
93  uint32_t cableDelay;
95 
100 typedef struct
101 {
103  uint8_t masterSA[6];
104  uint8_t subdomainUUID[16];
106 
111 typedef struct
112 {
113  uint16_t Status;
114  uint16_t SecondsHigh;
115  uint32_t SecondsLow;
116  uint32_t Nanoseconds;
118 
123 typedef struct
124 {
125  uint32_t TorgSec;
126  uint32_t TorgNsec;
127  uint32_t TDelay;
128 
129  uint32_t IEP_count_tS;
130  uint32_t IEP_count_tL_R;
131  uint32_t IEP_count_tL_F;
132  uint32_t IEP_count_fn;
133 
134  uint64_t tick_S;
135  uint64_t tick_L;
136  uint64_t tick_fn;
137 } LatchVars;
138 
139 /* ========================================================================== */
140 /* Function Declarations */
141 /* ========================================================================== */
142 
151 typedef void (*ptcpCallBack_t)(uint32_t arg, uint32_t arg2);
152 
162  ptcpCallBack_t callBack);
163 
173  ptcpCallBack_t callBack);
174 
183  uint8_t portNum);
184 
193 void PN_PTCP_getLocalDelayValues(PN_Handle pnHandle, uint8_t portNum,
194  uint32_t *outRxDelay, uint32_t *outTxDelay);
195 
204 void PN_PTCP_getRemoteDelayValues(PN_Handle pnHandle, uint8_t portNum,
205  uint32_t *outRxDelay, uint32_t *outTxDelay);
206 
213 void PN_PTCP_getSyncInfo(PN_Handle pnHandle, ptcpSyncInfo_t *syncInfo);
214 
221 void PN_PTCP_getSyncMasterAddress(PN_Handle pnHandle, uint8_t *addr);
222 
232 void PN_PTCP_setPllWindow(PN_Handle pnHandle, uint32_t pllWindowSize);
233 
243  uint32_t syncTimeoutFactor);
244 
254  uint32_t takeoverTimeoutFactor);
255 
262 void PN_PTCP_setSyncUUID(PN_Handle pnHandle, uint8_t *subdomainUUID);
263 
270 void PN_PTCP_configureSyncFwd(PRUICSS_HwAttrs const *pruicssHwAttrs,
272 
281 void PN_PTCP_configureDelayMeasurement(PN_Handle pnHandle, uint8_t portNum,
283 
292 void PN_PTCP_configureDelayResp(PRUICSS_HwAttrs const *pruicssHwAttrs,
293  uint8_t portNum,
315  PNIO_TimeStamp *p_PNIO_TimeStamp, int32_t LatchEn);
316 
317 
319 
320 #endif /* IPTCPDRV_H_ */
ptcpPortDelayVal_t::cableDelay
uint32_t cableDelay
Definition: iPtcpDrv.h:93
PNIO_TimeStamp::Status
uint16_t Status
Definition: iPtcpDrv.h:113
disable
@ disable
Definition: iPtcpDrv.h:62
PN_Handle
struct PN_Config_s * PN_Handle
Alias for Profinet Handle containing base addresses and modules.
Definition: PN_Handle.h:96
LatchVars::IEP_count_tL_R
uint32_t IEP_count_tL_R
Definition: iPtcpDrv.h:130
LatchVars::TorgSec
uint32_t TorgSec
Definition: iPtcpDrv.h:125
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:75
ptcpPortDelayVal_t::rxDelayLocal
uint32_t rxDelayLocal
Definition: iPtcpDrv.h:89
SYNC_TIMEOUT
@ SYNC_TIMEOUT
Definition: iPtcpDrv.h:76
ptcpPortDelayVal_t
Structure containing the port delay values of the local and remote.
Definition: iPtcpDrv.h:88
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:91
PNIO_TimeStamp::Nanoseconds
uint32_t Nanoseconds
Definition: iPtcpDrv.h:116
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:74
PNIO_TimeStamp::SecondsLow
uint32_t SecondsLow
Definition: iPtcpDrv.h:115
LatchVars::tick_S
uint64_t tick_S
Definition: iPtcpDrv.h:134
ptcpSyncInfo_t::syncState
syncState_t syncState
Definition: iPtcpDrv.h:102
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:135
LatchVars
Definition: iPtcpDrv.h:124
LatchVars::IEP_count_fn
uint32_t IEP_count_fn
Definition: iPtcpDrv.h:132
LatchVars::TDelay
uint32_t TDelay
Definition: iPtcpDrv.h:127
PNIO_TimeStamp
Definition: iPtcpDrv.h:112
PNIO_TimeStamp::SecondsHigh
uint16_t SecondsHigh
Definition: iPtcpDrv.h:114
LatchVars::tick_fn
uint64_t tick_fn
Definition: iPtcpDrv.h:136
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:92
ptcpPortDelayVal_t::txDelayLocal
uint32_t txDelayLocal
Definition: iPtcpDrv.h:90
OUT_OF_SYNC
@ OUT_OF_SYNC
Definition: iPtcpDrv.h:73
LatchVars::IEP_count_tL_F
uint32_t IEP_count_tL_F
Definition: iPtcpDrv.h:131
PN_PTCP_latchInit
void PN_PTCP_latchInit(PN_Handle pnHandle)
LatchVars::TorgNsec
uint32_t TorgNsec
Definition: iPtcpDrv.h:126
ptcpSyncInfo_t
Structure containing current sync info.
Definition: iPtcpDrv.h:101
syncState_t
syncState_t
Enum for the various sync states.
Definition: iPtcpDrv.h:72
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:129
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:61
ptcpCallBack_t
void(* ptcpCallBack_t)(uint32_t arg, uint32_t arg2)
Definition: iPtcpDrv.h:151
enable
@ enable
Definition: iPtcpDrv.h:63