Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

slave.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: slave.h 682 2006-11-07 12:13:30Z 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_SLAVE_STATE_ACK_ERR = 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     uint16_t est_length; 
00122 }
00123 ec_sii_sync_t;
00124 
00125 /*****************************************************************************/
00126 
00131 typedef enum
00132 {
00133     EC_RX_PDO, 
00134     EC_TX_PDO 
00135 }
00136 ec_sii_pdo_type_t;
00137 
00138 /*****************************************************************************/
00139 
00144 typedef struct
00145 {
00146     struct list_head list; 
00147     ec_sii_pdo_type_t type; 
00148     uint16_t index; 
00149     uint8_t sync_index; 
00150     char *name; 
00151     struct list_head entries; 
00152 }
00153 ec_sii_pdo_t;
00154 
00155 /*****************************************************************************/
00156 
00161 typedef struct
00162 {
00163     struct list_head list; 
00164     uint16_t index; 
00165     uint8_t subindex; 
00166     char *name; 
00167     uint8_t bit_length; 
00168 }
00169 ec_sii_pdo_entry_t;
00170 
00171 /*****************************************************************************/
00172 
00177 typedef struct
00178 {
00179     unsigned int index; 
00180     const ec_domain_t *domain; 
00181     const ec_sii_sync_t *sync; 
00182     uint32_t logical_start_address; 
00183 }
00184 ec_fmmu_t;
00185 
00186 /*****************************************************************************/
00187 
00192 struct ec_slave
00193 {
00194     struct list_head list; 
00195     struct kobject kobj; 
00196     ec_master_t *master; 
00198     ec_slave_state_t requested_state; 
00199     ec_slave_state_t current_state; 
00200     unsigned int configured; 
00201     unsigned int error_flag; 
00202     unsigned int online; 
00204     // addresses
00205     uint16_t ring_position; 
00206     uint16_t station_address; 
00207     uint16_t coupler_index; 
00208     uint16_t coupler_subindex; 
00210     // base data
00211     uint8_t base_type; 
00212     uint8_t base_revision; 
00213     uint16_t base_build; 
00214     uint16_t base_fmmu_count; 
00215     uint16_t base_sync_count; 
00217     // data link status
00218     uint8_t dl_link[4]; 
00219     uint8_t dl_loop[4]; 
00220     uint8_t dl_signal[4]; 
00222     // EEPROM
00223     uint8_t *eeprom_data; 
00224     uint16_t eeprom_size; 
00225     uint16_t *new_eeprom_data; 
00226     uint16_t new_eeprom_size; 
00228     // slave information interface
00229     uint16_t sii_alias; 
00230     uint32_t sii_vendor_id; 
00231     uint32_t sii_product_code; 
00232     uint32_t sii_revision_number; 
00233     uint32_t sii_serial_number; 
00234     uint16_t sii_rx_mailbox_offset; 
00235     uint16_t sii_rx_mailbox_size; 
00236     uint16_t sii_tx_mailbox_offset; 
00237     uint16_t sii_tx_mailbox_size; 
00238     uint16_t sii_mailbox_protocols; 
00239     uint8_t sii_physical_layer[4]; 
00240     struct list_head sii_strings; 
00241     struct list_head sii_syncs; 
00242     struct list_head sii_pdos; 
00243     char *sii_group; 
00244     char *sii_image; 
00245     char *sii_order; 
00246     char *sii_name; 
00248     ec_fmmu_t fmmus[EC_MAX_FMMUS]; 
00249     uint8_t fmmu_count; 
00251     struct kobject sdo_kobj; 
00252     struct list_head sdo_dictionary; 
00253     struct list_head sdo_confs; 
00254     uint8_t sdo_dictionary_fetched; 
00255     unsigned long jiffies_preop; 
00256 };
00257 
00258 /*****************************************************************************/
00259 
00260 // slave construction/destruction
00261 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t);
00262 void ec_slave_destroy(ec_slave_t *);
00263 
00264 void ec_slave_reset(ec_slave_t *);
00265 
00266 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *,
00267                           const ec_sii_sync_t *);
00268 
00269 void ec_slave_request_state(ec_slave_t *, ec_slave_state_t);
00270 
00271 // SII categories
00272 int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *);
00273 void ec_slave_fetch_general(ec_slave_t *, const uint8_t *);
00274 int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t);
00275 int ec_slave_fetch_pdo(ec_slave_t *, const uint8_t *, size_t,
00276                        ec_sii_pdo_type_t);
00277 int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
00278 
00279 // misc.
00280 uint16_t ec_slave_calc_sync_size(const ec_slave_t *,
00281                                  const ec_sii_sync_t *);
00282 
00283 int ec_slave_is_coupler(const ec_slave_t *);
00284 int ec_slave_has_subbus(const ec_slave_t *);
00285 
00286 int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t);
00287 
00288 void ec_slave_sdo_dict_info(const ec_slave_t *,
00289                             unsigned int *, unsigned int *);
00290 
00291 /*****************************************************************************/
00292 
00293 #endif

Generated on Tue Nov 7 15:03:36 2006 for IgH EtherCAT master by  doxygen 1.4.4