1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: include file for EPL API layer
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
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.
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.
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.
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.
50 -------------------------------------------------------------------------
56 $Revision: 1.8 $ $Date: 2008/11/17 16:40:39 $
63 -------------------------------------------------------------------------
67 2006/05/22 d.k.: start of the implementation, version 1.00
69 ****************************************************************************/
80 //---------------------------------------------------------------------------
82 //---------------------------------------------------------------------------
84 //---------------------------------------------------------------------------
86 //---------------------------------------------------------------------------
89 unsigned int m_uiNodeId;
90 tEplNmtState m_NmtState;
91 tEplNmtNodeEvent m_NodeEvent;
92 WORD m_wErrorCode; // EPL error code if m_NodeEvent == kEplNmtNodeEventError
98 tEplNmtState m_NmtState; // local NMT state
99 tEplNmtBootEvent m_BootEvent;
100 WORD m_wErrorCode; // EPL error code if m_BootEvent == kEplNmtBootEventError
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)
111 kEplApiEventNmtStateChange = 0x10, // m_NmtStateChange
112 // kEplApiEventRequestNmt = 0x11, // m_bNmtCmd
113 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
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;
134 typedef tEplKernel(*tEplApiCbEvent) (tEplApiEventType EventType_p, // IN: event type (enum)
135 tEplApiEventArg *pEventArg_p, // IN: event argument (union)
139 unsigned int m_uiSizeOfStruct;
140 BOOL m_fAsyncOnly; // do not need to register PRes
141 unsigned int m_uiNodeId; // local node ID
142 u8 m_abMacAddress[6]; // local MAC address
144 // 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
169 // 0x1C14: DLL_LossOfFrameTolerance_U32 in [ns]
170 DWORD m_dwLossOfFrameTolerance;
172 // 0x1F8A: NMT_MNCycleTiming_REC
173 // 0x1F8A.1: WaitSoCPReq_U32 in [ns]
174 DWORD m_dwWaitSocPreq;
176 // 0x1F8A.2: AsyncSlotTimeout_U32 in [ns]
177 DWORD m_dwAsyncSlotTimeout;
179 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
190 DWORD m_dwSubnetMask;
191 DWORD m_dwDefaultGateway;
193 u8 m_abVendorSpecificExt2[48];
195 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)
199 tEplApiCbEvent m_pfnCbEvent;
200 void *m_pEventUserArg;
201 tEplSyncCb m_pfnCbSync;
207 unsigned int m_uiSize;
209 } tEplApiProcessImage;
211 //---------------------------------------------------------------------------
212 // function prototypes
213 //---------------------------------------------------------------------------
215 tEplKernel EplApiInitialize(tEplApiInitParam *pInitParam_p);
217 tEplKernel EplApiShutdown(void);
219 tEplKernel EplApiReadObject(tEplSdoComConHdl *pSdoComConHdl_p,
220 unsigned int uiNodeId_p,
221 unsigned int uiIndex_p,
222 unsigned int uiSubindex_p,
224 unsigned int *puiSize_p,
225 tEplSdoType SdoType_p, void *pUserArg_p);
227 tEplKernel EplApiWriteObject(tEplSdoComConHdl *pSdoComConHdl_p,
228 unsigned int uiNodeId_p,
229 unsigned int uiIndex_p,
230 unsigned int uiSubindex_p,
232 unsigned int uiSize_p,
233 tEplSdoType SdoType_p, void *pUserArg_p);
235 tEplKernel EplApiFreeSdoChannel(tEplSdoComConHdl SdoComConHdl_p);
237 tEplKernel EplApiReadLocalObject(unsigned int uiIndex_p,
238 unsigned int uiSubindex_p,
240 unsigned int *puiSize_p);
242 tEplKernel EplApiWriteLocalObject(unsigned int uiIndex_p,
243 unsigned int uiSubindex_p,
245 unsigned int uiSize_p);
247 tEplKernel EplApiCbObdAccess(tEplObdCbParam *pParam_p);
249 tEplKernel EplApiLinkObject(unsigned int uiObjIndex_p,
251 unsigned int *puiVarEntries_p,
252 tEplObdSize *pEntrySize_p,
253 unsigned int uiFirstSubindex_p);
255 tEplKernel EplApiExecNmtCommand(tEplNmtEvent NmtEvent_p);
257 tEplKernel EplApiProcess(void);
259 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
260 tEplKernel EplApiMnTriggerStateChange(unsigned int uiNodeId_p,
261 tEplNmtNodeCommand NodeCommand_p);
264 tEplKernel EplApiGetIdentResponse(unsigned int uiNodeId_p,
265 tEplIdentResponse **ppIdentResponse_p);
267 // functions for process image will be implemented in separate file
268 tEplKernel EplApiProcessImageSetup(void);
269 tEplKernel EplApiProcessImageExchangeIn(tEplApiProcessImage *pPI_p);
270 tEplKernel EplApiProcessImageExchangeOut(tEplApiProcessImage *pPI_p);
272 #endif // #ifndef _EPL_API_H_