AM263Px INDUSTRIAL COMMUNICATIONS SDK  2026.00.00
iPnOs.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 IPNOS_H_
34 #define IPNOS_H_
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 
42 /* ========================================================================== */
43 /* Doxygen */
44 /* ========================================================================== */
45 
71 /* ========================================================================== */
72 /* Include Files */
73 /* ========================================================================== */
74 
75 #include "PN_Handle.h"
76 #include "iRtcDrv2.h"
77 #include <networking/icss_emac/source/icss_emac_stormControl.h>
78 #include <networking/icss_emac/source/icss_emac_local.h>
79 
80 /* ========================================================================== */
81 /* Macros */
82 /* ========================================================================== */
83 
84 #define PTCP_TASK_PRIORITY 26
85 #define SYNC_MONITOR_TASK_PRIORITY 11
86 #define LEGACY_MODE_TASK_PRIOROTY 3
87 #define MRP_TASK_PRIORITY 23
88 #define BACKGROUND_TASK_PRIORITY 11
89 #define MRPD_TASK_PRIORITY 22
90 
91 /* ========================================================================== */
92 /* Error Macros */
93 /* ========================================================================== */
94 
97 /* Common success return value across all API's*/
98 #define PN_OS_API_SUCCESS 0
99 
100 /* PN_initOs specific error codes */
101 #define PN_ERR_INIT_PTCP_TASK (-1)
102 #define PN_ERR_INIT_SYNC_MONITOR (-2)
103 #define PN_ERR_INIT_LEGACY_MODE (-3)
104 #define PN_ERR_INIT_MRP_TASK (-4)
105 #define PN_ERR_INIT_BACKGROUND_TASK (-5)
106 #define PN_ERR_INIT_MRPD_TASK (-6)
107 
108 #define PN_ERR_PKT_TYPE_NOT_PPM (-7)
109 #define PN_ERR_PKT_TYPE_NOT_CPM (-8)
110 
111 #define PN_ERR_INVALID_BUFF_INDEX (-9)
112 
116 /* ========================================================================== */
117 /* Function Declarations */
118 /* ========================================================================== */
131 uint8_t *PN_getPpmBuff(t_rtcPacket *pkt);
132 
143 uint8_t *PN_relPpmBuff(PN_Handle pnHandle, t_rtcPacket *pkt);
144 
159 int32_t PN_checkLastPPM(PN_Handle pnHandle, t_rtcPacket *pkt);
160 
176 int32_t PN_nextCpmRdy(PN_Handle pnHandle,
177  t_rtcPacket *pkt);
178 
179 
192 uint8_t *PN_getLastCpm(PN_Handle pnHandle, t_rtcPacket *pkt);
193 
208 uint32_t PN_enterFlushMode(PN_Handle pnHandle);
213 typedef enum
214 {
219  MRPEXIT
235 
243 void PN_setLegState(void *arg, void *arg2);
244 
252 void PN_setLegPkt(void *arg, void *arg2);
263 int32_t PN_initOs(PN_Handle pnHandle);
264 
271 int32_t PN_RTC_setupIsr(PN_Handle pnHandle);
272 
279 int32_t PN_RTC_enableISR(PN_Handle pnHandle);
280 
287 int32_t PN_RTC_disableISR(PN_Handle pnHandle);
288 
303 int32_t PN_OS_txPacket(PN_Handle pnHandle,
304  const uint8_t *srcAddress, int32_t portNumber, int32_t queuePriority,
305  int32_t lengthOfPacket);
306 
307 
308 #ifdef __cplusplus
309 }
310 #endif
311 
312 #endif /* IPNOS_H_ */
PN_nextCpmRdy
int32_t PN_nextCpmRdy(PN_Handle pnHandle, t_rtcPacket *pkt)
Swap CPM NEXT with LAST and set validLast flag.
MRPEXIT
@ MRPEXIT
Definition: iPnOs.h:219
PN_Handle
struct PN_Config_s * PN_Handle
Alias for Profinet Handle containing base addresses and modules.
Definition: PN_Handle.h:98
PN_RTC_setupIsr
int32_t PN_RTC_setupIsr(PN_Handle pnHandle)
Interrupt management function Initializes PPM/CPM/DHT interrupts. (OS dependent!)
MRPCHECK
@ MRPCHECK
Definition: iPnOs.h:218
iRtcDrv2.h
PN_getPpmBuff
uint8_t * PN_getPpmBuff(t_rtcPacket *pkt)
Return a pointer to buffer indicated by NEXT This will be the next available free buffer(in the trip...
MRPREADY
@ MRPREADY
Definition: iPnOs.h:215
PN_setLegState
void PN_setLegState(void *arg, void *arg2)
Sets the state of legacy state machine This API is registered as a callback in PN_registerSetState.
tLegStates
tLegStates
possible states for legacy suppport state machine
Definition: iRtcDrv2.h:613
PN_RTC_disableISR
int32_t PN_RTC_disableISR(PN_Handle pnHandle)
Disables the PN interrupts.
PN_checkLastPPM
int32_t PN_checkLastPPM(PN_Handle pnHandle, t_rtcPacket *pkt)
Update proc pointer in paket object and udpate descriptor if there is a new last buffer.
tMrpStates
tMrpStates
Definition: iPnOs.h:214
PN_getLastCpm
uint8_t * PN_getLastCpm(PN_Handle pnHandle, t_rtcPacket *pkt)
Swap CPM LAST with PROC if validLast is true, clear validLast flag.
PN_Handle.h
PN_RTC_enableISR
int32_t PN_RTC_enableISR(PN_Handle pnHandle)
Enables the PN interrupts.
MRPENTER
@ MRPENTER
Definition: iPnOs.h:216
PN_setLegPkt
void PN_setLegPkt(void *arg, void *arg2)
Sets the Ethernet packet to output during legacy startup Usually a copy of RTC3 PPM....
t_rtcPacket
real-time packet structure
Definition: iRtcDrv2.h:239
PN_initOs
int32_t PN_initOs(PN_Handle pnHandle)
Initialization function for all PN driver tasks, mutexes.
PN_getLegState
tLegStates PN_getLegState(void)
Returns the IRT Legacy mode state.
PN_OS_txPacket
int32_t PN_OS_txPacket(PN_Handle pnHandle, const uint8_t *srcAddress, int32_t portNumber, int32_t queuePriority, int32_t lengthOfPacket)
Switch driver extension of TxPacket.
MRPWAIT
@ MRPWAIT
Definition: iPnOs.h:217
PN_relPpmBuff
uint8_t * PN_relPpmBuff(PN_Handle pnHandle, t_rtcPacket *pkt)
Swap NEXT with LAST and return new NEXT address .
PN_enterFlushMode
uint32_t PN_enterFlushMode(PN_Handle pnHandle)
Used to signal topology change to MRP state machine.