Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / epl / EplApiGeneric.c
1 /****************************************************************************
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: source file for generic EPL API module
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: EplApiGeneric.c,v $
53
54 $Author: D.Krueger $
55
56 $Revision: 1.21 $ $Date: 2008/11/21 09:00:38 $
57
58 $State: Exp $
59
60 Build Environment:
61 GCC V3.4
62
63 -------------------------------------------------------------------------
64
65 Revision History:
66
67 2006/09/05 d.k.: start of the implementation, version 1.00
68
69 ****************************************************************************/
70
71 #include "Epl.h"
72 #include "kernel/EplDllk.h"
73 #include "kernel/EplErrorHandlerk.h"
74 #include "kernel/EplEventk.h"
75 #include "kernel/EplNmtk.h"
76 #include "kernel/EplObdk.h"
77 #include "kernel/EplTimerk.h"
78 #include "kernel/EplDllkCal.h"
79 #include "kernel/EplPdokCal.h"
80 #include "user/EplDlluCal.h"
81 #include "user/EplLedu.h"
82 #include "user/EplNmtCnu.h"
83 #include "user/EplNmtMnu.h"
84 #include "user/EplSdoComu.h"
85 #include "user/EplIdentu.h"
86 #include "user/EplStatusu.h"
87
88 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
89 #include "kernel/EplPdok.h"
90 #endif
91
92 #include "SharedBuff.h"
93
94 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) == 0)
95 #error "EPL API layer needs EPL module OBDK!"
96 #endif
97
98 /***************************************************************************/
99 /* */
100 /* */
101 /* G L O B A L D E F I N I T I O N S */
102 /* */
103 /* */
104 /***************************************************************************/
105
106 //---------------------------------------------------------------------------
107 // const defines
108 //---------------------------------------------------------------------------
109
110 //---------------------------------------------------------------------------
111 // local types
112 //---------------------------------------------------------------------------
113
114 //---------------------------------------------------------------------------
115 // modul globale vars
116 //---------------------------------------------------------------------------
117
118 //---------------------------------------------------------------------------
119 // local function prototypes
120 //---------------------------------------------------------------------------
121
122 /***************************************************************************/
123 /* */
124 /* */
125 /* C L A S S EplApi */
126 /* */
127 /* */
128 /***************************************************************************/
129 //
130 // Description:
131 //
132 //
133 /***************************************************************************/
134
135 //=========================================================================//
136 // //
137 // P R I V A T E D E F I N I T I O N S //
138 // //
139 //=========================================================================//
140
141 //---------------------------------------------------------------------------
142 // const defines
143 //---------------------------------------------------------------------------
144
145 //---------------------------------------------------------------------------
146 // local types
147 //---------------------------------------------------------------------------
148
149 typedef struct {
150 tEplApiInitParam m_InitParam;
151
152 } tEplApiInstance;
153
154 //---------------------------------------------------------------------------
155 // local vars
156 //---------------------------------------------------------------------------
157
158 static tEplApiInstance EplApiInstance_g;
159
160 //---------------------------------------------------------------------------
161 // local function prototypes
162 //---------------------------------------------------------------------------
163
164 // NMT state change event callback function
165 static tEplKernel PUBLIC EplApiCbNmtStateChange(tEplEventNmtStateChange
166 NmtStateChange_p);
167
168 // update DLL configuration from OD
169 static tEplKernel PUBLIC EplApiUpdateDllConfig(BOOL fUpdateIdentity_p);
170
171 // update OD from init param
172 static tEplKernel PUBLIC EplApiUpdateObd(void);
173
174 // process events from user event queue
175 static tEplKernel PUBLIC EplApiProcessEvent(tEplEvent * pEplEvent_p);
176
177 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)
178 // callback function of SDO module
179 static tEplKernel PUBLIC EplApiCbSdoCon(tEplSdoComFinished * pSdoComFinished_p);
180 #endif
181
182 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
183 // callback functions of NmtMnu module
184 static tEplKernel PUBLIC EplApiCbNodeEvent(unsigned int uiNodeId_p,
185 tEplNmtNodeEvent NodeEvent_p,
186 tEplNmtState NmtState_p,
187 WORD wErrorCode_p,
188 BOOL fMandatory_p);
189
190 static tEplKernel PUBLIC EplApiCbBootEvent(tEplNmtBootEvent BootEvent_p,
191 tEplNmtState NmtState_p,
192 WORD wErrorCode_p);
193 #endif
194
195 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
196 // callback function of Ledu module
197 static tEplKernel PUBLIC EplApiCbLedStateChange(tEplLedType LedType_p,
198 BOOL fOn_p);
199 #endif
200
201 // OD initialization function (implemented in Objdict.c)
202 tEplKernel PUBLIC EplObdInitRam(tEplObdInitParam MEM * pInitParam_p);
203
204 //=========================================================================//
205 // //
206 // P U B L I C F U N C T I O N S //
207 // //
208 //=========================================================================//
209
210 //---------------------------------------------------------------------------
211 //
212 // Function: EplApiInitialize()
213 //
214 // Description: add and initialize new instance of EPL stack.
215 // After return from this function the application must start
216 // the NMT state machine via
217 // EplApiExecNmtCommand(kEplNmtEventSwReset)
218 // and thereby the whole EPL stack :-)
219 //
220 // Parameters: pInitParam_p = initialisation parameters
221 //
222 // Returns: tEplKernel = error code
223 //
224 //
225 // State:
226 //
227 //---------------------------------------------------------------------------
228
229 tEplKernel PUBLIC EplApiInitialize(tEplApiInitParam * pInitParam_p)
230 {
231 tEplKernel Ret = kEplSuccessful;
232 tEplObdInitParam ObdInitParam;
233 tEplDllkInitParam DllkInitParam;
234 #ifndef EPL_NO_FIFO
235 tShbError ShbError;
236 #endif
237
238 // reset instance structure
239 EPL_MEMSET(&EplApiInstance_g, 0, sizeof(EplApiInstance_g));
240
241 EPL_MEMCPY(&EplApiInstance_g.m_InitParam, pInitParam_p,
242 min(sizeof(tEplApiInitParam),
243 pInitParam_p->m_uiSizeOfStruct));
244
245 // check event callback function pointer
246 if (EplApiInstance_g.m_InitParam.m_pfnCbEvent == NULL) { // application must always have an event callback function
247 Ret = kEplApiInvalidParam;
248 goto Exit;
249 }
250 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
251 // init OD
252 // FIXME
253 // Ret = EplObdInitRam(&ObdInitParam);
254 // if (Ret != kEplSuccessful)
255 // {
256 // goto Exit;
257 // }
258
259 // initialize EplObd module
260 Ret = EplObdInit(&ObdInitParam);
261 if (Ret != kEplSuccessful) {
262 goto Exit;
263 }
264 #endif
265
266 #ifndef EPL_NO_FIFO
267 ShbError = ShbInit();
268 if (ShbError != kShbOk) {
269 Ret = kEplNoResource;
270 goto Exit;
271 }
272 #endif
273
274 // initialize EplEventk module
275 Ret = EplEventkInit(EplApiInstance_g.m_InitParam.m_pfnCbSync);
276 if (Ret != kEplSuccessful) {
277 goto Exit;
278 }
279 // initialize EplEventu module
280 Ret = EplEventuInit(EplApiProcessEvent);
281 if (Ret != kEplSuccessful) {
282 goto Exit;
283 }
284 // init EplTimerk module
285 Ret = EplTimerkInit();
286 if (Ret != kEplSuccessful) {
287 goto Exit;
288 }
289 // initialize EplNmtk module before DLL
290 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
291 Ret = EplNmtkInit();
292 if (Ret != kEplSuccessful) {
293 goto Exit;
294 }
295 #endif
296
297 // initialize EplDllk module
298 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
299 EPL_MEMCPY(DllkInitParam.m_be_abSrcMac,
300 EplApiInstance_g.m_InitParam.m_abMacAddress, 6);
301 Ret = EplDllkAddInstance(&DllkInitParam);
302 if (Ret != kEplSuccessful) {
303 goto Exit;
304 }
305 // initialize EplErrorHandlerk module
306 Ret = EplErrorHandlerkInit();
307 if (Ret != kEplSuccessful) {
308 goto Exit;
309 }
310 // initialize EplDllkCal module
311 Ret = EplDllkCalAddInstance();
312 if (Ret != kEplSuccessful) {
313 goto Exit;
314 }
315 #endif
316
317 // initialize EplDlluCal module
318 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
319 Ret = EplDlluCalAddInstance();
320 if (Ret != kEplSuccessful) {
321 goto Exit;
322 }
323 #endif
324
325 // initialize EplPdok module
326 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
327 Ret = EplPdokAddInstance();
328 if (Ret != kEplSuccessful) {
329 goto Exit;
330 }
331
332 Ret = EplPdokCalAddInstance();
333 if (Ret != kEplSuccessful) {
334 goto Exit;
335 }
336 #endif
337
338 // initialize EplNmtCnu module
339 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
340 Ret = EplNmtCnuAddInstance(EplApiInstance_g.m_InitParam.m_uiNodeId);
341 if (Ret != kEplSuccessful) {
342 goto Exit;
343 }
344 #endif
345
346 // initialize EplNmtu module
347 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
348 Ret = EplNmtuInit();
349 if (Ret != kEplSuccessful) {
350 goto Exit;
351 }
352 // register NMT event callback function
353 Ret = EplNmtuRegisterStateChangeCb(EplApiCbNmtStateChange);
354 if (Ret != kEplSuccessful) {
355 goto Exit;
356 }
357 #endif
358
359 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
360 // initialize EplNmtMnu module
361 Ret = EplNmtMnuInit(EplApiCbNodeEvent, EplApiCbBootEvent);
362 if (Ret != kEplSuccessful) {
363 goto Exit;
364 }
365 // initialize EplIdentu module
366 Ret = EplIdentuInit();
367 if (Ret != kEplSuccessful) {
368 goto Exit;
369 }
370 // initialize EplStatusu module
371 Ret = EplStatusuInit();
372 if (Ret != kEplSuccessful) {
373 goto Exit;
374 }
375 #endif
376
377 // initialize EplLedu module
378 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
379 Ret = EplLeduInit(EplApiCbLedStateChange);
380 if (Ret != kEplSuccessful) {
381 goto Exit;
382 }
383 #endif
384
385 // init SDO module
386 #if ((((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOS)) != 0) || \
387 (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0))
388 // init sdo command layer
389 Ret = EplSdoComInit();
390 if (Ret != kEplSuccessful) {
391 goto Exit;
392 }
393 #endif
394
395 // the application must start NMT state machine
396 // via EplApiExecNmtCommand(kEplNmtEventSwReset)
397 // and thereby the whole EPL stack
398
399 Exit:
400 return Ret;
401 }
402
403 //---------------------------------------------------------------------------
404 //
405 // Function: EplApiShutdown()
406 //
407 // Description: deletes an instance of EPL stack
408 //
409 // Parameters: (none)
410 //
411 // Returns: tEplKernel = error code
412 //
413 //
414 // State:
415 //
416 //---------------------------------------------------------------------------
417
418 tEplKernel PUBLIC EplApiShutdown(void)
419 {
420 tEplKernel Ret = kEplSuccessful;
421
422 // $$$ d.k.: check if NMT state is NMT_GS_OFF
423
424 // $$$ d.k.: maybe delete event queues at first, but this implies that
425 // no other module must not use the event queues for communication
426 // during shutdown.
427
428 // delete instance for all modules
429
430 // deinitialize EplSdoCom module
431 #if ((((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOS)) != 0) || \
432 (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0))
433 Ret = EplSdoComDelInstance();
434 // PRINTF1("EplSdoComDelInstance(): 0x%X\n", Ret);
435 #endif
436
437 // deinitialize EplLedu module
438 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
439 Ret = EplLeduDelInstance();
440 // PRINTF1("EplLeduDelInstance(): 0x%X\n", Ret);
441 #endif
442
443 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
444 // deinitialize EplNmtMnu module
445 Ret = EplNmtMnuDelInstance();
446 // PRINTF1("EplNmtMnuDelInstance(): 0x%X\n", Ret);
447
448 // deinitialize EplIdentu module
449 Ret = EplIdentuDelInstance();
450 // PRINTF1("EplIdentuDelInstance(): 0x%X\n", Ret);
451
452 // deinitialize EplStatusu module
453 Ret = EplStatusuDelInstance();
454 // PRINTF1("EplStatusuDelInstance(): 0x%X\n", Ret);
455 #endif
456
457 // deinitialize EplNmtCnu module
458 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
459 Ret = EplNmtCnuDelInstance();
460 // PRINTF1("EplNmtCnuDelInstance(): 0x%X\n", Ret);
461 #endif
462
463 // deinitialize EplNmtu module
464 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
465 Ret = EplNmtuDelInstance();
466 // PRINTF1("EplNmtuDelInstance(): 0x%X\n", Ret);
467 #endif
468
469 // deinitialize EplDlluCal module
470 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
471 Ret = EplDlluCalDelInstance();
472 // PRINTF1("EplDlluCalDelInstance(): 0x%X\n", Ret);
473
474 #endif
475
476 // deinitialize EplEventu module
477 Ret = EplEventuDelInstance();
478 // PRINTF1("EplEventuDelInstance(): 0x%X\n", Ret);
479
480 // deinitialize EplNmtk module
481 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
482 Ret = EplNmtkDelInstance();
483 // PRINTF1("EplNmtkDelInstance(): 0x%X\n", Ret);
484 #endif
485
486 // deinitialize EplDllk module
487 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
488 Ret = EplDllkDelInstance();
489 // PRINTF1("EplDllkDelInstance(): 0x%X\n", Ret);
490
491 // deinitialize EplDllkCal module
492 Ret = EplDllkCalDelInstance();
493 // PRINTF1("EplDllkCalDelInstance(): 0x%X\n", Ret);
494 #endif
495
496 // deinitialize EplEventk module
497 Ret = EplEventkDelInstance();
498 // PRINTF1("EplEventkDelInstance(): 0x%X\n", Ret);
499
500 // deinitialize EplTimerk module
501 Ret = EplTimerkDelInstance();
502 // PRINTF1("EplTimerkDelInstance(): 0x%X\n", Ret);
503
504 #ifndef EPL_NO_FIFO
505 ShbExit();
506 #endif
507
508 return Ret;
509 }
510
511 //----------------------------------------------------------------------------
512 // Function: EplApiExecNmtCommand()
513 //
514 // Description: executes a NMT command, i.e. post the NMT command/event to the
515 // NMTk module. NMT commands which are not appropriate in the current
516 // NMT state are silently ignored. Please keep in mind that the
517 // NMT state may change until the NMT command is actually executed.
518 //
519 // Parameters: NmtEvent_p = NMT command/event
520 //
521 // Returns: tEplKernel = error code
522 //
523 // State:
524 //----------------------------------------------------------------------------
525
526 tEplKernel PUBLIC EplApiExecNmtCommand(tEplNmtEvent NmtEvent_p)
527 {
528 tEplKernel Ret = kEplSuccessful;
529
530 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
531 Ret = EplNmtuNmtEvent(NmtEvent_p);
532 #endif
533
534 return Ret;
535 }
536
537 //----------------------------------------------------------------------------
538 // Function: EplApiLinkObject()
539 //
540 // Description: Function maps array of application variables onto specified object in OD
541 //
542 // Parameters: uiObjIndex_p = Function maps variables for this object index
543 // pVar_p = Pointer to data memory area for the specified object
544 // puiVarEntries_p = IN: pointer to number of entries to map
545 // OUT: pointer to number of actually used entries
546 // pEntrySize_p = IN: pointer to size of one entry;
547 // if size is zero, the actual size will be read from OD
548 // OUT: pointer to entire size of all entries mapped
549 // uiFirstSubindex_p = This is the first subindex to be mapped.
550 //
551 // Returns: tEplKernel = error code
552 //
553 // State:
554 //----------------------------------------------------------------------------
555
556 tEplKernel PUBLIC EplApiLinkObject(unsigned int uiObjIndex_p,
557 void *pVar_p,
558 unsigned int *puiVarEntries_p,
559 tEplObdSize * pEntrySize_p,
560 unsigned int uiFirstSubindex_p)
561 {
562 BYTE bVarEntries;
563 BYTE bIndexEntries;
564 BYTE MEM *pbData;
565 unsigned int uiSubindex;
566 tEplVarParam VarParam;
567 tEplObdSize EntrySize;
568 tEplObdSize UsedSize;
569
570 tEplKernel RetCode = kEplSuccessful;
571
572 if ((pVar_p == NULL)
573 || (puiVarEntries_p == NULL)
574 || (*puiVarEntries_p == 0)
575 || (pEntrySize_p == NULL)) {
576 RetCode = kEplApiInvalidParam;
577 goto Exit;
578 }
579
580 pbData = (BYTE MEM *) pVar_p;
581 bVarEntries = (BYTE) * puiVarEntries_p;
582 UsedSize = 0;
583
584 // init VarParam structure with default values
585 VarParam.m_uiIndex = uiObjIndex_p;
586 VarParam.m_ValidFlag = kVarValidAll;
587
588 if (uiFirstSubindex_p != 0) { // check if object exists by reading subindex 0x00,
589 // because user wants to link a variable to a subindex unequal 0x00
590 // read number of entries
591 EntrySize = (tEplObdSize) sizeof(bIndexEntries);
592 RetCode = EplObdReadEntry(uiObjIndex_p,
593 0x00,
594 (void GENERIC *)&bIndexEntries,
595 &EntrySize);
596
597 if ((RetCode != kEplSuccessful) || (bIndexEntries == 0x00)) {
598 // Object doesn't exist or invalid entry number
599 RetCode = kEplObdIndexNotExist;
600 goto Exit;
601 }
602 } else { // user wants to link a variable to subindex 0x00
603 // that's OK
604 bIndexEntries = 0;
605 }
606
607 // Correct number of entries if number read from OD is greater
608 // than the specified number.
609 // This is done, so that we do not set more entries than subindexes the
610 // object actually has.
611 if ((bIndexEntries > (bVarEntries + uiFirstSubindex_p - 1)) &&
612 (bVarEntries != 0x00)) {
613 bIndexEntries = (BYTE) (bVarEntries + uiFirstSubindex_p - 1);
614 }
615 // map entries
616 for (uiSubindex = uiFirstSubindex_p; uiSubindex <= bIndexEntries;
617 uiSubindex++) {
618 // if passed entry size is 0, then get size from OD
619 if (*pEntrySize_p == 0x00) {
620 // read entry size
621 EntrySize = EplObdGetDataSize(uiObjIndex_p, uiSubindex);
622
623 if (EntrySize == 0x00) {
624 // invalid entry size (maybe object doesn't exist or entry of type DOMAIN is empty)
625 RetCode = kEplObdSubindexNotExist;
626 break;
627 }
628 } else { // use passed entry size
629 EntrySize = *pEntrySize_p;
630 }
631
632 VarParam.m_uiSubindex = uiSubindex;
633
634 // set pointer to user var
635 VarParam.m_Size = EntrySize;
636 VarParam.m_pData = pbData;
637
638 UsedSize += EntrySize;
639 pbData += EntrySize;
640
641 RetCode = EplObdDefineVar(&VarParam);
642 if (RetCode != kEplSuccessful) {
643 break;
644 }
645 }
646
647 // set number of mapped entries and entry size
648 *puiVarEntries_p = ((bIndexEntries - uiFirstSubindex_p) + 1);
649 *pEntrySize_p = UsedSize;
650
651 Exit:
652
653 return (RetCode);
654
655 }
656
657 // ----------------------------------------------------------------------------
658 //
659 // Function: EplApiReadObject()
660 //
661 // Description: reads the specified entry from the OD of the specified node.
662 // If this node is a remote node, it performs a SDO transfer, which
663 // means this function returns kEplApiTaskDeferred and the application
664 // is informed via the event callback function when the task is completed.
665 //
666 // Parameters: pSdoComConHdl_p = INOUT: pointer to SDO connection handle (may be NULL in case of local OD access)
667 // uiNodeId_p = IN: node ID (0 = itself)
668 // uiIndex_p = IN: index of object in OD
669 // uiSubindex_p = IN: sub-index of object in OD
670 // pDstData_le_p = OUT: pointer to data in little endian
671 // puiSize_p = INOUT: pointer to size of data
672 // SdoType_p = IN: type of SDO transfer
673 // pUserArg_p = IN: user-definable argument pointer,
674 // which will be passed to the event callback function
675 //
676 // Return: tEplKernel = error code
677 //
678 // ----------------------------------------------------------------------------
679
680 tEplKernel PUBLIC EplApiReadObject(tEplSdoComConHdl * pSdoComConHdl_p,
681 unsigned int uiNodeId_p,
682 unsigned int uiIndex_p,
683 unsigned int uiSubindex_p,
684 void *pDstData_le_p,
685 unsigned int *puiSize_p,
686 tEplSdoType SdoType_p, void *pUserArg_p)
687 {
688 tEplKernel Ret = kEplSuccessful;
689
690 if ((uiIndex_p == 0) || (pDstData_le_p == NULL) || (puiSize_p == NULL)
691 || (*puiSize_p == 0)) {
692 Ret = kEplApiInvalidParam;
693 goto Exit;
694 }
695
696 if (uiNodeId_p == 0 || uiNodeId_p == EplObdGetNodeId()) { // local OD access can be performed
697 tEplObdSize ObdSize;
698
699 ObdSize = (tEplObdSize) * puiSize_p;
700 Ret =
701 EplObdReadEntryToLe(uiIndex_p, uiSubindex_p, pDstData_le_p,
702 &ObdSize);
703 *puiSize_p = (unsigned int)ObdSize;
704 } else { // perform SDO transfer
705 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)
706 tEplSdoComTransParamByIndex TransParamByIndex;
707 // tEplSdoComConHdl SdoComConHdl;
708
709 // check if application provides space for handle
710 if (pSdoComConHdl_p == NULL) {
711 Ret = kEplApiInvalidParam;
712 goto Exit;
713 // pSdoComConHdl_p = &SdoComConHdl;
714 }
715 // init command layer connection
716 Ret = EplSdoComDefineCon(pSdoComConHdl_p, uiNodeId_p, // target node id
717 SdoType_p); // SDO type
718 if ((Ret != kEplSuccessful) && (Ret != kEplSdoComHandleExists)) {
719 goto Exit;
720 }
721 TransParamByIndex.m_pData = pDstData_le_p;
722 TransParamByIndex.m_SdoAccessType = kEplSdoAccessTypeRead;
723 TransParamByIndex.m_SdoComConHdl = *pSdoComConHdl_p;
724 TransParamByIndex.m_uiDataSize = *puiSize_p;
725 TransParamByIndex.m_uiIndex = uiIndex_p;
726 TransParamByIndex.m_uiSubindex = uiSubindex_p;
727 TransParamByIndex.m_pfnSdoFinishedCb = EplApiCbSdoCon;
728 TransParamByIndex.m_pUserArg = pUserArg_p;
729
730 Ret = EplSdoComInitTransferByIndex(&TransParamByIndex);
731 if (Ret != kEplSuccessful) {
732 goto Exit;
733 }
734 Ret = kEplApiTaskDeferred;
735
736 #else
737 Ret = kEplApiInvalidParam;
738 #endif
739 }
740
741 Exit:
742 return Ret;
743 }
744
745 // ----------------------------------------------------------------------------
746 //
747 // Function: EplApiWriteObject()
748 //
749 // Description: writes the specified entry to the OD of the specified node.
750 // If this node is a remote node, it performs a SDO transfer, which
751 // means this function returns kEplApiTaskDeferred and the application
752 // is informed via the event callback function when the task is completed.
753 //
754 // Parameters: pSdoComConHdl_p = INOUT: pointer to SDO connection handle (may be NULL in case of local OD access)
755 // uiNodeId_p = IN: node ID (0 = itself)
756 // uiIndex_p = IN: index of object in OD
757 // uiSubindex_p = IN: sub-index of object in OD
758 // pSrcData_le_p = IN: pointer to data in little endian
759 // uiSize_p = IN: size of data in bytes
760 // SdoType_p = IN: type of SDO transfer
761 // pUserArg_p = IN: user-definable argument pointer,
762 // which will be passed to the event callback function
763 //
764 // Return: tEplKernel = error code
765 //
766 // ----------------------------------------------------------------------------
767
768 tEplKernel PUBLIC EplApiWriteObject(tEplSdoComConHdl * pSdoComConHdl_p,
769 unsigned int uiNodeId_p,
770 unsigned int uiIndex_p,
771 unsigned int uiSubindex_p,
772 void *pSrcData_le_p,
773 unsigned int uiSize_p,
774 tEplSdoType SdoType_p, void *pUserArg_p)
775 {
776 tEplKernel Ret = kEplSuccessful;
777
778 if ((uiIndex_p == 0) || (pSrcData_le_p == NULL) || (uiSize_p == 0)) {
779 Ret = kEplApiInvalidParam;
780 goto Exit;
781 }
782
783 if (uiNodeId_p == 0 || uiNodeId_p == EplObdGetNodeId()) { // local OD access can be performed
784
785 Ret =
786 EplObdWriteEntryFromLe(uiIndex_p, uiSubindex_p,
787 pSrcData_le_p, uiSize_p);
788 } else { // perform SDO transfer
789 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)
790 tEplSdoComTransParamByIndex TransParamByIndex;
791 // tEplSdoComConHdl SdoComConHdl;
792
793 // check if application provides space for handle
794 if (pSdoComConHdl_p == NULL) {
795 Ret = kEplApiInvalidParam;
796 goto Exit;
797 // pSdoComConHdl_p = &SdoComConHdl;
798 }
799 // d.k.: How to recycle command layer connection?
800 // Try to redefine it, which will return kEplSdoComHandleExists
801 // and the existing command layer handle.
802 // If the returned handle is busy, EplSdoComInitTransferByIndex()
803 // will return with error.
804 // $$$ d.k.: Collisions may occur with Configuration Manager, if both the application and
805 // Configuration Manager, are trying to communicate with the very same node.
806 // possible solution: disallow communication by application if Configuration Manager is busy
807
808 // init command layer connection
809 Ret = EplSdoComDefineCon(pSdoComConHdl_p, uiNodeId_p, // target node id
810 SdoType_p); // SDO type
811 if ((Ret != kEplSuccessful) && (Ret != kEplSdoComHandleExists)) {
812 goto Exit;
813 }
814 TransParamByIndex.m_pData = pSrcData_le_p;
815 TransParamByIndex.m_SdoAccessType = kEplSdoAccessTypeWrite;
816 TransParamByIndex.m_SdoComConHdl = *pSdoComConHdl_p;
817 TransParamByIndex.m_uiDataSize = uiSize_p;
818 TransParamByIndex.m_uiIndex = uiIndex_p;
819 TransParamByIndex.m_uiSubindex = uiSubindex_p;
820 TransParamByIndex.m_pfnSdoFinishedCb = EplApiCbSdoCon;
821 TransParamByIndex.m_pUserArg = pUserArg_p;
822
823 Ret = EplSdoComInitTransferByIndex(&TransParamByIndex);
824 if (Ret != kEplSuccessful) {
825 goto Exit;
826 }
827 Ret = kEplApiTaskDeferred;
828
829 #else
830 Ret = kEplApiInvalidParam;
831 #endif
832 }
833
834 Exit:
835 return Ret;
836 }
837
838 // ----------------------------------------------------------------------------
839 //
840 // Function: EplApiFreeSdoChannel()
841 //
842 // Description: frees the specified SDO channel.
843 // This function must be called after each call to EplApiReadObject()/EplApiWriteObject()
844 // which returns kEplApiTaskDeferred and the application
845 // is informed via the event callback function when the task is completed.
846 //
847 // Parameters: SdoComConHdl_p = IN: SDO connection handle
848 //
849 // Return: tEplKernel = error code
850 //
851 // ----------------------------------------------------------------------------
852
853 tEplKernel PUBLIC EplApiFreeSdoChannel(tEplSdoComConHdl SdoComConHdl_p)
854 {
855 tEplKernel Ret = kEplSuccessful;
856
857 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)
858
859 // init command layer connection
860 Ret = EplSdoComUndefineCon(SdoComConHdl_p);
861
862 #else
863 Ret = kEplApiInvalidParam;
864 #endif
865
866 return Ret;
867 }
868
869 // ----------------------------------------------------------------------------
870 //
871 // Function: EplApiReadLocalObject()
872 //
873 // Description: reads the specified entry from the local OD.
874 //
875 // Parameters: uiIndex_p = IN: index of object in OD
876 // uiSubindex_p = IN: sub-index of object in OD
877 // pDstData_p = OUT: pointer to data in platform byte order
878 // puiSize_p = INOUT: pointer to size of data
879 //
880 // Return: tEplKernel = error code
881 //
882 // ----------------------------------------------------------------------------
883
884 tEplKernel PUBLIC EplApiReadLocalObject(unsigned int uiIndex_p,
885 unsigned int uiSubindex_p,
886 void *pDstData_p,
887 unsigned int *puiSize_p)
888 {
889 tEplKernel Ret = kEplSuccessful;
890 tEplObdSize ObdSize;
891
892 ObdSize = (tEplObdSize) * puiSize_p;
893 Ret = EplObdReadEntry(uiIndex_p, uiSubindex_p, pDstData_p, &ObdSize);
894 *puiSize_p = (unsigned int)ObdSize;
895
896 return Ret;
897 }
898
899 // ----------------------------------------------------------------------------
900 //
901 // Function: EplApiWriteLocalObject()
902 //
903 // Description: writes the specified entry to the local OD.
904 //
905 // Parameters: uiIndex_p = IN: index of object in OD
906 // uiSubindex_p = IN: sub-index of object in OD
907 // pSrcData_p = IN: pointer to data in platform byte order
908 // uiSize_p = IN: size of data in bytes
909 //
910 // Return: tEplKernel = error code
911 //
912 // ----------------------------------------------------------------------------
913
914 tEplKernel PUBLIC EplApiWriteLocalObject(unsigned int uiIndex_p,
915 unsigned int uiSubindex_p,
916 void *pSrcData_p,
917 unsigned int uiSize_p)
918 {
919 tEplKernel Ret = kEplSuccessful;
920
921 Ret =
922 EplObdWriteEntry(uiIndex_p, uiSubindex_p, pSrcData_p,
923 (tEplObdSize) uiSize_p);
924
925 return Ret;
926 }
927
928 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
929 // ----------------------------------------------------------------------------
930 //
931 // Function: EplApiMnTriggerStateChange()
932 //
933 // Description: triggers the specified node command for the specified node.
934 //
935 // Parameters: uiNodeId_p = node ID for which the node command will be executed
936 // NodeCommand_p = node command
937 //
938 // Return: tEplKernel = error code
939 //
940 // ----------------------------------------------------------------------------
941
942 tEplKernel PUBLIC EplApiMnTriggerStateChange(unsigned int uiNodeId_p,
943 tEplNmtNodeCommand NodeCommand_p)
944 {
945 tEplKernel Ret = kEplSuccessful;
946
947 Ret = EplNmtMnuTriggerStateChange(uiNodeId_p, NodeCommand_p);
948
949 return Ret;
950 }
951
952 #endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
953
954 //---------------------------------------------------------------------------
955 //
956 // Function: EplApiCbObdAccess
957 //
958 // Description: callback function for OD accesses
959 //
960 // Parameters: pParam_p = OBD parameter
961 //
962 // Returns: tEplKernel = error code
963 //
964 //
965 // State:
966 //
967 //---------------------------------------------------------------------------
968
969 tEplKernel PUBLIC EplApiCbObdAccess(tEplObdCbParam MEM * pParam_p)
970 {
971 tEplKernel Ret = kEplSuccessful;
972
973 #if (EPL_API_OBD_FORWARD_EVENT != FALSE)
974 tEplApiEventArg EventArg;
975
976 // call user callback
977 // must be disabled for EplApiLinuxKernel.c, because of reentrancy problem
978 // for local OD access. This is not so bad as user callback function in
979 // application does not use OD callbacks at the moment.
980 EventArg.m_ObdCbParam = *pParam_p;
981 Ret = EplApiInstance_g.m_InitParam.m_pfnCbEvent(kEplApiEventObdAccess,
982 &EventArg,
983 EplApiInstance_g.
984 m_InitParam.
985 m_pEventUserArg);
986 #endif
987
988 switch (pParam_p->m_uiIndex) {
989 //case 0x1006: // NMT_CycleLen_U32 (valid on reset)
990 case 0x1C14: // DLL_LossOfFrameTolerance_U32
991 //case 0x1F98: // NMT_CycleTiming_REC (valid on reset)
992 {
993 if (pParam_p->m_ObdEvent == kEplObdEvPostWrite) {
994 // update DLL configuration
995 Ret = EplApiUpdateDllConfig(FALSE);
996 }
997 break;
998 }
999
1000 case 0x1020: // CFM_VerifyConfiguration_REC.ConfId_U32 != 0
1001 {
1002 if ((pParam_p->m_ObdEvent == kEplObdEvPostWrite)
1003 && (pParam_p->m_uiSubIndex == 3)
1004 && (*((DWORD *) pParam_p->m_pArg) != 0)) {
1005 DWORD dwVerifyConfInvalid = 0;
1006 // set CFM_VerifyConfiguration_REC.VerifyConfInvalid_U32 to 0
1007 Ret =
1008 EplObdWriteEntry(0x1020, 4,
1009 &dwVerifyConfInvalid, 4);
1010 // ignore any error because this objekt is optional
1011 Ret = kEplSuccessful;
1012 }
1013 break;
1014 }
1015
1016 case 0x1F9E: // NMT_ResetCmd_U8
1017 {
1018 if (pParam_p->m_ObdEvent == kEplObdEvPreWrite) {
1019 BYTE bNmtCommand;
1020
1021 bNmtCommand = *((BYTE *) pParam_p->m_pArg);
1022 // check value range
1023 switch ((tEplNmtCommand) bNmtCommand) {
1024 case kEplNmtCmdResetNode:
1025 case kEplNmtCmdResetCommunication:
1026 case kEplNmtCmdResetConfiguration:
1027 case kEplNmtCmdSwReset:
1028 case kEplNmtCmdInvalidService:
1029 // valid command identifier specified
1030 break;
1031
1032 default:
1033 pParam_p->m_dwAbortCode =
1034 EPL_SDOAC_VALUE_RANGE_EXCEEDED;
1035 Ret = kEplObdAccessViolation;
1036 break;
1037 }
1038 } else if (pParam_p->m_ObdEvent == kEplObdEvPostWrite) {
1039 BYTE bNmtCommand;
1040
1041 bNmtCommand = *((BYTE *) pParam_p->m_pArg);
1042 // check value range
1043 switch ((tEplNmtCommand) bNmtCommand) {
1044 case kEplNmtCmdResetNode:
1045 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
1046 Ret =
1047 EplNmtuNmtEvent
1048 (kEplNmtEventResetNode);
1049 #endif
1050 break;
1051
1052 case kEplNmtCmdResetCommunication:
1053 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
1054 Ret =
1055 EplNmtuNmtEvent
1056 (kEplNmtEventResetCom);
1057 #endif
1058 break;
1059
1060 case kEplNmtCmdResetConfiguration:
1061 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
1062 Ret =
1063 EplNmtuNmtEvent
1064 (kEplNmtEventResetConfig);
1065 #endif
1066 break;
1067
1068 case kEplNmtCmdSwReset:
1069 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
1070 Ret =
1071 EplNmtuNmtEvent
1072 (kEplNmtEventSwReset);
1073 #endif
1074 break;
1075
1076 case kEplNmtCmdInvalidService:
1077 break;
1078
1079 default:
1080 pParam_p->m_dwAbortCode =
1081 EPL_SDOAC_VALUE_RANGE_EXCEEDED;
1082 Ret = kEplObdAccessViolation;
1083 break;
1084 }
1085 }
1086 break;
1087 }
1088
1089 default:
1090 break;
1091 }
1092
1093 //Exit:
1094 return Ret;
1095 }
1096
1097 //=========================================================================//
1098 // //
1099 // P R I V A T E F U N C T I O N S //
1100 // //
1101 //=========================================================================//
1102
1103 //---------------------------------------------------------------------------
1104 //
1105 // Function: EplApiProcessEvent
1106 //
1107 // Description: processes events from event queue and forwards these to
1108 // the application's event callback function
1109 //
1110 // Parameters: pEplEvent_p = pointer to event
1111 //
1112 // Returns: tEplKernel = errorcode
1113 //
1114 // State:
1115 //
1116 //---------------------------------------------------------------------------
1117
1118 static tEplKernel PUBLIC EplApiProcessEvent(tEplEvent * pEplEvent_p)
1119 {
1120 tEplKernel Ret;
1121 tEplEventError *pEventError;
1122 tEplApiEventType EventType;
1123
1124 Ret = kEplSuccessful;
1125
1126 // process event
1127 switch (pEplEvent_p->m_EventType) {
1128 // error event
1129 case kEplEventTypeError:
1130 {
1131 pEventError = (tEplEventError *) pEplEvent_p->m_pArg;
1132 switch (pEventError->m_EventSource) {
1133 // treat the errors from the following sources as critical
1134 case kEplEventSourceEventk:
1135 case kEplEventSourceEventu:
1136 case kEplEventSourceDllk:
1137 {
1138 EventType = kEplApiEventCriticalError;
1139 // halt the stack by entering NMT state Off
1140 Ret =
1141 EplNmtuNmtEvent
1142 (kEplNmtEventCriticalError);
1143 break;
1144 }
1145
1146 // the other errors are just warnings
1147 default:
1148 {
1149 EventType = kEplApiEventWarning;
1150 break;
1151 }
1152 }
1153
1154 // call user callback
1155 Ret =
1156 EplApiInstance_g.m_InitParam.m_pfnCbEvent(EventType,
1157 (tEplApiEventArg
1158 *)
1159 pEventError,
1160 EplApiInstance_g.
1161 m_InitParam.
1162 m_pEventUserArg);
1163 // discard error from callback function, because this could generate an endless loop
1164 Ret = kEplSuccessful;
1165 break;
1166 }
1167
1168 // at present, there are no other events for this module
1169 default:
1170 break;
1171 }
1172
1173 return Ret;
1174 }
1175
1176 //---------------------------------------------------------------------------
1177 //
1178 // Function: EplApiCbNmtStateChange
1179 //
1180 // Description: callback function for NMT state changes
1181 //
1182 // Parameters: NmtStateChange_p = NMT state change event
1183 //
1184 // Returns: tEplKernel = error code
1185 //
1186 //
1187 // State:
1188 //
1189 //---------------------------------------------------------------------------
1190
1191 static tEplKernel PUBLIC EplApiCbNmtStateChange(tEplEventNmtStateChange
1192 NmtStateChange_p)
1193 {
1194 tEplKernel Ret = kEplSuccessful;
1195 BYTE bNmtState;
1196 tEplApiEventArg EventArg;
1197
1198 // save NMT state in OD
1199 bNmtState = (BYTE) NmtStateChange_p.m_NewNmtState;
1200 Ret = EplObdWriteEntry(0x1F8C, 0, &bNmtState, 1);
1201 if (Ret != kEplSuccessful) {
1202 goto Exit;
1203 }
1204 // do work which must be done in that state
1205 switch (NmtStateChange_p.m_NewNmtState) {
1206 // EPL stack is not running
1207 case kEplNmtGsOff:
1208 break;
1209
1210 // first init of the hardware
1211 case kEplNmtGsInitialising:
1212 #if 0
1213 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
1214 // configure SDO via UDP (i.e. bind it to the EPL ethernet interface)
1215 Ret =
1216 EplSdoUdpuConfig(EplApiInstance_g.m_InitParam.m_dwIpAddress,
1217 EPL_C_SDO_EPL_PORT);
1218 if (Ret != kEplSuccessful) {
1219 goto Exit;
1220 }
1221 #endif
1222 #endif
1223
1224 break;
1225
1226 // init of the manufacturer-specific profile area and the
1227 // standardised device profile area
1228 case kEplNmtGsResetApplication:
1229 {
1230 // reset application part of OD
1231 Ret = EplObdAccessOdPart(kEplObdPartApp,
1232 kEplObdDirLoad);
1233 if (Ret != kEplSuccessful) {
1234 goto Exit;
1235 }
1236
1237 break;
1238 }
1239
1240 // init of the communication profile area
1241 case kEplNmtGsResetCommunication:
1242 {
1243 // reset communication part of OD
1244 Ret = EplObdAccessOdPart(kEplObdPartGen,
1245 kEplObdDirLoad);
1246
1247 if (Ret != kEplSuccessful) {
1248 goto Exit;
1249 }
1250 // $$$ d.k.: update OD only if OD was not loaded from non-volatile memory
1251 Ret = EplApiUpdateObd();
1252 if (Ret != kEplSuccessful) {
1253 goto Exit;
1254 }
1255
1256 break;
1257 }
1258
1259 // build the configuration with infos from OD
1260 case kEplNmtGsResetConfiguration:
1261 {
1262
1263 Ret = EplApiUpdateDllConfig(TRUE);
1264 if (Ret != kEplSuccessful) {
1265 goto Exit;
1266 }
1267
1268 break;
1269 }
1270
1271 //-----------------------------------------------------------
1272 // CN part of the state machine
1273
1274 // node liste for EPL-Frames and check timeout
1275 case kEplNmtCsNotActive:
1276 {
1277 // indicate completion of reset in NMT_ResetCmd_U8
1278 bNmtState = (BYTE) kEplNmtCmdInvalidService;
1279 Ret = EplObdWriteEntry(0x1F9E, 0, &bNmtState, 1);
1280 if (Ret != kEplSuccessful) {
1281 goto Exit;
1282 }
1283
1284 break;
1285 }
1286
1287 // node process only async frames
1288 case kEplNmtCsPreOperational1:
1289 {
1290 break;
1291 }
1292
1293 // node process isochronus and asynchronus frames
1294 case kEplNmtCsPreOperational2:
1295 {
1296 break;
1297 }
1298
1299 // node should be configured und application is ready
1300 case kEplNmtCsReadyToOperate:
1301 {
1302 break;
1303 }
1304
1305 // normal work state
1306 case kEplNmtCsOperational:
1307 {
1308 break;
1309 }
1310
1311 // node stopped by MN
1312 // -> only process asynchronus frames
1313 case kEplNmtCsStopped:
1314 {
1315 break;
1316 }
1317
1318 // no EPL cycle
1319 // -> normal ethernet communication
1320 case kEplNmtCsBasicEthernet:
1321 {
1322 break;
1323 }
1324
1325 //-----------------------------------------------------------
1326 // MN part of the state machine
1327
1328 // node listens for EPL-Frames and check timeout
1329 case kEplNmtMsNotActive:
1330 {
1331 break;
1332 }
1333
1334 // node processes only async frames
1335 case kEplNmtMsPreOperational1:
1336 {
1337 break;
1338 }
1339
1340 // node processes isochronous and asynchronous frames
1341 case kEplNmtMsPreOperational2:
1342 {
1343 break;
1344 }
1345
1346 // node should be configured und application is ready
1347 case kEplNmtMsReadyToOperate:
1348 {
1349 break;
1350 }
1351
1352 // normal work state
1353 case kEplNmtMsOperational:
1354 {
1355 break;
1356 }
1357
1358 // no EPL cycle
1359 // -> normal ethernet communication
1360 case kEplNmtMsBasicEthernet:
1361 {
1362 break;
1363 }
1364
1365 default:
1366 {
1367 TRACE0
1368 ("EplApiCbNmtStateChange(): unhandled NMT state\n");
1369 }
1370 }
1371
1372 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
1373 // forward event to Led module
1374 Ret = EplLeduCbNmtStateChange(NmtStateChange_p);
1375 if (Ret != kEplSuccessful) {
1376 goto Exit;
1377 }
1378 #endif
1379
1380 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1381 // forward event to NmtMn module
1382 Ret = EplNmtMnuCbNmtStateChange(NmtStateChange_p);
1383 if (Ret != kEplSuccessful) {
1384 goto Exit;
1385 }
1386 #endif
1387
1388 // call user callback
1389 EventArg.m_NmtStateChange = NmtStateChange_p;
1390 Ret =
1391 EplApiInstance_g.m_InitParam.
1392 m_pfnCbEvent(kEplApiEventNmtStateChange, &EventArg,
1393 EplApiInstance_g.m_InitParam.m_pEventUserArg);
1394
1395 Exit:
1396 return Ret;
1397 }
1398
1399 //---------------------------------------------------------------------------
1400 //
1401 // Function: EplApiUpdateDllConfig
1402 //
1403 // Description: update configuration of DLL
1404 //
1405 // Parameters: fUpdateIdentity_p = TRUE, if identity must be updated
1406 //
1407 // Returns: tEplKernel = error code
1408 //
1409 //
1410 // State:
1411 //
1412 //---------------------------------------------------------------------------
1413
1414 static tEplKernel PUBLIC EplApiUpdateDllConfig(BOOL fUpdateIdentity_p)
1415 {
1416 tEplKernel Ret = kEplSuccessful;
1417 tEplDllConfigParam DllConfigParam;
1418 tEplDllIdentParam DllIdentParam;
1419 tEplObdSize ObdSize;
1420 WORD wTemp;
1421 BYTE bTemp;
1422
1423 // configure Dll
1424 EPL_MEMSET(&DllConfigParam, 0, sizeof(DllConfigParam));
1425 DllConfigParam.m_uiNodeId = EplObdGetNodeId();
1426
1427 // Cycle Length (0x1006: NMT_CycleLen_U32) in [us]
1428 ObdSize = 4;
1429 Ret =
1430 EplObdReadEntry(0x1006, 0, &DllConfigParam.m_dwCycleLen, &ObdSize);
1431 if (Ret != kEplSuccessful) {
1432 goto Exit;
1433 }
1434 // 0x1F82: NMT_FeatureFlags_U32
1435 ObdSize = 4;
1436 Ret =
1437 EplObdReadEntry(0x1F82, 0, &DllConfigParam.m_dwFeatureFlags,
1438 &ObdSize);
1439 if (Ret != kEplSuccessful) {
1440 goto Exit;
1441 }
1442 // d.k. There is no dependance between FeatureFlags and async-only CN
1443 DllConfigParam.m_fAsyncOnly = EplApiInstance_g.m_InitParam.m_fAsyncOnly;
1444
1445 // 0x1C14: DLL_LossOfFrameTolerance_U32 in [ns]
1446 ObdSize = 4;
1447 Ret =
1448 EplObdReadEntry(0x1C14, 0, &DllConfigParam.m_dwLossOfFrameTolerance,
1449 &ObdSize);
1450 if (Ret != kEplSuccessful) {
1451 goto Exit;
1452 }
1453 // 0x1F98: NMT_CycleTiming_REC
1454 // 0x1F98.1: IsochrTxMaxPayload_U16
1455 ObdSize = 2;
1456 Ret = EplObdReadEntry(0x1F98, 1, &wTemp, &ObdSize);
1457 if (Ret != kEplSuccessful) {
1458 goto Exit;
1459 }
1460 DllConfigParam.m_uiIsochrTxMaxPayload = wTemp;
1461
1462 // 0x1F98.2: IsochrRxMaxPayload_U16
1463 ObdSize = 2;
1464 Ret = EplObdReadEntry(0x1F98, 2, &wTemp, &ObdSize);
1465 if (Ret != kEplSuccessful) {
1466 goto Exit;
1467 }
1468 DllConfigParam.m_uiIsochrRxMaxPayload = wTemp;
1469
1470 // 0x1F98.3: PResMaxLatency_U32
1471 ObdSize = 4;
1472 Ret =
1473 EplObdReadEntry(0x1F98, 3, &DllConfigParam.m_dwPresMaxLatency,
1474 &ObdSize);
1475 if (Ret != kEplSuccessful) {
1476 goto Exit;
1477 }
1478 // 0x1F98.4: PReqActPayloadLimit_U16
1479 ObdSize = 2;
1480 Ret = EplObdReadEntry(0x1F98, 4, &wTemp, &ObdSize);
1481 if (Ret != kEplSuccessful) {
1482 goto Exit;
1483 }
1484 DllConfigParam.m_uiPreqActPayloadLimit = wTemp;
1485
1486 // 0x1F98.5: PResActPayloadLimit_U16
1487 ObdSize = 2;
1488 Ret = EplObdReadEntry(0x1F98, 5, &wTemp, &ObdSize);
1489 if (Ret != kEplSuccessful) {
1490 goto Exit;
1491 }
1492 DllConfigParam.m_uiPresActPayloadLimit = wTemp;
1493
1494 // 0x1F98.6: ASndMaxLatency_U32
1495 ObdSize = 4;
1496 Ret =
1497 EplObdReadEntry(0x1F98, 6, &DllConfigParam.m_dwAsndMaxLatency,
1498 &ObdSize);
1499 if (Ret != kEplSuccessful) {
1500 goto Exit;
1501 }
1502 // 0x1F98.7: MultiplCycleCnt_U8
1503 ObdSize = 1;
1504 Ret = EplObdReadEntry(0x1F98, 7, &bTemp, &ObdSize);
1505 if (Ret != kEplSuccessful) {
1506 goto Exit;
1507 }
1508 DllConfigParam.m_uiMultiplCycleCnt = bTemp;
1509
1510 // 0x1F98.8: AsyncMTU_U16
1511 ObdSize = 2;
1512 Ret = EplObdReadEntry(0x1F98, 8, &wTemp, &ObdSize);
1513 if (Ret != kEplSuccessful) {
1514 goto Exit;
1515 }
1516 DllConfigParam.m_uiAsyncMtu = wTemp;
1517
1518 // $$$ Prescaler
1519
1520 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1521 // 0x1F8A.1: WaitSoCPReq_U32 in [ns]
1522 ObdSize = 4;
1523 Ret =
1524 EplObdReadEntry(0x1F8A, 1, &DllConfigParam.m_dwWaitSocPreq,
1525 &ObdSize);
1526 if (Ret != kEplSuccessful) {
1527 goto Exit;
1528 }
1529 // 0x1F8A.2: AsyncSlotTimeout_U32 in [ns] (optional)
1530 ObdSize = 4;
1531 Ret =
1532 EplObdReadEntry(0x1F8A, 2, &DllConfigParam.m_dwAsyncSlotTimeout,
1533 &ObdSize);
1534 /* if(Ret != kEplSuccessful)
1535 {
1536 goto Exit;
1537 }*/
1538 #endif
1539
1540 DllConfigParam.m_uiSizeOfStruct = sizeof(DllConfigParam);
1541 Ret = EplDllkConfig(&DllConfigParam);
1542 if (Ret != kEplSuccessful) {
1543 goto Exit;
1544 }
1545
1546 if (fUpdateIdentity_p != FALSE) {
1547 // configure Identity
1548 EPL_MEMSET(&DllIdentParam, 0, sizeof(DllIdentParam));
1549 ObdSize = 4;
1550 Ret =
1551 EplObdReadEntry(0x1000, 0, &DllIdentParam.m_dwDeviceType,
1552 &ObdSize);
1553 if (Ret != kEplSuccessful) {
1554 goto Exit;
1555 }
1556
1557 ObdSize = 4;
1558 Ret =
1559 EplObdReadEntry(0x1018, 1, &DllIdentParam.m_dwVendorId,
1560 &ObdSize);
1561 if (Ret != kEplSuccessful) {
1562 goto Exit;
1563 }
1564 ObdSize = 4;
1565 Ret =
1566 EplObdReadEntry(0x1018, 2, &DllIdentParam.m_dwProductCode,
1567 &ObdSize);
1568 if (Ret != kEplSuccessful) {
1569 goto Exit;
1570 }
1571 ObdSize = 4;
1572 Ret =
1573 EplObdReadEntry(0x1018, 3,
1574 &DllIdentParam.m_dwRevisionNumber,
1575 &ObdSize);
1576 if (Ret != kEplSuccessful) {
1577 goto Exit;
1578 }
1579 ObdSize = 4;
1580 Ret =
1581 EplObdReadEntry(0x1018, 4, &DllIdentParam.m_dwSerialNumber,
1582 &ObdSize);
1583 if (Ret != kEplSuccessful) {
1584 goto Exit;
1585 }
1586
1587 DllIdentParam.m_dwIpAddress =
1588 EplApiInstance_g.m_InitParam.m_dwIpAddress;
1589 DllIdentParam.m_dwSubnetMask =
1590 EplApiInstance_g.m_InitParam.m_dwSubnetMask;
1591 EPL_MEMCPY(DllIdentParam.m_sHostname,
1592 EplApiInstance_g.m_InitParam.m_sHostname,
1593 sizeof(DllIdentParam.m_sHostname));
1594
1595 ObdSize = 4;
1596 Ret =
1597 EplObdReadEntry(0x1020, 1,
1598 &DllIdentParam.m_dwVerifyConfigurationDate,
1599 &ObdSize);
1600 // ignore any error, because this object is optional
1601
1602 ObdSize = 4;
1603 Ret =
1604 EplObdReadEntry(0x1020, 2,
1605 &DllIdentParam.m_dwVerifyConfigurationTime,
1606 &ObdSize);
1607 // ignore any error, because this object is optional
1608
1609 // $$$ d.k.: fill rest of ident structure
1610
1611 DllIdentParam.m_uiSizeOfStruct = sizeof(DllIdentParam);
1612 Ret = EplDllkSetIdentity(&DllIdentParam);
1613 if (Ret != kEplSuccessful) {
1614 goto Exit;
1615 }
1616 }
1617
1618 Exit:
1619 return Ret;
1620 }
1621
1622 //---------------------------------------------------------------------------
1623 //
1624 // Function: EplApiUpdateObd
1625 //
1626 // Description: update OD from init param
1627 //
1628 // Parameters: (none)
1629 //
1630 // Returns: tEplKernel = error code
1631 //
1632 //
1633 // State:
1634 //
1635 //---------------------------------------------------------------------------
1636
1637 static tEplKernel PUBLIC EplApiUpdateObd(void)
1638 {
1639 tEplKernel Ret = kEplSuccessful;
1640 WORD wTemp;
1641 BYTE bTemp;
1642
1643 // set node id in OD
1644 Ret = EplObdSetNodeId(EplApiInstance_g.m_InitParam.m_uiNodeId, // node id
1645 kEplObdNodeIdHardware); // set by hardware
1646 if (Ret != kEplSuccessful) {
1647 goto Exit;
1648 }
1649
1650 if (EplApiInstance_g.m_InitParam.m_dwCycleLen != -1) {
1651 Ret =
1652 EplObdWriteEntry(0x1006, 0,
1653 &EplApiInstance_g.m_InitParam.m_dwCycleLen,
1654 4);
1655 /* if(Ret != kEplSuccessful)
1656 {
1657 goto Exit;
1658 }*/
1659 }
1660
1661 if (EplApiInstance_g.m_InitParam.m_dwLossOfFrameTolerance != -1) {
1662 Ret =
1663 EplObdWriteEntry(0x1C14, 0,
1664 &EplApiInstance_g.m_InitParam.
1665 m_dwLossOfFrameTolerance, 4);
1666 /* if(Ret != kEplSuccessful)
1667 {
1668 goto Exit;
1669 } */
1670 }
1671 // d.k. There is no dependance between FeatureFlags and async-only CN.
1672 if (EplApiInstance_g.m_InitParam.m_dwFeatureFlags != -1) {
1673 Ret =
1674 EplObdWriteEntry(0x1F82, 0,
1675 &EplApiInstance_g.m_InitParam.
1676 m_dwFeatureFlags, 4);
1677 /* if(Ret != kEplSuccessful)
1678 {
1679 goto Exit;
1680 } */
1681 }
1682
1683 wTemp = (WORD) EplApiInstance_g.m_InitParam.m_uiIsochrTxMaxPayload;
1684 Ret = EplObdWriteEntry(0x1F98, 1, &wTemp, 2);
1685 /* if(Ret != kEplSuccessful)
1686 {
1687 goto Exit;
1688 }*/
1689
1690 wTemp = (WORD) EplApiInstance_g.m_InitParam.m_uiIsochrRxMaxPayload;
1691 Ret = EplObdWriteEntry(0x1F98, 2, &wTemp, 2);
1692 /* if(Ret != kEplSuccessful)
1693 {
1694 goto Exit;
1695 }*/
1696
1697 Ret =
1698 EplObdWriteEntry(0x1F98, 3,
1699 &EplApiInstance_g.m_InitParam.m_dwPresMaxLatency,
1700 4);
1701 /* if(Ret != kEplSuccessful)
1702 {
1703 goto Exit;
1704 }*/
1705
1706 if (EplApiInstance_g.m_InitParam.m_uiPreqActPayloadLimit <=
1707 EPL_C_DLL_ISOCHR_MAX_PAYL) {
1708 wTemp =
1709 (WORD) EplApiInstance_g.m_InitParam.m_uiPreqActPayloadLimit;
1710 Ret = EplObdWriteEntry(0x1F98, 4, &wTemp, 2);
1711 /* if(Ret != kEplSuccessful)
1712 {
1713 goto Exit;
1714 }*/
1715 }
1716
1717 if (EplApiInstance_g.m_InitParam.m_uiPresActPayloadLimit <=
1718 EPL_C_DLL_ISOCHR_MAX_PAYL) {
1719 wTemp =
1720 (WORD) EplApiInstance_g.m_InitParam.m_uiPresActPayloadLimit;
1721 Ret = EplObdWriteEntry(0x1F98, 5, &wTemp, 2);
1722 /* if(Ret != kEplSuccessful)
1723 {
1724 goto Exit;
1725 }*/
1726 }
1727
1728 Ret =
1729 EplObdWriteEntry(0x1F98, 6,
1730 &EplApiInstance_g.m_InitParam.m_dwAsndMaxLatency,
1731 4);
1732 /* if(Ret != kEplSuccessful)
1733 {
1734 goto Exit;
1735 }*/
1736
1737 if (EplApiInstance_g.m_InitParam.m_uiMultiplCycleCnt <= 0xFF) {
1738 bTemp = (BYTE) EplApiInstance_g.m_InitParam.m_uiMultiplCycleCnt;
1739 Ret = EplObdWriteEntry(0x1F98, 7, &bTemp, 1);
1740 /* if(Ret != kEplSuccessful)
1741 {
1742 goto Exit;
1743 }*/
1744 }
1745
1746 if (EplApiInstance_g.m_InitParam.m_uiAsyncMtu <=
1747 EPL_C_DLL_MAX_ASYNC_MTU) {
1748 wTemp = (WORD) EplApiInstance_g.m_InitParam.m_uiAsyncMtu;
1749 Ret = EplObdWriteEntry(0x1F98, 8, &wTemp, 2);
1750 /* if(Ret != kEplSuccessful)
1751 {
1752 goto Exit;
1753 }*/
1754 }
1755
1756 if (EplApiInstance_g.m_InitParam.m_uiPrescaler <= 1000) {
1757 wTemp = (WORD) EplApiInstance_g.m_InitParam.m_uiPrescaler;
1758 Ret = EplObdWriteEntry(0x1F98, 9, &wTemp, 2);
1759 // ignore return code
1760 Ret = kEplSuccessful;
1761 }
1762 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1763 if (EplApiInstance_g.m_InitParam.m_dwWaitSocPreq != -1) {
1764 Ret =
1765 EplObdWriteEntry(0x1F8A, 1,
1766 &EplApiInstance_g.m_InitParam.
1767 m_dwWaitSocPreq, 4);
1768 /* if(Ret != kEplSuccessful)
1769 {
1770 goto Exit;
1771 } */
1772 }
1773
1774 if ((EplApiInstance_g.m_InitParam.m_dwAsyncSlotTimeout != 0)
1775 && (EplApiInstance_g.m_InitParam.m_dwAsyncSlotTimeout != -1)) {
1776 Ret =
1777 EplObdWriteEntry(0x1F8A, 2,
1778 &EplApiInstance_g.m_InitParam.
1779 m_dwAsyncSlotTimeout, 4);
1780 /* if(Ret != kEplSuccessful)
1781 {
1782 goto Exit;
1783 } */
1784 }
1785 #endif
1786
1787 // configure Identity
1788 if (EplApiInstance_g.m_InitParam.m_dwDeviceType != -1) {
1789 Ret =
1790 EplObdWriteEntry(0x1000, 0,
1791 &EplApiInstance_g.m_InitParam.
1792 m_dwDeviceType, 4);
1793 /* if(Ret != kEplSuccessful)
1794 {
1795 goto Exit;
1796 }*/
1797 }
1798
1799 if (EplApiInstance_g.m_InitParam.m_dwVendorId != -1) {
1800 Ret =
1801 EplObdWriteEntry(0x1018, 1,
1802 &EplApiInstance_g.m_InitParam.m_dwVendorId,
1803 4);
1804 /* if(Ret != kEplSuccessful)
1805 {
1806 goto Exit;
1807 }*/
1808 }
1809
1810 if (EplApiInstance_g.m_InitParam.m_dwProductCode != -1) {
1811 Ret =
1812 EplObdWriteEntry(0x1018, 2,
1813 &EplApiInstance_g.m_InitParam.
1814 m_dwProductCode, 4);
1815 /* if(Ret != kEplSuccessful)
1816 {
1817 goto Exit;
1818 }*/
1819 }
1820
1821 if (EplApiInstance_g.m_InitParam.m_dwRevisionNumber != -1) {
1822 Ret =
1823 EplObdWriteEntry(0x1018, 3,
1824 &EplApiInstance_g.m_InitParam.
1825 m_dwRevisionNumber, 4);
1826 /* if(Ret != kEplSuccessful)
1827 {
1828 goto Exit;
1829 }*/
1830 }
1831
1832 if (EplApiInstance_g.m_InitParam.m_dwSerialNumber != -1) {
1833 Ret =
1834 EplObdWriteEntry(0x1018, 4,
1835 &EplApiInstance_g.m_InitParam.
1836 m_dwSerialNumber, 4);
1837 /* if(Ret != kEplSuccessful)
1838 {
1839 goto Exit;
1840 }*/
1841 }
1842
1843 if (EplApiInstance_g.m_InitParam.m_pszDevName != NULL) {
1844 // write Device Name (0x1008)
1845 Ret =
1846 EplObdWriteEntry(0x1008, 0,
1847 (void GENERIC *)EplApiInstance_g.
1848 m_InitParam.m_pszDevName,
1849 (tEplObdSize) strlen(EplApiInstance_g.
1850 m_InitParam.
1851 m_pszDevName));
1852 /* if (Ret != kEplSuccessful)
1853 {
1854 goto Exit;
1855 }*/
1856 }
1857
1858 if (EplApiInstance_g.m_InitParam.m_pszHwVersion != NULL) {
1859 // write Hardware version (0x1009)
1860 Ret =
1861 EplObdWriteEntry(0x1009, 0,
1862 (void GENERIC *)EplApiInstance_g.
1863 m_InitParam.m_pszHwVersion,
1864 (tEplObdSize) strlen(EplApiInstance_g.
1865 m_InitParam.
1866 m_pszHwVersion));
1867 /* if (Ret != kEplSuccessful)
1868 {
1869 goto Exit;
1870 }*/
1871 }
1872
1873 if (EplApiInstance_g.m_InitParam.m_pszSwVersion != NULL) {
1874 // write Software version (0x100A)
1875 Ret =
1876 EplObdWriteEntry(0x100A, 0,
1877 (void GENERIC *)EplApiInstance_g.
1878 m_InitParam.m_pszSwVersion,
1879 (tEplObdSize) strlen(EplApiInstance_g.
1880 m_InitParam.
1881 m_pszSwVersion));
1882 /* if (Ret != kEplSuccessful)
1883 {
1884 goto Exit;
1885 }*/
1886 }
1887
1888 Exit:
1889 return Ret;
1890 }
1891
1892 //---------------------------------------------------------------------------
1893 //
1894 // Function: EplApiCbSdoCon
1895 //
1896 // Description: callback function for SDO transfers
1897 //
1898 // Parameters: pSdoComFinished_p = SDO parameter
1899 //
1900 // Returns: tEplKernel = error code
1901 //
1902 //
1903 // State:
1904 //
1905 //---------------------------------------------------------------------------
1906
1907 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)
1908 static tEplKernel PUBLIC EplApiCbSdoCon(tEplSdoComFinished * pSdoComFinished_p)
1909 {
1910 tEplKernel Ret;
1911 tEplApiEventArg EventArg;
1912
1913 Ret = kEplSuccessful;
1914
1915 // call user callback
1916 EventArg.m_Sdo = *pSdoComFinished_p;
1917 Ret = EplApiInstance_g.m_InitParam.m_pfnCbEvent(kEplApiEventSdo,
1918 &EventArg,
1919 EplApiInstance_g.
1920 m_InitParam.
1921 m_pEventUserArg);
1922
1923 return Ret;
1924
1925 }
1926 #endif
1927
1928 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1929
1930 //---------------------------------------------------------------------------
1931 //
1932 // Function: EplApiCbNodeEvent
1933 //
1934 // Description: callback function for node events
1935 //
1936 // Parameters: uiNodeId_p = node ID of the CN
1937 // NodeEvent_p = event from the specified CN
1938 // NmtState_p = current NMT state of the CN
1939 // wErrorCode_p = EPL error code if NodeEvent_p==kEplNmtNodeEventError
1940 // fMandatory_p = flag if CN is mandatory
1941 //
1942 // Returns: tEplKernel = error code
1943 //
1944 //
1945 // State:
1946 //
1947 //---------------------------------------------------------------------------
1948
1949 static tEplKernel PUBLIC EplApiCbNodeEvent(unsigned int uiNodeId_p,
1950 tEplNmtNodeEvent NodeEvent_p,
1951 tEplNmtState NmtState_p,
1952 WORD wErrorCode_p, BOOL fMandatory_p)
1953 {
1954 tEplKernel Ret;
1955 tEplApiEventArg EventArg;
1956
1957 Ret = kEplSuccessful;
1958
1959 // call user callback
1960 EventArg.m_Node.m_uiNodeId = uiNodeId_p;
1961 EventArg.m_Node.m_NodeEvent = NodeEvent_p;
1962 EventArg.m_Node.m_NmtState = NmtState_p;
1963 EventArg.m_Node.m_wErrorCode = wErrorCode_p;
1964 EventArg.m_Node.m_fMandatory = fMandatory_p;
1965
1966 Ret = EplApiInstance_g.m_InitParam.m_pfnCbEvent(kEplApiEventNode,
1967 &EventArg,
1968 EplApiInstance_g.
1969 m_InitParam.
1970 m_pEventUserArg);
1971
1972 return Ret;
1973
1974 }
1975
1976 //---------------------------------------------------------------------------
1977 //
1978 // Function: EplApiCbBootEvent
1979 //
1980 // Description: callback function for boot events
1981 //
1982 // Parameters: BootEvent_p = event from the boot-up process
1983 // NmtState_p = current local NMT state
1984 // wErrorCode_p = EPL error code if BootEvent_p==kEplNmtBootEventError
1985 //
1986 // Returns: tEplKernel = error code
1987 //
1988 //
1989 // State:
1990 //
1991 //---------------------------------------------------------------------------
1992
1993 static tEplKernel PUBLIC EplApiCbBootEvent(tEplNmtBootEvent BootEvent_p,
1994 tEplNmtState NmtState_p,
1995 WORD wErrorCode_p)
1996 {
1997 tEplKernel Ret;
1998 tEplApiEventArg EventArg;
1999
2000 Ret = kEplSuccessful;
2001
2002 // call user callback
2003 EventArg.m_Boot.m_BootEvent = BootEvent_p;
2004 EventArg.m_Boot.m_NmtState = NmtState_p;
2005 EventArg.m_Boot.m_wErrorCode = wErrorCode_p;
2006
2007 Ret = EplApiInstance_g.m_InitParam.m_pfnCbEvent(kEplApiEventBoot,
2008 &EventArg,
2009 EplApiInstance_g.
2010 m_InitParam.
2011 m_pEventUserArg);
2012
2013 return Ret;
2014
2015 }
2016
2017 #endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
2018
2019 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
2020
2021 //---------------------------------------------------------------------------
2022 //
2023 // Function: EplApiCbLedStateChange
2024 //
2025 // Description: callback function for LED change events.
2026 //
2027 // Parameters: LedType_p = type of LED
2028 // fOn_p = state of LED
2029 //
2030 // Returns: tEplKernel = errorcode
2031 //
2032 // State:
2033 //
2034 //---------------------------------------------------------------------------
2035
2036 static tEplKernel PUBLIC EplApiCbLedStateChange(tEplLedType LedType_p,
2037 BOOL fOn_p)
2038 {
2039 tEplKernel Ret;
2040 tEplApiEventArg EventArg;
2041
2042 Ret = kEplSuccessful;
2043
2044 // call user callback
2045 EventArg.m_Led.m_LedType = LedType_p;
2046 EventArg.m_Led.m_fOn = fOn_p;
2047
2048 Ret = EplApiInstance_g.m_InitParam.m_pfnCbEvent(kEplApiEventLed,
2049 &EventArg,
2050 EplApiInstance_g.
2051 m_InitParam.
2052 m_pEventUserArg);
2053
2054 return Ret;
2055
2056 }
2057
2058 #endif
2059
2060 // EOF