fp@792: /****************************************************************************** fp@792: * fp@792: * $Id$ fp@792: * fp@1326: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH fp@792: * fp@792: * This file is part of the IgH EtherCAT Master. fp@792: * fp@1326: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1326: * modify it under the terms of the GNU General Public License version 2, as fp@1326: * published by the Free Software Foundation. fp@792: * fp@1326: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1326: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1326: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1326: * Public License for more details. fp@792: * fp@1326: * You should have received a copy of the GNU General Public License along fp@1326: * with the IgH EtherCAT Master; if not, write to the Free Software fp@792: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@792: * fp@1363: * --- fp@1363: * fp@1363: * The license mentioned above concerns the source code only. Using the fp@1363: * EtherCAT technology and brand is only permitted in compliance with the fp@1363: * industrial property and similar rights of Beckhoff Automation GmbH. fp@792: * fp@792: *****************************************************************************/ fp@792: fp@792: /** fp@792: \file fp@792: EtherCAT slave configuration structure. fp@792: */ fp@792: fp@792: /*****************************************************************************/ fp@792: fp@883: #ifndef __EC_SLAVE_CONFIG_H__ fp@883: #define __EC_SLAVE_CONFIG_H__ fp@792: fp@792: #include fp@792: fp@792: #include "globals.h" fp@792: #include "slave.h" fp@1055: #include "sync_config.h" fp@792: #include "fmmu_config.h" fp@792: fp@792: /*****************************************************************************/ fp@792: fp@1921: /** Convenience macro for printing configuration-specific information to fp@1921: * syslog. fp@1921: * fp@1921: * This will print the message in \a fmt with a prefixed fp@1921: * "EtherCAT :: ", where INDEX is the master index fp@1921: * and ALIAS and POSITION identify the configuration. fp@1921: * fp@1921: * \param sc EtherCAT slave configuration fp@1921: * \param fmt format string (like in printf()) fp@1921: * \param args arguments (optional) fp@1921: */ fp@1921: #define EC_CONFIG_INFO(sc, fmt, args...) \ fp@1921: printk(KERN_INFO "EtherCAT %u %u:%u: " fmt, sc->master->index, \ fp@1921: sc->alias, sc->position, ##args) fp@1921: fp@1921: /** Convenience macro for printing configuration-specific errors to syslog. fp@1921: * fp@1921: * This will print the message in \a fmt with a prefixed fp@1921: * "EtherCAT :: ", where INDEX is the master index fp@1921: * and ALIAS and POSITION identify the configuration. fp@1921: * fp@1921: * \param sc EtherCAT slave configuration fp@1921: * \param fmt format string (like in printf()) fp@1921: * \param args arguments (optional) fp@1921: */ fp@1921: #define EC_CONFIG_ERR(sc, fmt, args...) \ fp@1921: printk(KERN_ERR "EtherCAT ERROR %u %u:%u: " fmt, sc->master->index, \ fp@1921: sc->alias, sc->position, ##args) fp@1921: fp@1921: /** Convenience macro for printing configuration-specific warnings to syslog. fp@1921: * fp@1921: * This will print the message in \a fmt with a prefixed fp@1921: * "EtherCAT :: ", where INDEX is the master index fp@1921: * and ALIAS and POSITION identify the configuration. fp@1921: * fp@1921: * \param sc EtherCAT slave configuration fp@1921: * \param fmt format string (like in printf()) fp@1921: * \param args arguments (optional) fp@1921: */ fp@1921: #define EC_CONFIG_WARN(sc, fmt, args...) \ fp@1921: printk(KERN_WARNING "EtherCAT WARNING %u %u:%u: " fmt, \ fp@1921: sc->master->index, sc->alias, sc->position, ##args) fp@1921: fp@1921: /** Convenience macro for printing configuration-specific debug messages to fp@1921: * syslog. fp@1921: * fp@1921: * This will print the message in \a fmt with a prefixed fp@1921: * "EtherCAT :: ", where INDEX is the master index fp@1921: * and ALIAS and POSITION identify the configuration. fp@1921: * fp@1921: * \param sc EtherCAT slave configuration fp@1921: * \param fmt format string (like in printf()) fp@1921: * \param args arguments (optional) fp@1921: */ fp@1921: #define EC_CONFIG_DBG(sc, level, fmt, args...) \ fp@1921: do { \ fp@1921: if (sc->master->debug_level >= level) { \ fp@1921: printk(KERN_DEBUG "EtherCAT DEBUG %u %u:%u: " fmt, \ fp@1921: sc->master->index, sc->alias, sc->position, ##args); \ fp@1921: } \ fp@1921: } while (0) fp@1921: fp@1921: /*****************************************************************************/ fp@1921: fp@792: /** EtherCAT slave configuration. fp@792: */ fp@792: struct ec_slave_config { fp@792: struct list_head list; /**< List item. */ fp@792: ec_master_t *master; /**< Master owning the slave configuration. */ fp@792: fp@792: uint16_t alias; /**< Slave alias. */ fp@792: uint16_t position; /**< Index after alias. If alias is zero, this is the fp@792: ring position. */ fp@792: uint32_t vendor_id; /**< Slave vendor ID. */ fp@792: uint32_t product_code; /**< Slave product code. */ fp@792: fp@1509: uint16_t watchdog_divider; /**< Watchdog divider as a number of 40ns fp@1509: intervals (see spec. reg. 0x0400). */ fp@1509: uint16_t watchdog_intervals; /**< Process data watchdog intervals (see fp@1509: spec. reg. 0x0420). */ fp@1509: fp@792: ec_slave_t *slave; /**< Slave pointer. This is \a NULL, if the slave is fp@792: offline. */ fp@792: fp@1082: ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]; /**< Sync manager fp@1055: configurations. */ fp@1055: ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]; /**< FMMU configurations. */ fp@1055: uint8_t used_fmmus; /**< Number of FMMUs used. */ fp@1438: uint16_t dc_assign_activate; /**< Vendor-specific AssignActivate word. */ fp@1438: ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT]; /**< DC sync signals. */ fp@1392: fp@1327: struct list_head sdo_configs; /**< List of SDO configurations. */ fp@1327: struct list_head sdo_requests; /**< List of SDO requests. */ fp@1209: struct list_head voe_handlers; /**< List of VoE handlers. */ fp@1844: struct list_head soe_configs; /**< List of SoE configurations. */ fp@792: }; fp@792: fp@792: /*****************************************************************************/ fp@792: fp@995: void ec_slave_config_init(ec_slave_config_t *, ec_master_t *, uint16_t, fp@1010: uint16_t, uint32_t, uint32_t); fp@995: void ec_slave_config_clear(ec_slave_config_t *); fp@792: fp@792: int ec_slave_config_attach(ec_slave_config_t *); fp@792: void ec_slave_config_detach(ec_slave_config_t *); fp@792: fp@1055: void ec_slave_config_load_default_sync_config(ec_slave_config_t *); fp@792: fp@990: unsigned int ec_slave_config_sdo_count(const ec_slave_config_t *); fp@990: const ec_sdo_request_t *ec_slave_config_get_sdo_by_pos_const( fp@990: const ec_slave_config_t *, unsigned int); fp@1966: unsigned int ec_slave_config_idn_count(const ec_slave_config_t *); fp@1966: const ec_soe_request_t *ec_slave_config_get_idn_by_pos_const( fp@1966: const ec_slave_config_t *, unsigned int); fp@1351: ec_sdo_request_t *ec_slave_config_find_sdo_request(ec_slave_config_t *, fp@1351: unsigned int); fp@1263: ec_voe_handler_t *ec_slave_config_find_voe_handler(ec_slave_config_t *, fp@1507: unsigned int); fp@990: fp@1312: ec_sdo_request_t *ecrt_slave_config_create_sdo_request_err( fp@1312: ec_slave_config_t *, uint16_t, uint8_t, size_t); fp@1312: ec_voe_handler_t *ecrt_slave_config_create_voe_handler_err( fp@1312: ec_slave_config_t *, size_t); fp@1312: fp@792: /*****************************************************************************/ fp@792: fp@792: #endif