#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 uint8 ec_mbxbuft[EC_MAXMBX+1] |
mailbox buffer array
void ec_clearmbx | ( | ec_mbxbuft * | Mbx | ) |
Clear mailbox buffer.
[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.
[in] | slave | = Slave number |
int ec_eeprom2pdi | ( | uint16 | slave | ) |
Set eeprom control to PDI. Only if set to master.
[in] | slave | = Slave number |
Dump complete EEPROM data from slave in buffer.
[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
[in] | ifname | = Dev name, f.e. "eth0" |
int ec_init_redundant | ( | const char * | ifname, | |
const char * | if2name | |||
) |
Initialise lib in redundant NIC mode
[in] | ifname | = Primary Dev name, f.e. "eth0" |
[in] | if2name | = Secondary Dev name, f.e. "eth1" |
int ec_mbxreceive | ( | uint16 | slave, | |
ec_mbxbuft * | mbx, | |||
int | timeout | |||
) |
Read OUT mailbox from slave. Supports Mailbox Link Layer with repeat requests.
[in] | slave | = Slave number |
[out] | mbx | = Mailbox data |
[in] | timeout | = Timeout in us |
int ec_mbxsend | ( | uint16 | slave, | |
ec_mbxbuft * | mbx, | |||
int | timeout | |||
) |
Write IN mailbox to slave.
[in] | slave | = Slave number |
[out] | mbx | = Mailbox data |
[in] | timeout | = Timeout in us |
Get index of next mailbox counter value. Used for Mailbox Link Layer.
[in] | cnt | = Mailbox counter value [0..7] |
Pops an error from the list.
[out] | Ec | = Struct describing the error. |
void ec_pusherror | ( | const ec_errort * | Ec | ) |
Pushes an error on the error list.
[in] | Ec | Struct describing the error. |
Read EEPROM from slave bypassing cache.
[in] | slave | = Slave number |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | timeout | = Timeout in us. |
Read EEPROM from slave bypassing cache. Parallel read step 1, make request to slave.
[in] | slave | = Slave number |
[in] | eeproma | = (WORD) Address in the EEPROM |
Read EEPROM from slave bypassing cache. Parallel read step 2, actual read from slave.
[in] | slave | = Slave number |
[in] | timeout | = Timeout in us. |
Read EEPROM from slave bypassing cache. FPRD method.
[in] | configadr | = configured address of slave |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | timeout | = Timeout in us. |
int ec_readstate | ( | void | ) |
Read all slave states in ec_slave.
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.
[in] | timeout | = Timeout in us. |
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.
Find SII section header in slave EEPROM.
[in] | slave | = slave number |
[in] | cat | = section category |
uint16 ec_siiFMMU | ( | uint16 | slave, | |
ec_eepromFMMUt * | FMMU | |||
) |
Get FMMU data from SII FMMU section in slave EEPROM.
[in] | slave | = slave number |
[out] | FMMU | = FMMU struct from SII, max. 4 FMMU's |
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.
[in] | slave | = slave number |
[in] | address | = eeprom address in bytes (slave uses words) |
uint16 ec_siiPDO | ( | uint16 | slave, | |
ec_eepromPDOt * | PDO, | |||
uint8 | t | |||
) |
Get PDO data from SII PDO section in slave EEPROM.
[in] | slave | = slave number |
[out] | PDO | = PDO struct from SII |
[in] | t | = 0=RXPDO 1=TXPDO |
uint16 ec_siiSM | ( | uint16 | slave, | |
ec_eepromSMt * | SM | |||
) |
Get SM data from SII SM section in slave EEPROM.
[in] | slave | = slave number |
[out] | SM | = first SM struct from SII |
uint16 ec_siiSMnext | ( | uint16 | slave, | |
ec_eepromSMt * | SM, | |||
uint16 | n | |||
) |
Get next SM data from SII SM section in slave EEPROM.
[in] | slave | = slave number |
[out] | SM | = first SM struct from SII |
[in] | n | = SM number |
Get string from SII string section in slave EEPROM.
[out] | str | = requested string, 0x00 if not found |
[in] | slave | = slave number |
[in] | Sn | = string number |
Check actual slave state. This is a blocking function.
[in] | slave | = Slave number, 0 = all slaves |
[in] | reqstate | = Requested state |
[in] | timeout | = Timout value in us |
Write EEPROM to slave bypassing cache.
[in] | slave | = Slave number |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | data | = 16bit data |
[in] | timeout | = Timeout in us. |
Write EEPROM to slave bypassing cache. FPWR method.
[in] | configadr | = configured address of slave |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | data | = 16bit data |
[in] | timeout | = Timeout in us. |
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.
[in] | slave | = Slave number, 0 = master |
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().
int ec_slavecount |
number of slaves found by configuration function
number of slaves found on the network