fp@39: /****************************************************************************** fp@0: * fp@39: * $Id$ fp@0: * fp@197: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@197: * fp@197: * This file is part of the IgH EtherCAT Master. fp@197: * fp@197: * The IgH EtherCAT Master is free software; you can redistribute it fp@197: * and/or modify it under the terms of the GNU General Public License fp@197: * as published by the Free Software Foundation; version 2 of the License. fp@197: * fp@197: * The IgH EtherCAT Master is distributed in the hope that it will be fp@197: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@197: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@197: * GNU General Public License for more details. fp@197: * fp@197: * You should have received a copy of the GNU General Public License fp@197: * along with the IgH EtherCAT Master; if not, write to the Free Software fp@197: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@197: * fp@39: *****************************************************************************/ fp@0: fp@199: /** fp@199: \file fp@199: Global definitions and macros. fp@199: */ fp@199: fp@199: /*****************************************************************************/ fp@199: fp@0: #ifndef _EC_GLOBALS_ fp@0: #define _EC_GLOBALS_ fp@0: fp@152: #include fp@152: fp@196: /****************************************************************************** fp@196: * EtherCAT master fp@196: *****************************************************************************/ fp@41: fp@197: /** master main version */ fp@196: #define EC_MASTER_VERSION_MAIN 1 fp@197: fp@197: /** master sub version (after the dot) */ fp@196: #define EC_MASTER_VERSION_SUB 0 fp@197: fp@197: /** master extra version (just a string) */ fp@196: #define EC_MASTER_VERSION_EXTRA "trunk" fp@196: fp@196: /** maximum number of FMMUs per slave */ fp@196: #define EC_MAX_FMMUS 16 fp@196: fp@212: /** size of the EoE tx queue */ fp@214: #define EC_EOE_TX_QUEUE_SIZE 100 fp@212: fp@228: /** clock frequency for the EoE state machines */ fp@228: #define EC_EOE_FREQUENCY 1000 fp@228: fp@196: /****************************************************************************** fp@196: * EtherCAT protocol fp@196: *****************************************************************************/ fp@196: fp@196: /** size of an EtherCAT frame header */ fp@196: #define EC_FRAME_HEADER_SIZE 2 fp@196: fp@196: /** size of an EtherCAT command header */ fp@196: #define EC_COMMAND_HEADER_SIZE 10 fp@196: fp@196: /** size of an EtherCAT command footer */ fp@196: #define EC_COMMAND_FOOTER_SIZE 2 fp@196: fp@196: /** size of a sync manager configuration page */ fp@196: #define EC_SYNC_SIZE 8 fp@196: fp@196: /** size of an FMMU configuration page */ fp@196: #define EC_FMMU_SIZE 16 fp@196: fp@196: /** resulting maximum data size of a single command in a frame */ fp@211: #define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \ fp@196: - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE) fp@0: fp@152: /*****************************************************************************/ fp@152: fp@84: #define EC_INFO(fmt, args...) \ fp@84: printk(KERN_INFO "EtherCAT: " fmt, ##args) fp@84: #define EC_ERR(fmt, args...) \ fp@84: printk(KERN_ERR "EtherCAT ERROR: " fmt, ##args) fp@84: #define EC_WARN(fmt, args...) \ fp@84: printk(KERN_WARNING "EtherCAT WARNING: " fmt, ##args) fp@84: #define EC_DBG(fmt, args...) \ fp@84: printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args) fp@84: fp@184: #define EC_LIT(X) #X fp@184: #define EC_STR(X) EC_LIT(X) fp@184: fp@199: /** fp@199: Convenience macro for defining SysFS attributes. fp@199: */ fp@199: fp@184: #define EC_SYSFS_READ_ATTR(NAME) \ fp@184: static struct attribute attr_##NAME = { \ fp@184: .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO \ fp@184: } fp@184: fp@41: /*****************************************************************************/ fp@41: fp@152: extern void ec_print_data(const uint8_t *, size_t); fp@152: extern void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t); fp@152: fp@152: /*****************************************************************************/ fp@152: fp@164: /** fp@195: Code - Message pair. fp@164: Some EtherCAT commands support reading a status code to display a certain fp@164: message. This type allows to map a code to a message string. fp@164: */ fp@164: fp@164: typedef struct fp@164: { fp@195: uint32_t code; /**< code */ fp@195: const char *message; /**< message belonging to \a code */ fp@164: } fp@164: ec_code_msg_t; fp@164: fp@164: /*****************************************************************************/ fp@164: fp@0: #endif fp@73: