fp@39: /****************************************************************************** fp@0: * fp@39: * $Id$ fp@0: * fp@1618: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@1618: * fp@1618: * This file is part of the IgH EtherCAT Master. fp@1618: * fp@1618: * The IgH EtherCAT Master is free software; you can redistribute it fp@1618: * and/or modify it under the terms of the GNU General Public License fp@1619: * as published by the Free Software Foundation; either version 2 of the fp@1619: * License, or (at your option) any later version. fp@1618: * fp@1618: * The IgH EtherCAT Master is distributed in the hope that it will be fp@1618: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1618: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@1618: * GNU General Public License for more details. fp@1618: * fp@1618: * You should have received a copy of the GNU General Public License fp@1618: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@1618: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1618: * fp@1619: * The right to use EtherCAT Technology is granted and comes free of fp@1619: * charge under condition of compatibility of product made by fp@1619: * Licensee. People intending to distribute/sell products based on the fp@1619: * code, have to sign an agreement to guarantee that products using fp@1619: * software based on IgH EtherCAT master stay compatible with the actual fp@1619: * EtherCAT specification (which are released themselves as an open fp@1619: * standard) as the (only) precondition to have the right to use EtherCAT fp@1619: * Technology, IP and trade marks. fp@1619: * fp@39: *****************************************************************************/ fp@0: fp@1618: /** fp@1618: \file fp@1618: EtherCAT master structure. fp@1618: */ fp@1618: fp@1618: /*****************************************************************************/ fp@1618: 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@1619: #include "fsm.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@1624: EC_MASTER_MODE_ORPHANED, fp@191: EC_MASTER_MODE_IDLE, fp@191: EC_MASTER_MODE_RUNNING fp@191: } fp@191: ec_master_mode_t; fp@191: fp@191: /*****************************************************************************/ fp@191: fp@191: /** fp@1618: Cyclic statistics. fp@98: */ fp@98: fp@98: typedef struct fp@98: { fp@1624: unsigned int timeouts; /**< datagram timeouts */ fp@1624: unsigned int delayed; /**< delayed datagrams */ fp@195: unsigned int corrupted; /**< corrupted frames */ fp@1624: unsigned int unmatched; /**< unmatched datagrams */ 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@1618: EtherCAT master. fp@195: Manages slaves, domains and IO. fp@0: */ fp@0: fp@55: struct ec_master fp@0: { fp@1619: struct list_head list; /**< list item for module's master list */ fp@1619: unsigned int reserved; /**< non-zero, if the master is reserved for RT */ fp@1619: unsigned int index; /**< master index */ fp@1619: fp@195: struct kobject kobj; /**< kobject */ fp@1619: 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@1619: fp@195: ec_device_t *device; /**< EtherCAT device */ fp@1619: fp@1624: struct list_head datagram_queue; /**< datagram queue */ fp@1624: uint8_t datagram_index; /**< current datagram index */ fp@1619: fp@195: struct list_head domains; /**< list of domains */ fp@1619: fp@1624: ec_datagram_t simple_datagram; /**< datagram structure for fp@1624: initialization */ fp@1619: unsigned int timeout; /**< timeout in synchronous IO */ fp@1619: fp@195: int debug_level; /**< master debug level */ fp@195: ec_stats_t stats; /**< cyclic statistics */ fp@1619: fp@1619: struct workqueue_struct *workqueue; /**< master workqueue */ fp@1624: struct work_struct idle_work; /**< free run work object */ fp@1619: ec_fsm_t fsm; /**< master state machine */ fp@195: ec_master_mode_t mode; /**< master mode */ fp@1619: fp@1623: struct timer_list eoe_timer; /**< EoE timer object */ fp@1619: unsigned int eoe_running; /**< non-zero, if EoE processing is active. */ fp@1619: struct list_head eoe_handlers; /**< Ethernet-over-EtherCAT handlers */ fp@1624: spinlock_t internal_lock; /**< spinlock used in idle mode */ fp@1619: int (*request_cb)(void *); /**< lock request callback */ fp@1619: void (*release_cb)(void *); /**< lock release callback */ fp@1619: void *cb_data; /**< data parameter of locking callbacks */ fp@1621: fp@1621: uint8_t eeprom_write_enable; /**< allow write operations to EEPROMs */ fp@55: }; fp@0: fp@39: /*****************************************************************************/ fp@0: fp@195: // master creation and deletion fp@1619: int ec_master_init(ec_master_t *, unsigned int, 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@1624: void ec_master_idle_start(ec_master_t *); fp@1624: void ec_master_idle_stop(ec_master_t *); fp@191: fp@1619: // EoE fp@1619: void ec_master_eoe_start(ec_master_t *); fp@1619: void ec_master_eoe_stop(ec_master_t *); fp@1619: fp@98: // IO fp@98: void ec_master_receive(ec_master_t *, const uint8_t *, size_t); fp@1624: void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *); fp@1624: int ec_master_simple_io(ec_master_t *, ec_datagram_t *); fp@0: fp@195: // slave management fp@98: int ec_master_bus_scan(ec_master_t *); fp@0: fp@195: // misc. fp@1619: void ec_master_clear_slaves(ec_master_t *); fp@1621: void ec_sync_config(const ec_sync_t *, const ec_slave_t *, uint8_t *); fp@1624: void ec_eeprom_sync_config(const ec_eeprom_sync_t *, const ec_slave_t *, fp@1624: uint8_t *); fp@1621: void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *); fp@98: void ec_master_output_stats(ec_master_t *); fp@145: fp@39: /*****************************************************************************/ fp@0: fp@0: #endif