IgH EtherCAT Master  1.5.2
domain.c File Reference

EtherCAT domain methods. More...

Go to the source code of this file.

Macros

#define DEBUG_REDUNDANCY   0
 Extra debug output for redundancy functions.
 
#define list_next_entry(pos, member)   list_entry((pos)->member.next, typeof(*(pos)), member)
 

Functions

void ec_domain_clear_data (ec_domain_t *domain)
 Frees internally allocated memory. More...
 
void ec_domain_init (ec_domain_t *domain, ec_master_t *master, unsigned int index)
 Domain constructor. More...
 
void ec_domain_clear (ec_domain_t *domain)
 Domain destructor. More...
 
void ec_domain_add_fmmu_config (ec_domain_t *domain, ec_fmmu_config_t *fmmu)
 Adds an FMMU configuration to the domain. More...
 
int ec_domain_add_datagram_pair (ec_domain_t *domain, uint32_t logical_offset, size_t data_size, uint8_t *data, const unsigned int used[])
 Allocates a domain datagram pair and appends it to the list. More...
 
static int shall_count (const ec_fmmu_config_t *cur_fmmu, const ec_fmmu_config_t *first_fmmu)
 Domain finish helper function. More...
 
static int emplace_datagram (ec_domain_t *domain, uint32_t datagram_begin_offset, uint32_t datagram_end_offset, const ec_fmmu_config_t *datagram_first_fmmu, const ec_fmmu_config_t *datagram_end_fmmu)
 Domain finish helper function. More...
 
int ec_domain_finish (ec_domain_t *domain, uint32_t base_address)
 Finishes a domain. More...
 
unsigned int ec_domain_fmmu_count (const ec_domain_t *domain)
 Get the number of FMMU configurations of the domain.
 
const ec_fmmu_config_tec_domain_find_fmmu (const ec_domain_t *domain, unsigned int pos)
 Get a certain FMMU configuration via its position in the list. More...
 
int ecrt_domain_reg_pdo_entry_list (ec_domain_t *domain, const ec_pdo_entry_reg_t *regs)
 Registers a bunch of PDO entries for a domain. More...
 
size_t ecrt_domain_size (const ec_domain_t *domain)
 Returns the current size of the domain's process data. More...
 
void ecrt_domain_external_memory (ec_domain_t *domain, uint8_t *mem)
 Provide external memory to store the domain's process data. More...
 
uint8_t * ecrt_domain_data (ec_domain_t *domain)
 Returns the domain's process data. More...
 
void ecrt_domain_process (ec_domain_t *domain)
 Determines the states of the domain's datagrams. More...
 
void ecrt_domain_queue (ec_domain_t *domain)
 (Re-)queues all domain datagrams in the master's datagram queue. More...
 
void ecrt_domain_state (const ec_domain_t *domain, ec_domain_state_t *state)
 Reads the state of a domain. More...
 

Detailed Description

EtherCAT domain methods.

Definition in file domain.c.

Function Documentation

◆ ec_domain_clear_data()

void ec_domain_clear_data ( ec_domain_t domain)

Frees internally allocated memory.

Parameters
domainEtherCAT domain.

Definition at line 115 of file domain.c.

◆ ec_domain_init()

void ec_domain_init ( ec_domain_t domain,
ec_master_t master,
unsigned int  index 
)

Domain constructor.

Parameters
domainEtherCAT domain.
masterParent master.
indexIndex.

Definition at line 63 of file domain.c.

◆ ec_domain_clear()

void ec_domain_clear ( ec_domain_t domain)

Domain destructor.

Parameters
domainEtherCAT domain

Definition at line 97 of file domain.c.

◆ ec_domain_add_fmmu_config()

void ec_domain_add_fmmu_config ( ec_domain_t domain,
ec_fmmu_config_t fmmu 
)

Adds an FMMU configuration to the domain.

Parameters
domainEtherCAT domain.
fmmuFMMU configuration.

Definition at line 131 of file domain.c.

◆ ec_domain_add_datagram_pair()

int ec_domain_add_datagram_pair ( ec_domain_t domain,
uint32_t  logical_offset,
size_t  data_size,
uint8_t *  data,
const unsigned int  used[] 
)

Allocates a domain datagram pair and appends it to the list.

The datagrams' types and expected working counters are determined by the number of input and output fmmus that share the datagrams.

Return values
0Success.
<0Error code.
Parameters
domainEtherCAT domain.
logical_offsetLogical offset.
data_sizeSize of the data.
dataProcess data.
usedSlave config counter for in/out.

Definition at line 187 of file domain.c.

◆ shall_count()

static int shall_count ( const ec_fmmu_config_t cur_fmmu,
const ec_fmmu_config_t first_fmmu 
)
static

Domain finish helper function.

Detects, if a slave configuration has already been taken into account for a datagram's expected working counter calculation.

Walks through the list of all FMMU configurations for the current datagram and ends before the current datagram.

Returns
Non-zero if slave connfig was already counted.
Parameters
cur_fmmuCurrent FMMU with direction to search for.
first_fmmuDatagram's first FMMU.

Definition at line 235 of file domain.c.

◆ emplace_datagram()

static int emplace_datagram ( ec_domain_t domain,
uint32_t  datagram_begin_offset,
uint32_t  datagram_end_offset,
const ec_fmmu_config_t datagram_first_fmmu,
const ec_fmmu_config_t datagram_end_fmmu 
)
static

Domain finish helper function.

Known boundaries for a datagram have been identified. Scans the datagram FMMU boundaries for WKC counters and then creates the datagram_pair.

Parameters
domainThe parent domain
datagram_begin_offsetDatagram's logical beginning offset
datagram_end_offsetLogical end offset (one past last byte)
datagram_first_fmmuThe begin FMMU in the datagram
datagram_end_fmmuThe end (one past last) FMMU
Returns
Non-zero if error emplacing domain

Definition at line 269 of file domain.c.

◆ ec_domain_finish()

int ec_domain_finish ( ec_domain_t domain,
uint32_t  base_address 
)

Finishes a domain.

This allocates the necessary datagrams and writes the correct logical addresses to every configured FMMU.

Return values
0Success
<0Error code.
Parameters
domainEtherCAT domain.
base_addressLogical base address.

Definition at line 308 of file domain.c.

◆ ec_domain_find_fmmu()

const ec_fmmu_config_t* ec_domain_find_fmmu ( const ec_domain_t domain,
unsigned int  pos 
)

Get a certain FMMU configuration via its position in the list.

Returns
FMMU at position pos, or NULL.
Parameters
domainEtherCAT domain.
posList position.

Definition at line 426 of file domain.c.