Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx
[linux-2.6] / drivers / staging / epl / EplPdok.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 kernel PDO 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: EplPdok.c,v $
53
54                 $Author: D.Krueger $
55
56                 $Revision: 1.8 $  $Date: 2008/10/17 15:32:32 $
57
58                 $State: Exp $
59
60                 Build Environment:
61                     GCC V3.4
62
63   -------------------------------------------------------------------------
64
65   Revision History:
66
67   2006/05/22 d.k.:   start of the implementation, version 1.00
68
69 ****************************************************************************/
70
71 #include "kernel/EplPdok.h"
72 #include "kernel/EplPdokCal.h"
73 #include "kernel/EplEventk.h"
74 #include "kernel/EplObdk.h"
75
76 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
77 #include "plccore.h"
78 #define PDO_LED 0x08
79 #endif
80
81 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
82
83 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) == 0)
84
85 #error 'ERROR: Missing DLLk-Modul!'
86
87 #endif
88
89 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) == 0)
90
91 #error 'ERROR: Missing OBDk-Modul!'
92
93 #endif
94 /***************************************************************************/
95 /*                                                                         */
96 /*                                                                         */
97 /*          G L O B A L   D E F I N I T I O N S                            */
98 /*                                                                         */
99 /*                                                                         */
100 /***************************************************************************/
101
102 //---------------------------------------------------------------------------
103 // const defines
104 //---------------------------------------------------------------------------
105
106 #define EPL_PDOK_OBD_IDX_RX_COMM_PARAM  0x1400
107 #define EPL_PDOK_OBD_IDX_RX_MAPP_PARAM  0x1600
108 #define EPL_PDOK_OBD_IDX_TX_COMM_PARAM  0x1800
109 #define EPL_PDOK_OBD_IDX_TX_MAPP_PARAM  0x1A00
110
111 //---------------------------------------------------------------------------
112 // local types
113 //---------------------------------------------------------------------------
114
115 //---------------------------------------------------------------------------
116 // modul globale vars
117 //---------------------------------------------------------------------------
118
119 //---------------------------------------------------------------------------
120 // local function prototypes
121 //---------------------------------------------------------------------------
122
123 /***************************************************************************/
124 /*                                                                         */
125 /*                                                                         */
126 /*          C L A S S  EplPdok                                             */
127 /*                                                                         */
128 /*                                                                         */
129 /***************************************************************************/
130 //
131 // Description:
132 //
133 //
134 /***************************************************************************/
135
136 //=========================================================================//
137 //                                                                         //
138 //          P R I V A T E   D E F I N I T I O N S                          //
139 //                                                                         //
140 //=========================================================================//
141
142 //---------------------------------------------------------------------------
143 // const defines
144 //---------------------------------------------------------------------------
145
146 //---------------------------------------------------------------------------
147 // local types
148 //---------------------------------------------------------------------------
149
150 //---------------------------------------------------------------------------
151 // local vars
152 //---------------------------------------------------------------------------
153
154 //---------------------------------------------------------------------------
155 // local function prototypes
156 //---------------------------------------------------------------------------
157
158 //=========================================================================//
159 //                                                                         //
160 //          P U B L I C   F U N C T I O N S                                //
161 //                                                                         //
162 //=========================================================================//
163
164 //---------------------------------------------------------------------------
165 //
166 // Function:    EplPdokAddInstance()
167 //
168 // Description: add and initialize new instance of EPL stack
169 //
170 // Parameters:  none
171 //
172 // Returns:     tEplKernel              = error code
173 //
174 //
175 // State:
176 //
177 //---------------------------------------------------------------------------
178
179 tEplKernel EplPdokAddInstance(void)
180 {
181
182         return kEplSuccessful;
183 }
184
185 //---------------------------------------------------------------------------
186 //
187 // Function:    EplPdokDelInstance()
188 //
189 // Description: deletes an instance of EPL stack
190 //
191 // Parameters:  none
192 //
193 // Returns:     tEplKernel              = error code
194 //
195 //
196 // State:
197 //
198 //---------------------------------------------------------------------------
199
200 tEplKernel EplPdokDelInstance(void)
201 {
202
203         return kEplSuccessful;
204 }
205
206 //---------------------------------------------------------------------------
207 //
208 // Function:    EplPdokCbPdoReceived
209 //
210 // Description: This function is called by DLL if PRes or PReq frame was
211 //              received. It posts the frame to the event queue.
212 //              It is called in states NMT_CS_READY_TO_OPERATE and NMT_CS_OPERATIONAL.
213 //              The passed PDO needs not to be valid.
214 //
215 // Parameters:  pFrameInfo_p            = pointer to frame info structure
216 //
217 // Returns:     tEplKernel              = error code
218 //
219 //
220 // State:
221 //
222 //---------------------------------------------------------------------------
223
224 tEplKernel EplPdokCbPdoReceived(tEplFrameInfo * pFrameInfo_p)
225 {
226         tEplKernel Ret = kEplSuccessful;
227         tEplEvent Event;
228
229 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
230         // reset LED
231 //    MCF_GPIO_PODR_PCIBG &= ~PDO_LED;  // Level
232 #endif
233
234         Event.m_EventSink = kEplEventSinkPdok;
235         Event.m_EventType = kEplEventTypePdoRx;
236         // limit copied data to size of PDO (because from some CNs the frame is larger than necessary)
237         Event.m_uiSize = AmiGetWordFromLe(&pFrameInfo_p->m_pFrame->m_Data.m_Pres.m_le_wSize) + 24;      // pFrameInfo_p->m_uiFrameSize;
238         Event.m_pArg = pFrameInfo_p->m_pFrame;
239         Ret = EplEventkPost(&Event);
240
241 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
242         // set LED
243 //    MCF_GPIO_PODR_PCIBG |= PDO_LED;  // Level
244 #endif
245
246         return Ret;
247 }
248
249 //---------------------------------------------------------------------------
250 //
251 // Function:    EplPdokCbPdoTransmitted
252 //
253 // Description: This function is called by DLL if PRes or PReq frame was
254 //              sent. It posts the pointer to the frame to the event queue.
255 //              It is called in NMT_CS_PRE_OPERATIONAL_2,
256 //              NMT_CS_READY_TO_OPERATE and NMT_CS_OPERATIONAL.
257 //
258 // Parameters:  pFrameInfo_p            = pointer to frame info structure
259 //
260 // Returns:     tEplKernel              = error code
261 //
262 //
263 // State:
264 //
265 //---------------------------------------------------------------------------
266
267 tEplKernel EplPdokCbPdoTransmitted(tEplFrameInfo * pFrameInfo_p)
268 {
269         tEplKernel Ret = kEplSuccessful;
270         tEplEvent Event;
271
272 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
273         // reset LED
274         MCF_GPIO_PODR_PCIBG &= ~PDO_LED;        // Level
275 #endif
276
277         Event.m_EventSink = kEplEventSinkPdok;
278         Event.m_EventType = kEplEventTypePdoTx;
279         Event.m_uiSize = sizeof(tEplFrameInfo);
280         Event.m_pArg = pFrameInfo_p;
281         Ret = EplEventkPost(&Event);
282
283 #if (DEV_SYSTEM == _DEV_GNU_CF548X_)
284         // set LED
285         MCF_GPIO_PODR_PCIBG |= PDO_LED; // Level
286 #endif
287
288         return Ret;
289 }
290
291 //---------------------------------------------------------------------------
292 //
293 // Function:    EplPdokCbSoa
294 //
295 // Description: This function is called by DLL if SoA frame was
296 //              received resp. sent. It posts this event to the event queue.
297 //
298 // Parameters:  pFrameInfo_p            = pointer to frame info structure
299 //
300 // Returns:     tEplKernel              = error code
301 //
302 //
303 // State:
304 //
305 //---------------------------------------------------------------------------
306
307 tEplKernel EplPdokCbSoa(tEplFrameInfo * pFrameInfo_p)
308 {
309         tEplKernel Ret = kEplSuccessful;
310         tEplEvent Event;
311
312         Event.m_EventSink = kEplEventSinkPdok;
313         Event.m_EventType = kEplEventTypePdoSoa;
314         Event.m_uiSize = 0;
315         Event.m_pArg = NULL;
316         Ret = EplEventkPost(&Event);
317
318         return Ret;
319 }
320
321 //---------------------------------------------------------------------------
322 //
323 // Function:    EplPdokProcess
324 //
325 // Description: This function processes all received and transmitted PDOs.
326 //              This function must not be interrupted by any other task
327 //              except ISRs (like the ethernet driver ISR, which may call
328 //              EplPdokCbFrameReceived() or EplPdokCbFrameTransmitted()).
329 //
330 // Parameters:  pEvent_p                = pointer to event structure
331 //
332 // Returns:     tEplKernel              = error code
333 //
334 //
335 // State:
336 //
337 //---------------------------------------------------------------------------
338
339 tEplKernel EplPdokProcess(tEplEvent * pEvent_p)
340 {
341         tEplKernel Ret = kEplSuccessful;
342         WORD wPdoSize;
343         WORD wBitOffset;
344         WORD wBitSize;
345         WORD wVarSize;
346         QWORD qwObjectMapping;
347         BYTE bMappSubindex;
348         BYTE bObdSubindex;
349         WORD wObdMappIndex;
350         WORD wObdCommIndex;
351         WORD wPdoId;
352         BYTE bObdData;
353         BYTE bObjectCount;
354         BYTE bFrameData;
355         BOOL fValid;
356         tEplObdSize ObdSize;
357         tEplFrame *pFrame;
358         tEplFrameInfo *pFrameInfo;
359         unsigned int uiNodeId;
360         tEplMsgType MsgType;
361
362         // 0xFF=invalid, RPDO: 0x00=PReq, localNodeId=PRes, remoteNodeId=PRes
363         //               TPDO: 0x00=PRes, MN: CnNodeId=PReq
364
365         switch (pEvent_p->m_EventType) {
366         case kEplEventTypePdoRx:        // RPDO received
367                 pFrame = (tEplFrame *) pEvent_p->m_pArg;
368
369                 // check if received RPDO is valid
370                 bFrameData =
371                     AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
372                 if ((bFrameData & EPL_FRAME_FLAG1_RD) == 0) {   // RPDO invalid
373                         goto Exit;
374                 }
375                 // retrieve EPL message type
376                 MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
377                 if (MsgType == kEplMsgTypePreq) {       // RPDO is PReq frame
378                         uiNodeId = EPL_PDO_PREQ_NODE_ID;        // 0x00
379                 } else {        // RPDO is PRes frame
380                         // retrieve node ID
381                         uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
382                 }
383
384                 // search for appropriate valid RPDO in OD
385                 wObdMappIndex = EPL_PDOK_OBD_IDX_RX_MAPP_PARAM;
386                 for (wObdCommIndex = EPL_PDOK_OBD_IDX_RX_COMM_PARAM;
387                      wObdCommIndex < (EPL_PDOK_OBD_IDX_RX_COMM_PARAM + 0x00FF);
388                      wObdCommIndex++, wObdMappIndex++) {
389                         ObdSize = 1;
390                         // read node ID from OD
391                         Ret =
392                             EplObdReadEntry(wObdCommIndex, 0x01, &bObdData,
393                                             &ObdSize);
394                         if ((Ret == kEplObdIndexNotExist)
395                             || (Ret == kEplObdSubindexNotExist)
396                             || (Ret == kEplObdIllegalPart)) {   // PDO does not exist; last PDO reached
397                                 Ret = kEplSuccessful;
398                                 goto Exit;
399                         } else if (Ret != kEplSuccessful) {     // other fatal error occured
400                                 goto Exit;
401                         }
402                         // entry read successfully
403                         if (bObdData != uiNodeId) {     // node ID does not equal - wrong PDO, try next PDO in OD
404                                 continue;
405                         }
406                         ObdSize = 1;
407                         // read number of mapped objects from OD; this indicates if the PDO is valid
408                         Ret =
409                             EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount,
410                                             &ObdSize);
411                         if ((Ret == kEplObdIndexNotExist)
412                             || (Ret == kEplObdSubindexNotExist)
413                             || (Ret == kEplObdIllegalPart)) {   // PDO does not exist; last PDO reached
414                                 Ret = kEplSuccessful;
415                                 goto Exit;
416                         } else if (Ret != kEplSuccessful) {     // other fatal error occured
417                                 goto Exit;
418                         }
419                         // entry read successfully
420                         if (bObjectCount == 0) {        // PDO in OD not valid, try next PDO in OD
421                                 continue;
422                         }
423
424                         ObdSize = 1;
425                         // check PDO mapping version
426                         Ret =
427                             EplObdReadEntry(wObdCommIndex, 0x02, &bObdData,
428                                             &ObdSize);
429                         if (Ret != kEplSuccessful) {    // other fatal error occured
430                                 goto Exit;
431                         }
432                         // entry read successfully
433                         // retrieve PDO version from frame
434                         bFrameData =
435                             AmiGetByteFromLe(&pFrame->m_Data.m_Pres.
436                                              m_le_bPdoVersion);
437                         if ((bObdData & EPL_VERSION_MAIN) != (bFrameData & EPL_VERSION_MAIN)) { // PDO versions do not match
438                                 // $$$ raise PDO error
439                                 // termiate processing of this RPDO
440                                 goto Exit;
441                         }
442                         // valid RPDO found
443
444                         // retrieve PDO size
445                         wPdoSize =
446                             AmiGetWordFromLe(&pFrame->m_Data.m_Pres.m_le_wSize);
447
448                         // process mapping
449                         for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
450                              bMappSubindex++) {
451                                 ObdSize = 8;    // QWORD
452                                 // read object mapping from OD
453                                 Ret =
454                                     EplObdReadEntry(wObdMappIndex,
455                                                     bMappSubindex,
456                                                     &qwObjectMapping, &ObdSize);
457                                 if (Ret != kEplSuccessful) {    // other fatal error occured
458                                         goto Exit;
459                                 }
460                                 // check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
461                                 if (qwObjectMapping == 0) {     // invalid entry, continue with next entry
462                                         continue;
463                                 }
464                                 // decode object mapping
465                                 wObdCommIndex =
466                                     (WORD) (qwObjectMapping &
467                                             0x000000000000FFFFLL);
468                                 bObdSubindex =
469                                     (BYTE) ((qwObjectMapping &
470                                              0x0000000000FF0000LL) >> 16);
471                                 wBitOffset =
472                                     (WORD) ((qwObjectMapping &
473                                              0x0000FFFF00000000LL) >> 32);
474                                 wBitSize =
475                                     (WORD) ((qwObjectMapping &
476                                              0xFFFF000000000000LL) >> 48);
477
478                                 // check if object exceeds PDO size
479                                 if (((wBitOffset + wBitSize) >> 3) > wPdoSize) {        // wrong object mapping; PDO size is too low
480                                         // $$$ raise PDO error
481                                         // terminate processing of this RPDO
482                                         goto Exit;
483                                 }
484                                 // copy object from RPDO to process/OD variable
485                                 ObdSize = wBitSize >> 3;
486                                 Ret =
487                                     EplObdWriteEntryFromLe(wObdCommIndex,
488                                                            bObdSubindex,
489                                                            &pFrame->m_Data.
490                                                            m_Pres.
491                                                            m_le_abPayload[(wBitOffset >> 3)], ObdSize);
492                                 if (Ret != kEplSuccessful) {    // other fatal error occured
493                                         goto Exit;
494                                 }
495
496                         }
497
498                         // processing finished successfully
499                         goto Exit;
500                 }
501                 break;
502
503         case kEplEventTypePdoTx:        // TPDO transmitted
504                 pFrameInfo = (tEplFrameInfo *) pEvent_p->m_pArg;
505                 pFrame = pFrameInfo->m_pFrame;
506
507                 // set TPDO invalid, so that only fully processed TPDOs are sent as valid
508                 bFrameData =
509                     AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
510                 AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1,
511                                (bFrameData & ~EPL_FRAME_FLAG1_RD));
512
513                 // retrieve EPL message type
514                 MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
515                 if (MsgType == kEplMsgTypePres) {       // TPDO is PRes frame
516                         uiNodeId = EPL_PDO_PRES_NODE_ID;        // 0x00
517                 } else {        // TPDO is PReq frame
518                         // retrieve node ID
519                         uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bDstNodeId);
520                 }
521
522                 // search for appropriate valid TPDO in OD
523                 wObdMappIndex = EPL_PDOK_OBD_IDX_TX_MAPP_PARAM;
524                 wObdCommIndex = EPL_PDOK_OBD_IDX_TX_COMM_PARAM;
525                 for (wPdoId = 0;; wPdoId++, wObdCommIndex++, wObdMappIndex++) {
526                         ObdSize = 1;
527                         // read node ID from OD
528                         Ret =
529                             EplObdReadEntry(wObdCommIndex, 0x01, &bObdData,
530                                             &ObdSize);
531                         if ((Ret == kEplObdIndexNotExist)
532                             || (Ret == kEplObdSubindexNotExist)
533                             || (Ret == kEplObdIllegalPart)) {   // PDO does not exist; last PDO reached
534                                 Ret = kEplSuccessful;
535                                 goto Exit;
536                         } else if (Ret != kEplSuccessful) {     // other fatal error occured
537                                 goto Exit;
538                         }
539                         // entry read successfully
540                         if (bObdData != uiNodeId) {     // node ID does not equal - wrong PDO, try next PDO in OD
541                                 continue;
542                         }
543                         ObdSize = 1;
544                         // read number of mapped objects from OD; this indicates if the PDO is valid
545                         Ret =
546                             EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount,
547                                             &ObdSize);
548                         if ((Ret == kEplObdIndexNotExist)
549                             || (Ret == kEplObdSubindexNotExist)
550                             || (Ret == kEplObdIllegalPart)) {   // PDO does not exist; last PDO reached
551                                 Ret = kEplSuccessful;
552                                 goto Exit;
553                         } else if (Ret != kEplSuccessful) {     // other fatal error occured
554                                 goto Exit;
555                         }
556                         // entry read successfully
557                         if (bObjectCount == 0) {        // PDO in OD not valid, try next PDO in OD
558                                 continue;
559                         }
560                         // valid TPDO found
561
562                         ObdSize = 1;
563                         // get PDO mapping version from OD
564                         Ret =
565                             EplObdReadEntry(wObdCommIndex, 0x02, &bObdData,
566                                             &ObdSize);
567                         if (Ret != kEplSuccessful) {    // other fatal error occured
568                                 goto Exit;
569                         }
570                         // entry read successfully
571                         // set PDO version in frame
572                         AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion,
573                                        bObdData);
574
575                         // calculate PDO size
576                         wPdoSize = 0;
577
578                         // process mapping
579                         for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
580                              bMappSubindex++) {
581                                 ObdSize = 8;    // QWORD
582                                 // read object mapping from OD
583                                 Ret =
584                                     EplObdReadEntry(wObdMappIndex,
585                                                     bMappSubindex,
586                                                     &qwObjectMapping, &ObdSize);
587                                 if (Ret != kEplSuccessful) {    // other fatal error occured
588                                         goto Exit;
589                                 }
590                                 // check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
591                                 if (qwObjectMapping == 0) {     // invalid entry, continue with next entry
592                                         continue;
593                                 }
594                                 // decode object mapping
595                                 wObdCommIndex =
596                                     (WORD) (qwObjectMapping &
597                                             0x000000000000FFFFLL);
598                                 bObdSubindex =
599                                     (BYTE) ((qwObjectMapping &
600                                              0x0000000000FF0000LL) >> 16);
601                                 wBitOffset =
602                                     (WORD) ((qwObjectMapping &
603                                              0x0000FFFF00000000LL) >> 32);
604                                 wBitSize =
605                                     (WORD) ((qwObjectMapping &
606                                              0xFFFF000000000000LL) >> 48);
607
608                                 // calculate max PDO size
609                                 ObdSize = wBitSize >> 3;
610                                 wVarSize = (wBitOffset >> 3) + (WORD) ObdSize;
611                                 if ((unsigned int)(wVarSize + 24) > pFrameInfo->m_uiFrameSize) {        // TPDO is too short
612                                         // $$$ raise PDO error, set Ret
613                                         goto Exit;
614                                 }
615                                 if (wVarSize > wPdoSize) {      // memorize new PDO size
616                                         wPdoSize = wVarSize;
617                                 }
618                                 // copy object from process/OD variable to TPDO
619                                 Ret =
620                                     EplObdReadEntryToLe(wObdCommIndex,
621                                                         bObdSubindex,
622                                                         &pFrame->m_Data.m_Pres.
623                                                         m_le_abPayload[(wBitOffset >> 3)], &ObdSize);
624                                 if (Ret != kEplSuccessful) {    // other fatal error occured
625                                         goto Exit;
626                                 }
627
628                         }
629
630                         // set PDO size in frame
631                         AmiSetWordToLe(&pFrame->m_Data.m_Pres.m_le_wSize,
632                                        wPdoSize);
633
634                         Ret = EplPdokCalAreTpdosValid(&fValid);
635                         if (fValid != FALSE) {
636                                 // set TPDO valid
637                                 bFrameData =
638                                     AmiGetByteFromLe(&pFrame->m_Data.m_Pres.
639                                                      m_le_bFlag1);
640                                 AmiSetByteToLe(&pFrame->m_Data.m_Pres.
641                                                m_le_bFlag1,
642                                                (bFrameData |
643                                                 EPL_FRAME_FLAG1_RD));
644                         }
645                         // processing finished successfully
646
647                         goto Exit;
648                 }
649                 break;
650
651         case kEplEventTypePdoSoa:       // SoA received
652
653                 // invalidate TPDOs
654                 Ret = EplPdokCalSetTpdosValid(FALSE);
655                 break;
656
657         default:
658                 {
659                         ASSERTMSG(FALSE,
660                                   "EplPdokProcess(): unhandled event type!\n");
661                 }
662         }
663
664       Exit:
665         return Ret;
666 }
667
668 //=========================================================================//
669 //                                                                         //
670 //          P R I V A T E   F U N C T I O N S                              //
671 //                                                                         //
672 //=========================================================================//
673
674 //---------------------------------------------------------------------------
675 //
676 // Function:
677 //
678 // Description:
679 //
680 //
681 //
682 // Parameters:
683 //
684 //
685 // Returns:
686 //
687 //
688 // State:
689 //
690 //---------------------------------------------------------------------------
691
692 #endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
693
694 // EOF