AM64x MCU+ SDK  08.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 /* ========================================================================== */
37 /* Include Files */
38 /* ========================================================================== */
39 
40 #include "pnDrvConfig.h"
41 #include "iPtcpDrv.h"
42 #include "iPtcpUtils.h"
43 #include "iRtcDrv2.h"
44 #include "iPnOs.h"
45 #include <kernel/dpl/HwiP.h>
46 #include <kernel/dpl/SemaphoreP.h>
47 #include <kernel/dpl/TaskP.h>
48 #include <stdint.h>
49 
50 /* ========================================================================== */
51 /* Macros & Typedefs */
52 /* ========================================================================== */
53 
54 /*TODO: Review this*/
55 #define PN_TASK_STACK_SIZE (2048)
56 
57 typedef void (*PN_getMACAddress)(uint8_t index, uint8_t *lclMac);
58 
59 /* ========================================================================== */
60 /* Structure Declarations */
61 /* ========================================================================== */
62 /*
63 * \brief PN_PtcpDebug
64 * Structure storing the debug info for PTCP
65 */
66 typedef struct PN_PtcpDebug_s
67 {
71  int32_t debugDelayIndex;
73  int32_t debugSyncIndex;
75  int32_t maxDeltaT;
77  int32_t minDeltaT;
81  int32_t maxDelay;
83  int32_t minDelay;
85  int32_t delayOutOfRange;
87  uint32_t syncmissCounter;
88 } PN_PtcpDebug;
89 
90 /*
91 * \brief PN_TimerAttrs
92 * Structure storing the interrupt configurations
93 */
94 typedef struct PN_PtcpTimerAttrs_s
95 {
97  uint32_t ptcpTimerID;
101 
102 /*TODO: Review this*/
103 /*
104 * \brief PN_PtcpConfig
105 * Structure storing the PTCP info
106 */
107 typedef struct PN_PtcpConfig_s
108 {
110  uint32_t pnCyclePeriod;
112  uint32_t mandCtrAdj;
114  uint32_t T2_prev[PTCP_NUM_PORTS];
116  uint32_t T1_prev[PTCP_NUM_PORTS];
118  uint32_t T1_CTR_prev[PTCP_NUM_PORTS];
120  float rcf_prev[PTCP_NUM_PORTS];
122  uint16_t seqId;
124  int32_t delayIndex;
126  int32_t syncIndex;
128  uint32_t numInSync;
130  int32_t syncDeltaTs[SYNC_FILTER_SIZE];
132  uint32_t *pSyncTorgNs;
136  uint32_t *pSyncRxSOF;
138  uint32_t *pSyncTorgSecs;
140  uint16_t *pPmCycleCounter;
142  uint16_t *pPmPhaseCounter;
144  uint8_t *pSubDomainUUID;
146  uint8_t *pSyncMasterMac;
148  uint8_t *pSyncInitFlag;
152  uint32_t prev_cDelay[PTCP_NUM_PORTS];
154  uint32_t prev_lDelay[PTCP_NUM_PORTS];
162  uint8_t masterChange;
164  uint8_t phaseCtrChange;
168  uint16_t maxSeqId;
170  uint16_t minSeqId;
186  /* Semaphores */
191  /* Callbacks */
196  /*TODO: Check if this should be always included*/
197  /* Debug */
205  /* Timer for PTCP */
207 } PN_PtcpConfig;
208 
209 
210 typedef struct PN_IsoMConfig_s
211 {
217  uint8_t isoMNumEvents;
220 
221  uint32_t event1Handle;
222 
223  uint32_t event2Handle;
224 
226 
227 /*TODO: Review the changes here*/
228 /*
229 * \brief PN_Config
230 * Profinet handle - stores the Profinet configuration
231 */
232 typedef struct PN_Config_s
233 {
235  uint8_t initRtcDrvFlag;
237  uint8_t initRtcMemFlag;
256  irtLegStateCall; /* Required? Just sets the value for legState(above), can be done directly? */
265  /*TODO: Review this*/
272  /* Task Handles */
283  /*TODO: Review this change*/
285  uint32_t pnIsoMObject;
288  /*TODO: Review this*/
291  /*TODO: Review this*/
293 #ifdef PTCP_SUPPORT
294  uint32_t PTCP_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
295  uint32_t PTCP_syncMonitorTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
296 #endif /*PTCP_SUPPORT*/
297 #ifdef IRT_LEGACY_STARTUP_SUPPORT
298  uint32_t IRT_legacyTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
299 #endif /*IRT_LEGACY_STARTUP_SUPPORT*/
300 #ifdef MRP_SUPPORT
301  uint32_t MRP_CPMTaskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
302 #endif /*MRP_SUPPORT*/
303 #ifdef WATCHDOG_SUPPORT
304  uint32_t tapWatchDog_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)));
305 #endif /*WATCHDOG_SUPPORT*/
306 
307 } PN_Config;
308 
309 #endif /* PN_HANDLE_DEF_H_ */
PN_PtcpDebug::maxDelay
int32_t maxDelay
Definition: PN_HandleDef.h:81
PN_Config::getMACAddress
PN_getMACAddress getMACAddress
Definition: PN_HandleDef.h:290
PN_PtcpConfig::pSyncInDelayPlusLD
uint32_t * pSyncInDelayPlusLD
Definition: PN_HandleDef.h:134
PN_PtcpConfig::mandCtrAdj
uint32_t mandCtrAdj
Definition: PN_HandleDef.h:112
PN_PtcpConfig::pSyncRxSOF
uint32_t * pSyncRxSOF
Definition: PN_HandleDef.h:136
PN_IsoMConfig
Definition: PN_HandleDef.h:211
PN_IntConfig
Definition: PN_Handle.h:78
PN_PtcpTimerAttrs
Definition: PN_HandleDef.h:95
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:368
PN_IsoMConfig::isoMIntCreateFlag
uint8_t isoMIntCreateFlag
Definition: PN_HandleDef.h:215
PN_PtcpConfig::pSyncTorgNs
uint32_t * pSyncTorgNs
Definition: PN_HandleDef.h:132
PN_PtcpConfig::deviceSyncInfo
volatile ptcpSyncInfo_t deviceSyncInfo
Definition: PN_HandleDef.h:172
PN_Config::irtLegPktCall
pnLegCallBack_t irtLegPktCall
Definition: PN_HandleDef.h:258
PN_PtcpDebug
Definition: PN_HandleDef.h:67
PN_PtcpConfig::ptcpEnableSlowCompensation
uint8_t ptcpEnableSlowCompensation
Definition: PN_HandleDef.h:204
pnLegCallBack_t
void(* pnLegCallBack_t)(void *arg, void *arg2)
Callback function for processing Profinet IRQs.
Definition: iRtcDrv2.h:549
index
uint16_t index
Definition: tisci_rm_proxy.h:3
PN_PtcpConfig::ptcpTimer
PN_PtcpTimerAttrs ptcpTimer
Definition: PN_HandleDef.h:206
PN_PtcpConfig::calculatedCycleCtr
uint16_t calculatedCycleCtr
Definition: PN_HandleDef.h:160
PN_PtcpConfig::minSeqId
uint16_t minSeqId
Definition: PN_HandleDef.h:170
iPtcpDrv.h
PN_Config::WatchDogTimerTaskObject
TaskP_Object WatchDogTimerTaskObject
Definition: PN_HandleDef.h:282
iRtcDrv2.h
PN_PtcpConfig::pSyncMasterMac
uint8_t * pSyncMasterMac
Definition: PN_HandleDef.h:146
PN_TASK_STACK_SIZE
#define PN_TASK_STACK_SIZE
Definition: PN_HandleDef.h:55
PN_PtcpDebug::debugSyncIndex
int32_t debugSyncIndex
Definition: PN_HandleDef.h:73
PN_PtcpConfig::cycleCtrInitPending
uint8_t cycleCtrInitPending
Definition: PN_HandleDef.h:158
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:199
t_ppmBlock
Definition: iRtcDrv2.h:155
SYNC_FILTER_SIZE
#define SYNC_FILTER_SIZE
Definition: iPtcpUtils.h:272
PN_Config::switchReady
SemaphoreP_Object switchReady
Definition: PN_HandleDef.h:292
debugDelay_t
Definition: iPtcpUtils.h:378
ptcpPortDelayVal_t
Structure containing the port delay values of the local and remote.
Definition: iPtcpDrv.h:88
PN_PtcpConfig::masterChange
uint8_t masterChange
Definition: PN_HandleDef.h:162
PN_Config
Definition: PN_HandleDef.h:233
PN_Config::PTCPTaskObject
TaskP_Object PTCPTaskObject
Definition: PN_HandleDef.h:274
PN_PtcpConfig::currentPtcpStatus
volatile currentPtcpStatus_t currentPtcpStatus
Definition: PN_HandleDef.h:178
PN_PtcpConfig::maxSeqId
uint16_t maxSeqId
Definition: PN_HandleDef.h:168
t_descList
Definition: iRtcDrv2.h:207
TaskP_Object
Opaque task object used with the task APIs.
Definition: TaskP.h:94
SemaphoreP.h
PN_PtcpConfig::ptcpDelayUpdateCall
ptcpCallBack_t ptcpDelayUpdateCall
Definition: PN_HandleDef.h:195
PN_IsoMConfig::isoMInterruptObject
HwiP_Object isoMInterruptObject
Definition: PN_HandleDef.h:213
tLegStates
tLegStates
possible states for legacy suppport state machine
Definition: iRtcDrv2.h:535
PN_PtcpConfig::pSyncInitFlag
uint8_t * pSyncInitFlag
Definition: PN_HandleDef.h:148
PN_PtcpConfig::g_T1
PNIO_TimeStamp g_T1
Definition: PN_HandleDef.h:201
PN_Config::icssWatchDogEnabled
int32_t icssWatchDogEnabled
Definition: PN_HandleDef.h:262
PN_PtcpConfig::clkChangeNotifyDelay
uint32_t clkChangeNotifyDelay
Definition: PN_HandleDef.h:150
PN_Config::initRtcDrvFlag
uint8_t initRtcDrvFlag
Definition: PN_HandleDef.h:235
PN_Config::currPN
t_cfgPN currPN
Definition: PN_HandleDef.h:243
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:256
PN_PtcpDebug::debugDelayIndex
int32_t debugDelayIndex
Definition: PN_HandleDef.h:71
tMrpStates
tMrpStates
Definition: iPnOs.h:160
PN_PtcpConfig::ptcpTriggerMeasurementSem
SemaphoreP_Object ptcpTriggerMeasurementSem
Definition: PN_HandleDef.h:190
PN_Config::pnPtcpConfig
PN_PtcpConfig pnPtcpConfig
Definition: PN_HandleDef.h:271
HwiP.h
PN_PtcpConfig::pnCyclePeriod
uint32_t pnCyclePeriod
Definition: PN_HandleDef.h:110
PN_PtcpDebug::syncmissCounter
uint32_t syncmissCounter
Definition: PN_HandleDef.h:87
PN_IsoMConfig::event2Handle
uint32_t event2Handle
Definition: PN_HandleDef.h:223
PN_IsoMConfig::event1Handle
uint32_t event1Handle
Definition: PN_HandleDef.h:221
PN_Config::LegModeTaskObject
TaskP_Object LegModeTaskObject
Definition: PN_HandleDef.h:278
PN_IntAttrs
Definition: PN_Handle.h:55
PN_Config::cpmList
t_descList cpmList
Definition: PN_HandleDef.h:239
PN_Config::SyncMonitorTaskObject
TaskP_Object SyncMonitorTaskObject
Definition: PN_HandleDef.h:276
PN_PtcpConfig::phaseCtrChange
uint8_t phaseCtrChange
Definition: PN_HandleDef.h:164
PN_PtcpConfig::ptcpSyncFilterfactor
uint8_t ptcpSyncFilterfactor
Definition: PN_HandleDef.h:202
PN_Config::icssWachDogTimerPeriod
int32_t icssWachDogTimerPeriod
Definition: PN_HandleDef.h:260
PN_Config::legState
tLegStates legState
Definition: PN_HandleDef.h:251
PN_IsoMConfig::isoMNumEvents
uint8_t isoMNumEvents
Definition: PN_HandleDef.h:217
PN_PtcpConfig::numInSync
uint32_t numInSync
Definition: PN_HandleDef.h:128
PN_PtcpTimerAttrs::ptcpTimerHandle
void * ptcpTimerHandle
Definition: PN_HandleDef.h:99
PN_PtcpConfig::seqId
uint16_t seqId
Definition: PN_HandleDef.h:122
PN_PtcpConfig::ptcpStartSem
SemaphoreP_Object ptcpStartSem
Definition: PN_HandleDef.h:188
PN_Config::pnIsoMConfig
PN_IsoMConfig pnIsoMConfig
Definition: PN_HandleDef.h:287
PN_getMACAddress
void(* PN_getMACAddress)(uint8_t index, uint8_t *lclMac)
Definition: PN_HandleDef.h:57
PN_IsoMConfig::isoMIntConfig
PN_IntAttrs isoMIntConfig
Definition: PN_HandleDef.h:219
PN_PtcpConfig::delayIndex
int32_t delayIndex
Definition: PN_HandleDef.h:124
TaskP.h
LatchVars
Definition: iPtcpDrv.h:124
PN_PtcpConfig::ptcpSync0PinPulseWidth
uint32_t ptcpSync0PinPulseWidth
Definition: PN_HandleDef.h:176
devicePortOffsets_t
Definition: iPtcpUtils.h:356
deviceDelays_t
Definition: iPtcpUtils.h:346
PN_PtcpDebug::minDeltaT
int32_t minDeltaT
Definition: PN_HandleDef.h:77
PN_Config::__attribute__
uint32_t tapWatchDog_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
PN_PtcpConfig::initPmCycleCtrDone
uint8_t initPmCycleCtrDone
Definition: PN_HandleDef.h:156
PN_Config::MrpMachineTaskObject
TaskP_Object MrpMachineTaskObject
Definition: PN_HandleDef.h:280
PN_PtcpConfig::g_Latch
LatchVars g_Latch
Definition: PN_HandleDef.h:200
PNIO_TimeStamp
Definition: iPtcpDrv.h:112
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:91
PN_PtcpDebug::deltaTOutOfRange
int32_t deltaTOutOfRange
Definition: PN_HandleDef.h:79
t_rtcPacket
real-time packet structure
Definition: iRtcDrv2.h:178
PN_PtcpConfig::syncIndex
int32_t syncIndex
Definition: PN_HandleDef.h:126
PN_Config::mrpState
tMrpStates mrpState
Definition: PN_HandleDef.h:249
PN_Config::pruicssHandle
PRUICSS_Handle pruicssHandle
Definition: PN_HandleDef.h:267
iPnOs.h
t_cfgPN
Definition: iRtcDrv2.h:230
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
PN_Config::emacHandle
ICSS_EMAC_Handle emacHandle
Definition: PN_HandleDef.h:264
PN_PtcpConfig::pSyncTorgSecs
uint32_t * pSyncTorgSecs
Definition: PN_HandleDef.h:138
PN_PtcpConfig::ptcpSync0PinStart
uint32_t ptcpSync0PinStart
Definition: PN_HandleDef.h:174
PN_Config::initRtcMemFlag
uint8_t initRtcMemFlag
Definition: PN_HandleDef.h:237
PN_PtcpConfig::firstDelayBurst
int32_t firstDelayBurst
Definition: PN_HandleDef.h:166
ptcpSyncInfo_t
Structure containing current sync info.
Definition: iPtcpDrv.h:101
PN_PtcpConfig::pPmCycleCounter
uint16_t * pPmCycleCounter
Definition: PN_HandleDef.h:140
PN_Config::ppmList
t_descList ppmList
Definition: PN_HandleDef.h:241
PN_Config::__attribute__
uint32_t PTCP_taskStack[PN_TASK_STACK_SIZE/sizeof(uint32_t)] __attribute__((aligned(32)))
t_cpmBlock
Definition: iRtcDrv2.h:167
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:142
PN_PtcpDebug::minDelay
int32_t minDelay
Definition: PN_HandleDef.h:83
PN_PtcpConfig::ptcpSyncStatusCall
ptcpCallBack_t ptcpSyncStatusCall
Definition: PN_HandleDef.h:193
PN_Config::pLegPkt
t_rtcPacket * pLegPkt
Definition: PN_HandleDef.h:253
currentPtcpStatus_t
Definition: iPtcpUtils.h:323
PRUICSS_Handle
struct PRUICSS_Config_s * PRUICSS_Handle
A handle that is returned from a PRUICSS_open() call. This handle is required for calling other APIs.
Definition: pruicss/g_v0/pruicss.h:234
PN_PtcpConfig::pSubDomainUUID
uint8_t * pSubDomainUUID
Definition: PN_HandleDef.h:144
PN_PtcpDebug::delayOutOfRange
int32_t delayOutOfRange
Definition: PN_HandleDef.h:85
PN_PtcpDebug::maxDeltaT
int32_t maxDeltaT
Definition: PN_HandleDef.h:75
PN_Config::cpmBlock
t_cpmBlock cpmBlock
Definition: PN_HandleDef.h:247
PTCP_NUM_PORTS
#define PTCP_NUM_PORTS
Definition: iPtcpUtils.h:174
PN_PtcpConfig
Definition: PN_HandleDef.h:108
ptcpCallBack_t
void(* ptcpCallBack_t)(uint32_t arg, uint32_t arg2)
Definition: iPtcpDrv.h:151
PN_Config::pnIntConfig
PN_IntConfig pnIntConfig
Definition: PN_HandleDef.h:269
PN_Config::pnIsoMObject
uint32_t pnIsoMObject
Definition: PN_HandleDef.h:285
PN_PtcpTimerAttrs::ptcpTimerID
uint32_t ptcpTimerID
Definition: PN_HandleDef.h:97