AM261x INDUSTRIAL COMMUNICATIONS SDK  10.02.00
PN_HandleDef.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 PN_HANDLE_DEF_H_
34 #define PN_HANDLE_DEF_H_
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 
42 /* ========================================================================== */
43 /* Include Files */
44 /* ========================================================================== */
45 
46 #include "pnDrvConfig.h"
47 #include "iPtcpDrv.h"
48 #include "iPtcpUtils.h"
49 #include "iRtcDrv2.h"
50 #include "iPnOs.h"
51 #include <kernel/dpl/HwiP.h>
52 #include <kernel/dpl/SemaphoreP.h>
53 #include <kernel/dpl/TaskP.h>
54 #include <stdint.h>
55 
56 /* ========================================================================== */
57 /* Macros & Typedefs */
58 /* ========================================================================== */
59 
60 /*TODO: Review this*/
61 #define PN_TASK_STACK_SIZE (2048)
62 
63 typedef void (*PN_getMACAddress)(uint8_t index, uint8_t *lclMac);
64 
65 /* ========================================================================== */
66 /* Structure Declarations */
67 /* ========================================================================== */
68 /*
69 * \brief PN_PtcpDebug
70 * Structure storing the debug info for PTCP
71 */
72 typedef struct PN_PtcpDebug_s
73 {
77  int32_t debugDelayIndex;
79  int32_t debugSyncIndex;
81  int32_t maxDeltaT;
83  int32_t minDeltaT;
87  int32_t maxDelay;
89  int32_t minDelay;
91  int32_t delayOutOfRange;
93  uint32_t syncmissCounter;
94 } PN_PtcpDebug;
95 
96 /*
97 * \brief PN_TimerAttrs
98 * Structure storing the interrupt configurations
99 */
100 typedef struct PN_PtcpTimerAttrs_s
101 {
103  uint32_t ptcpTimerID;
107 
108 /*
109 * \brief PN_PtcpConfig
110 * Structure storing the PTCP info
111 */
112 typedef struct PN_PtcpConfig_s
113 {
115  uint32_t pnCyclePeriod;
117  uint32_t mandCtrAdj;
119  uint32_t T2_prev[PTCP_NUM_PORTS];
121  uint32_t T1_prev[PTCP_NUM_PORTS];
123  uint32_t T1_CTR_prev[PTCP_NUM_PORTS];
125  float rcf_prev[PTCP_NUM_PORTS];
127  uint16_t seqId;
129  int32_t delayIndex;
131  int32_t syncIndex;
133  uint32_t numInSync;
135  int32_t syncDeltaTs[SYNC_FILTER_SIZE];
137  uint32_t *pSyncTorgNs;
141  uint32_t *pSyncRxSOF;
143  uint32_t *pSyncTorgSecs;
145  uint16_t *pPmCycleCounter;
147  uint16_t *pPmPhaseCounter;
149  uint8_t *pSubDomainUUID;
151  uint8_t *pSyncMasterMac;
153  uint8_t *pSyncInitFlag;
157  uint32_t prev_cDelay[PTCP_NUM_PORTS];
159  uint32_t prev_lDelay[PTCP_NUM_PORTS];
167  uint8_t masterChange;
169  uint8_t phaseCtrChange;
173  uint16_t maxSeqId;
175  uint16_t minSeqId;
191  /* Semaphores */
193  SemaphoreP_Object ptcpStartSem;
195  SemaphoreP_Object ptcpTriggerMeasurementSem;
196  /* Callbacks */
201  /*TODO: Check if this should be always included*/
202  /* Debug */
210  /* Timer for PTCP */
218  /* Port at which sync frame is received. To be used by application if required */
219  uint8_t SyncCtrlPort;
220  /* Flag set if received sync frame is followup frame. To be used by application if required */
221  uint8_t SyncCtrlFup;
222  /* IEP increment count */
223  uint8_t iepStepCount;
224 } PN_PtcpConfig;
225 
226 
227 typedef struct PN_IsoMConfig_s
228 {
237 
238  uint8_t isoMNumEvents;
239 
241 
242 /*
243 * \brief PN_Config
244 * Profinet handle - stores the Profinet configuration
245 */
246 typedef struct PN_Config_s
247 {
249  uint8_t initRtcDrvFlag;
251  uint8_t initRtcMemFlag;
270  irtLegStateCall; /* Required? Just sets the value for legState(above), can be done directly? */
280  PRUICSS_Handle pruicssHandle;
285  /* Task Handles */
287  TaskP_Object PTCPTaskObject;
289  TaskP_Object SyncMonitorTaskObject;
291  TaskP_Object LegModeTaskObject;
293  TaskP_Object MrpMachineTaskObject;
297  uint32_t* pnIsoMObject;
300  /*TODO: Review this*/
303  /*TODO: Review this*/
304  SemaphoreP_Object switchReady;
305 #ifdef PTCP_SUPPORT
306  uint32_t PTCP_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
307  uint32_t PTCP_syncMonitorTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
308 #endif /*PTCP_SUPPORT*/
309 #ifdef IRT_LEGACY_STARTUP_SUPPORT
310  uint32_t IRT_legacyTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
311 #endif /*IRT_LEGACY_STARTUP_SUPPORT*/
312 #ifdef MRP_SUPPORT
313  uint32_t MRP_CPMTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
314 #endif /*MRP_SUPPORT*/
315  uint32_t background_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
316  /* Callback for thread safety entry. Enter critical section*/
318  /* Callback for thread safety exit. Exit critical section*/
320 } PN_Config;
321 
322 
323 #ifdef __cplusplus
324 }
325 #endif
326 
327 #endif /* PN_HANDLE_DEF_H_ */
PN_PtcpDebug::maxDelay
int32_t maxDelay
Definition: PN_HandleDef.h:87
PN_PtcpConfig::SyncCtrlFup
uint8_t SyncCtrlFup
Definition: PN_HandleDef.h:221
PN_Config::getMACAddress
PN_getMACAddress getMACAddress
Definition: PN_HandleDef.h:302
PN_PtcpConfig::prevPnCyclePeriod
uint32_t prevPnCyclePeriod
Definition: PN_HandleDef.h:213
PN_Config::backgroundTimerTaskObject
TaskP_Object backgroundTimerTaskObject
Definition: PN_HandleDef.h:295
PN_PtcpConfig::pSyncInDelayPlusLD
uint32_t * pSyncInDelayPlusLD
Definition: PN_HandleDef.h:139
PN_PtcpConfig::mandCtrAdj
uint32_t mandCtrAdj
Definition: PN_HandleDef.h:117
PN_PtcpConfig::pSyncRxSOF
uint32_t * pSyncRxSOF
Definition: PN_HandleDef.h:141
PN_IsoMConfig
Definition: PN_HandleDef.h:228
PN_IntConfig
Definition: PN_Handle.h:84
PN_PtcpTimerAttrs
Definition: PN_HandleDef.h:101
ICSS_EMAC_Handle
struct ICSS_EMAC_Config_s * ICSS_EMAC_Handle
Alias for ICSS EMAC Handle containing base addresses and modules.
Definition: icss_emac.h:467
PN_PtcpConfig::pSyncTorgNs
uint32_t * pSyncTorgNs
Definition: PN_HandleDef.h:137
PN_PtcpConfig::deviceSyncInfo
volatile ptcpSyncInfo_t deviceSyncInfo
Definition: PN_HandleDef.h:177
PN_Config::irtLegPktCall
pnLegCallBack_t irtLegPktCall
Definition: PN_HandleDef.h:272
PN_PtcpConfig::enableCustomSyncMonitorFlag
uint8_t enableCustomSyncMonitorFlag
Definition: PN_HandleDef.h:217
PN_PtcpDebug
Definition: PN_HandleDef.h:73
PN_PtcpConfig::ptcpEnableSlowCompensation
uint8_t ptcpEnableSlowCompensation
Definition: PN_HandleDef.h:209
pnLegCallBack_t
void(* pnLegCallBack_t)(void *arg, void *arg2)
Callback function for processing Profinet IRQs.
Definition: iRtcDrv2.h:555
PN_PtcpConfig::ptcpTimer
PN_PtcpTimerAttrs ptcpTimer
Definition: PN_HandleDef.h:211
pnDrvThreadSafe_t
void(* pnDrvThreadSafe_t)(void)
Definition: iRtcDrv2.h:557
PN_PtcpConfig::calculatedCycleCtr
uint16_t calculatedCycleCtr
Definition: PN_HandleDef.h:165
PN_PtcpConfig::minSeqId
uint16_t minSeqId
Definition: PN_HandleDef.h:175
iPtcpDrv.h
PN_Config::__attribute__
uint32_t background_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
iRtcDrv2.h
PN_PtcpConfig::pSyncMasterMac
uint8_t * pSyncMasterMac
Definition: PN_HandleDef.h:151
PN_TASK_STACK_SIZE
#define PN_TASK_STACK_SIZE
Definition: PN_HandleDef.h:61
PN_PtcpDebug::debugSyncIndex
int32_t debugSyncIndex
Definition: PN_HandleDef.h:79
PN_PtcpConfig::cycleCtrInitPending
uint8_t cycleCtrInitPending
Definition: PN_HandleDef.h:163
PN_Config::__attribute__
uint32_t PTCP_syncMonitorTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
PN_PtcpConfig::pnPtcpDebugAttrs
PN_PtcpDebug pnPtcpDebugAttrs
Definition: PN_HandleDef.h:204
t_ppmBlock
Definition: iRtcDrv2.h:161
PN_IsoMConfig::isoMInterruptObjectEv2
HwiP_Object isoMInterruptObjectEv2
Definition: PN_HandleDef.h:234
SYNC_FILTER_SIZE
#define SYNC_FILTER_SIZE
Definition: iPtcpUtils.h:286
PN_Config::switchReady
SemaphoreP_Object switchReady
Definition: PN_HandleDef.h:304
debugDelay_t
Definition: iPtcpUtils.h:392
PN_IsoMConfig::isoMIntConfigEv1
PN_IntAttrs isoMIntConfigEv1
Definition: PN_HandleDef.h:232
ptcpPortDelayVal_t
Structure containing the port delay values of the local and remote.
Definition: iPtcpDrv.h:95
PN_PtcpConfig::masterChange
uint8_t masterChange
Definition: PN_HandleDef.h:167
PN_Config
Definition: PN_HandleDef.h:247
PN_Config::PTCPTaskObject
TaskP_Object PTCPTaskObject
Definition: PN_HandleDef.h:287
PN_PtcpConfig::currentPtcpStatus
volatile currentPtcpStatus_t currentPtcpStatus
Definition: PN_HandleDef.h:183
PN_PtcpConfig::maxSeqId
uint16_t maxSeqId
Definition: PN_HandleDef.h:173
t_descList
Definition: iRtcDrv2.h:213
PN_PtcpConfig::ptcpDelayUpdateCall
ptcpCallBack_t ptcpDelayUpdateCall
Definition: PN_HandleDef.h:200
tLegStates
tLegStates
possible states for legacy suppport state machine
Definition: iRtcDrv2.h:541
PN_IsoMConfig::isoMInterruptObjectEv1
HwiP_Object isoMInterruptObjectEv1
Definition: PN_HandleDef.h:230
PN_PtcpConfig::pSyncInitFlag
uint8_t * pSyncInitFlag
Definition: PN_HandleDef.h:153
PN_PtcpConfig::g_T1
PNIO_TimeStamp g_T1
Definition: PN_HandleDef.h:206
PN_Config::icssWatchDogEnabled
int32_t icssWatchDogEnabled
Definition: PN_HandleDef.h:276
PN_PtcpConfig::clkChangeNotifyDelay
uint32_t clkChangeNotifyDelay
Definition: PN_HandleDef.h:155
PN_Config::initRtcDrvFlag
uint8_t initRtcDrvFlag
Definition: PN_HandleDef.h:249
PN_Config::lockSynchronizedExit
pnDrvThreadSafe_t lockSynchronizedExit
Definition: PN_HandleDef.h:319
PN_Config::currPN
t_cfgPN currPN
Definition: PN_HandleDef.h:257
PN_Config::__attribute__
uint32_t MRP_CPMTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
PN_Config::irtLegStateCall
pnLegCallBack_t irtLegStateCall
Definition: PN_HandleDef.h:270
PN_IsoMConfig::isoMIntConfigEv2
PN_IntAttrs isoMIntConfigEv2
Definition: PN_HandleDef.h:236
PN_PtcpDebug::debugDelayIndex
int32_t debugDelayIndex
Definition: PN_HandleDef.h:77
tMrpStates
tMrpStates
Definition: iPnOs.h:178
PN_PtcpConfig::ptcpTriggerMeasurementSem
SemaphoreP_Object ptcpTriggerMeasurementSem
Definition: PN_HandleDef.h:195
PN_Config::pnPtcpConfig
PN_PtcpConfig pnPtcpConfig
Definition: PN_HandleDef.h:284
PN_PtcpConfig::SyncCtrlPort
uint8_t SyncCtrlPort
Definition: PN_HandleDef.h:219
PN_PtcpConfig::pnCyclePeriod
uint32_t pnCyclePeriod
Definition: PN_HandleDef.h:115
PN_PtcpDebug::syncmissCounter
uint32_t syncmissCounter
Definition: PN_HandleDef.h:93
PN_Config::LegModeTaskObject
TaskP_Object LegModeTaskObject
Definition: PN_HandleDef.h:291
PN_IntAttrs
Definition: PN_Handle.h:61
PN_Config::cpmList
t_descList cpmList
Definition: PN_HandleDef.h:253
PN_Config::SyncMonitorTaskObject
TaskP_Object SyncMonitorTaskObject
Definition: PN_HandleDef.h:289
PN_PtcpConfig::phaseCtrChange
uint8_t phaseCtrChange
Definition: PN_HandleDef.h:169
PN_PtcpConfig::ptcpSyncFilterfactor
uint8_t ptcpSyncFilterfactor
Definition: PN_HandleDef.h:207
PN_Config::icssWachDogTimerPeriod
int32_t icssWachDogTimerPeriod
Definition: PN_HandleDef.h:274
PN_Config::legState
tLegStates legState
Definition: PN_HandleDef.h:265
PN_IsoMConfig::isoMNumEvents
uint8_t isoMNumEvents
Definition: PN_HandleDef.h:238
PN_PtcpConfig::numInSync
uint32_t numInSync
Definition: PN_HandleDef.h:133
PN_PtcpTimerAttrs::ptcpTimerHandle
void * ptcpTimerHandle
Definition: PN_HandleDef.h:105
PN_PtcpConfig::seqId
uint16_t seqId
Definition: PN_HandleDef.h:127
PN_PtcpConfig::ptcpStartSem
SemaphoreP_Object ptcpStartSem
Definition: PN_HandleDef.h:193
PN_Config::pnIsoMConfig
PN_IsoMConfig pnIsoMConfig
Definition: PN_HandleDef.h:299
PN_getMACAddress
void(* PN_getMACAddress)(uint8_t index, uint8_t *lclMac)
Definition: PN_HandleDef.h:63
PN_PtcpConfig::delayIndex
int32_t delayIndex
Definition: PN_HandleDef.h:129
LatchVars
Definition: iPtcpDrv.h:131
PN_PtcpConfig::ptcpSync0PinPulseWidth
uint32_t ptcpSync0PinPulseWidth
Definition: PN_HandleDef.h:181
devicePortOffsets_t
Definition: iPtcpUtils.h:370
PN_PtcpConfig::iepStepCount
uint8_t iepStepCount
Definition: PN_HandleDef.h:223
deviceDelays_t
Definition: iPtcpUtils.h:360
ptcpSyncCallBack_t
void(* ptcpSyncCallBack_t)(PN_Handle arg1)
Definition: iPtcpDrv.h:169
PN_PtcpDebug::minDeltaT
int32_t minDeltaT
Definition: PN_HandleDef.h:83
PN_PtcpConfig::initPmCycleCtrDone
uint8_t initPmCycleCtrDone
Definition: PN_HandleDef.h:161
PN_PtcpConfig::ptcpSyncMonitorCall
ptcpSyncCallBack_t ptcpSyncMonitorCall
Definition: PN_HandleDef.h:215
PN_Config::MrpMachineTaskObject
TaskP_Object MrpMachineTaskObject
Definition: PN_HandleDef.h:293
PN_PtcpConfig::g_Latch
LatchVars g_Latch
Definition: PN_HandleDef.h:205
PNIO_TimeStamp
Definition: iPtcpDrv.h:119
PN_Config::lockSynchronizedEntry
pnDrvThreadSafe_t lockSynchronizedEntry
Definition: PN_HandleDef.h:317
PN_PtcpDebug::deltaTOutOfRange
int32_t deltaTOutOfRange
Definition: PN_HandleDef.h:85
t_rtcPacket
real-time packet structure
Definition: iRtcDrv2.h:184
PN_PtcpConfig::syncIndex
int32_t syncIndex
Definition: PN_HandleDef.h:131
PN_Config::mrpState
tMrpStates mrpState
Definition: PN_HandleDef.h:263
PN_Config::pruicssHandle
PRUICSS_Handle pruicssHandle
Definition: PN_HandleDef.h:280
iPnOs.h
t_cfgPN
Definition: iRtcDrv2.h:236
PN_Config::emacHandle
ICSS_EMAC_Handle emacHandle
Definition: PN_HandleDef.h:278
PN_PtcpConfig::pSyncTorgSecs
uint32_t * pSyncTorgSecs
Definition: PN_HandleDef.h:143
PN_PtcpConfig::ptcpSync0PinStart
uint32_t ptcpSync0PinStart
Definition: PN_HandleDef.h:179
PN_Config::initRtcMemFlag
uint8_t initRtcMemFlag
Definition: PN_HandleDef.h:251
PN_PtcpConfig::firstDelayBurst
int32_t firstDelayBurst
Definition: PN_HandleDef.h:171
ptcpSyncInfo_t
Structure containing current sync info.
Definition: iPtcpDrv.h:108
PN_PtcpConfig::pPmCycleCounter
uint16_t * pPmCycleCounter
Definition: PN_HandleDef.h:145
PN_Config::ppmList
t_descList ppmList
Definition: PN_HandleDef.h:255
PN_Config::__attribute__
uint32_t PTCP_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
t_cpmBlock
Definition: iRtcDrv2.h:173
PN_Config::pnIsoMObject
uint32_t * pnIsoMObject
Definition: PN_HandleDef.h:297
iPtcpUtils.h
PN_Config::__attribute__
uint32_t IRT_legacyTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
PN_PtcpConfig::pPmPhaseCounter
uint16_t * pPmPhaseCounter
Definition: PN_HandleDef.h:147
PN_PtcpDebug::minDelay
int32_t minDelay
Definition: PN_HandleDef.h:89
PN_PtcpConfig::ptcpSyncStatusCall
ptcpCallBack_t ptcpSyncStatusCall
Definition: PN_HandleDef.h:198
PN_Config::pLegPkt
t_rtcPacket * pLegPkt
Definition: PN_HandleDef.h:267
currentPtcpStatus_t
Definition: iPtcpUtils.h:337
PN_PtcpConfig::pSubDomainUUID
uint8_t * pSubDomainUUID
Definition: PN_HandleDef.h:149
PN_PtcpDebug::delayOutOfRange
int32_t delayOutOfRange
Definition: PN_HandleDef.h:91
PN_PtcpDebug::maxDeltaT
int32_t maxDeltaT
Definition: PN_HandleDef.h:81
PN_Config::cpmBlock
t_cpmBlock cpmBlock
Definition: PN_HandleDef.h:261
PTCP_NUM_PORTS
#define PTCP_NUM_PORTS
Definition: iPtcpUtils.h:180
PN_PtcpConfig
Definition: PN_HandleDef.h:113
ptcpCallBack_t
void(* ptcpCallBack_t)(uint32_t arg, uint32_t arg2)
Definition: iPtcpDrv.h:167
PN_Config::pnIntConfig
PN_IntConfig pnIntConfig
Definition: PN_HandleDef.h:282
PN_PtcpTimerAttrs::ptcpTimerID
uint32_t ptcpTimerID
Definition: PN_HandleDef.h:103