fp@98: /****************************************************************************** fp@98: * fp@98: * c o m m a n d . h fp@98: * fp@195: * EtherCAT command structure. fp@98: * fp@98: * $Id$ fp@98: * fp@98: *****************************************************************************/ fp@98: fp@98: #ifndef _EC_COMMAND_H_ fp@98: #define _EC_COMMAND_H_ fp@98: fp@98: #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@195: 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@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@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