slave.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: slave.h 516 2006-08-09 15:04:07Z fp $
00004  *
00005  *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
00006  *
00007  *  This file is part of the IgH EtherCAT Master.
00008  *
00009  *  The IgH EtherCAT Master is free software; you can redistribute it
00010  *  and/or modify it under the terms of the GNU General Public License
00011  *  as published by the Free Software Foundation; either version 2 of the
00012  *  License, or (at your option) any later version.
00013  *
00014  *  The IgH EtherCAT Master is distributed in the hope that it will be
00015  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with the IgH EtherCAT Master; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  *  The right to use EtherCAT Technology is granted and comes free of
00024  *  charge under condition of compatibility of product made by
00025  *  Licensee. People intending to distribute/sell products based on the
00026  *  code, have to sign an agreement to guarantee that products using
00027  *  software based on IgH EtherCAT master stay compatible with the actual
00028  *  EtherCAT specification (which are released themselves as an open
00029  *  standard) as the (only) precondition to have the right to use EtherCAT
00030  *  Technology, IP and trade marks.
00031  *
00032  *****************************************************************************/
00033 
00039 /*****************************************************************************/
00040 
00041 #ifndef _EC_SLAVE_H_
00042 #define _EC_SLAVE_H_
00043 
00044 #include <linux/list.h>
00045 #include <linux/kobject.h>
00046 
00047 #include "../include/ecrt.h"
00048 
00049 #include "globals.h"
00050 #include "datagram.h"
00051 
00052 /*****************************************************************************/
00053 
00058 typedef enum
00059 {
00060     EC_SLAVE_STATE_UNKNOWN = 0x00,
00062     EC_SLAVE_STATE_INIT = 0x01,
00064     EC_SLAVE_STATE_PREOP = 0x02,
00066     EC_SLAVE_STATE_SAVEOP = 0x04,
00068     EC_SLAVE_STATE_OP = 0x08,
00070     EC_ACK = 0x10
00072 }
00073 ec_slave_state_t;
00074 
00075 /*****************************************************************************/
00076 
00081 enum
00082 {
00083     EC_MBOX_AOE = 0x01, 
00084     EC_MBOX_EOE = 0x02, 
00085     EC_MBOX_COE = 0x04, 
00086     EC_MBOX_FOE = 0x08, 
00087     EC_MBOX_SOE = 0x10, 
00088     EC_MBOX_VOE = 0x20  
00089 };
00090 
00091 /*****************************************************************************/
00092 
00097 typedef struct
00098 {
00099     struct list_head list; 
00100     size_t size; 
00101     char *data; 
00102 }
00103 ec_sii_string_t;
00104 
00105 /*****************************************************************************/
00106 
00111 typedef struct
00112 {
00113     struct list_head list; 
00114     unsigned int index; 
00115     uint16_t physical_start_address; 
00116     uint16_t length; 
00117     uint8_t control_register; 
00118     uint8_t enable; 
00119 }
00120 ec_sii_sync_t;
00121 
00122 /*****************************************************************************/
00123 
00128 typedef enum
00129 {
00130     EC_RX_PDO, 
00131     EC_TX_PDO 
00132 }
00133 ec_sii_pdo_type_t;
00134 
00135 /*****************************************************************************/
00136 
00141 typedef struct
00142 {
00143     struct list_head list; 
00144     ec_sii_pdo_type_t type; 
00145     uint16_t index; 
00146     uint8_t sync_index; 
00147     char *name; 
00148     struct list_head entries; 
00149 }
00150 ec_sii_pdo_t;
00151 
00152 /*****************************************************************************/
00153 
00158 typedef struct
00159 {
00160     struct list_head list; 
00161     uint16_t index; 
00162     uint8_t subindex; 
00163     char *name; 
00164     uint8_t bit_length; 
00165 }
00166 ec_sii_pdo_entry_t;
00167 
00168 /*****************************************************************************/
00169 
00174 typedef struct
00175 {
00176     struct list_head list; 
00177     uint16_t index; 
00178     uint8_t object_code; 
00179     char *name; 
00180     struct list_head entries; 
00181 }
00182 ec_sdo_t;
00183 
00184 /*****************************************************************************/
00185 
00190 typedef struct
00191 {
00192     struct list_head list; 
00193     uint8_t subindex; 
00194     uint16_t data_type; 
00195     uint16_t bit_length; 
00196     char *name; 
00197 }
00198 ec_sdo_entry_t;
00199 
00200 /*****************************************************************************/
00201 
00202 typedef struct
00203 {
00204     struct list_head list; 
00205     uint16_t index; 
00206     uint8_t subindex; 
00207     uint8_t *data; 
00208     size_t size; 
00209 }
00210 ec_sdo_data_t;
00211 
00212 /*****************************************************************************/
00213 
00218 typedef struct
00219 {
00220     const ec_domain_t *domain; 
00221     const ec_sii_sync_t *sync; 
00222     uint32_t logical_start_address; 
00223 }
00224 ec_fmmu_t;
00225 
00226 /*****************************************************************************/
00227 
00232 typedef struct
00233 {
00234     struct list_head list; 
00235     const ec_sii_pdo_t *pdo; 
00236     size_t size; 
00237 }
00238 ec_varsize_t;
00239 
00240 /*****************************************************************************/
00241 
00246 struct ec_slave
00247 {
00248     struct list_head list; 
00249     struct kobject kobj; 
00250     ec_master_t *master; 
00252     ec_slave_state_t requested_state; 
00253     ec_slave_state_t current_state; 
00254     unsigned int error_flag; 
00255     unsigned int online; 
00256     uint8_t registered; 
00258     // addresses
00259     uint16_t ring_position; 
00260     uint16_t station_address; 
00261     uint16_t coupler_index; 
00262     uint16_t coupler_subindex; 
00264     // base data
00265     uint8_t base_type; 
00266     uint8_t base_revision; 
00267     uint16_t base_build; 
00268     uint16_t base_fmmu_count; 
00269     uint16_t base_sync_count; 
00271     // data link status
00272     uint8_t dl_link[4]; 
00273     uint8_t dl_loop[4]; 
00274     uint8_t dl_signal[4]; 
00276     // EEPROM
00277     uint8_t *eeprom_data; 
00278     uint16_t eeprom_size; 
00279     uint16_t *new_eeprom_data; 
00280     uint16_t new_eeprom_size; 
00282     // slave information interface
00283     uint16_t sii_alias; 
00284     uint32_t sii_vendor_id; 
00285     uint32_t sii_product_code; 
00286     uint32_t sii_revision_number; 
00287     uint32_t sii_serial_number; 
00288     uint16_t sii_rx_mailbox_offset; 
00289     uint16_t sii_rx_mailbox_size; 
00290     uint16_t sii_tx_mailbox_offset; 
00291     uint16_t sii_tx_mailbox_size; 
00292     uint16_t sii_mailbox_protocols; 
00293     uint8_t sii_physical_layer[4]; 
00294     struct list_head sii_strings; 
00295     struct list_head sii_syncs; 
00296     struct list_head sii_pdos; 
00297     char *sii_group; 
00298     char *sii_image; 
00299     char *sii_order; 
00300     char *sii_name; 
00302     ec_fmmu_t fmmus[EC_MAX_FMMUS]; 
00303     uint8_t fmmu_count; 
00305     struct list_head sdo_dictionary; 
00306     struct list_head sdo_confs; 
00308     struct list_head varsize_fields; 
00310 };
00311 
00312 /*****************************************************************************/
00313 
00314 // slave construction/destruction
00315 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t);
00316 void ec_slave_clear(struct kobject *);
00317 
00318 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *,
00319                           const ec_sii_sync_t *);
00320 
00321 // CoE
00322 //int ec_slave_fetch_sdo_list(ec_slave_t *);
00323 
00324 // SII categories
00325 int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *);
00326 void ec_slave_fetch_general(ec_slave_t *, const uint8_t *);
00327 int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t);
00328 int ec_slave_fetch_pdo(ec_slave_t *, const uint8_t *, size_t,
00329                        ec_sii_pdo_type_t);
00330 int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
00331 
00332 // misc.
00333 uint16_t ec_slave_calc_sync_size(const ec_slave_t *,
00334                                  const ec_sii_sync_t *);
00335 
00336 int ec_slave_is_coupler(const ec_slave_t *);
00337 
00338 /*****************************************************************************/
00339 
00340 #endif

Generated on Fri Sep 1 14:56:56 2006 for IgH EtherCAT master by  doxygen 1.4.6