📄 cd_util.h
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** CD_UTIL.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Communications Device common code private interfaces.
**
** Services prototyped here are implemented in one of the following .c files:
**
** cd_util.c - All non hardware specific services
** ca_cd.c - CNA10 specific versions of some services
** ca_hw.c - Platform specific versions of some services
** sm_cd.c - SMAC specific versions of some services
** sm_hw.c - Platform specific versions of some services
**
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major> Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
** ASIC independent private services: (Defined in cd_util.h or cd_util.c)
**
** cd_CalcLinkTimeout() - Calculate unscheduled link timeout
** cd_CommissionTransports() - Create/start class 1 or 3 transport(s)
** cd_DecommissionTransports()- Stop/delete class 1 or 3 transport(s)
** cd_DeleteTranport() - Stop/delete a class 1 or class 3 transport
** cd_LookupTransportRecord() - Find a transport record in the list
** cd_RouteClass3Packet() - Pre-route a received class 3 packet
** cd_RouteFixedTagPacket() - Pre-route a received fixed tag packet
** cd_TxClass3Packet() - Transmit a class 3 packet
** cd_TxFixedTagPacket() - Transmit any fixed tag packet
**
**
** ASIC dependent private services: (Defined in ca_cd.c or sm_cd.c)
**
** cd_FlushUnschedTx() - Flush all queued unscheduled tx packets
** cd_GetNetMode() - Get current net mode from comm device
** cd_Init() - ASIC specific one time initialization
** cd_LoadUnschedTxPacket() - Load an unsched tx packet into the ASIC
** cd_Reset() - ASIC specific reset initialization
** cd_StartTransport() - ASIC specific transport setup
** cd_StopTransport() - ASIC specific transport shutdown
**
*****************************************************************************
*****************************************************************************
** **
** ETHERNET/IP EXAMPLE CODE **
** COPYRIGHT (c) 2000-2005 ODVA (Open DeviceNet Vendor Association) **
** & ControlNet International Ltd. **
** **
** All rights reserved, except as specifically licensed in writing. **
** Use of the Ethernet/IP Example Protocol Software is subject to **
** ODVA's and ControlNet International's Terms of Use Agreement. **
** The following work constitutes example program code and is intended **
** merely to illustrate useful programming techniques. The user is **
** responsible for applying the code correctly. The code is provided **
** AS IS without warranty and is in no way guaranteed to be error-free. **
** **
*****************************************************************************
*****************************************************************************
*/
/****************************************************************************
*****************************************************************************
**
** Change Log
** ----------
**
**
*****************************************************************************
*****************************************************************************
*/
#ifndef CD_UTIL_H
#define CD_UTIL_H
/*
** Determine if this code is to be included
*/
#ifdef CD_EN_OBJECTS
/****************************************************************************
**
** Symbols
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
**
** CD_FIRST_XXX
** CD_LAST_XXX
**
** Interesting points within the transport record lookup table.
** Transport lookup table is broken into 3 portions:
** Class 1 Consumer
** Class 1 Producer
** Class 3
** If we're a keeper on the CNA10 ASIC, reserve the last class 1 producer
** transport for TUI transmission.
**
**---------------------------------------------------------------------------
*/
#define CD_FIRST_C1C_TRANSPORT 1
#define CD_LAST_C1C_TRANSPORT ( CD_NUM_CLASS_1 )
#define CD_FIRST_C1P_TRANSPORT ( ( CD_NUM_CLASS_1 ) + 1 )
#define CD_LAST_C1P_TRANSPORT ( 2 * ( CD_NUM_CLASS_1 ) )
#define CD_FIRST_C3_TRANSPORT ( ( 2 * ( CD_NUM_CLASS_1 ) ) + 1 )
#define CD_LAST_C3_TRANSPORT ( ( 2 * ( CD_NUM_CLASS_1 ) ) + ( CD_NUM_CLASS_3 ) )
#define EN_CD_FIRST_C1C_TRANSPORT 1
#define EN_CD_LAST_C1C_TRANSPORT ( EN_CD_NUM_CLASS_1 )
#define EN_CD_FIRST_C1P_TRANSPORT ( ( EN_CD_NUM_CLASS_1 ) + 1 )
#define EN_CD_LAST_C1P_TRANSPORT ( 2 * ( EN_CD_NUM_CLASS_1 ) )
#define EN_CD_FIRST_C3_TRANSPORT ( ( 2 * ( EN_CD_NUM_CLASS_1 ) ) + 1 )
#define EN_CD_LAST_C3_TRANSPORT ( ( 2 * ( EN_CD_NUM_CLASS_1 ) ) + ( EN_CD_NUM_CLASS_3 ) )
#define CD_RADIOACTIVE_MASK 0xFE00
#define CD_RADIOACTIVE_ROTATE_BITS 0x007F
#define CD_RADIOACTIVE_ROTATE_SHIFT 0x9
#define CD_TUI_TRANSPORT 0
/*---------------------------------------------------------------------------
**
** General transport processing state.
**
**---------------------------------------------------------------------------
*/
#define CD_TS_STATE_MASK 0x001F
#define CD_TS_RESERVED 0x0001
#define CD_TS_STARTED 0x0002
#define CD_TS_CLOSING 0x0004
#define CD_TS_FAULTED 0x0008
/****************************************************************************
**
** Typedefs
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
**
** cd_TransportRecordType
**
** Transport record structure.
** Everything needed for the proper care and feeding of one transport.
**
** Class 1 connections use 2 transports (1 producer, 1 consumer).
** Class 1 connections use dedicated buffers to pass data.
** Class 3 connections use 1 transport.
** Class 3 connections use combuf/tribble sets to pass data.
**
** Additional ASIC specific data may be appended to this record via the
** union of structures method.
**
**---------------------------------------------------------------------------
*/
typedef struct cd_TransportRecordType
{
/*
** Transport processing state information.
*/
UINT16 iState;
/*
** General use data.
*/
UINT16 iTransportId; /* Transport number w/RadioActive bits */
UINT16 iClass; /* Transport class */
BOOL fServerConsumer; /* Server (class 3)/consumer (class 1) */
BOOL fDupNotify; /* App wants notification of dup data */
LeUINT16 iLeSeqCount; /* Most recent transport sequence count */
GS_TimerType xRxTimer; /* Transport receive watchdog timer */
CD_TimeoutTrrblType *pRxTot; /* Timeout tribble for above timer */
UINT8 abRxTag[ 4 ]; /* Receive tag */
UINT8 abTxTag[ 4 ]; /* Transmit tag */
UINT8 bTransportType; /* Type of Xport (Provide/Call func ...)*/
/*
** Class 1 connection specific data
*/
UINT8 *pBufA; /* Dedicated data buffers */
UINT8 *pBufB;
#ifdef CD_EN_OBJECTS
/* Unlike class 1 controlnet which is scheduled, Class 1 ethernet uses a
Change of State algoriythm, with timeout packet intervals used for resends */
UINT32 fFirstMessageRcvd; /* Flag that indicates the first message received 0 = True */
UINT32 iSeqCount; /* Most recent Common Packet sequence count */
UINT32 iMsecLastSent; /* Msec mark this structure was last sent at */
UINT32 iMsecLastRecv; /* Msec mark this was last receved at */
UINT32 iTimeLeft; /* TIme Remaining before a transport timeout would have occured */
UINT32 lProApi; /* Producer actual packet interval (usecs)*/
UINT32 lConApi; /* Consumer actual packet interval (usecs)*/
UINT32 lProInhib; /* Minimum packet interval for change of state data (Msecs)*/
UINT32 bClassTrigger; /* If cyclic, rely only on the API task for sends */
GS_SemaphoreType xSBufAccess; /* Semaphore to lock access to data buffer */
GS_TimerType xAPITimer; /* Timer to support API rate */
CD_TransportTrrblType *xAPITot; /* Timeout tribble for above timer */
#endif
UINT16 iBufState; /* Dedicated buffer state */
UINT16 iDataSize; /* Connection data size */
/* ASIC Buffer size may be bigger... */
UINT8 bTxStartNut; /* Starting nut for transmission */
UINT8 bTxRate; /* How often */
FD_pFuncPPPIType pRxCopyFunction; /* Rx class 1 data copy func in app */
void *xRxAppHandle; /* Parameter to call above with.
** In the case of class 3 data,
** this is also passed back in the
** xUserHandle of the packet TRRBL.
*/
FD_pFuncPPPIType pTxCopyFunction; /* Tx class 1 data copy func in app */
void *xTxAppHandle; /* Parameter to call above with */
/*
** start edits: October,13th 2005, H.F.
*/
int itsProAssemDataAreaId; /* only useful in conjunction with PRODUCER */
/*
** end edits: October,13th 2005, H.F.
*/
/*
** Class 3 connection specific data
*/
GS_MsgQueueType xQid; /* Queue to send Rx class 3 data to */
CB_ComBufType *pCbFreshest; /* Combuf containing freshest Tx data */
/* NULL if no Tx data available */
GS_TimerType xRetryTimer; /* Client retry timer */
CD_TimeoutTrrblType *pRetryTot; /* Timeout tribble for above timer */
BOOL fVerified; /* App has verified latest reception */
/*
** Bridged connection data
*/
BOOL fBridged; /* TRUE means, This is a bridged connection
** so don't do retries. In addition, only
** send data once (only send data when data
** is received).
*/
UINT16 iOtherTransportId; /* Transport for other side of bridged
** class 3 connection or producer/consumer
** link for bridged class 1 connection
** (used when multicast needs to re-use
** a transport which is already in use.
*/
#ifdef CD_EN_OBJECTS
ECE sEce; /* Encapsulation session management structure */
#endif
#if CN_CD_MAX_MULTICAST > EN_CD_MAX_MULTICAST
UINT16 aiConnectionSn[ CN_CD_MAX_MULTICAST ]; /* Connection identifiers */
#else
UINT16 aiConnectionSn[ EN_CD_MAX_MULTICAST ]; /* Connection identifiers */
#endif
}
cd_TransportRecordType;
/*---------------------------------------------------------------------------
**
** cd_DataType
**
** All private global data associated with a communications device.
**
**---------------------------------------------------------------------------
*/
typedef struct cd_DataType
{
/*
** Network Attachement Monitor state transition count. Used to determine
** if a configuration packet is stale.
*/
UINT16 iStateTransitionCount;
/*
** Details of previous TUI reception.
** Needed for duplicate TUI filtering & reception timing.
*/
UINT8 bTuiMacId;
LeUINT16 iLeTuiFlags;
LeUINT32 lLeTuiCrc;
CD_TimeoutTrrblType *pTrrblNutTimer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -