HID: fix bus endianity in file2alias
[linux-2.6/mini2440.git] / drivers / staging / epl / EplNmtk.c
blob4e2d0e15e9473be92070ab0deb01e166f1a1e7e2
1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
6 Project: openPOWERLINK
8 Description: source file for NMT-Kernelspace-Module
10 License:
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
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.
41 Severability Clause:
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 -------------------------------------------------------------------------
52 $RCSfile: EplNmtk.c,v $
54 $Author: D.Krueger $
56 $Revision: 1.12 $ $Date: 2008/11/13 17:13:09 $
58 $State: Exp $
60 Build Environment:
61 GCC V3.4
63 -------------------------------------------------------------------------
65 Revision History:
67 2006/06/09 k.t.: start of the implementation
69 ****************************************************************************/
71 #include "kernel/EplNmtk.h"
72 #include "kernel/EplTimerk.h"
74 #include "kernel/EplDllk.h" // for EplDllkProcess()
76 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
77 /***************************************************************************/
78 /* */
79 /* */
80 /* G L O B A L D E F I N I T I O N S */
81 /* */
82 /* */
83 /***************************************************************************/
85 //---------------------------------------------------------------------------
86 // const defines
87 //---------------------------------------------------------------------------
89 // TracePoint support for realtime-debugging
90 #ifdef _DBG_TRACE_POINTS_
91 void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
92 void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
93 #define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
94 #define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
95 #else
96 #define TGT_DBG_SIGNAL_TRACE_POINT(p)
97 #define TGT_DBG_POST_TRACE_VALUE(v)
98 #endif
99 #define EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent_p, OldNmtState_p, NewNmtState_p) \
100 TGT_DBG_POST_TRACE_VALUE((kEplEventSinkNmtk << 28) | (NmtEvent_p << 16) \
101 | ((OldNmtState_p & 0xFF) << 8) \
102 | (NewNmtState_p & 0xFF))
104 //---------------------------------------------------------------------------
105 // local types
106 //---------------------------------------------------------------------------
107 // struct for instance table
108 INSTANCE_TYPE_BEGIN EPL_MCO_DECL_INSTANCE_MEMBER()
110 STATIC volatile tEplNmtState INST_FAR m_NmtState;
111 STATIC volatile BOOL INST_FAR m_fEnableReadyToOperate;
112 STATIC volatile BOOL INST_FAR m_fAppReadyToOperate;
113 STATIC volatile BOOL INST_FAR m_fTimerMsPreOp2;
114 STATIC volatile BOOL INST_FAR m_fAllMandatoryCNIdent;
115 STATIC volatile BOOL INST_FAR m_fFrozen;
117 INSTANCE_TYPE_END
118 //---------------------------------------------------------------------------
119 // modul globale vars
120 //---------------------------------------------------------------------------
121 // This macro replace the unspecific pointer to an instance through
122 // the modul specific type for the local instance table. This macro
123 // must defined in each modul.
124 //#define tEplPtrInstance tEplInstanceInfo MEM*
125 EPL_MCO_DECL_INSTANCE_VAR()
126 //---------------------------------------------------------------------------
127 // local function prototypes
128 //---------------------------------------------------------------------------
129 EPL_MCO_DEFINE_INSTANCE_FCT()
131 /***************************************************************************/
132 /* */
133 /* */
134 /* C L A S S <NMT_Kernel-Module> */
135 /* */
136 /* */
137 /***************************************************************************/
139 // Description: This module realize the NMT-State-Machine of the EPL-Stack
142 /***************************************************************************/
143 //=========================================================================//
144 // //
145 // P U B L I C F U N C T I O N S //
146 // //
147 //=========================================================================//
148 //---------------------------------------------------------------------------
150 // Function: EplNmtkInit
152 // Description: initializes the first instance
156 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
157 // uiNodeId_p = Node Id of the lokal node
160 // Returns: tEplKernel = Errorcode
163 // State:
165 //---------------------------------------------------------------------------
166 EPLDLLEXPORT tEplKernel PUBLIC EplNmtkInit(EPL_MCO_DECL_PTR_INSTANCE_PTR)
168 tEplKernel Ret;
170 Ret = EplNmtkAddInstance(EPL_MCO_PTR_INSTANCE_PTR);
172 return Ret;
175 //---------------------------------------------------------------------------
177 // Function: EplNmtkAddInstance
179 // Description: adds a new instance
183 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
186 // Returns: tEplKernel = Errorcode
189 // State:
191 //---------------------------------------------------------------------------
192 EPLDLLEXPORT tEplKernel PUBLIC EplNmtkAddInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR)
194 EPL_MCO_DECL_INSTANCE_PTR_LOCAL tEplKernel Ret;
195 //tEplEvent Event;
196 //tEplEventNmtStateChange NmtStateChange;
198 // check if pointer to instance pointer valid
199 // get free instance and set the globale instance pointer
200 // set also the instance addr to parameterlist
201 EPL_MCO_CHECK_PTR_INSTANCE_PTR();
202 EPL_MCO_GET_FREE_INSTANCE_PTR();
203 EPL_MCO_SET_PTR_INSTANCE_PTR();
205 // sign instance as used
206 EPL_MCO_WRITE_INSTANCE_STATE(kStateUsed);
208 Ret = kEplSuccessful;
210 // initialize intern vaiables
211 // 2006/07/31 d.k.: set NMT-State to kEplNmtGsOff
212 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff;
213 // set NMT-State to kEplNmtGsInitialising
214 //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising;
216 // set flags to FALSE
217 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE;
218 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE;
219 EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) = FALSE;
220 EPL_MCO_GLB_VAR(m_fAllMandatoryCNIdent) = FALSE;
221 EPL_MCO_GLB_VAR(m_fFrozen) = FALSE;
223 // EPL_MCO_GLB_VAR(m_TimerHdl) = 0;
225 // inform higher layer about state change
226 // 2006/07/31 d.k.: The EPL API layer/application has to start NMT state
227 // machine via NmtEventSwReset after initialisation of
228 // all modules has been completed. DLL has to be initialised
229 // after NMTk because NMT state shall not be uninitialised
230 // at that time.
231 /* NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState);
232 NmtStateChange.m_NmtEvent = kEplNmtEventNoEvent;
233 Event.m_EventSink = kEplEventSinkNmtu;
234 Event.m_EventType = kEplEventTypeNmtStateChange;
235 EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
236 Event.m_pArg = &NmtStateChange;
237 Event.m_uiSize = sizeof(NmtStateChange);
238 Ret = EplEventkPost(&Event);
240 return Ret;
243 //---------------------------------------------------------------------------
245 // Function: EplNmtkDelInstance
247 // Description: delete instance
251 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
254 // Returns: tEplKernel = Errorcode
257 // State:
259 //---------------------------------------------------------------------------
260 #if (EPL_USE_DELETEINST_FUNC != FALSE)
261 EPLDLLEXPORT tEplKernel PUBLIC EplNmtkDelInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR)
263 tEplKernel Ret = kEplSuccessful;
264 // check for all API function if instance is valid
265 EPL_MCO_CHECK_INSTANCE_STATE();
267 // set NMT-State to kEplNmtGsOff
268 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff;
270 // sign instance as unused
271 EPL_MCO_WRITE_INSTANCE_STATE(kStateUnused);
273 // delete timer
274 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
276 return Ret;
278 #endif // (EPL_USE_DELETEINST_FUNC != FALSE)
280 //---------------------------------------------------------------------------
282 // Function: EplNmtkProcess
284 // Description: main process function
285 // -> process NMT-State-Maschine und read NMT-Events from Queue
289 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instance pointer
290 // pEvent_p = Epl-Event with NMT-event to process
293 // Returns: tEplKernel = Errorcode
296 // State:
298 //---------------------------------------------------------------------------
299 EPLDLLEXPORT tEplKernel PUBLIC EplNmtkProcess(EPL_MCO_DECL_PTR_INSTANCE_PTR_
300 tEplEvent * pEvent_p)
302 tEplKernel Ret;
303 tEplNmtState OldNmtState;
304 tEplNmtEvent NmtEvent;
305 tEplEvent Event;
306 tEplEventNmtStateChange NmtStateChange;
308 // check for all API function if instance is valid
309 EPL_MCO_CHECK_INSTANCE_STATE();
311 Ret = kEplSuccessful;
313 switch (pEvent_p->m_EventType) {
314 case kEplEventTypeNmtEvent:
316 NmtEvent = *((tEplNmtEvent *) pEvent_p->m_pArg);
317 break;
320 case kEplEventTypeTimer:
322 NmtEvent =
323 (tEplNmtEvent) ((tEplTimerEventArg *) pEvent_p->
324 m_pArg)->m_ulArg;
325 break;
327 default:
329 Ret = kEplNmtInvalidEvent;
330 goto Exit;
334 // save NMT-State
335 // needed for later comparison to
336 // inform hgher layer about state change
337 OldNmtState = EPL_MCO_GLB_VAR(m_NmtState);
339 // NMT-State-Maschine
340 switch (EPL_MCO_GLB_VAR(m_NmtState)) {
341 //-----------------------------------------------------------
342 // general part of the statemaschine
344 // first init of the hardware
345 case kEplNmtGsOff:
347 // leave this state only if higher layer says so
348 if (NmtEvent == kEplNmtEventSwReset) { // new state kEplNmtGsInitialising
349 EPL_MCO_GLB_VAR(m_NmtState) =
350 kEplNmtGsInitialising;
352 break;
355 // first init of the hardware
356 case kEplNmtGsInitialising:
358 // leave this state only if higher layer says so
360 // check events
361 switch (NmtEvent) {
362 // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
363 // NMT Command SwitchOff
364 case kEplNmtEventCriticalError:
365 case kEplNmtEventSwitchOff:
367 EPL_MCO_GLB_VAR(m_NmtState) =
368 kEplNmtGsOff;
369 break;
372 // new state kEplNmtGsResetApplication
373 case kEplNmtEventEnterResetApp:
375 EPL_MCO_GLB_VAR(m_NmtState) =
376 kEplNmtGsResetApplication;
377 break;
380 default:
382 break;
385 break;
388 // init of the manufacturer-specific profile area and the
389 // standardised device profile area
390 case kEplNmtGsResetApplication:
392 // check events
393 switch (NmtEvent) {
394 // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
395 // NMT Command SwitchOff
396 case kEplNmtEventCriticalError:
397 case kEplNmtEventSwitchOff:
399 EPL_MCO_GLB_VAR(m_NmtState) =
400 kEplNmtGsOff;
401 break;
404 // NMT Command SwReset
405 case kEplNmtEventSwReset:
407 EPL_MCO_GLB_VAR(m_NmtState) =
408 kEplNmtGsInitialising;
409 break;
412 // leave this state only if higher layer
413 // say so
414 case kEplNmtEventEnterResetCom:
416 // new state kEplNmtGsResetCommunication
417 EPL_MCO_GLB_VAR(m_NmtState) =
418 kEplNmtGsResetCommunication;
419 break;
422 default:
424 break;
427 break;
430 // init of the communication profile area
431 case kEplNmtGsResetCommunication:
433 // check events
434 switch (NmtEvent) {
435 // 2006/07/31 d.k.: react also on NMT reset commands in ResetComm state
436 // NMT Command SwitchOff
437 case kEplNmtEventCriticalError:
438 case kEplNmtEventSwitchOff:
440 EPL_MCO_GLB_VAR(m_NmtState) =
441 kEplNmtGsOff;
442 break;
445 // NMT Command SwReset
446 case kEplNmtEventSwReset:
448 EPL_MCO_GLB_VAR(m_NmtState) =
449 kEplNmtGsInitialising;
450 break;
453 // NMT Command ResetNode
454 case kEplNmtEventResetNode:
456 EPL_MCO_GLB_VAR(m_NmtState) =
457 kEplNmtGsResetApplication;
458 break;
461 // leave this state only if higher layer
462 // say so
463 case kEplNmtEventEnterResetConfig:
465 // new state kEplNmtGsResetCommunication
466 EPL_MCO_GLB_VAR(m_NmtState) =
467 kEplNmtGsResetConfiguration;
468 break;
471 default:
473 break;
476 break;
479 // build the configuration with infos from OD
480 case kEplNmtGsResetConfiguration:
482 // reset flags
483 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE;
484 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE;
485 EPL_MCO_GLB_VAR(m_fFrozen) = FALSE;
487 // check events
488 switch (NmtEvent) {
489 // 2006/07/31 d.k.: react also on NMT reset commands in ResetConf state
490 // NMT Command SwitchOff
491 case kEplNmtEventCriticalError:
492 case kEplNmtEventSwitchOff:
494 EPL_MCO_GLB_VAR(m_NmtState) =
495 kEplNmtGsOff;
496 break;
499 // NMT Command SwReset
500 case kEplNmtEventSwReset:
502 EPL_MCO_GLB_VAR(m_NmtState) =
503 kEplNmtGsInitialising;
504 break;
507 // NMT Command ResetNode
508 case kEplNmtEventResetNode:
510 EPL_MCO_GLB_VAR(m_NmtState) =
511 kEplNmtGsResetApplication;
512 break;
515 // NMT Command ResetCommunication
516 case kEplNmtEventResetCom:
518 EPL_MCO_GLB_VAR(m_NmtState) =
519 kEplNmtGsResetCommunication;
520 break;
523 // leave this state only if higher layer says so
524 case kEplNmtEventEnterCsNotActive:
525 { // Node should be CN
526 EPL_MCO_GLB_VAR(m_NmtState) =
527 kEplNmtCsNotActive;
528 break;
532 case kEplNmtEventEnterMsNotActive:
533 { // Node should be CN
534 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
535 // no MN functionality
536 // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
537 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
538 #else
540 EPL_MCO_GLB_VAR(m_NmtState) =
541 kEplNmtMsNotActive;
542 #endif
543 break;
547 default:
549 break;
552 break;
555 //-----------------------------------------------------------
556 // CN part of the statemaschine
558 // node liste for EPL-Frames and check timeout
559 case kEplNmtCsNotActive:
562 // check events
563 switch (NmtEvent) {
564 // 2006/07/31 d.k.: react also on NMT reset commands in NotActive state
565 // NMT Command SwitchOff
566 case kEplNmtEventCriticalError:
567 case kEplNmtEventSwitchOff:
569 EPL_MCO_GLB_VAR(m_NmtState) =
570 kEplNmtGsOff;
571 break;
574 // NMT Command SwReset
575 case kEplNmtEventSwReset:
577 EPL_MCO_GLB_VAR(m_NmtState) =
578 kEplNmtGsInitialising;
579 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
580 break;
583 // NMT Command ResetNode
584 case kEplNmtEventResetNode:
586 EPL_MCO_GLB_VAR(m_NmtState) =
587 kEplNmtGsResetApplication;
588 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
589 break;
592 // NMT Command ResetCommunication
593 // or internal Communication error
594 case kEplNmtEventResetCom:
595 case kEplNmtEventInternComError:
597 EPL_MCO_GLB_VAR(m_NmtState) =
598 kEplNmtGsResetCommunication;
599 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
600 break;
603 // NMT Command Reset Configuration
604 case kEplNmtEventResetConfig:
606 EPL_MCO_GLB_VAR(m_NmtState) =
607 kEplNmtGsResetConfiguration;
608 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
609 break;
612 // see if SoA or SoC received
613 // k.t. 20.07.2006: only SoA forces change of state
614 // see EPL V2 DS 1.0.0 p.267
615 // case kEplNmtEventDllCeSoc:
616 case kEplNmtEventDllCeSoa:
617 { // new state PRE_OPERATIONAL1
618 EPL_MCO_GLB_VAR(m_NmtState) =
619 kEplNmtCsPreOperational1;
620 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
621 break;
623 // timeout for SoA and Soc
624 case kEplNmtEventTimerBasicEthernet:
626 // new state BASIC_ETHERNET
627 EPL_MCO_GLB_VAR(m_NmtState) =
628 kEplNmtCsBasicEthernet;
629 break;
632 default:
634 break;
636 } // end of switch(NmtEvent)
638 break;
641 // node processes only async frames
642 case kEplNmtCsPreOperational1:
645 // check events
646 switch (NmtEvent) {
647 // NMT Command SwitchOff
648 case kEplNmtEventCriticalError:
649 case kEplNmtEventSwitchOff:
651 EPL_MCO_GLB_VAR(m_NmtState) =
652 kEplNmtGsOff;
653 break;
656 // NMT Command SwReset
657 case kEplNmtEventSwReset:
659 EPL_MCO_GLB_VAR(m_NmtState) =
660 kEplNmtGsInitialising;
661 break;
664 // NMT Command ResetNode
665 case kEplNmtEventResetNode:
667 EPL_MCO_GLB_VAR(m_NmtState) =
668 kEplNmtGsResetApplication;
669 break;
672 // NMT Command ResetCommunication
673 // or internal Communication error
674 case kEplNmtEventResetCom:
675 case kEplNmtEventInternComError:
677 EPL_MCO_GLB_VAR(m_NmtState) =
678 kEplNmtGsResetCommunication;
679 break;
682 // NMT Command Reset Configuration
683 case kEplNmtEventResetConfig:
685 EPL_MCO_GLB_VAR(m_NmtState) =
686 kEplNmtGsResetConfiguration;
687 break;
690 // NMT Command StopNode
691 case kEplNmtEventStopNode:
693 EPL_MCO_GLB_VAR(m_NmtState) =
694 kEplNmtCsStopped;
695 break;
698 // check if SoC received
699 case kEplNmtEventDllCeSoc:
701 EPL_MCO_GLB_VAR(m_NmtState) =
702 kEplNmtCsPreOperational2;
703 break;
706 default:
708 break;
711 } // end of switch(NmtEvent)
713 break;
716 // node processes isochronous and asynchronous frames
717 case kEplNmtCsPreOperational2:
719 // check events
720 switch (NmtEvent) {
721 // NMT Command SwitchOff
722 case kEplNmtEventCriticalError:
723 case kEplNmtEventSwitchOff:
725 EPL_MCO_GLB_VAR(m_NmtState) =
726 kEplNmtGsOff;
727 break;
730 // NMT Command SwReset
731 case kEplNmtEventSwReset:
733 EPL_MCO_GLB_VAR(m_NmtState) =
734 kEplNmtGsInitialising;
735 break;
738 // NMT Command ResetNode
739 case kEplNmtEventResetNode:
741 EPL_MCO_GLB_VAR(m_NmtState) =
742 kEplNmtGsResetApplication;
743 break;
746 // NMT Command ResetCommunication
747 // or internal Communication error
748 case kEplNmtEventResetCom:
749 case kEplNmtEventInternComError:
751 EPL_MCO_GLB_VAR(m_NmtState) =
752 kEplNmtGsResetCommunication;
753 break;
756 // NMT Command Reset Configuration
757 case kEplNmtEventResetConfig:
759 EPL_MCO_GLB_VAR(m_NmtState) =
760 kEplNmtGsResetConfiguration;
761 break;
764 // NMT Command StopNode
765 case kEplNmtEventStopNode:
767 // reset flags
768 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
769 = FALSE;
770 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
771 FALSE;
772 EPL_MCO_GLB_VAR(m_NmtState) =
773 kEplNmtCsStopped;
774 break;
777 // error occured
778 case kEplNmtEventNmtCycleError:
780 // reset flags
781 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
782 = FALSE;
783 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
784 FALSE;
785 EPL_MCO_GLB_VAR(m_NmtState) =
786 kEplNmtCsPreOperational1;
787 break;
790 // check if application is ready to operate
791 case kEplNmtEventEnterReadyToOperate:
793 // check if command NMTEnableReadyToOperate from MN was received
794 if (EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) == TRUE) { // reset flags
795 EPL_MCO_GLB_VAR
796 (m_fEnableReadyToOperate) =
797 FALSE;
798 EPL_MCO_GLB_VAR
799 (m_fAppReadyToOperate) =
800 FALSE;
801 // change state
802 EPL_MCO_GLB_VAR(m_NmtState) =
803 kEplNmtCsReadyToOperate;
804 } else { // set Flag
805 EPL_MCO_GLB_VAR
806 (m_fAppReadyToOperate) =
807 TRUE;
809 break;
812 // NMT Commando EnableReadyToOperate
813 case kEplNmtEventEnableReadyToOperate:
815 // check if application is ready
816 if (EPL_MCO_GLB_VAR(m_fAppReadyToOperate) == TRUE) { // reset flags
817 EPL_MCO_GLB_VAR
818 (m_fEnableReadyToOperate) =
819 FALSE;
820 EPL_MCO_GLB_VAR
821 (m_fAppReadyToOperate) =
822 FALSE;
823 // change state
824 EPL_MCO_GLB_VAR(m_NmtState) =
825 kEplNmtCsReadyToOperate;
826 } else { // set Flag
827 EPL_MCO_GLB_VAR
828 (m_fEnableReadyToOperate) =
829 TRUE;
831 break;
834 default:
836 break;
839 } // end of switch(NmtEvent)
840 break;
843 // node should be configured und application is ready
844 case kEplNmtCsReadyToOperate:
846 // check events
847 switch (NmtEvent) {
848 // NMT Command SwitchOff
849 case kEplNmtEventCriticalError:
850 case kEplNmtEventSwitchOff:
852 EPL_MCO_GLB_VAR(m_NmtState) =
853 kEplNmtGsOff;
854 break;
857 // NMT Command SwReset
858 case kEplNmtEventSwReset:
860 EPL_MCO_GLB_VAR(m_NmtState) =
861 kEplNmtGsInitialising;
862 break;
865 // NMT Command ResetNode
866 case kEplNmtEventResetNode:
868 EPL_MCO_GLB_VAR(m_NmtState) =
869 kEplNmtGsResetApplication;
870 break;
873 // NMT Command ResetCommunication
874 // or internal Communication error
875 case kEplNmtEventResetCom:
876 case kEplNmtEventInternComError:
878 EPL_MCO_GLB_VAR(m_NmtState) =
879 kEplNmtGsResetCommunication;
880 break;
883 // NMT Command ResetConfiguration
884 case kEplNmtEventResetConfig:
886 EPL_MCO_GLB_VAR(m_NmtState) =
887 kEplNmtGsResetConfiguration;
888 break;
891 // NMT Command StopNode
892 case kEplNmtEventStopNode:
894 EPL_MCO_GLB_VAR(m_NmtState) =
895 kEplNmtCsStopped;
896 break;
899 // error occured
900 case kEplNmtEventNmtCycleError:
902 EPL_MCO_GLB_VAR(m_NmtState) =
903 kEplNmtCsPreOperational1;
904 break;
907 // NMT Command StartNode
908 case kEplNmtEventStartNode:
910 EPL_MCO_GLB_VAR(m_NmtState) =
911 kEplNmtCsOperational;
912 break;
915 default:
917 break;
920 } // end of switch(NmtEvent)
921 break;
924 // normal work state
925 case kEplNmtCsOperational:
928 // check events
929 switch (NmtEvent) {
930 // NMT Command SwitchOff
931 case kEplNmtEventCriticalError:
932 case kEplNmtEventSwitchOff:
934 EPL_MCO_GLB_VAR(m_NmtState) =
935 kEplNmtGsOff;
936 break;
939 // NMT Command SwReset
940 case kEplNmtEventSwReset:
942 EPL_MCO_GLB_VAR(m_NmtState) =
943 kEplNmtGsInitialising;
944 break;
947 // NMT Command ResetNode
948 case kEplNmtEventResetNode:
950 EPL_MCO_GLB_VAR(m_NmtState) =
951 kEplNmtGsResetApplication;
952 break;
955 // NMT Command ResetCommunication
956 // or internal Communication error
957 case kEplNmtEventResetCom:
958 case kEplNmtEventInternComError:
960 EPL_MCO_GLB_VAR(m_NmtState) =
961 kEplNmtGsResetCommunication;
962 break;
965 // NMT Command ResetConfiguration
966 case kEplNmtEventResetConfig:
968 EPL_MCO_GLB_VAR(m_NmtState) =
969 kEplNmtGsResetConfiguration;
970 break;
973 // NMT Command StopNode
974 case kEplNmtEventStopNode:
976 EPL_MCO_GLB_VAR(m_NmtState) =
977 kEplNmtCsStopped;
978 break;
981 // NMT Command EnterPreOperational2
982 case kEplNmtEventEnterPreOperational2:
984 EPL_MCO_GLB_VAR(m_NmtState) =
985 kEplNmtCsPreOperational2;
986 break;
989 // error occured
990 case kEplNmtEventNmtCycleError:
992 EPL_MCO_GLB_VAR(m_NmtState) =
993 kEplNmtCsPreOperational1;
994 break;
997 default:
999 break;
1002 } // end of switch(NmtEvent)
1003 break;
1006 // node stopped by MN
1007 // -> only process asynchronous frames
1008 case kEplNmtCsStopped:
1010 // check events
1011 switch (NmtEvent) {
1012 // NMT Command SwitchOff
1013 case kEplNmtEventCriticalError:
1014 case kEplNmtEventSwitchOff:
1016 EPL_MCO_GLB_VAR(m_NmtState) =
1017 kEplNmtGsOff;
1018 break;
1021 // NMT Command SwReset
1022 case kEplNmtEventSwReset:
1024 EPL_MCO_GLB_VAR(m_NmtState) =
1025 kEplNmtGsInitialising;
1026 break;
1029 // NMT Command ResetNode
1030 case kEplNmtEventResetNode:
1032 EPL_MCO_GLB_VAR(m_NmtState) =
1033 kEplNmtGsResetApplication;
1034 break;
1037 // NMT Command ResetCommunication
1038 // or internal Communication error
1039 case kEplNmtEventResetCom:
1040 case kEplNmtEventInternComError:
1042 EPL_MCO_GLB_VAR(m_NmtState) =
1043 kEplNmtGsResetCommunication;
1044 break;
1047 // NMT Command ResetConfiguration
1048 case kEplNmtEventResetConfig:
1050 EPL_MCO_GLB_VAR(m_NmtState) =
1051 kEplNmtGsResetConfiguration;
1052 break;
1055 // NMT Command EnterPreOperational2
1056 case kEplNmtEventEnterPreOperational2:
1058 EPL_MCO_GLB_VAR(m_NmtState) =
1059 kEplNmtCsPreOperational2;
1060 break;
1063 // error occured
1064 case kEplNmtEventNmtCycleError:
1066 EPL_MCO_GLB_VAR(m_NmtState) =
1067 kEplNmtCsPreOperational1;
1068 break;
1071 default:
1073 break;
1076 } // end of switch(NmtEvent)
1077 break;
1080 // no epl cycle
1081 // -> normal ethernet communication
1082 case kEplNmtCsBasicEthernet:
1084 // check events
1085 switch (NmtEvent) {
1086 // NMT Command SwitchOff
1087 case kEplNmtEventCriticalError:
1088 case kEplNmtEventSwitchOff:
1090 EPL_MCO_GLB_VAR(m_NmtState) =
1091 kEplNmtGsOff;
1092 break;
1095 // NMT Command SwReset
1096 case kEplNmtEventSwReset:
1098 EPL_MCO_GLB_VAR(m_NmtState) =
1099 kEplNmtGsInitialising;
1100 break;
1103 // NMT Command ResetNode
1104 case kEplNmtEventResetNode:
1106 EPL_MCO_GLB_VAR(m_NmtState) =
1107 kEplNmtGsResetApplication;
1108 break;
1111 // NMT Command ResetCommunication
1112 // or internal Communication error
1113 case kEplNmtEventResetCom:
1114 case kEplNmtEventInternComError:
1116 EPL_MCO_GLB_VAR(m_NmtState) =
1117 kEplNmtGsResetCommunication;
1118 break;
1121 // NMT Command ResetConfiguration
1122 case kEplNmtEventResetConfig:
1124 EPL_MCO_GLB_VAR(m_NmtState) =
1125 kEplNmtGsResetConfiguration;
1126 break;
1129 // error occured
1130 // d.k.: how does this error occur? on CRC errors
1131 /* case kEplNmtEventNmtCycleError:
1133 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1134 break;
1137 case kEplNmtEventDllCeSoc:
1138 case kEplNmtEventDllCePreq:
1139 case kEplNmtEventDllCePres:
1140 case kEplNmtEventDllCeSoa:
1141 { // Epl-Frame on net -> stop any communication
1142 EPL_MCO_GLB_VAR(m_NmtState) =
1143 kEplNmtCsPreOperational1;
1144 break;
1147 default:
1149 break;
1152 } // end of switch(NmtEvent)
1154 break;
1157 //-----------------------------------------------------------
1158 // MN part of the statemaschine
1160 // MN listen to network
1161 // -> if no EPL traffic go to next state
1162 case kEplNmtMsNotActive:
1164 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
1165 // no MN functionality
1166 // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
1167 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
1168 #else
1170 // check events
1171 switch (NmtEvent) {
1172 // NMT Command SwitchOff
1173 case kEplNmtEventCriticalError:
1174 case kEplNmtEventSwitchOff:
1176 EPL_MCO_GLB_VAR(m_NmtState) =
1177 kEplNmtGsOff;
1178 break;
1181 // NMT Command SwReset
1182 case kEplNmtEventSwReset:
1184 EPL_MCO_GLB_VAR(m_NmtState) =
1185 kEplNmtGsInitialising;
1186 break;
1189 // NMT Command ResetNode
1190 case kEplNmtEventResetNode:
1192 EPL_MCO_GLB_VAR(m_NmtState) =
1193 kEplNmtGsResetApplication;
1194 break;
1197 // NMT Command ResetCommunication
1198 // or internal Communication error
1199 case kEplNmtEventResetCom:
1200 case kEplNmtEventInternComError:
1202 EPL_MCO_GLB_VAR(m_NmtState) =
1203 kEplNmtGsResetCommunication;
1204 break;
1207 // NMT Command ResetConfiguration
1208 case kEplNmtEventResetConfig:
1210 EPL_MCO_GLB_VAR(m_NmtState) =
1211 kEplNmtGsResetConfiguration;
1212 break;
1215 // EPL frames received
1216 case kEplNmtEventDllCeSoc:
1217 case kEplNmtEventDllCeSoa:
1218 { // other MN in network
1219 // $$$ d.k.: generate error history entry
1220 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
1221 break;
1224 // timeout event
1225 case kEplNmtEventTimerBasicEthernet:
1227 if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) { // new state BasicEthernet
1228 EPL_MCO_GLB_VAR(m_NmtState) =
1229 kEplNmtMsBasicEthernet;
1231 break;
1234 // timeout event
1235 case kEplNmtEventTimerMsPreOp1:
1237 if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) { // new state PreOp1
1238 EPL_MCO_GLB_VAR(m_NmtState) =
1239 kEplNmtMsPreOperational1;
1240 EPL_MCO_GLB_VAR
1241 (m_fTimerMsPreOp2) = FALSE;
1242 EPL_MCO_GLB_VAR
1243 (m_fAllMandatoryCNIdent) =
1244 FALSE;
1247 break;
1250 default:
1252 break;
1255 } // end of switch(NmtEvent)
1257 #endif // ((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
1259 break;
1261 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1262 // MN process reduces epl cycle
1263 case kEplNmtMsPreOperational1:
1265 // check events
1266 switch (NmtEvent) {
1267 // NMT Command SwitchOff
1268 case kEplNmtEventCriticalError:
1269 case kEplNmtEventSwitchOff:
1271 EPL_MCO_GLB_VAR(m_NmtState) =
1272 kEplNmtGsOff;
1273 break;
1276 // NMT Command SwReset
1277 case kEplNmtEventSwReset:
1279 EPL_MCO_GLB_VAR(m_NmtState) =
1280 kEplNmtGsInitialising;
1281 break;
1284 // NMT Command ResetNode
1285 case kEplNmtEventResetNode:
1287 EPL_MCO_GLB_VAR(m_NmtState) =
1288 kEplNmtGsResetApplication;
1289 break;
1292 // NMT Command ResetCommunication
1293 // or internal Communication error
1294 case kEplNmtEventResetCom:
1295 case kEplNmtEventInternComError:
1297 EPL_MCO_GLB_VAR(m_NmtState) =
1298 kEplNmtGsResetCommunication;
1299 break;
1302 // NMT Command ResetConfiguration
1303 case kEplNmtEventResetConfig:
1305 EPL_MCO_GLB_VAR(m_NmtState) =
1306 kEplNmtGsResetConfiguration;
1307 break;
1310 // EPL frames received
1311 case kEplNmtEventDllCeSoc:
1312 case kEplNmtEventDllCeSoa:
1313 { // other MN in network
1314 // $$$ d.k.: generate error history entry
1315 EPL_MCO_GLB_VAR(m_NmtState) =
1316 kEplNmtGsResetCommunication;
1317 break;
1320 // error occured
1321 // d.k. MSPreOp1->CSPreOp1: nonsense -> keep state
1323 case kEplNmtEventNmtCycleError:
1325 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1326 break;
1330 case kEplNmtEventAllMandatoryCNIdent:
1331 { // all mandatory CN identified
1332 if (EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) !=
1333 FALSE) {
1334 EPL_MCO_GLB_VAR(m_NmtState) =
1335 kEplNmtMsPreOperational2;
1336 } else {
1337 EPL_MCO_GLB_VAR
1338 (m_fAllMandatoryCNIdent) =
1339 TRUE;
1341 break;
1344 case kEplNmtEventTimerMsPreOp2:
1345 { // residence time for PreOp1 is elapsed
1346 if (EPL_MCO_GLB_VAR
1347 (m_fAllMandatoryCNIdent) != FALSE) {
1348 EPL_MCO_GLB_VAR(m_NmtState) =
1349 kEplNmtMsPreOperational2;
1350 } else {
1351 EPL_MCO_GLB_VAR
1352 (m_fTimerMsPreOp2) = TRUE;
1354 break;
1357 default:
1359 break;
1362 } // end of switch(NmtEvent)
1363 break;
1366 // MN process full epl cycle
1367 case kEplNmtMsPreOperational2:
1369 // check events
1370 switch (NmtEvent) {
1371 // NMT Command SwitchOff
1372 case kEplNmtEventCriticalError:
1373 case kEplNmtEventSwitchOff:
1375 EPL_MCO_GLB_VAR(m_NmtState) =
1376 kEplNmtGsOff;
1377 break;
1380 // NMT Command SwReset
1381 case kEplNmtEventSwReset:
1383 EPL_MCO_GLB_VAR(m_NmtState) =
1384 kEplNmtGsInitialising;
1385 break;
1388 // NMT Command ResetNode
1389 case kEplNmtEventResetNode:
1391 EPL_MCO_GLB_VAR(m_NmtState) =
1392 kEplNmtGsResetApplication;
1393 break;
1396 // NMT Command ResetCommunication
1397 // or internal Communication error
1398 case kEplNmtEventResetCom:
1399 case kEplNmtEventInternComError:
1401 EPL_MCO_GLB_VAR(m_NmtState) =
1402 kEplNmtGsResetCommunication;
1403 break;
1406 // NMT Command ResetConfiguration
1407 case kEplNmtEventResetConfig:
1409 EPL_MCO_GLB_VAR(m_NmtState) =
1410 kEplNmtGsResetConfiguration;
1411 break;
1414 // EPL frames received
1415 case kEplNmtEventDllCeSoc:
1416 case kEplNmtEventDllCeSoa:
1417 { // other MN in network
1418 // $$$ d.k.: generate error history entry
1419 EPL_MCO_GLB_VAR(m_NmtState) =
1420 kEplNmtGsResetCommunication;
1421 break;
1424 // error occured
1425 case kEplNmtEventNmtCycleError:
1427 EPL_MCO_GLB_VAR(m_NmtState) =
1428 kEplNmtMsPreOperational1;
1429 break;
1432 case kEplNmtEventEnterReadyToOperate:
1434 EPL_MCO_GLB_VAR(m_NmtState) =
1435 kEplNmtMsReadyToOperate;
1436 break;
1439 default:
1441 break;
1444 } // end of switch(NmtEvent)
1446 break;
1449 // all madatory nodes ready to operate
1450 // -> MN process full epl cycle
1451 case kEplNmtMsReadyToOperate:
1454 // check events
1455 switch (NmtEvent) {
1456 // NMT Command SwitchOff
1457 case kEplNmtEventCriticalError:
1458 case kEplNmtEventSwitchOff:
1460 EPL_MCO_GLB_VAR(m_NmtState) =
1461 kEplNmtGsOff;
1462 break;
1465 // NMT Command SwReset
1466 case kEplNmtEventSwReset:
1468 EPL_MCO_GLB_VAR(m_NmtState) =
1469 kEplNmtGsInitialising;
1470 break;
1473 // NMT Command ResetNode
1474 case kEplNmtEventResetNode:
1476 EPL_MCO_GLB_VAR(m_NmtState) =
1477 kEplNmtGsResetApplication;
1478 break;
1481 // NMT Command ResetCommunication
1482 // or internal Communication error
1483 case kEplNmtEventResetCom:
1484 case kEplNmtEventInternComError:
1486 EPL_MCO_GLB_VAR(m_NmtState) =
1487 kEplNmtGsResetCommunication;
1488 break;
1491 // NMT Command ResetConfiguration
1492 case kEplNmtEventResetConfig:
1494 EPL_MCO_GLB_VAR(m_NmtState) =
1495 kEplNmtGsResetConfiguration;
1496 break;
1499 // EPL frames received
1500 case kEplNmtEventDllCeSoc:
1501 case kEplNmtEventDllCeSoa:
1502 { // other MN in network
1503 // $$$ d.k.: generate error history entry
1504 EPL_MCO_GLB_VAR(m_NmtState) =
1505 kEplNmtGsResetCommunication;
1506 break;
1509 // error occured
1510 case kEplNmtEventNmtCycleError:
1512 EPL_MCO_GLB_VAR(m_NmtState) =
1513 kEplNmtMsPreOperational1;
1514 break;
1517 case kEplNmtEventEnterMsOperational:
1519 EPL_MCO_GLB_VAR(m_NmtState) =
1520 kEplNmtMsOperational;
1521 break;
1524 default:
1526 break;
1529 } // end of switch(NmtEvent)
1531 break;
1534 // normal eplcycle processing
1535 case kEplNmtMsOperational:
1537 // check events
1538 switch (NmtEvent) {
1539 // NMT Command SwitchOff
1540 case kEplNmtEventCriticalError:
1541 case kEplNmtEventSwitchOff:
1543 EPL_MCO_GLB_VAR(m_NmtState) =
1544 kEplNmtGsOff;
1545 break;
1548 // NMT Command SwReset
1549 case kEplNmtEventSwReset:
1551 EPL_MCO_GLB_VAR(m_NmtState) =
1552 kEplNmtGsInitialising;
1553 break;
1556 // NMT Command ResetNode
1557 case kEplNmtEventResetNode:
1559 EPL_MCO_GLB_VAR(m_NmtState) =
1560 kEplNmtGsResetApplication;
1561 break;
1564 // NMT Command ResetCommunication
1565 // or internal Communication error
1566 case kEplNmtEventResetCom:
1567 case kEplNmtEventInternComError:
1569 EPL_MCO_GLB_VAR(m_NmtState) =
1570 kEplNmtGsResetCommunication;
1571 break;
1574 // NMT Command ResetConfiguration
1575 case kEplNmtEventResetConfig:
1577 EPL_MCO_GLB_VAR(m_NmtState) =
1578 kEplNmtGsResetConfiguration;
1579 break;
1582 // EPL frames received
1583 case kEplNmtEventDllCeSoc:
1584 case kEplNmtEventDllCeSoa:
1585 { // other MN in network
1586 // $$$ d.k.: generate error history entry
1587 EPL_MCO_GLB_VAR(m_NmtState) =
1588 kEplNmtGsResetCommunication;
1589 break;
1592 // error occured
1593 case kEplNmtEventNmtCycleError:
1595 EPL_MCO_GLB_VAR(m_NmtState) =
1596 kEplNmtMsPreOperational1;
1597 break;
1600 default:
1602 break;
1605 } // end of switch(NmtEvent)
1606 break;
1609 // normal ethernet traffic
1610 case kEplNmtMsBasicEthernet:
1613 // check events
1614 switch (NmtEvent) {
1615 // NMT Command SwitchOff
1616 case kEplNmtEventCriticalError:
1617 case kEplNmtEventSwitchOff:
1619 EPL_MCO_GLB_VAR(m_NmtState) =
1620 kEplNmtGsOff;
1621 break;
1624 // NMT Command SwReset
1625 case kEplNmtEventSwReset:
1627 EPL_MCO_GLB_VAR(m_NmtState) =
1628 kEplNmtGsInitialising;
1629 break;
1632 // NMT Command ResetNode
1633 case kEplNmtEventResetNode:
1635 EPL_MCO_GLB_VAR(m_NmtState) =
1636 kEplNmtGsResetApplication;
1637 break;
1640 // NMT Command ResetCommunication
1641 // or internal Communication error
1642 case kEplNmtEventResetCom:
1643 case kEplNmtEventInternComError:
1645 EPL_MCO_GLB_VAR(m_NmtState) =
1646 kEplNmtGsResetCommunication;
1647 break;
1650 // NMT Command ResetConfiguration
1651 case kEplNmtEventResetConfig:
1653 EPL_MCO_GLB_VAR(m_NmtState) =
1654 kEplNmtGsResetConfiguration;
1655 break;
1658 // EPL frames received
1659 case kEplNmtEventDllCeSoc:
1660 case kEplNmtEventDllCeSoa:
1661 { // other MN in network
1662 // $$$ d.k.: generate error history entry
1663 EPL_MCO_GLB_VAR(m_NmtState) =
1664 kEplNmtGsResetCommunication;
1665 break;
1668 // error occured
1669 // d.k. BE->PreOp1 on cycle error? No
1670 /* case kEplNmtEventNmtCycleError:
1672 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1673 break;
1676 default:
1678 break;
1681 } // end of switch(NmtEvent)
1682 break;
1684 #endif //#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1686 default:
1688 //DEBUG_EPL_DBGLVL_NMTK_TRACE0(EPL_DBGLVL_NMT ,"Error in EplNmtProcess: Unknown NMT-State");
1689 //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication;
1690 Ret = kEplNmtInvalidState;
1691 goto Exit;
1694 } // end of switch(NmtEvent)
1696 // inform higher layer about State-Change if needed
1697 if (OldNmtState != EPL_MCO_GLB_VAR(m_NmtState)) {
1698 EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent, OldNmtState,
1699 EPL_MCO_GLB_VAR(m_NmtState));
1701 // d.k.: memorize NMT state before posting any events
1702 NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState);
1704 // inform DLL
1705 if ((OldNmtState > kEplNmtGsResetConfiguration)
1706 && (EPL_MCO_GLB_VAR(m_NmtState) <=
1707 kEplNmtGsResetConfiguration)) {
1708 // send DLL DEINIT
1709 Event.m_EventSink = kEplEventSinkDllk;
1710 Event.m_EventType = kEplEventTypeDllkDestroy;
1711 EPL_MEMSET(&Event.m_NetTime, 0x00,
1712 sizeof(Event.m_NetTime));
1713 Event.m_pArg = &OldNmtState;
1714 Event.m_uiSize = sizeof(OldNmtState);
1715 // d.k.: directly call DLLk process function, because
1716 // 1. execution of process function is still synchonized and serialized,
1717 // 2. it is the same as without event queues (i.e. well tested),
1718 // 3. DLLk will get those necessary events even if event queue is full,
1719 // 4. event queue is very inefficient
1720 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
1721 Ret = EplDllkProcess(&Event);
1722 #else
1723 Ret = EplEventkPost(&Event);
1724 #endif
1725 } else if ((OldNmtState <= kEplNmtGsResetConfiguration)
1726 && (EPL_MCO_GLB_VAR(m_NmtState) >
1727 kEplNmtGsResetConfiguration)) {
1728 // send DLL INIT
1729 Event.m_EventSink = kEplEventSinkDllk;
1730 Event.m_EventType = kEplEventTypeDllkCreate;
1731 EPL_MEMSET(&Event.m_NetTime, 0x00,
1732 sizeof(Event.m_NetTime));
1733 Event.m_pArg = &NmtStateChange.m_NewNmtState;
1734 Event.m_uiSize = sizeof(NmtStateChange.m_NewNmtState);
1735 // d.k.: directly call DLLk process function, because
1736 // 1. execution of process function is still synchonized and serialized,
1737 // 2. it is the same as without event queues (i.e. well tested),
1738 // 3. DLLk will get those necessary events even if event queue is full
1739 // 4. event queue is very inefficient
1740 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
1741 Ret = EplDllkProcess(&Event);
1742 #else
1743 Ret = EplEventkPost(&Event);
1744 #endif
1745 } else
1746 if ((EPL_MCO_GLB_VAR(m_NmtState) == kEplNmtCsBasicEthernet)
1747 || (EPL_MCO_GLB_VAR(m_NmtState) ==
1748 kEplNmtMsBasicEthernet)) {
1749 tEplDllAsyncReqPriority AsyncReqPriority;
1751 // send DLL Fill Async Tx Buffer, because state BasicEthernet was entered
1752 Event.m_EventSink = kEplEventSinkDllk;
1753 Event.m_EventType = kEplEventTypeDllkFillTx;
1754 EPL_MEMSET(&Event.m_NetTime, 0x00,
1755 sizeof(Event.m_NetTime));
1756 AsyncReqPriority = kEplDllAsyncReqPrioGeneric;
1757 Event.m_pArg = &AsyncReqPriority;
1758 Event.m_uiSize = sizeof(AsyncReqPriority);
1759 // d.k.: directly call DLLk process function, because
1760 // 1. execution of process function is still synchonized and serialized,
1761 // 2. it is the same as without event queues (i.e. well tested),
1762 // 3. DLLk will get those necessary events even if event queue is full
1763 // 4. event queue is very inefficient
1764 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
1765 Ret = EplDllkProcess(&Event);
1766 #else
1767 Ret = EplEventkPost(&Event);
1768 #endif
1770 // inform higher layer about state change
1771 NmtStateChange.m_NmtEvent = NmtEvent;
1772 Event.m_EventSink = kEplEventSinkNmtu;
1773 Event.m_EventType = kEplEventTypeNmtStateChange;
1774 EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
1775 Event.m_pArg = &NmtStateChange;
1776 Event.m_uiSize = sizeof(NmtStateChange);
1777 Ret = EplEventkPost(&Event);
1778 EPL_DBGLVL_NMTK_TRACE2
1779 ("EplNmtkProcess(NMT-Event = 0x%04X): New NMT-State = 0x%03X\n",
1780 NmtEvent, NmtStateChange.m_NewNmtState);
1784 Exit:
1786 return Ret;
1789 //---------------------------------------------------------------------------
1791 // Function: EplNmtkGetNmtState
1793 // Description: return the actuell NMT-State and the bits
1794 // to for MN- or CN-mode
1798 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instancepointer
1801 // Returns: tEplNmtState = NMT-State
1804 // State:
1806 //---------------------------------------------------------------------------
1807 EPLDLLEXPORT tEplNmtState PUBLIC
1808 EplNmtkGetNmtState(EPL_MCO_DECL_PTR_INSTANCE_PTR)
1810 tEplNmtState NmtState;
1812 NmtState = EPL_MCO_GLB_VAR(m_NmtState);
1814 return NmtState;
1818 //=========================================================================//
1819 // //
1820 // P R I V A T E D E F I N I T I O N S //
1821 // //
1822 //=========================================================================//
1823 EPL_MCO_DECL_INSTANCE_FCT()
1824 //---------------------------------------------------------------------------
1826 // Function:
1828 // Description:
1832 // Parameters:
1835 // Returns:
1838 // State:
1840 //---------------------------------------------------------------------------
1841 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
1842 // EOF