ethercatbase.c File Reference

Base EtherCAT functions. More...

#include <stdio.h>
#include <string.h>
#include "ethercattype.h"
#include "nicdrv.h"
#include "ethercatbase.h"
Include dependency graph for ethercatbase.c:

Go to the source code of this file.

Functions

int ec_setupdatagram (void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data)
 Generate and set EtherCAT datagram in a standard ethernet frame.
int ec_adddatagram (void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
 Add EtherCAT datagram to a standard ethernet frame with existing datagram(s).
int ec_BWR (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 BRW "broadcast write" primitive.
int ec_BRD (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 BRD "broadcast read" primitive.
int ec_APRD (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 APRD "auto increment address read" primitive.
int ec_ARMW (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 APRMW "auto increment address read, multiple write" primitive.
int ec_FRMW (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 FPRMW "configured address read, multiple write" primitive.
uint16 ec_APRDw (uint16 ADP, uint16 ADO, int timeout)
 APRDw "auto increment address read" word return primitive.
int ec_FPRD (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 FPRD "configured address read" primitive.
uint16 ec_FPRDw (uint16 ADP, uint16 ADO, int16 timeout)
 FPRDw "configured address read" word return primitive.
int ec_APWRw (uint16 ADP, uint16 ADO, uint16 data, int timeout)
 APWRw "auto increment address write" word primitive.
int ec_APWR (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 APWR "auto increment address write" primitive.
int ec_FPWRw (uint16 ADP, uint16 ADO, uint16 data, int timeout)
 FPWR "configured address write" primitive.
int ec_FPWR (uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
 FPWR "configured address write" primitive.
int ec_LRW (uint32 LogAdr, uint16 length, void *data, int timeout)
 LRW "logical memory read / write" primitive.
int ec_LRD (uint32 LogAdr, uint16 length, void *data, int timeout)
 LRD "logical memory read" primitive.
int ec_LWR (uint32 LogAdr, uint16 length, void *data, int timeout)
 LWR "logical memory write" primitive.
int ec_LRWDC (uint32 LogAdr, uint16 length, void *data, uint16 DCrs, int64 *DCtime, int timeout)
 LRW "logical memory read / write" primitive plus Clock Distribution.

Detailed Description

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.

Definition in file ethercatbase.c.


Function Documentation

int ec_adddatagram ( void *  frame,
uint8  com,
uint8  idx,
boolean  more,
uint16  ADP,
uint16  ADO,
uint16  length,
void *  data 
)

Add EtherCAT datagram to a standard ethernet frame with existing datagram(s).

Parameters:
[out] frame = framebuffer
[in] com = command
[in] idx = index used for TX and RX buffers
[in] more = TRUE if still more datagrams to follow
[in] ADP = Address Position
[in] ADO = Address Offset
[in] length = length of datagram excluding EtherCAT header
[in] data = databuffer to be copied in datagram
Returns:
Offset to data in rx frame, usefull to retrieve data after RX.

Definition at line 109 of file ethercatbase.c.

Here is the caller graph for this function:

int ec_APRD ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

APRD "auto increment address read" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, each slave ++, slave that has 0 excecutes
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[out] data = databuffer to put slave data in
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 220 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

uint16 ec_APRDw ( uint16  ADP,
uint16  ADO,
int  timeout 
)

APRDw "auto increment address read" word return primitive.

Blocking.

Parameters:
[in] ADP = Address Position, each slave ++, slave that has 0 reads.
[in] ADO = Address Offset, slave memory address
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
word data from slave

Definition at line 298 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_APWR ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

APWR "auto increment address write" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, each slave ++, slave that has 0 writes.
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[in] data = databuffer to write to slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 372 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_APWRw ( uint16  ADP,
uint16  ADO,
uint16  data,
int  timeout 
)

APWRw "auto increment address write" word primitive.

Blocking.

Parameters:
[in] ADP = Address Position, each slave ++, slave that has 0 writes.
[in] ADO = Address Offset, slave memory address
[in] data = word data to write to slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 358 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_ARMW ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

APRMW "auto increment address read, multiple write" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, each slave ++, slave that has 0 reads, following slaves write.
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[out] data = databuffer to put slave data in
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 247 of file ethercatbase.c.

Here is the call graph for this function:

int ec_BRD ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

BRD "broadcast read" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, normally 0
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[out] data = databuffer to put slave data in
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 189 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_BWR ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

BRW "broadcast write" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, normally 0
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[in] data = databuffer to be written to slaves
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 163 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_FPRD ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

FPRD "configured address read" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, slave that has address reads.
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[out] data = databuffer to put slave data in
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 317 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

uint16 ec_FPRDw ( uint16  ADP,
uint16  ADO,
int16  timeout 
)

FPRDw "configured address read" word return primitive.

Blocking.

Parameters:
[in] ADP = Address Position, slave that has address reads.
[in] ADO = Address Offset, slave memory address
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
word data from slave

Definition at line 341 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_FPWR ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

FPWR "configured address write" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, slave that has address writes.
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[in] data = databuffer to write to slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 407 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_FPWRw ( uint16  ADP,
uint16  ADO,
uint16  data,
int  timeout 
)

FPWR "configured address write" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, slave that has address writes.
[in] ADO = Address Offset, slave memory address
[in] data = word to write to slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 393 of file ethercatbase.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_FRMW ( uint16  ADP,
uint16  ADO,
uint16  length,
void *  data,
int  timeout 
)

FPRMW "configured address read, multiple write" primitive.

Blocking.

Parameters:
[in] ADP = Address Position, slave that has address reads, following slaves write.
[in] ADO = Address Offset, slave memory address
[in] length = length of databuffer
[out] data = databuffer to put slave data in
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 274 of file ethercatbase.c.

Here is the call graph for this function:

int ec_LRD ( uint32  LogAdr,
uint16  length,
void *  data,
int  timeout 
)

LRD "logical memory read" primitive.

Blocking.

Parameters:
[in] LogAdr = Logical memory address
[in] length = length of bytes to read from slave.
[out] data = databuffer to read from slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 453 of file ethercatbase.c.

Here is the call graph for this function:

int ec_LRW ( uint32  LogAdr,
uint16  length,
void *  data,
int  timeout 
)

LRW "logical memory read / write" primitive.

Blocking.

Parameters:
[in] LogAdr = Logical memory address
[in] length = length of databuffer
[in,out] data = databuffer to write to and read from slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 428 of file ethercatbase.c.

Here is the call graph for this function:

int ec_LRWDC ( uint32  LogAdr,
uint16  length,
void *  data,
uint16  DCrs,
int64 DCtime,
int  timeout 
)

LRW "logical memory read / write" primitive plus Clock Distribution.

Blocking. Frame consists of two datagrams, one LRW and one FPRMW.

Parameters:
[in] LogAdr = Logical memory address
[in] length = length of databuffer
[in,out] data = databuffer to write to and read from slave.
[in] DCrs = Distributed Clock reference slave address.
[out] DCtime = DC time read from reference slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 502 of file ethercatbase.c.

Here is the call graph for this function:

int ec_LWR ( uint32  LogAdr,
uint16  length,
void *  data,
int  timeout 
)

LWR "logical memory write" primitive.

Blocking.

Parameters:
[in] LogAdr = Logical memory address
[in] length = length of databuffer
[in] data = databuffer to write to slave.
[in] timeout = timeout in us, standard is EC_TIMEOUTRET
Returns:
Workcounter or EC_NOFRAME

Definition at line 478 of file ethercatbase.c.

Here is the call graph for this function:

int ec_setupdatagram ( void *  frame,
uint8  com,
uint8  idx,
uint16  ADP,
uint16  ADO,
uint16  length,
void *  data 
)

Generate and set EtherCAT datagram in a standard ethernet frame.

Parameters:
[out] frame = framebuffer
[in] com = command
[in] idx = index used for TX and RX buffers
[in] ADP = Address Position
[in] ADO = Address Offset
[in] length = length of datagram excluding EtherCAT header
[in] data = databuffer to be copied in datagram
Returns:
always 0

Definition at line 69 of file ethercatbase.c.

Here is the caller graph for this function:

Generated by  doxygen 1.6.3