ethercatmain.h File Reference

Headerfile for ethercatmain.c. More...


Data Structures

struct  ec_fmmut
struct  ec_smt
struct  ec_slavet
struct  ec_eepromFMMUt
struct  ec_eepromSMt
struct  ec_eepromPDOt
struct  ec_mbxheadert

Defines

#define PACKED   __attribute__((__packed__))
#define EC_MAXELIST   64
#define EC_MAXNAME   36
#define EC_MAXSLAVE   200
#define EC_MAXMBX   0x3ff
#define EC_MAXEEPDO   0x200
#define EC_MAXSM   4
#define EC_MAXFMMU   4

Typedefs

typedef uint8 ec_mbxbuft [EC_MAXMBX+1]

Functions

void ec_pusherror (const ec_errort *Ec)
boolean ec_poperror (ec_errort *Ec)
int ec_init (const char *ifname)
int ec_init_redundant (const char *ifname, const char *if2name)
void ec_close (void)
uint8 ec_siigetbyte (uint16 slave, uint16 address)
int16 ec_siifind (uint16 slave, uint16 cat)
void ec_siistring (char *str, uint16 slave, uint16 Sn)
uint16 ec_siiFMMU (uint16 slave, ec_eepromFMMUt *FMMU)
uint16 ec_siiSM (uint16 slave, ec_eepromSMt *SM)
uint16 ec_siiSMnext (uint16 slave, ec_eepromSMt *SM, uint16 n)
uint16 ec_siiPDO (uint16 slave, ec_eepromPDOt *PDO, uint8 t)
int ec_readstate (void)
int ec_writestate (uint16 slave)
uint16 ec_statecheck (uint16 slave, uint16 reqstate, int timeout)
uint8 ec_nextmbxcnt (uint8 cnt)
void ec_clearmbx (ec_mbxbuft *Mbx)
int ec_mbxsend (uint16 slave, ec_mbxbuft *mbx, int timeout)
int ec_mbxreceive (uint16 slave, ec_mbxbuft *mbx, int timeout)
void ec_esidump (uint16 slave, uint8 *esibuf)
uint32 ec_readeeprom (uint16 slave, uint16 eeproma, int16 timeout)
int ec_writeeeprom (uint16 slave, uint16 eeproma, uint16 data, int16 timeout)
int ec_eeprom2master (uint16 slave)
int ec_eeprom2pdi (uint16 slave)
uint64 ec_readeepromFP (uint16 configadr, uint16 eeproma, int16 timeout)
int ec_writeeepromFP (uint16 configadr, uint16 eeproma, uint16 data, int16 timeout)
void ec_readeeprom1 (uint16 slave, uint16 eeproma)
uint32 ec_readeeprom2 (uint16 slave, int16 timeout)
int ec_send_processdata (void)
int ec_receive_processdata (int timeout)

Variables

ec_slavet ec_slave [EC_MAXSLAVE]
int ec_slavecount
uint16 ec_DCtO
int64 ec_DCtime


Detailed Description

Headerfile for ethercatmain.c.


Define Documentation

#define EC_MAXEEPDO   0x200

max. eeprom PDO entries

#define EC_MAXELIST   64

max etries in EtherCAT error list

#define EC_MAXFMMU   4

max. FMMU used

#define EC_MAXMBX   0x3ff

max. mailbox size

#define EC_MAXNAME   36

max length of readable name in slavelist and Object Description List

#define EC_MAXSLAVE   200

max number of slaves in array

#define EC_MAXSM   4

max. SM used

#define PACKED   __attribute__((__packed__))


Typedef Documentation

typedef uint8 ec_mbxbuft[EC_MAXMBX+1]

mailbox buffer array


Function Documentation

void ec_clearmbx ( ec_mbxbuft Mbx  ) 

Clear mailbox buffer.

Parameters:
[out] Mbx = Mailbox buffer to clear

void ec_close ( void   ) 

Close lib.

int ec_eeprom2master ( uint16  slave  ) 

Set eeprom control to master. Only if set to PDI.

Parameters:
[in] slave = Slave number
Returns:
>0 if OK

int ec_eeprom2pdi ( uint16  slave  ) 

Set eeprom control to PDI. Only if set to master.

Parameters:
[in] slave = Slave number
Returns:
>0 if OK

void ec_esidump ( uint16  slave,
uint8 esibuf 
)

Dump complete EEPROM data from slave in buffer.

Parameters:
[in] slave = Slave number
[out] esibuf = EEPROM data buffer, make sure it is big enough.

int ec_init ( const char *  ifname  ) 

Initialise lib in single NIC mode

Parameters:
[in] ifname = Dev name, f.e. "eth0"
Returns:
>0 if OK

int ec_init_redundant ( const char *  ifname,
const char *  if2name 
)

Initialise lib in redundant NIC mode

Parameters:
[in] ifname = Primary Dev name, f.e. "eth0"
[in] if2name = Secondary Dev name, f.e. "eth1"
Returns:
>0 if OK

int ec_mbxreceive ( uint16  slave,
ec_mbxbuft mbx,
int  timeout 
)

Read OUT mailbox from slave. Supports Mailbox Link Layer with repeat requests.

Parameters:
[in] slave = Slave number
[out] mbx = Mailbox data
[in] timeout = Timeout in us
Returns:
Work counter (>0 is success)

int ec_mbxsend ( uint16  slave,
ec_mbxbuft mbx,
int  timeout 
)

Write IN mailbox to slave.

Parameters:
[in] slave = Slave number
[out] mbx = Mailbox data
[in] timeout = Timeout in us
Returns:
Work counter (>0 is success)

uint8 ec_nextmbxcnt ( uint8  cnt  ) 

Get index of next mailbox counter value. Used for Mailbox Link Layer.

Parameters:
[in] cnt = Mailbox counter value [0..7]
Returns:
next mailbox counter value

boolean ec_poperror ( ec_errort Ec  ) 

Pops an error from the list.

Parameters:
[out] Ec = Struct describing the error.
Returns:
TRUE if an error was popped.

void ec_pusherror ( const ec_errort Ec  ) 

Pushes an error on the error list.

Parameters:
[in] Ec Struct describing the error.

uint32 ec_readeeprom ( uint16  slave,
uint16  eeproma,
int16  timeout 
)

Read EEPROM from slave bypassing cache.

Parameters:
[in] slave = Slave number
[in] eeproma = (WORD) Address in the EEPROM
[in] timeout = Timeout in us.
Returns:
EEPROM data 32bit

void ec_readeeprom1 ( uint16  slave,
uint16  eeproma 
)

Read EEPROM from slave bypassing cache. Parallel read step 1, make request to slave.

Parameters:
[in] slave = Slave number
[in] eeproma = (WORD) Address in the EEPROM

uint32 ec_readeeprom2 ( uint16  slave,
int16  timeout 
)

Read EEPROM from slave bypassing cache. Parallel read step 2, actual read from slave.

Parameters:
[in] slave = Slave number
[in] timeout = Timeout in us.
Returns:
EEPROM data 32bit

uint64 ec_readeepromFP ( uint16  configadr,
uint16  eeproma,
int16  timeout 
)

Read EEPROM from slave bypassing cache. FPRD method.

Parameters:
[in] configadr = configured address of slave
[in] eeproma = (WORD) Address in the EEPROM
[in] timeout = Timeout in us.
Returns:
EEPROM data 64bit or 32bit

int ec_readstate ( void   ) 

Read all slave states in ec_slave.

Returns:
lowest state found

int ec_receive_processdata ( int  timeout  ) 

Receive processdata from slaves. Second part from ec_send_processdata(). Received datagrams are recombined with the processdata with help from the stack. If a datagram contains input processdata it copies it to the processdata structure.

Parameters:
[in] timeout = Timeout in us.
Returns:
Work counter.

int ec_send_processdata ( void   ) 

Transmit processdata to slaves. Uses LRW, or LRD/LWR if LRW is not allowed (blockLRW). Both the input and output processdata are transmitted. The outputs with the actual data, the inputs have a placeholder. The inputs are gathered with the receive processdata function. In contrast to the base LRW function this function is non-blocking. If the processdata does not fit in one datagram, multiple are used. In order to recombine the slave response, a stack is used.

Returns:
>0 if processdata is transmitted.

int16 ec_siifind ( uint16  slave,
uint16  cat 
)

Find SII section header in slave EEPROM.

Parameters:
[in] slave = slave number
[in] cat = section category
Returns:
byte address of section at section length entry, if not available then 0

uint16 ec_siiFMMU ( uint16  slave,
ec_eepromFMMUt FMMU 
)

Get FMMU data from SII FMMU section in slave EEPROM.

Parameters:
[in] slave = slave number
[out] FMMU = FMMU struct from SII, max. 4 FMMU's
Returns:
number of FMMU's defined in section

uint8 ec_siigetbyte ( uint16  slave,
uint16  address 
)

Read one byte from slave EEPROM via cache. If the cache location is empty then a read request is made to the slave. Depending on the slave capabillities the request is 4 or 8 bytes.

Parameters:
[in] slave = slave number
[in] address = eeprom address in bytes (slave uses words)
Returns:
requested byte, if not available then 0xff

uint16 ec_siiPDO ( uint16  slave,
ec_eepromPDOt PDO,
uint8  t 
)

Get PDO data from SII PDO section in slave EEPROM.

Parameters:
[in] slave = slave number
[out] PDO = PDO struct from SII
[in] t = 0=RXPDO 1=TXPDO
Returns:
mapping size in bits of PDO

uint16 ec_siiSM ( uint16  slave,
ec_eepromSMt SM 
)

Get SM data from SII SM section in slave EEPROM.

Parameters:
[in] slave = slave number
[out] SM = first SM struct from SII
Returns:
number of SM's defined in section

uint16 ec_siiSMnext ( uint16  slave,
ec_eepromSMt SM,
uint16  n 
)

Get next SM data from SII SM section in slave EEPROM.

Parameters:
[in] slave = slave number
[out] SM = first SM struct from SII
[in] n = SM number
Returns:
>0 if OK

void ec_siistring ( char *  str,
uint16  slave,
uint16  Sn 
)

Get string from SII string section in slave EEPROM.

Parameters:
[out] str = requested string, 0x00 if not found
[in] slave = slave number
[in] Sn = string number

uint16 ec_statecheck ( uint16  slave,
uint16  reqstate,
int  timeout 
)

Check actual slave state. This is a blocking function.

Parameters:
[in] slave = Slave number, 0 = all slaves
[in] reqstate = Requested state
[in] timeout = Timout value in us
Returns:
Requested state, or found state after timeout.

int ec_writeeeprom ( uint16  slave,
uint16  eeproma,
uint16  data,
int16  timeout 
)

Write EEPROM to slave bypassing cache.

Parameters:
[in] slave = Slave number
[in] eeproma = (WORD) Address in the EEPROM
[in] data = 16bit data
[in] timeout = Timeout in us.
Returns:
>0 if OK

int ec_writeeepromFP ( uint16  configadr,
uint16  eeproma,
uint16  data,
int16  timeout 
)

Write EEPROM to slave bypassing cache. FPWR method.

Parameters:
[in] configadr = configured address of slave
[in] eeproma = (WORD) Address in the EEPROM
[in] data = 16bit data
[in] timeout = Timeout in us.
Returns:
>0 if OK

int ec_writestate ( uint16  slave  ) 

Write slave state, if slave = 0 then write to all slaves. The function does not check if the actual state is changed.

Parameters:
[in] slave = Slave number, 0 = master
Returns:
0


Variable Documentation

ec_slavet ec_slave[EC_MAXSLAVE]

main slave data structure array

Main slave data array. Each slave found on the network gets its own record. ec_slave[0] is reserved for the master. Structure gets filled in by the configuration function ec_config().

number of slaves found by configuration function

number of slaves found on the network


Generated on Sat Sep 12 23:04:10 2009 for SOEM by  doxygen 1.5.8