fp@98: /****************************************************************************** fp@98: * fp@98: * $Id$ fp@98: * 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@246: * as published by the Free Software Foundation; either version 2 of the fp@246: * License, or (at your option) any later version. 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@246: * The right to use EtherCAT Technology is granted and comes free of fp@246: * charge under condition of compatibility of product made by fp@246: * Licensee. People intending to distribute/sell products based on the fp@246: * code, have to sign an agreement to guarantee that products using fp@246: * software based on IgH EtherCAT master stay compatible with the actual fp@246: * EtherCAT specification (which are released themselves as an open fp@246: * standard) as the (only) precondition to have the right to use EtherCAT fp@246: * Technology, IP and trade marks. fp@246: * fp@98: *****************************************************************************/ fp@98: fp@199: /** fp@199: \file fp@293: EtherCAT datagram structure. fp@199: */ fp@199: fp@199: /*****************************************************************************/ fp@199: fp@293: #ifndef _EC_DATAGRAM_H_ fp@293: #define _EC_DATAGRAM_H_ fp@98: fp@98: #include fp@294: #include fp@208: #include fp@98: fp@98: #include "globals.h" fp@98: fp@98: /*****************************************************************************/ fp@98: fp@1745: /** size of the datagram description string */ fp@1745: #define EC_DATAGRAM_NAME_SIZE 20 fp@1745: fp@1745: /*****************************************************************************/ fp@1745: fp@98: /** fp@293: EtherCAT datagram type. fp@98: */ fp@98: fp@98: typedef enum fp@98: { fp@1715: EC_DATAGRAM_NONE = 0x00, /**< Dummy */ fp@1715: EC_DATAGRAM_APRD = 0x01, /**< Auto-increment physical read */ fp@1715: EC_DATAGRAM_APWR = 0x02, /**< Auto-increment physical write */ fp@1715: EC_DATAGRAM_NPRD = 0x04, /**< Node-addressed physical read */ fp@1715: EC_DATAGRAM_NPWR = 0x05, /**< Node-addressed physical write */ fp@1715: EC_DATAGRAM_BRD = 0x07, /**< Broadcast read */ fp@1715: EC_DATAGRAM_BWR = 0x08, /**< Broadcast write */ fp@1715: EC_DATAGRAM_LRW = 0x0C /**< Logical read/write */ fp@98: } fp@293: ec_datagram_type_t; fp@98: fp@98: /** fp@293: EtherCAT datagram state. fp@98: */ fp@98: fp@98: typedef enum fp@98: { fp@1739: EC_DATAGRAM_INIT, /**< new datagram */ fp@1739: EC_DATAGRAM_QUEUED, /**< datagram queued for sending */ fp@1739: EC_DATAGRAM_SENT, /**< datagram has been sent (still in the queue) */ fp@1739: EC_DATAGRAM_RECEIVED, /**< datagram has been received (dequeued) */ fp@1739: EC_DATAGRAM_TIMED_OUT, /**< datagram timed out (dequeued) */ fp@1739: EC_DATAGRAM_ERROR /**< error while sending/receiving (dequeued) */ fp@98: } fp@293: ec_datagram_state_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@293: EtherCAT datagram. fp@98: */ fp@98: fp@98: typedef struct fp@98: { fp@293: struct list_head list; /**< needed by domain datagram lists */ fp@293: struct list_head queue; /**< master datagram queue item */ fp@1732: struct list_head sent; /**< master list item for sent datagrams */ fp@293: ec_datagram_type_t type; /**< datagram type (APRD, BWR, etc) */ fp@1745: uint8_t address[EC_ADDR_LEN]; /**< recipient address */ fp@293: uint8_t *data; /**< datagram data */ fp@293: size_t mem_size; /**< datagram \a data memory size */ fp@195: size_t data_size; /**< size of the data in \a data */ fp@293: uint8_t index; /**< datagram index (set by master) */ fp@195: uint16_t working_counter; /**< working counter */ fp@293: ec_datagram_state_t state; /**< datagram state */ fp@1719: cycles_t cycles_sent; /**< time, the datagram was sent */ fp@1739: unsigned long jiffies_sent; /**< jiffies, when the datagram was sent */ fp@1739: cycles_t cycles_received; /**< time, when the datagram was received */ fp@1745: unsigned long jiffies_received; /**< jiffies the datagram was received */ fp@1745: unsigned int skip_count; /**< number of requeues when not yet received */ fp@1745: unsigned long stats_output_jiffies; /**< last statistics output */ fp@1745: char name[EC_DATAGRAM_NAME_SIZE]; /**< description of the datagram */ fp@98: } fp@293: ec_datagram_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@293: void ec_datagram_init(ec_datagram_t *); fp@293: void ec_datagram_clear(ec_datagram_t *); fp@293: int ec_datagram_prealloc(ec_datagram_t *, size_t); fp@144: fp@293: int ec_datagram_nprd(ec_datagram_t *, uint16_t, uint16_t, size_t); fp@293: int ec_datagram_npwr(ec_datagram_t *, uint16_t, uint16_t, size_t); fp@293: int ec_datagram_aprd(ec_datagram_t *, uint16_t, uint16_t, size_t); fp@293: int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t); fp@293: int ec_datagram_brd(ec_datagram_t *, uint16_t, size_t); fp@293: int ec_datagram_bwr(ec_datagram_t *, uint16_t, size_t); fp@293: int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t); fp@98: fp@1745: void ec_datagram_print_wc_error(const ec_datagram_t *); fp@1745: void ec_datagram_output_stats(ec_datagram_t *datagram); fp@1745: fp@98: /*****************************************************************************/ fp@98: fp@98: #endif