fp@39: /****************************************************************************** fp@0: * fp@39: * $Id$ fp@0: * fp@1685: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH fp@197: * fp@197: * This file is part of the IgH EtherCAT Master. fp@197: * fp@1685: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1685: * modify it under the terms of the GNU General Public License version 2, as fp@1685: * published by the Free Software Foundation. fp@197: * fp@1685: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1685: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1685: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1685: * Public License for more details. fp@197: * fp@1685: * You should have received a copy of the GNU General Public License along fp@1685: * 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@1685: * Using the EtherCAT technology and brand is permitted in compliance with fp@1685: * the industrial property and similar rights of Beckhoff Automation GmbH. fp@246: * fp@39: *****************************************************************************/ fp@0: fp@199: /** fp@199: \file fp@791: EtherCAT slave structure. fp@199: */ fp@199: fp@199: /*****************************************************************************/ fp@199: fp@883: #ifndef __EC_SLAVE_H__ fp@883: #define __EC_SLAVE_H__ fp@0: fp@145: #include fp@182: #include fp@145: fp@325: #include "../include/ecrt.h" fp@325: fp@145: #include "globals.h" fp@293: #include "datagram.h" fp@627: #include "pdo.h" fp@628: #include "sync.h" fp@847: #include "sdo.h" fp@0: fp@39: /*****************************************************************************/ fp@0: fp@834: /** Slave information interface data. fp@834: */ fp@834: typedef struct { fp@834: // Non-category data fp@834: uint16_t alias; /**< Configured station alias. */ fp@834: uint32_t vendor_id; /**< Vendor ID. */ fp@834: uint32_t product_code; /**< Vendor-specific product code. */ fp@834: uint32_t revision_number; /**< Revision number. */ fp@834: uint32_t serial_number; /**< Serial number. */ fp@1709: uint16_t boot_rx_mailbox_offset; /**< Bootstrap receive mailbox address. */ fp@1709: uint16_t boot_rx_mailbox_size; /**< Bootstrap receive mailbox size. */ fp@1709: uint16_t boot_tx_mailbox_offset; /**< Bootstrap transmit mailbox address. */ fp@1709: uint16_t boot_tx_mailbox_size; /**< Bootstrap transmit mailbox size. */ fp@1709: uint16_t std_rx_mailbox_offset; /**< Standard receive mailbox address. */ fp@1709: uint16_t std_rx_mailbox_size; /**< Standard receive mailbox size. */ fp@1709: uint16_t std_tx_mailbox_offset; /**< Standard transmit mailbox address. */ fp@1709: uint16_t std_tx_mailbox_size; /**< Standard transmit mailbox size. */ fp@834: uint16_t mailbox_protocols; /**< Supported mailbox protocols. */ fp@834: fp@834: // Strings fp@872: char **strings; /**< Strings in SII categories. */ fp@1000: unsigned int string_count; /**< Number of SII strings. */ fp@834: fp@834: // General fp@835: unsigned int has_general; /**< General category present. */ fp@1000: char *group; /**< Group name. */ fp@1000: char *image; /**< Image name. */ fp@1000: char *order; /**< Order number. */ fp@1000: char *name; /**< Slave name. */ fp@1055: uint8_t physical_layer[EC_MAX_PORTS]; /**< Port media. */ fp@835: ec_sii_coe_details_t coe_details; /**< CoE detail flags. */ fp@836: ec_sii_general_flags_t general_flags; /**< General flags. */ fp@1000: int16_t current_on_ebus; /**< Power consumption in mA. */ fp@834: fp@834: // SyncM fp@1000: ec_sync_t *syncs; /**< SYNC MANAGER categories. */ fp@1000: unsigned int sync_count; /**< Number of sync managers. */ fp@834: fp@834: // [RT]XPDO fp@1000: struct list_head pdos; /**< SII [RT]XPDO categories. */ fp@834: } ec_sii_t; fp@834: fp@834: /*****************************************************************************/ fp@834: fp@1000: /** EtherCAT slave port information. fp@1000: */ fp@1000: typedef struct { fp@1000: uint8_t dl_link; /**< Link detected. */ fp@1000: uint8_t dl_loop; /**< Loop closed. */ fp@1000: uint8_t dl_signal; /**< Detected signal on RX port. */ fp@1000: } ec_slave_port_t; fp@1000: fp@1000: /*****************************************************************************/ fp@1000: fp@792: /** EtherCAT slave. fp@635: */ fp@73: struct ec_slave fp@73: { fp@1000: ec_master_t *master; /**< Master owning the slave. */ fp@195: fp@195: // addresses fp@1000: uint16_t ring_position; /**< Ring position. */ fp@1000: uint16_t station_address; /**< Configured station address. */ fp@195: fp@792: // configuration fp@792: ec_slave_config_t *config; /**< Current configuration. */ fp@792: ec_slave_state_t requested_state; /**< Requested application state. */ fp@792: ec_slave_state_t current_state; /**< Current application state. */ fp@792: unsigned int error_flag; /**< Stop processing after an error. */ fp@908: unsigned int force_config; /**< Force (re-)configuration. */ fp@1711: uint16_t configured_rx_mailbox_offset; fp@1711: uint16_t configured_rx_mailbox_size; fp@1711: uint16_t configured_tx_mailbox_offset; fp@1711: uint16_t configured_tx_mailbox_size; fp@792: fp@195: // base data fp@1000: uint8_t base_type; /**< Slave type. */ fp@1000: uint8_t base_revision; /**< Revision. */ fp@1000: uint16_t base_build; /**< Build number. */ fp@1000: uint16_t base_fmmu_count; /**< Number of supported FMMUs. */ fp@195: fp@195: // data link status fp@1092: ec_slave_port_t ports[EC_MAX_PORTS]; /**< Port link status. */ fp@195: fp@872: // SII fp@977: uint16_t *sii_words; /**< Complete SII image. */ fp@977: size_t sii_nwords; /**< Size of the SII contents in words. */ fp@325: fp@1000: // Slave information interface fp@1000: ec_sii_t sii; /**< Extracted SII data. */ fp@195: fp@1686: struct list_head sdo_dictionary; /**< SDO dictionary list */ fp@1000: uint8_t sdo_dictionary_fetched; /**< Dictionary has been fetched. */ fp@1000: unsigned long jiffies_preop; /**< Time, the slave went to PREOP. */ fp@73: }; fp@73: fp@73: /*****************************************************************************/ fp@73: fp@195: // slave construction/destruction fp@992: void ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t); fp@992: void ec_slave_clear(ec_slave_t *); fp@73: fp@870: void ec_slave_clear_sync_managers(ec_slave_t *); fp@870: fp@446: void ec_slave_request_state(ec_slave_t *, ec_slave_state_t); fp@610: void ec_slave_set_state(ec_slave_t *, ec_slave_state_t); fp@446: fp@325: // SII categories fp@742: int ec_slave_fetch_sii_strings(ec_slave_t *, const uint8_t *, size_t); fp@742: int ec_slave_fetch_sii_general(ec_slave_t *, const uint8_t *, size_t); fp@620: int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t); fp@620: int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t, fp@792: ec_direction_t); fp@238: fp@195: // misc. fp@1055: ec_sync_t *ec_slave_get_sync(ec_slave_t *, uint8_t); fp@1055: fp@423: void ec_slave_sdo_dict_info(const ec_slave_t *, fp@635: unsigned int *, unsigned int *); fp@740: ec_sdo_t *ec_slave_get_sdo(ec_slave_t *, uint16_t); fp@967: const ec_sdo_t *ec_slave_get_sdo_const(const ec_slave_t *, uint16_t); fp@964: const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t); fp@964: uint16_t ec_slave_sdo_count(const ec_slave_t *); fp@799: const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t); fp@1186: void ec_slave_attach_pdo_names(ec_slave_t *); fp@423: fp@39: /*****************************************************************************/ fp@0: fp@0: #endif