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@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@98: *****************************************************************************/ fp@98: fp@199: /** fp@199: \file fp@199: EtherCAT command structure. fp@199: */ fp@199: fp@199: /*****************************************************************************/ fp@199: fp@98: #ifndef _EC_COMMAND_H_ fp@98: #define _EC_COMMAND_H_ fp@98: fp@98: #include fp@208: #include fp@98: fp@98: #include "globals.h" fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@195: EtherCAT command type. fp@98: */ fp@98: fp@98: typedef enum fp@98: { fp@98: EC_CMD_NONE = 0x00, /**< Dummy */ fp@98: EC_CMD_APRD = 0x01, /**< Auto-increment physical read */ fp@98: EC_CMD_APWR = 0x02, /**< Auto-increment physical write */ fp@98: EC_CMD_NPRD = 0x04, /**< Node-addressed physical read */ fp@98: EC_CMD_NPWR = 0x05, /**< Node-addressed physical write */ fp@98: EC_CMD_BRD = 0x07, /**< Broadcast read */ fp@98: EC_CMD_BWR = 0x08, /**< Broadcast write */ fp@98: EC_CMD_LRW = 0x0C /**< Logical read/write */ fp@98: } fp@98: ec_command_type_t; fp@98: fp@98: /** fp@195: EtherCAT command state. fp@98: */ fp@98: fp@98: typedef enum fp@98: { fp@195: EC_CMD_INIT, /**< new command */ fp@195: EC_CMD_QUEUED, /**< command queued by master */ fp@195: EC_CMD_SENT, /**< command has been sent */ fp@195: EC_CMD_RECEIVED, /**< command has been received */ fp@195: EC_CMD_TIMEOUT, /**< command timed out */ fp@195: EC_CMD_ERROR /**< error while sending/receiving */ fp@98: } fp@98: ec_command_state_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@195: EtherCAT address. fp@98: */ fp@98: fp@98: typedef union fp@98: { fp@98: struct fp@98: { fp@195: uint16_t slave; /**< configured or autoincrement address */ fp@195: uint16_t mem; /**< physical memory address */ fp@98: } fp@195: physical; /**< physical address */ fp@98: fp@195: uint32_t logical; /**< logical address */ fp@98: } fp@98: ec_address_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@199: EtherCAT command. fp@98: */ fp@98: fp@98: typedef struct fp@98: { fp@195: struct list_head list; /**< needed by domain command lists */ fp@195: struct list_head queue; /**< master command queue item */ fp@195: ec_command_type_t type; /**< command type (APRD, BWR, etc) */ fp@195: ec_address_t address; /**< receipient address */ fp@195: uint8_t *data; /**< command data */ fp@195: size_t mem_size; /**< command \a data memory size */ fp@195: size_t data_size; /**< size of the data in \a data */ fp@195: uint8_t index; /**< command index (set by master) */ fp@195: uint16_t working_counter; /**< working counter */ fp@195: ec_command_state_t state; /**< command state */ fp@208: cycles_t t_sent; /**< time, the commands was sent */ fp@98: } fp@98: ec_command_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@144: void ec_command_init(ec_command_t *); fp@144: void ec_command_clear(ec_command_t *); fp@238: int ec_command_prealloc(ec_command_t *, size_t); fp@144: fp@144: int ec_command_nprd(ec_command_t *, uint16_t, uint16_t, size_t); fp@144: int ec_command_npwr(ec_command_t *, uint16_t, uint16_t, size_t); fp@144: int ec_command_aprd(ec_command_t *, uint16_t, uint16_t, size_t); fp@144: int ec_command_apwr(ec_command_t *, uint16_t, uint16_t, size_t); fp@144: int ec_command_brd(ec_command_t *, uint16_t, size_t); fp@144: int ec_command_bwr(ec_command_t *, uint16_t, size_t); fp@144: int ec_command_lrw(ec_command_t *, uint32_t, size_t); fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: #endif