libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
ec.h File Reference

ethercat master functions. More...

#include <libosal/types.h>
#include "libethercat/common.h"
#include "libethercat/dc.h"
#include "libethercat/slave.h"
#include "libethercat/hw.h"
#include "libethercat/regs.h"
#include "libethercat/idx.h"
#include "libethercat/datagram.h"
#include "libethercat/pool.h"
#include "libethercat/async_loop.h"
#include "libethercat/eeprom.h"

Go to the source code of this file.

Data Structures

struct  ec_pd_group
 process data group structure More...
 
struct  ec
 ethercat master structure More...
 

Macros

#define EC_SHORT_TIMEOUT_MBX   (10000000)
 Short timeout value in [ns].
 
#define EC_DEFAULT_TIMEOUT_MBX   (1000000000)
 Default timeout value in [ns].
 
#define EC_DEFAULT_DELAY   (2000000)
 Default delay in [ns].
 
#define ec_log(lvl, pre, format, ...)    _ec_log(pec, (lvl), (pre), (format), ##__VA_ARGS__)
 
#define ec_group_will_be_sent(pec, group)   (int)((((pec)->pd_groups[(group)].divisor_cnt+1) % (pec)->pd_groups[(group)].divisor) == 0)
 Group datagram will be send on next time step.
 
#define ec_group_was_sent(pec, group)   (int)((pec)->pd_groups[(group)].divisor_cnt == 0)
 Group datagram was sent.
 
#define ec_to_adr(ado, adp)    ((osal_uint32_t)(adp) << 16u) | ((ado) & 0xFFFFu)
 Macro for EtherCAT address generation.
 
#define ec_brd(pec, ado, data, datalen, wkc)
 Perform a broadcast read (BRD).
 
#define ec_bwr(pec, ado, data, datalen, wkc)
 Perform a broadcast write (BWR).
 
#define ec_brw(pec, ado, data, datalen, wkc)
 Perform a broadcast read/write (BRW).
 
#define ec_aprd(pec, adp, ado, data, datalen, wkc)
 Perform a positional physical read (APRD)
 
#define ec_apwr(pec, adp, ado, data, datalen, wkc)
 Perform a positional physical write (APWR)
 
#define ec_aprw(pec, adp, ado, data, datalen, wkc)
 Perform a positional physical read/write (APRW)
 
#define ec_fprd(pec, adp, ado, data, datalen, wkc)
 Perform a configured-address physical read (FPRD)
 
#define ec_fpwr(pec, adp, ado, data, datalen, wkc)
 Perform a configured-address physical write (FPWR)
 
#define ec_fprw(pec, adp, ado, data, datalen, wkc)
 Perform a configured-address physical read/write (FPRW)
 
#define ec_frmw(pec, adp, ado, data, datalen, wkc)
 Perform a configured-address physical read/multiple-write (FPMW)
 
#define check_ret(fcn, ...)
 Macro that checks return value and prints message in error case.
 
#define check_ec_bwr(...)   check_ret(ec_bwr, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_brd(...)   check_ret(ec_brd, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_brw(...)   check_ret(ec_brw, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_apwr(...)   check_ret(ec_apwr, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_aprd(...)   check_ret(ec_aprd, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_aprw(...)   check_ret(ec_aprw, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_fpwr(...)   check_ret(ec_fpwr, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_fprd(...)   check_ret(ec_fprd, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_fprw(...)   check_ret(ec_fprw, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 
#define check_ec_frmw(...)   check_ret(ec_frmw, __VA_ARGS__)
 Macro that checks return value and prints message in error case.
 

Typedefs

typedef struct ec_slave ec_slave_t
 
typedef struct ec_pd_group ec_pd_group_t
 process data group structure
 
typedef struct ec ec_t
 ethercat master structure
 

Functions

void _ec_log (ec_t *pec, int lvl, const osal_char_t *pre, const osal_char_t *format,...)
 EtherCAT logging function.
 
int ec_open (ec_t *pec, struct hw_common *phw, int eeprom_log)
 Open ethercat master.
 
int ec_close (ec_t *pec)
 Closes ethercat master.
 
int ec_configure_tun (ec_t *pec, osal_uint8_t ip_address[4])
 Configures tun device of EtherCAT master, used for EoE slaves.
 
void ec_configure_dc (ec_t *pec, osal_uint64_t timer, ec_dc_mode_t mode, void(*user_cb)(void *arg, int num), void *user_cb_arg)
 Configures distributed clocks settings on EtherCAT master.
 
int ec_create_pd_groups (ec_t *pec, osal_uint32_t pd_group_cnt)
 Create process data groups.
 
void ec_configure_pd_group (ec_t *pec, osal_uint16_t group, int clock_divisor, void(*user_cb)(void *arg, int num), void *user_cb_arg)
 Configure process data group settings.
 
int ec_destroy_pd_groups (ec_t *pec)
 Destroy process data groups.
 
int ec_transceive (ec_t *pec, osal_uint8_t cmd, osal_uint32_t adr, osal_uint8_t *data, osal_size_t datalen, osal_uint16_t *wkc)
 Syncronous ethercat read/write.
 
int ec_transmit_no_reply (ec_t *pec, osal_uint8_t cmd, osal_uint32_t adr, osal_uint8_t *data, osal_size_t datalen)
 Asyncronous ethercat read/write, answer don't care.
 
int ec_set_state (ec_t *pec, ec_state_t state)
 Set state on ethercat bus.
 
int ec_send_process_data (ec_t *pec)
 send process data with logical commands
 
int ec_send_distributed_clocks_sync (ec_t *pec)
 Send distributed clocks sync datagram.
 
int ec_send_distributed_clocks_sync_with_rtc (ec_t *pec, osal_uint64_t act_rtc_time)
 Send distributed clock sync datagram.
 
int ec_send_brd_ec_state (ec_t *pec)
 Send broadcast read to ec state.
 
int ec_get_slave_count (ec_t *pec)
 Return current slave count.
 

Detailed Description

ethercat master functions.

Author
Robert Burger rober.nosp@m.t.bu.nosp@m.rger@.nosp@m.dlr..nosp@m.de
Date
22 Nov 2016

These are EtherCAT master specific configuration functions.