include/ecrt.h
changeset 1341 32ba7ffb6c7f
parent 1327 4d179b06dd3c
child 1352 275d2fdeab48
equal deleted inserted replaced
1340:3d45edb1b4a1 1341:32ba7ffb6c7f
     1 /******************************************************************************
     1 /******************************************************************************
     2  *
     2  *
     3  * $Id$
     3  *  $Id$
     4  *
     4  *
     5  * Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
     5  *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
     6  *
     6  *
     7  * This file is part of the IgH EtherCAT master userspace library.
     7  *  This file is part of the IgH EtherCAT master userspace library.
     8  * 
     8  *  
     9  * The IgH EtherCAT master userspace library is free software; you can
     9  *  The IgH EtherCAT master userspace library is free software; you can
    10  * redistribute it and/or modify it under the terms of the GNU Lesser General
    10  *  redistribute it and/or modify it under the terms of the GNU Lesser General
    11  * Public License as published by the Free Software Foundation; version 2.1 of
    11  *  Public License as published by the Free Software Foundation; version 2.1
    12  * the License.
    12  *  of the License.
    13  *
    13  *
    14  * The IgH EtherCAT master userspace library is distributed in the hope that
    14  *  The IgH EtherCAT master userspace library is distributed in the hope that
    15  * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    15  *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    16  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU Lesser General Public License for more details.
    17  *  GNU Lesser General Public License for more details.
    18  *
    18  *
    19  * You should have received a copy of the GNU Lesser General Public License
    19  *  You should have received a copy of the GNU Lesser General Public License
    20  * along with the IgH EtherCAT master userspace library. If not, see
    20  *  along with the IgH EtherCAT master userspace library. If not, see
    21  * <http://www.gnu.org/licenses/>.
    21  *  <http://www.gnu.org/licenses/>.
    22  * 
    22  *  
    23  * Using the EtherCAT technology and brand is permitted in compliance with the
    23  *  Using the EtherCAT technology and brand is permitted in compliance with
    24  * industrial property and similar rights of Beckhoff Automation GmbH.
    24  *  the industrial property and similar rights of Beckhoff Automation GmbH.
    25  *
    25  *
    26  *****************************************************************************/
    26  *****************************************************************************/
    27 
    27 
    28 /** \file
    28 /** \file
    29  *
    29  *
    38  *
    38  *
    39  * Changes in version 1.5:
    39  * Changes in version 1.5:
    40  *
    40  *
    41  * - Changed the meaning of the negative return values of
    41  * - Changed the meaning of the negative return values of
    42  *   ecrt_slave_config_reg_pdo_entry() and ecrt_slave_config_sdo*().
    42  *   ecrt_slave_config_reg_pdo_entry() and ecrt_slave_config_sdo*().
       
    43  * - Imlemented the Vendor-specific over EtherCAT mailbox protocol. See
       
    44  *   ecrt_slave_config_create_voe_handler().
       
    45  * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also
       
    46  *   used by VoE handlers.
       
    47  * - Added ecrt_master_slave() to get information about a certain slave.
    43  *
    48  *
    44  * Changes in Version 1.4:
    49  * Changes in Version 1.4:
    45  *
    50  *
    46  * - Replaced ec_slave_t with ec_slave_config_t, separating the bus
    51  * - Replaced ec_slave_t with ec_slave_config_t, separating the bus
    47  *   configuration from the actual slaves. Therefore, renamed
    52  *   configuration from the actual slaves. Therefore, renamed
   132 
   137 
   133 /** Maximum number of sync managers per slave.
   138 /** Maximum number of sync managers per slave.
   134  */
   139  */
   135 #define EC_MAX_SYNC_MANAGERS 16
   140 #define EC_MAX_SYNC_MANAGERS 16
   136 
   141 
       
   142 /** Maximum string length.
       
   143  *
       
   144  * Used in ec_slave_info_t.
       
   145  */
       
   146 #define EC_MAX_STRING_LENGTH 64
       
   147 
   137 /******************************************************************************
   148 /******************************************************************************
   138  * Data types 
   149  * Data types 
   139  *****************************************************************************/
   150  *****************************************************************************/
   140 
   151 
   141 struct ec_master;
   152 struct ec_master;
   194                                  - 8: \a OP
   205                                  - 8: \a OP
   195 
   206 
   196                                  Note that each state is coded in a different
   207                                  Note that each state is coded in a different
   197                                  bit! */
   208                                  bit! */
   198 } ec_slave_config_state_t;
   209 } ec_slave_config_state_t;
       
   210 
       
   211 /*****************************************************************************/
       
   212 
       
   213 /** Slave information.
       
   214  *
       
   215  * This is used as an output parameter of ecrt_master_slave().
       
   216  *
       
   217  * \see ecrt_master_slave().
       
   218  */
       
   219 typedef struct {
       
   220     uint16_t position; /**< Offset of the slave in the ring. */
       
   221     uint32_t vendor_id; /**< Vendor-ID stored on the slave. */
       
   222     uint32_t product_code; /**< Product-Code stored on the slave. */
       
   223     uint32_t revision_number; /**< Revision-Number stored on the slave. */
       
   224     uint32_t serial_number; /**< Serial-Number stored on the slave. */
       
   225     uint16_t alias; /**< The slaves alias if not equal to 0. */
       
   226     int16_t current_on_ebus;
       
   227     uint8_t al_state; /**< Current state of the slave. */
       
   228     uint8_t error_flag; /**< Error flag for that slave. */
       
   229     uint8_t sync_count; /**< Number of sync managers. */
       
   230     uint16_t sdo_count; /**< Number of SDO's. */
       
   231     char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. */
       
   232 } ec_slave_info_t;
   199 
   233 
   200 /*****************************************************************************/
   234 /*****************************************************************************/
   201 
   235 
   202 /** Domain working counter interpretation.
   236 /** Domain working counter interpretation.
   203  *
   237  *
   429         ec_master_t *master, /**< EtherCAT master */
   463         ec_master_t *master, /**< EtherCAT master */
   430         uint16_t alias, /**< Slave alias. */
   464         uint16_t alias, /**< Slave alias. */
   431         uint16_t position, /**< Slave position. */
   465         uint16_t position, /**< Slave position. */
   432         uint32_t vendor_id, /**< Expected vendor ID. */
   466         uint32_t vendor_id, /**< Expected vendor ID. */
   433         uint32_t product_code /**< Expected product code. */
   467         uint32_t product_code /**< Expected product code. */
       
   468         );
       
   469 
       
   470 /** Obtains slave information.
       
   471  *
       
   472  * Tries to find the slave with the given ring position. The obtained
       
   473  * information is stored in a structure. No memory is allocated on the heap in
       
   474  * this function.
       
   475  *
       
   476  * \attention The pointer to this structure must point to a valid variable.
       
   477  *
       
   478  * \return 0 in case of success, else < 0
       
   479  */
       
   480 int ecrt_master_slave(
       
   481         ec_master_t *master, /**< EtherCAT master */
       
   482         uint16_t position, /**< Slave position. */
       
   483         ec_slave_info_t *slave_info /**< Structure that will output the
       
   484                                       information */
   434         );
   485         );
   435 
   486 
   436 /** Finishes the configuration phase and prepares for cyclic operation.
   487 /** Finishes the configuration phase and prepares for cyclic operation.
   437  *
   488  *
   438  * This function tells the master that the configuration phase is finished and
   489  * This function tells the master that the configuration phase is finished and