blob: be60f771b63a14371f335042aad5ae04d65678e7 [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;
92 WORD m_wErrorCode; // EPL error code if m_NodeEvent == kEplNmtNodeEventError
93 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;
100 WORD 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-Hartmane0ca0592008-12-19 17:09:38 -0800134typedef tEplKernel(PUBLIC ROM * tEplApiCbEvent) (tEplApiEventType EventType_p, // IN: event type (enum)
135 tEplApiEventArg * pEventArg_p, // IN: event argument (union)
136 void GENERIC * 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
142 BYTE 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
145 DWORD m_dwFeatureFlags;
146 // Cycle Length (0x1006: NMT_CycleLen_U32) in [us]
147 DWORD m_dwCycleLen; // required for error detection
148 // 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
154 DWORD m_dwPresMaxLatency; // const in [ns], only required for IdentRes
155 // 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
160 DWORD m_dwAsndMaxLatency; // const in [ns], only required for IdentRes
161 // 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]
170 DWORD 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]
174 DWORD 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]
177 DWORD m_dwAsyncSlotTimeout;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800178
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800179 DWORD m_dwDeviceType; // NMT_DeviceType_U32
180 DWORD m_dwVendorId; // NMT_IdentityObject_REC.VendorId_U32
181 DWORD m_dwProductCode; // NMT_IdentityObject_REC.ProductCode_U32
182 DWORD m_dwRevisionNumber; // NMT_IdentityObject_REC.RevisionNo_U32
183 DWORD m_dwSerialNumber; // NMT_IdentityObject_REC.SerialNo_U32
184 QWORD m_qwVendorSpecificExt1;
185 DWORD m_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
186 DWORD m_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
187 DWORD m_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
188 DWORD m_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
189 DWORD m_dwIpAddress;
190 DWORD m_dwSubnetMask;
191 DWORD m_dwDefaultGateway;
192 BYTE m_sHostname[32];
193 BYTE 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-Hartmane0ca0592008-12-19 17:09:38 -0800215tEplKernel PUBLIC EplApiInitialize(tEplApiInitParam * pInitParam_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800216
217tEplKernel PUBLIC EplApiShutdown(void);
218
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800219tEplKernel PUBLIC 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-Hartmane0ca0592008-12-19 17:09:38 -0800227tEplKernel PUBLIC 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-Hartmane0ca0592008-12-19 17:09:38 -0800235tEplKernel PUBLIC EplApiFreeSdoChannel(tEplSdoComConHdl SdoComConHdl_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800236
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800237tEplKernel PUBLIC 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-Hartmane0ca0592008-12-19 17:09:38 -0800242tEplKernel PUBLIC 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-Hartmane0ca0592008-12-19 17:09:38 -0800247tEplKernel PUBLIC EplApiCbObdAccess(tEplObdCbParam MEM * pParam_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800248
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800249tEplKernel PUBLIC 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
255tEplKernel PUBLIC EplApiExecNmtCommand(tEplNmtEvent NmtEvent_p);
256
257tEplKernel PUBLIC EplApiProcess(void);
258
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800259#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
260tEplKernel PUBLIC EplApiMnTriggerStateChange(unsigned int uiNodeId_p,
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800261 tEplNmtNodeCommand NodeCommand_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800262#endif
263
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800264tEplKernel PUBLIC EplApiGetIdentResponse(unsigned int uiNodeId_p,
265 tEplIdentResponse **
266 ppIdentResponse_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800267
268// functions for process image will be implemented in separate file
269tEplKernel PUBLIC EplApiProcessImageSetup(void);
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800270tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage * pPI_p);
271tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage * pPI_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800272
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800273#endif // #ifndef _EPL_API_H_