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