forked from OpenEtherCATsociety/SOEM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethercatbase.c
637 lines (564 loc) · 21.3 KB
/
ethercatbase.c
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
/*
* Licensed under the GNU General Public License version 2 with exceptions. See
* LICENSE file in the project root for full license information
*/
/** \file
* \brief
* Base EtherCAT functions.
*
* Setting up a datagram in an ethernet frame.
* EtherCAT datagram primitives, broadcast, auto increment, configured and
* logical addressed data transfers. All base transfers are blocking, so
* wait for the frame to be returned to the master or timeout. If this is
* not acceptable build your own datagrams and use the functions from nicdrv.c.
*/
#include <stdio.h>
#include <string.h>
#include "oshw.h"
#include "osal.h"
#include "ethercattype.h"
#include "ethercatbase.h"
/** Write data to EtherCAT datagram.
*
* @param[out] datagramdata = data part of datagram
* @param[in] com = command
* @param[in] length = length of databuffer
* @param[in] data = databuffer to be copied into datagram
*/
static void ecx_writedatagramdata(void *datagramdata, ec_cmdtype com, uint16 length, const void * data)
{
if (length > 0)
{
switch (com)
{
case EC_CMD_NOP:
/* Fall-through */
case EC_CMD_APRD:
/* Fall-through */
case EC_CMD_FPRD:
/* Fall-through */
case EC_CMD_BRD:
/* Fall-through */
case EC_CMD_LRD:
/* no data to write. initialise data so frame is in a known state */
memset(datagramdata, 0, length);
break;
default:
memcpy(datagramdata, data, length);
break;
}
}
}
/** Generate and set EtherCAT datagram in a standard ethernet frame.
*
* @param[in] port = port context struct
* @param[out] frame = framebuffer
* @param[in] com = command
* @param[in] idx = index used for TX and RX buffers
* @param[in] ADP = Address Position
* @param[in] ADO = Address Offset
* @param[in] length = length of datagram excluding EtherCAT header
* @param[in] data = databuffer to be copied in datagram
* @return always 0
*/
int ecx_setupdatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data)
{
ec_comt *datagramP;
uint8 *frameP;
frameP = frame;
/* Ethernet header is preset and fixed in frame buffers
EtherCAT header needs to be added after that */
datagramP = (ec_comt*)&frameP[ETH_HEADERSIZE];
datagramP->elength = htoes(EC_ECATTYPE + EC_HEADERSIZE + length);
datagramP->command = com;
datagramP->index = idx;
datagramP->ADP = htoes(ADP);
datagramP->ADO = htoes(ADO);
datagramP->dlength = htoes(length);
ecx_writedatagramdata(&frameP[ETH_HEADERSIZE + EC_HEADERSIZE], com, length, data);
/* set WKC to zero */
frameP[ETH_HEADERSIZE + EC_HEADERSIZE + length] = 0x00;
frameP[ETH_HEADERSIZE + EC_HEADERSIZE + length + 1] = 0x00;
/* set size of frame in buffer array */
port->txbuflength[idx] = ETH_HEADERSIZE + EC_HEADERSIZE + EC_WKCSIZE + length;
return 0;
}
/** Add EtherCAT datagram to a standard ethernet frame with existing datagram(s).
*
* @param[in] port = port context struct
* @param[out] frame = framebuffer
* @param[in] com = command
* @param[in] idx = index used for TX and RX buffers
* @param[in] more = TRUE if still more datagrams to follow
* @param[in] ADP = Address Position
* @param[in] ADO = Address Offset
* @param[in] length = length of datagram excluding EtherCAT header
* @param[in] data = databuffer to be copied in datagram
* @return Offset to data in rx frame, usefull to retrieve data after RX.
*/
int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
{
ec_comt *datagramP;
uint8 *frameP;
uint16 prevlength;
frameP = frame;
/* copy previous frame size */
prevlength = port->txbuflength[idx];
datagramP = (ec_comt*)&frameP[ETH_HEADERSIZE];
/* add new datagram to ethernet frame size */
datagramP->elength = htoes( etohs(datagramP->elength) + EC_HEADERSIZE + length );
/* add "datagram follows" flag to previous subframe dlength */
datagramP->dlength = htoes( etohs(datagramP->dlength) | EC_DATAGRAMFOLLOWS );
/* set new EtherCAT header position */
datagramP = (ec_comt*)&frameP[prevlength - EC_ELENGTHSIZE];
datagramP->command = com;
datagramP->index = idx;
datagramP->ADP = htoes(ADP);
datagramP->ADO = htoes(ADO);
if (more)
{
/* this is not the last datagram to add */
datagramP->dlength = htoes(length | EC_DATAGRAMFOLLOWS);
}
else
{
/* this is the last datagram in the frame */
datagramP->dlength = htoes(length);
}
ecx_writedatagramdata(&frameP[prevlength + EC_HEADERSIZE - EC_ELENGTHSIZE], com, length, data);
/* set WKC to zero */
frameP[prevlength + EC_HEADERSIZE - EC_ELENGTHSIZE + length] = 0x00;
frameP[prevlength + EC_HEADERSIZE - EC_ELENGTHSIZE + length + 1] = 0x00;
/* set size of frame in buffer array */
port->txbuflength[idx] = prevlength + EC_HEADERSIZE - EC_ELENGTHSIZE + EC_WKCSIZE + length;
/* return offset to data in rx frame
14 bytes smaller than tx frame due to stripping of ethernet header */
return prevlength + EC_HEADERSIZE - EC_ELENGTHSIZE - ETH_HEADERSIZE;
}
/** BRW "broadcast write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, normally 0
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[in] data = databuffer to be written to slaves
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_BWR (ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
uint8 idx;
int wkc;
/* get fresh index */
idx = ecx_getindex (port);
/* setup datagram */
ecx_setupdatagram (port, &(port->txbuf[idx]), EC_CMD_BWR, idx, ADP, ADO, length, data);
/* send data and wait for answer */
wkc = ecx_srconfirm (port, idx, timeout);
/* clear buffer status */
ecx_setbufstat (port, idx, EC_BUF_EMPTY);
return wkc;
}
/** BRD "broadcast read" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, normally 0
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[out] data = databuffer to put slave data in
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
uint8 idx;
int wkc;
/* get fresh index */
idx = ecx_getindex(port);
/* setup datagram */
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_BRD, idx, ADP, ADO, length, data);
/* send data and wait for answer */
wkc = ecx_srconfirm (port, idx, timeout);
if (wkc > 0)
{
/* copy datagram to data buffer */
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
/* clear buffer status */
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** APRD "auto increment address read" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, each slave ++, slave that has 0 excecutes
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[out] data = databuffer to put slave data in
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
int wkc;
uint8 idx;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_APRD, idx, ADP, ADO, length, data);
wkc = ecx_srconfirm(port, idx, timeout);
if (wkc > 0)
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** APRMW "auto increment address read, multiple write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, each slave ++, slave that has 0 reads,
* following slaves write.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[out] data = databuffer to put slave data in
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_ARMW(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
int wkc;
uint8 idx;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_ARMW, idx, ADP, ADO, length, data);
wkc = ecx_srconfirm(port, idx, timeout);
if (wkc > 0)
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** FPRMW "configured address read, multiple write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, slave that has address reads,
* following slaves write.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[out] data = databuffer to put slave data in
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_FRMW(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
int wkc;
uint8 idx;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_FRMW, idx, ADP, ADO, length, data);
wkc = ecx_srconfirm(port, idx, timeout);
if (wkc > 0)
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** APRDw "auto increment address read" word return primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, each slave ++, slave that has 0 reads.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return word data from slave
*/
uint16 ecx_APRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout)
{
uint16 w;
w = 0;
ecx_APRD(port, ADP, ADO, sizeof(w), &w, timeout);
return w;
}
/** FPRD "configured address read" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, slave that has address reads.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[out] data = databuffer to put slave data in
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_FPRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
int wkc;
uint8 idx;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_FPRD, idx, ADP, ADO, length, data);
wkc = ecx_srconfirm(port, idx, timeout);
if (wkc > 0)
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** FPRDw "configured address read" word return primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, slave that has address reads.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return word data from slave
*/
uint16 ecx_FPRDw(ecx_portt *port, uint16 ADP, uint16 ADO, int timeout)
{
uint16 w;
w = 0;
ecx_FPRD(port, ADP, ADO, sizeof(w), &w, timeout);
return w;
}
/** APWR "auto increment address write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, each slave ++, slave that has 0 writes.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[in] data = databuffer to write to slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_APWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
uint8 idx;
int wkc;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_APWR, idx, ADP, ADO, length, data);
wkc = ecx_srconfirm(port, idx, timeout);
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** APWRw "auto increment address write" word primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, each slave ++, slave that has 0 writes.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] data = word data to write to slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_APWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
{
return ecx_APWR(port, ADP, ADO, sizeof(data), &data, timeout);
}
/** FPWR "configured address write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, slave that has address writes.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] length = length of databuffer
* @param[in] data = databuffer to write to slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_FPWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
int wkc;
uint8 idx;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_FPWR, idx, ADP, ADO, length, data);
wkc = ecx_srconfirm(port, idx, timeout);
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** FPWR "configured address write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] ADP = Address Position, slave that has address writes.
* @param[in] ADO = Address Offset, slave memory address
* @param[in] data = word to write to slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
{
return ecx_FPWR(port, ADP, ADO, sizeof(data), &data, timeout);
}
/** LRW "logical memory read / write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] LogAdr = Logical memory address
* @param[in] length = length of databuffer
* @param[in,out] data = databuffer to write to and read from slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_LRW(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, int timeout)
{
uint8 idx;
int wkc;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_LRW, idx, LO_WORD(LogAdr), HI_WORD(LogAdr), length, data);
wkc = ecx_srconfirm(port, idx, timeout);
if ((wkc > 0) && (port->rxbuf[idx][EC_CMDOFFSET] == EC_CMD_LRW))
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** LRD "logical memory read" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] LogAdr = Logical memory address
* @param[in] length = length of bytes to read from slave.
* @param[out] data = databuffer to read from slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_LRD(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, int timeout)
{
uint8 idx;
int wkc;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_LRD, idx, LO_WORD(LogAdr), HI_WORD(LogAdr), length, data);
wkc = ecx_srconfirm(port, idx, timeout);
if ((wkc > 0) && (port->rxbuf[idx][EC_CMDOFFSET]==EC_CMD_LRD))
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** LWR "logical memory write" primitive. Blocking.
*
* @param[in] port = port context struct
* @param[in] LogAdr = Logical memory address
* @param[in] length = length of databuffer
* @param[in] data = databuffer to write to slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_LWR(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, int timeout)
{
uint8 idx;
int wkc;
idx = ecx_getindex(port);
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_LWR, idx, LO_WORD(LogAdr), HI_WORD(LogAdr), length, data);
wkc = ecx_srconfirm(port, idx, timeout);
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
/** LRW "logical memory read / write" primitive plus Clock Distribution. Blocking.
* Frame consists of two datagrams, one LRW and one FPRMW.
*
* @param[in] port = port context struct
* @param[in] LogAdr = Logical memory address
* @param[in] length = length of databuffer
* @param[in,out] data = databuffer to write to and read from slave.
* @param[in] DCrs = Distributed Clock reference slave address.
* @param[out] DCtime = DC time read from reference slave.
* @param[in] timeout = timeout in us, standard is EC_TIMEOUTRET
* @return Workcounter or EC_NOFRAME
*/
int ecx_LRWDC(ecx_portt *port, uint32 LogAdr, uint16 length, void *data, uint16 DCrs, int64 *DCtime, int timeout)
{
uint16 DCtO;
uint8 idx;
int wkc;
uint64 DCtE;
idx = ecx_getindex(port);
/* LRW in first datagram */
ecx_setupdatagram(port, &(port->txbuf[idx]), EC_CMD_LRW, idx, LO_WORD(LogAdr), HI_WORD(LogAdr), length, data);
/* FPRMW in second datagram */
DCtE = htoell(*DCtime);
DCtO = ecx_adddatagram(port, &(port->txbuf[idx]), EC_CMD_FRMW, idx, FALSE, DCrs, ECT_REG_DCSYSTIME, sizeof(DCtime), &DCtE);
wkc = ecx_srconfirm(port, idx, timeout);
if ((wkc > 0) && (port->rxbuf[idx][EC_CMDOFFSET] == EC_CMD_LRW))
{
memcpy(data, &(port->rxbuf[idx][EC_HEADERSIZE]), length);
memcpy(&wkc, &(port->rxbuf[idx][EC_HEADERSIZE + length]), EC_WKCSIZE);
memcpy(&DCtE, &(port->rxbuf[idx][DCtO]), sizeof(*DCtime));
*DCtime = etohll(DCtE);
}
ecx_setbufstat(port, idx, EC_BUF_EMPTY);
return wkc;
}
#ifdef EC_VER1
int ec_setupdatagram(void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data)
{
return ecx_setupdatagram (&ecx_port, frame, com, idx, ADP, ADO, length, data);
}
int ec_adddatagram (void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
{
return ecx_adddatagram (&ecx_port, frame, com, idx, more, ADP, ADO, length, data);
}
int ec_BWR(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_BWR (&ecx_port, ADP, ADO, length, data, timeout);
}
int ec_BRD(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_BRD(&ecx_port, ADP, ADO, length, data, timeout);
}
int ec_APRD(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_APRD(&ecx_port, ADP, ADO, length, data, timeout);
}
int ec_ARMW(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_ARMW(&ecx_port, ADP, ADO, length, data, timeout);
}
int ec_FRMW(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_FRMW(&ecx_port, ADP, ADO, length, data, timeout);
}
uint16 ec_APRDw(uint16 ADP, uint16 ADO, int timeout)
{
uint16 w;
w = 0;
ec_APRD(ADP, ADO, sizeof(w), &w, timeout);
return w;
}
int ec_FPRD(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_FPRD(&ecx_port, ADP, ADO, length, data, timeout);
}
uint16 ec_FPRDw(uint16 ADP, uint16 ADO, int timeout)
{
uint16 w;
w = 0;
ec_FPRD(ADP, ADO, sizeof(w), &w, timeout);
return w;
}
int ec_APWR(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_APWR(&ecx_port, ADP, ADO, length, data, timeout);
}
int ec_APWRw(uint16 ADP, uint16 ADO, uint16 data, int timeout)
{
return ec_APWR(ADP, ADO, sizeof(data), &data, timeout);
}
int ec_FPWR(uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
{
return ecx_FPWR(&ecx_port, ADP, ADO, length, data, timeout);
}
int ec_FPWRw(uint16 ADP, uint16 ADO, uint16 data, int timeout)
{
return ec_FPWR(ADP, ADO, sizeof(data), &data, timeout);
}
int ec_LRW(uint32 LogAdr, uint16 length, void *data, int timeout)
{
return ecx_LRW(&ecx_port, LogAdr, length, data, timeout);
}
int ec_LRD(uint32 LogAdr, uint16 length, void *data, int timeout)
{
return ecx_LRD(&ecx_port, LogAdr, length, data, timeout);
}
int ec_LWR(uint32 LogAdr, uint16 length, void *data, int timeout)
{
return ecx_LWR(&ecx_port, LogAdr, length, data, timeout);
}
int ec_LRWDC(uint32 LogAdr, uint16 length, void *data, uint16 DCrs, int64 *DCtime, int timeout)
{
return ecx_LRWDC(&ecx_port, LogAdr, length, data, DCrs, DCtime, timeout);
}
#endif