blob: 7f22b04022b291dcfeff86c83d1601ce6ebf06f6 [file] [log] [blame]
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001/****************************************************************************
2
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
5
6 Project: openPOWERLINK
7
8 Description: include file for EPL API layer
9
10 License:
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
15
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of SYSTEC electronic GmbH nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without prior written permission. For written
26 permission, please contact info@systec-electronic.com.
27
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
40
41 Severability Clause:
42
43 If a provision of this License is or becomes illegal, invalid or
44 unenforceable in any jurisdiction, that shall not affect:
45 1. the validity or enforceability in that jurisdiction of any other
46 provision of this License; or
47 2. the validity or enforceability in other jurisdictions of that or
48 any other provision of this License.
49
50 -------------------------------------------------------------------------
51
52 $RCSfile: Epl.h,v $
53
54 $Author: D.Krueger $
55
56 $Revision: 1.8 $ $Date: 2008/11/17 16:40:39 $
57
58 $State: Exp $
59
60 Build Environment:
61 GCC V3.4
62
63 -------------------------------------------------------------------------
64
65 Revision History:
66
67 2006/05/22 d.k.: start of the implementation, version 1.00
68
Daniel Krueger9d7164c2008-12-19 11:41:57 -080069****************************************************************************/
70
71#ifndef _EPL_API_H_
72#define _EPL_API_H_
73
74#include "EplInc.h"
75#include "EplSdo.h"
76#include "EplObd.h"
77#include "EplLed.h"
78#include "EplEvent.h"
79
80//---------------------------------------------------------------------------
81// const defines
82//---------------------------------------------------------------------------
83
Daniel Krueger9d7164c2008-12-19 11:41:57 -080084//---------------------------------------------------------------------------
85// typedef
86//---------------------------------------------------------------------------
87
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -080088typedef struct {
89 unsigned int m_uiNodeId;
90 tEplNmtState m_NmtState;
91 tEplNmtNodeEvent m_NodeEvent;
Greg Kroah-Hartmandcf53712009-03-23 12:57:39 -070092 u16 m_wErrorCode; // EPL error code if m_NodeEvent == kEplNmtNodeEventError
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -080093 BOOL m_fMandatory;
Daniel Krueger9d7164c2008-12-19 11:41:57 -080094
95} tEplApiEventNode;
96
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -080097typedef struct {
98 tEplNmtState m_NmtState; // local NMT state
99 tEplNmtBootEvent m_BootEvent;
Greg Kroah-Hartmandcf53712009-03-23 12:57:39 -0700100 u16 m_wErrorCode; // EPL error code if m_BootEvent == kEplNmtBootEventError
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800101
102} tEplApiEventBoot;
103
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800104typedef struct {
105 tEplLedType m_LedType; // type of the LED (e.g. Status or Error)
106 BOOL m_fOn; // state of the LED (e.g. on or off)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800107
108} tEplApiEventLed;
109
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800110typedef enum {
111 kEplApiEventNmtStateChange = 0x10, // m_NmtStateChange
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800112// kEplApiEventRequestNmt = 0x11, // m_bNmtCmd
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800113 kEplApiEventCriticalError = 0x12, // m_InternalError, Stack halted
114 kEplApiEventWarning = 0x13, // m_InternalError, Stack running
115 kEplApiEventNode = 0x20, // m_Node
116 kEplApiEventBoot = 0x21, // m_Boot
117 kEplApiEventSdo = 0x62, // m_Sdo
118 kEplApiEventObdAccess = 0x69, // m_ObdCbParam
119 kEplApiEventLed = 0x70, // m_Led
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800120
121} tEplApiEventType;
122
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800123typedef union {
124 tEplEventNmtStateChange m_NmtStateChange;
125 tEplEventError m_InternalError;
126 tEplSdoComFinished m_Sdo;
127 tEplObdCbParam m_ObdCbParam;
128 tEplApiEventNode m_Node;
129 tEplApiEventBoot m_Boot;
130 tEplApiEventLed m_Led;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800131
132} tEplApiEventArg;
133
Greg Kroah-Hartman53184872009-03-23 11:48:19 -0700134typedef tEplKernel(*tEplApiCbEvent) (tEplApiEventType EventType_p, // IN: event type (enum)
135 tEplApiEventArg *pEventArg_p, // IN: event argument (union)
136 void *pUserArg_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800137
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800138typedef struct {
139 unsigned int m_uiSizeOfStruct;
140 BOOL m_fAsyncOnly; // do not need to register PRes
141 unsigned int m_uiNodeId; // local node ID
Greg Kroah-Hartman2ed53cf2009-03-23 12:36:38 -0700142 u8 m_abMacAddress[6]; // local MAC address
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800143
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800144 // 0x1F82: NMT_FeatureFlags_U32
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700145 u32 m_dwFeatureFlags;
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800146 // Cycle Length (0x1006: NMT_CycleLen_U32) in [us]
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700147 u32 m_dwCycleLen; // required for error detection
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800148 // 0x1F98: NMT_CycleTiming_REC
149 // 0x1F98.1: IsochrTxMaxPayload_U16
150 unsigned int m_uiIsochrTxMaxPayload; // const
151 // 0x1F98.2: IsochrRxMaxPayload_U16
152 unsigned int m_uiIsochrRxMaxPayload; // const
153 // 0x1F98.3: PResMaxLatency_U32
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700154 u32 m_dwPresMaxLatency; // const in [ns], only required for IdentRes
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800155 // 0x1F98.4: PReqActPayloadLimit_U16
156 unsigned int m_uiPreqActPayloadLimit; // required for initialisation (+28 bytes)
157 // 0x1F98.5: PResActPayloadLimit_U16
158 unsigned int m_uiPresActPayloadLimit; // required for initialisation of Pres frame (+28 bytes)
159 // 0x1F98.6: ASndMaxLatency_U32
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700160 u32 m_dwAsndMaxLatency; // const in [ns], only required for IdentRes
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800161 // 0x1F98.7: MultiplCycleCnt_U8
162 unsigned int m_uiMultiplCycleCnt; // required for error detection
163 // 0x1F98.8: AsyncMTU_U16
164 unsigned int m_uiAsyncMtu; // required to set up max frame size
165 // 0x1F98.9: Prescaler_U16
166 unsigned int m_uiPrescaler; // required for sync
167 // $$$ Multiplexed Slot
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800168
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800169 // 0x1C14: DLL_LossOfFrameTolerance_U32 in [ns]
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700170 u32 m_dwLossOfFrameTolerance;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800171
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800172 // 0x1F8A: NMT_MNCycleTiming_REC
173 // 0x1F8A.1: WaitSoCPReq_U32 in [ns]
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700174 u32 m_dwWaitSocPreq;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800175
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800176 // 0x1F8A.2: AsyncSlotTimeout_U32 in [ns]
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700177 u32 m_dwAsyncSlotTimeout;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800178
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700179 u32 m_dwDeviceType; // NMT_DeviceType_U32
180 u32 m_dwVendorId; // NMT_IdentityObject_REC.VendorId_U32
181 u32 m_dwProductCode; // NMT_IdentityObject_REC.ProductCode_U32
182 u32 m_dwRevisionNumber; // NMT_IdentityObject_REC.RevisionNo_U32
183 u32 m_dwSerialNumber; // NMT_IdentityObject_REC.SerialNo_U32
Greg Kroah-Hartmana5c30d92009-03-23 12:43:05 -0700184 u64 m_qwVendorSpecificExt1;
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700185 u32 m_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
186 u32 m_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
187 u32 m_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
188 u32 m_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
189 u32 m_dwIpAddress;
190 u32 m_dwSubnetMask;
191 u32 m_dwDefaultGateway;
Greg Kroah-Hartman2ed53cf2009-03-23 12:36:38 -0700192 u8 m_sHostname[32];
193 u8 m_abVendorSpecificExt2[48];
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800194
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800195 char *m_pszDevName; // NMT_ManufactDevName_VS (0x1008/0 local OD)
196 char *m_pszHwVersion; // NMT_ManufactHwVers_VS (0x1009/0 local OD)
197 char *m_pszSwVersion; // NMT_ManufactSwVers_VS (0x100A/0 local OD)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800198
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800199 tEplApiCbEvent m_pfnCbEvent;
200 void *m_pEventUserArg;
201 tEplSyncCb m_pfnCbSync;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800202
203} tEplApiInitParam;
204
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800205typedef struct {
206 void *m_pImage;
207 unsigned int m_uiSize;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800208
209} tEplApiProcessImage;
210
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800211//---------------------------------------------------------------------------
212// function prototypes
213//---------------------------------------------------------------------------
214
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700215tEplKernel EplApiInitialize(tEplApiInitParam *pInitParam_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800216
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700217tEplKernel EplApiShutdown(void);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800218
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700219tEplKernel EplApiReadObject(tEplSdoComConHdl *pSdoComConHdl_p,
220 unsigned int uiNodeId_p,
221 unsigned int uiIndex_p,
222 unsigned int uiSubindex_p,
223 void *pDstData_le_p,
224 unsigned int *puiSize_p,
225 tEplSdoType SdoType_p, void *pUserArg_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800226
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700227tEplKernel EplApiWriteObject(tEplSdoComConHdl *pSdoComConHdl_p,
228 unsigned int uiNodeId_p,
229 unsigned int uiIndex_p,
230 unsigned int uiSubindex_p,
231 void *pSrcData_le_p,
232 unsigned int uiSize_p,
233 tEplSdoType SdoType_p, void *pUserArg_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800234
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700235tEplKernel EplApiFreeSdoChannel(tEplSdoComConHdl SdoComConHdl_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800236
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700237tEplKernel EplApiReadLocalObject(unsigned int uiIndex_p,
238 unsigned int uiSubindex_p,
239 void *pDstData_p,
240 unsigned int *puiSize_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800241
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700242tEplKernel EplApiWriteLocalObject(unsigned int uiIndex_p,
243 unsigned int uiSubindex_p,
244 void *pSrcData_p,
245 unsigned int uiSize_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800246
Greg Kroah-Hartman5e9f6bc2009-03-23 12:09:26 -0700247tEplKernel EplApiCbObdAccess(tEplObdCbParam *pParam_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800248
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700249tEplKernel EplApiLinkObject(unsigned int uiObjIndex_p,
250 void *pVar_p,
251 unsigned int *puiVarEntries_p,
252 tEplObdSize *pEntrySize_p,
253 unsigned int uiFirstSubindex_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800254
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700255tEplKernel EplApiExecNmtCommand(tEplNmtEvent NmtEvent_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800256
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700257tEplKernel EplApiProcess(void);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800258
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800259#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700260tEplKernel EplApiMnTriggerStateChange(unsigned int uiNodeId_p,
261 tEplNmtNodeCommand NodeCommand_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800262#endif
263
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700264tEplKernel EplApiGetIdentResponse(unsigned int uiNodeId_p,
265 tEplIdentResponse **ppIdentResponse_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800266
267// functions for process image will be implemented in separate file
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700268tEplKernel EplApiProcessImageSetup(void);
269tEplKernel EplApiProcessImageExchangeIn(tEplApiProcessImage *pPI_p);
270tEplKernel EplApiProcessImageExchangeOut(tEplApiProcessImage *pPI_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800271
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800272#endif // #ifndef _EPL_API_H_