fp@39: /****************************************************************************** fp@0: * fp@54: * m a s t e r . h fp@0: * fp@195: * EtherCAT master structure. fp@0: * fp@39: * $Id$ fp@0: * fp@39: *****************************************************************************/ fp@0: fp@0: #ifndef _EC_MASTER_H_ fp@0: #define _EC_MASTER_H_ fp@0: fp@95: #include fp@178: #include fp@191: #include fp@95: fp@54: #include "device.h" fp@54: #include "domain.h" fp@0: fp@39: /*****************************************************************************/ fp@0: fp@0: /** fp@191: EtherCAT master mode. fp@191: */ fp@191: fp@191: typedef enum fp@191: { fp@191: EC_MASTER_MODE_IDLE, fp@191: EC_MASTER_MODE_FREERUN, fp@191: EC_MASTER_MODE_RUNNING fp@191: } fp@191: ec_master_mode_t; fp@191: fp@191: /*****************************************************************************/ fp@191: fp@191: /** fp@195: Cyclic EtherCAT statistics. fp@98: */ fp@98: fp@98: typedef struct fp@98: { fp@195: unsigned int timeouts; /**< command timeouts */ fp@195: unsigned int delayed; /**< delayed commands */ fp@195: unsigned int corrupted; /**< corrupted frames */ fp@195: unsigned int unmatched; /**< unmatched commands */ fp@195: unsigned int eoe_errors; /**< Ethernet-over-EtherCAT errors */ fp@195: cycles_t t_last; /**< time of last output */ fp@98: } fp@98: ec_stats_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@195: EtherCAT-Master. fp@195: Manages slaves, domains and IO. fp@0: */ fp@0: fp@55: struct ec_master fp@0: { fp@195: struct list_head list; /**< list item */ fp@195: struct kobject kobj; /**< kobject */ fp@195: unsigned int index; /**< master index */ fp@195: struct list_head slaves; /**< list of slaves on the bus */ fp@195: unsigned int slave_count; /**< number of slaves on the bus */ fp@195: ec_device_t *device; /**< EtherCAT device */ fp@195: struct list_head command_queue; /**< command queue */ fp@195: uint8_t command_index; /**< current command index */ fp@195: struct list_head domains; /**< list of domains */ fp@195: ec_command_t simple_command; /**< command structure for initialization */ fp@195: ec_command_t watch_command; /**< command for watching the slaves */ fp@195: unsigned int slaves_responding; /**< number of responding slaves */ fp@195: ec_slave_state_t slave_states; /**< states of the responding slaves */ fp@195: int debug_level; /**< master debug level */ fp@195: ec_stats_t stats; /**< cyclic statistics */ fp@195: unsigned int timeout; /**< timeout in synchronous IO */ fp@195: struct list_head eoe_slaves; /**< Ethernet-over-EtherCAT slaves */ fp@195: unsigned int reserved; /**< true, if the master is reserved for RT */ fp@195: struct timer_list freerun_timer; /**< timer object for free run mode */ fp@195: ec_master_mode_t mode; /**< master mode */ fp@55: }; fp@0: fp@39: /*****************************************************************************/ fp@0: fp@195: // master creation and deletion fp@178: int ec_master_init(ec_master_t *, unsigned int); fp@178: void ec_master_clear(struct kobject *); fp@56: void ec_master_reset(ec_master_t *); fp@98: fp@195: // free run fp@191: void ec_master_freerun_start(ec_master_t *); fp@191: void ec_master_freerun_stop(ec_master_t *); fp@191: fp@98: // IO fp@98: void ec_master_receive(ec_master_t *, const uint8_t *, size_t); fp@98: void ec_master_queue_command(ec_master_t *, ec_command_t *); fp@145: int ec_master_simple_io(ec_master_t *, ec_command_t *); fp@0: fp@195: // slave management fp@98: int ec_master_bus_scan(ec_master_t *); fp@0: fp@195: // misc. fp@98: void ec_master_debug(const ec_master_t *); fp@98: void ec_master_output_stats(ec_master_t *); fp@145: void ec_master_run_eoe(ec_master_t *); fp@145: fp@39: /*****************************************************************************/ fp@0: fp@0: #endif