EtherCAT realtime interface


Detailed Description

EtherCAT interface for realtime modules.

This interface is designed for realtime modules that want to use EtherCAT. There are functions to request a master, to map process data, to communicate with slaves via CoE and to configure and activate the bus.


Functions

ec_slave_tecrt_domain_register_pdo (ec_domain_t *domain, const char *address, uint32_t vendor_id, uint32_t product_code, uint16_t pdo_index, uint8_t pdo_subindex, void **data_ptr)
 Registers a PDO in a domain.
int ecrt_domain_register_pdo_list (ec_domain_t *domain, const ec_pdo_reg_t *pdos)
 Registeres a bunch of data fields.
void ecrt_domain_process (ec_domain_t *domain)
 Processes received process data and requeues the domain datagram(s).
int ecrt_domain_state (const ec_domain_t *domain)
 Returns the state of a domain.
ec_domain_tecrt_master_create_domain (ec_master_t *master)
 Creates a domain.
int ecrt_master_activate (ec_master_t *master)
 Configures all slaves and leads them to the OP state.
void ecrt_master_deactivate (ec_master_t *master)
 Resets all slaves to INIT state.
void ecrt_master_send (ec_master_t *master)
 Asynchronous sending of datagrams.
void ecrt_master_receive (ec_master_t *master)
 Asynchronous receiving of datagrams.
void ecrt_master_prepare (ec_master_t *master)
 Prepares synchronous IO.
void ecrt_master_run (ec_master_t *master)
 Does all cyclic master work.
ec_slave_tecrt_master_get_slave (const ec_master_t *master, const char *address)
 Translates an ASCII coded bus-address to a slave pointer.
void ecrt_master_callbacks (ec_master_t *master, int(*request_cb)(void *), void(*release_cb)(void *), void *cb_data)
 Sets the locking callbacks.
ec_master_tecrt_request_master (unsigned int master_index)
 Reserves an EtherCAT master for realtime operation.
void ecrt_release_master (ec_master_t *master)
 Releases a reserved EtherCAT master.
int ecrt_slave_conf_sdo8 (ec_slave_t *slave, uint16_t sdo_index, uint8_t sdo_subindex, uint8_t value)
int ecrt_slave_conf_sdo16 (ec_slave_t *slave, uint16_t sdo_index, uint8_t sdo_subindex, uint16_t value)
int ecrt_slave_conf_sdo32 (ec_slave_t *slave, uint16_t sdo_index, uint8_t sdo_subindex, uint32_t value)
int ecrt_slave_pdo_size (ec_slave_t *slave, uint16_t pdo_index, uint8_t pdo_subindex, size_t size)


Function Documentation

ec_slave_t* ecrt_domain_register_pdo ec_domain_t domain,
const char *  address,
uint32_t  vendor_id,
uint32_t  product_code,
uint16_t  pdo_index,
uint8_t  pdo_subindex,
void **  data_ptr
 

Registers a PDO in a domain.

  • If data_ptr is NULL, the slave is only validated.
    Returns:
    pointer to the slave on success, else NULL
Parameters:
domain  EtherCAT domain
address  ASCII address of the slave, see ecrt_master_get_slave()
vendor_id  vendor ID
product_code  product code
pdo_index  PDO index
pdo_subindex  PDO subindex
data_ptr  address of the process data pointer

Definition at line 416 of file domain.c.

int ecrt_domain_register_pdo_list ec_domain_t domain,
const ec_pdo_reg_t pdos
 

Registeres a bunch of data fields.

Caution! The list has to be terminated with a NULL structure ({})!

Returns:
0 in case of success, else < 0
Parameters:
domain  EtherCAT domain
pdos  array of PDO registrations

Definition at line 485 of file domain.c.

void ecrt_domain_process ec_domain_t domain  ) 
 

Processes received process data and requeues the domain datagram(s).

Parameters:
domain  EtherCAT domain

Definition at line 512 of file domain.c.

int ecrt_domain_state const ec_domain_t domain  ) 
 

Returns the state of a domain.

Returns:
0 if all datagrams were received, else -1.
Parameters:
domain  EtherCAT domain

Definition at line 555 of file domain.c.

ec_domain_t* ecrt_master_create_domain ec_master_t master  ) 
 

Creates a domain.

Returns:
pointer to new domain on success, else NULL
Parameters:
master  master

Definition at line 1112 of file master.c.

int ecrt_master_activate ec_master_t master  ) 
 

Configures all slaves and leads them to the OP state.

Does the complete configuration and activation for all slaves. Sets sync managers and FMMUs, and does the appropriate transitions, until the slave is operational.

Returns:
0 in case of success, else < 0
Parameters:
master  EtherCAT master

Definition at line 1158 of file master.c.

void ecrt_master_deactivate ec_master_t master  ) 
 

Resets all slaves to INIT state.

Parameters:
master  EtherCAT master

Definition at line 1209 of file master.c.

void ecrt_master_send ec_master_t master  ) 
 

Asynchronous sending of datagrams.

Parameters:
master  EtherCAT master

Definition at line 1262 of file master.c.

void ecrt_master_receive ec_master_t master  ) 
 

Asynchronous receiving of datagrams.

Parameters:
master  EtherCAT master

Definition at line 1289 of file master.c.

void ecrt_master_prepare ec_master_t master  ) 
 

Prepares synchronous IO.

Queues all domain datagrams and sends them. Then waits a certain time, so that ecrt_master_receive() can be called securely.

Parameters:
master  EtherCAT master

Definition at line 1326 of file master.c.

void ecrt_master_run ec_master_t master  ) 
 

Does all cyclic master work.

Parameters:
master  EtherCAT master

Definition at line 1354 of file master.c.

ec_slave_t* ecrt_master_get_slave const ec_master_t master,
const char *  address
 

Translates an ASCII coded bus-address to a slave pointer.

These are the valid addressing schemes:

  • "X" = the X. slave on the bus,
  • "X:Y" = the Y. slave after the X. branch (bus coupler),
  • "#X" = the slave with alias X,
  • "#X:Y" = the Y. slave after the branch (bus coupler) with alias X. X and Y are zero-based indices and may be provided in hexadecimal or octal notation (with respective prefix).
    Returns:
    pointer to the slave on success, else NULL
Parameters:
master  Master
address  address string

Definition at line 1378 of file master.c.

void ecrt_master_callbacks ec_master_t master,
int(*)(void *)  request_cb,
void(*)(void *)  release_cb,
void *  cb_data
 

Sets the locking callbacks.

The request_cb function must return zero, to allow another instance (the EoE process for example) to access the master. Non-zero means, that access is forbidden at this time.

Parameters:
master  EtherCAT master
request_cb  request lock CB
release_cb  release lock CB
cb_data  data parameter

Definition at line 1480 of file master.c.

ec_master_t* ecrt_request_master unsigned int  master_index  ) 
 

Reserves an EtherCAT master for realtime operation.

Returns:
pointer to reserved master, or NULL on error
Parameters:
master_index  master index

Definition at line 407 of file module.c.

void ecrt_release_master ec_master_t master  ) 
 

Releases a reserved EtherCAT master.

Parameters:
master  EtherCAT master

Definition at line 466 of file module.c.

int ecrt_slave_conf_sdo8 ec_slave_t slave,
uint16_t  sdo_index,
uint8_t  sdo_subindex,
uint8_t  value
 

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
sdo_index  SDO index
sdo_subindex  SDO subindex
value  new SDO value

Definition at line 915 of file slave.c.

int ecrt_slave_conf_sdo16 ec_slave_t slave,
uint16_t  sdo_index,
uint8_t  sdo_subindex,
uint16_t  value
 

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
sdo_index  SDO index
sdo_subindex  SDO subindex
value  new SDO value

Definition at line 933 of file slave.c.

int ecrt_slave_conf_sdo32 ec_slave_t slave,
uint16_t  sdo_index,
uint8_t  sdo_subindex,
uint32_t  value
 

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
sdo_index  SDO index
sdo_subindex  SDO subindex
value  new SDO value

Definition at line 951 of file slave.c.

int ecrt_slave_pdo_size ec_slave_t slave,
uint16_t  pdo_index,
uint8_t  pdo_subindex,
size_t  size
 

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
pdo_index  PDO index
pdo_subindex  PDO subindex
size  new PDO size

Definition at line 969 of file slave.c.


Generated on Fri Sep 1 14:56:57 2006 for IgH EtherCAT master by  doxygen 1.4.6