aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/epl/Epl.h
blob: 7f22b04022b291dcfeff86c83d1601ce6ebf06f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/****************************************************************************

  (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
      www.systec-electronic.com

  Project:      openPOWERLINK

  Description:  include file for EPL API layer

  License:

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.

    3. Neither the name of SYSTEC electronic GmbH nor the names of its
       contributors may be used to endorse or promote products derived
       from this software without prior written permission. For written
       permission, please contact info@systec-electronic.com.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.

    Severability Clause:

        If a provision of this License is or becomes illegal, invalid or
        unenforceable in any jurisdiction, that shall not affect:
        1. the validity or enforceability in that jurisdiction of any other
           provision of this License; or
        2. the validity or enforceability in other jurisdictions of that or
           any other provision of this License.

  -------------------------------------------------------------------------

                $RCSfile: Epl.h,v $

                $Author: D.Krueger $

                $Revision: 1.8 $  $Date: 2008/11/17 16:40:39 $

                $State: Exp $

                Build Environment:
                    GCC V3.4

  -------------------------------------------------------------------------

  Revision History:

  2006/05/22 d.k.:   start of the implementation, version 1.00

****************************************************************************/

#ifndef _EPL_API_H_
#define _EPL_API_H_

#include "EplInc.h"
#include "EplSdo.h"
#include "EplObd.h"
#include "EplLed.h"
#include "EplEvent.h"

//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------

typedef struct {
	unsigned int m_uiNodeId;
	tEplNmtState m_NmtState;
	tEplNmtNodeEvent m_NodeEvent;
	u16 m_wErrorCode;	// EPL error code if m_NodeEvent == kEplNmtNodeEventError
	BOOL m_fMandatory;

} tEplApiEventNode;

typedef struct {
	tEplNmtState m_NmtState;	// local NMT state
	tEplNmtBootEvent m_BootEvent;
	u16 m_wErrorCode;	// EPL error code if m_BootEvent == kEplNmtBootEventError

} tEplApiEventBoot;

typedef struct {
	tEplLedType m_LedType;	// type of the LED (e.g. Status or Error)
	BOOL m_fOn;		// state of the LED (e.g. on or off)

} tEplApiEventLed;

typedef enum {
	kEplApiEventNmtStateChange = 0x10,	// m_NmtStateChange
//    kEplApiEventRequestNmt     = 0x11,    // m_bNmtCmd
	kEplApiEventCriticalError = 0x12,	// m_InternalError, Stack halted
	kEplApiEventWarning = 0x13,	// m_InternalError, Stack running
	kEplApiEventNode = 0x20,	// m_Node
	kEplApiEventBoot = 0x21,	// m_Boot
	kEplApiEventSdo = 0x62,	// m_Sdo
	kEplApiEventObdAccess = 0x69,	// m_ObdCbParam
	kEplApiEventLed = 0x70,	// m_Led

} tEplApiEventType;

typedef union {
	tEplEventNmtStateChange m_NmtStateChange;
	tEplEventError m_InternalError;
	tEplSdoComFinished m_Sdo;
	tEplObdCbParam m_ObdCbParam;
	tEplApiEventNode m_Node;
	tEplApiEventBoot m_Boot;
	tEplApiEventLed m_Led;

} tEplApiEventArg;

typedef tEplKernel(*tEplApiCbEvent) (tEplApiEventType EventType_p,	// IN: event type (enum)
				     tEplApiEventArg *pEventArg_p,	// IN: event argument (union)
				      void *pUserArg_p);

typedef struct {
	unsigned int m_uiSizeOfStruct;
	BOOL m_fAsyncOnly;	// do not need to register PRes
	unsigned int m_uiNodeId;	// local node ID
	u8 m_abMacAddress[6];	// local MAC address

	// 0x1F82: NMT_FeatureFlags_U32
	u32 m_dwFeatureFlags;
	// Cycle Length (0x1006: NMT_CycleLen_U32) in [us]
	u32 m_dwCycleLen;	// required for error detection
	// 0x1F98: NMT_CycleTiming_REC
	// 0x1F98.1: IsochrTxMaxPayload_U16
	unsigned int m_uiIsochrTxMaxPayload;	// const
	// 0x1F98.2: IsochrRxMaxPayload_U16
	unsigned int m_uiIsochrRxMaxPayload;	// const
	// 0x1F98.3: PResMaxLatency_U32
	u32 m_dwPresMaxLatency;	// const in [ns], only required for IdentRes
	// 0x1F98.4: PReqActPayloadLimit_U16
	unsigned int m_uiPreqActPayloadLimit;	// required for initialisation (+28 bytes)
	// 0x1F98.5: PResActPayloadLimit_U16
	unsigned int m_uiPresActPayloadLimit;	// required for initialisation of Pres frame (+28 bytes)
	// 0x1F98.6: ASndMaxLatency_U32
	u32 m_dwAsndMaxLatency;	// const in [ns], only required for IdentRes
	// 0x1F98.7: MultiplCycleCnt_U8
	unsigned int m_uiMultiplCycleCnt;	// required for error detection
	// 0x1F98.8: AsyncMTU_U16
	unsigned int m_uiAsyncMtu;	// required to set up max frame size
	// 0x1F98.9: Prescaler_U16
	unsigned int m_uiPrescaler;	// required for sync
	// $$$ Multiplexed Slot

	// 0x1C14: DLL_LossOfFrameTolerance_U32 in [ns]
	u32 m_dwLossOfFrameTolerance;

	// 0x1F8A: NMT_MNCycleTiming_REC
	// 0x1F8A.1: WaitSoCPReq_U32 in [ns]
	u32 m_dwWaitSocPreq;

	// 0x1F8A.2: AsyncSlotTimeout_U32 in [ns]
	u32 m_dwAsyncSlotTimeout;

	u32 m_dwDeviceType;	// NMT_DeviceType_U32
	u32 m_dwVendorId;	// NMT_IdentityObject_REC.VendorId_U32
	u32 m_dwProductCode;	// NMT_IdentityObject_REC.ProductCode_U32
	u32 m_dwRevisionNumber;	// NMT_IdentityObject_REC.RevisionNo_U32
	u32 m_dwSerialNumber;	// NMT_IdentityObject_REC.SerialNo_U32
	u64 m_qwVendorSpecificExt1;
	u32 m_dwVerifyConfigurationDate;	// CFM_VerifyConfiguration_REC.ConfDate_U32
	u32 m_dwVerifyConfigurationTime;	// CFM_VerifyConfiguration_REC.ConfTime_U32
	u32 m_dwApplicationSwDate;	// PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
	u32 m_dwApplicationSwTime;	// PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
	u32 m_dwIpAddress;
	u32 m_dwSubnetMask;
	u32 m_dwDefaultGateway;
	u8 m_sHostname[32];
	u8 m_abVendorSpecificExt2[48];

	char *m_pszDevName;	// NMT_ManufactDevName_VS (0x1008/0 local OD)
	char *m_pszHwVersion;	// NMT_ManufactHwVers_VS  (0x1009/0 local OD)
	char *m_pszSwVersion;	// NMT_ManufactSwVers_VS  (0x100A/0 local OD)

	tEplApiCbEvent m_pfnCbEvent;
	void *m_pEventUserArg;
	tEplSyncCb m_pfnCbSync;

} tEplApiInitParam;

typedef struct {
	void *m_pImage;
	unsigned int m_uiSize;

} tEplApiProcessImage;

//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------

tEplKernel EplApiInitialize(tEplApiInitParam *pInitParam_p);

tEplKernel EplApiShutdown(void);

tEplKernel EplApiReadObject(tEplSdoComConHdl *pSdoComConHdl_p,
			    unsigned int uiNodeId_p,
			    unsigned int uiIndex_p,
			    unsigned int uiSubindex_p,
			    void *pDstData_le_p,
			    unsigned int *puiSize_p,
			    tEplSdoType SdoType_p, void *pUserArg_p);

tEplKernel EplApiWriteObject(tEplSdoComConHdl *pSdoComConHdl_p,
			     unsigned int uiNodeId_p,
			     unsigned int uiIndex_p,
			     unsigned int uiSubindex_p,
			     void *pSrcData_le_p,
			     unsigned int uiSize_p,
			     tEplSdoType SdoType_p, void *pUserArg_p);

tEplKernel EplApiFreeSdoChannel(tEplSdoComConHdl SdoComConHdl_p);

tEplKernel EplApiReadLocalObject(unsigned int uiIndex_p,
				 unsigned int uiSubindex_p,
				 void *pDstData_p,
				 unsigned int *puiSize_p);

tEplKernel EplApiWriteLocalObject(unsigned int uiIndex_p,
				  unsigned int uiSubindex_p,
				  void *pSrcData_p,
				  unsigned int uiSize_p);

tEplKernel EplApiCbObdAccess(tEplObdCbParam *pParam_p);

tEplKernel EplApiLinkObject(unsigned int uiObjIndex_p,
			    void *pVar_p,
			    unsigned int *puiVarEntries_p,
			    tEplObdSize *pEntrySize_p,
			    unsigned int uiFirstSubindex_p);

tEplKernel EplApiExecNmtCommand(tEplNmtEvent NmtEvent_p);

tEplKernel EplApiProcess(void);

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
tEplKernel EplApiMnTriggerStateChange(unsigned int uiNodeId_p,
				      tEplNmtNodeCommand NodeCommand_p);
#endif

tEplKernel EplApiGetIdentResponse(unsigned int uiNodeId_p,
				  tEplIdentResponse **ppIdentResponse_p);

// functions for process image will be implemented in separate file
tEplKernel EplApiProcessImageSetup(void);
tEplKernel EplApiProcessImageExchangeIn(tEplApiProcessImage *pPI_p);
tEplKernel EplApiProcessImageExchangeOut(tEplApiProcessImage *pPI_p);

#endif // #ifndef _EPL_API_H_