slave.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: slave.h 490 2006-08-02 12:25:25Z 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 "globals.h"
00048 #include "datagram.h"
00049 #include "types.h"
00050 
00051 /*****************************************************************************/
00052 
00057 typedef enum
00058 {
00059     EC_SLAVE_STATE_UNKNOWN = 0x00,
00061     EC_SLAVE_STATE_INIT = 0x01,
00063     EC_SLAVE_STATE_PREOP = 0x02,
00065     EC_SLAVE_STATE_SAVEOP = 0x04,
00067     EC_SLAVE_STATE_OP = 0x08,
00069     EC_ACK = 0x10
00071 }
00072 ec_slave_state_t;
00073 
00074 /*****************************************************************************/
00075 
00080 enum
00081 {
00082     EC_MBOX_AOE = 0x01, 
00083     EC_MBOX_EOE = 0x02, 
00084     EC_MBOX_COE = 0x04, 
00085     EC_MBOX_FOE = 0x08, 
00086     EC_MBOX_SOE = 0x10, 
00087     EC_MBOX_VOE = 0x20  
00088 };
00089 
00090 /*****************************************************************************/
00091 
00096 typedef struct
00097 {
00098     const ec_domain_t *domain; 
00099     const ec_sync_t *sync; 
00100     uint32_t logical_start_address; 
00101 }
00102 ec_fmmu_t;
00103 
00104 /*****************************************************************************/
00105 
00110 typedef struct
00111 {
00112     struct list_head list; 
00113     size_t size; 
00114     char *data; 
00115 }
00116 ec_eeprom_string_t;
00117 
00118 /*****************************************************************************/
00119 
00124 typedef struct
00125 {
00126     struct list_head list; 
00127     unsigned int index; 
00128     uint16_t physical_start_address; 
00129     uint16_t length; 
00130     uint8_t control_register; 
00131     uint8_t enable; 
00132 }
00133 ec_eeprom_sync_t;
00134 
00135 /*****************************************************************************/
00136 
00141 typedef enum
00142 {
00143     EC_RX_PDO, 
00144     EC_TX_PDO 
00145 }
00146 ec_pdo_type_t;
00147 
00148 /*****************************************************************************/
00149 
00154 typedef struct
00155 {
00156     struct list_head list; 
00157     ec_pdo_type_t type; 
00158     uint16_t index; 
00159     uint8_t sync_manager; 
00160     char *name; 
00161     struct list_head entries; 
00162 }
00163 ec_eeprom_pdo_t;
00164 
00165 /*****************************************************************************/
00166 
00171 typedef struct
00172 {
00173     struct list_head list; 
00174     uint16_t index; 
00175     uint8_t subindex; 
00176     char *name; 
00177     uint8_t bit_length; 
00178 }
00179 ec_eeprom_pdo_entry_t;
00180 
00181 /*****************************************************************************/
00182 
00187 typedef struct
00188 {
00189     struct list_head list; 
00190     uint16_t index; 
00191     //uint16_t type;
00192     uint8_t object_code; 
00193     char *name; 
00194     struct list_head entries; 
00195 }
00196 ec_sdo_t;
00197 
00198 /*****************************************************************************/
00199 
00204 typedef struct
00205 {
00206     struct list_head list; 
00207     uint8_t subindex; 
00208     uint16_t data_type; 
00209     uint16_t bit_length; 
00210     char *name; 
00211 }
00212 ec_sdo_entry_t;
00213 
00214 /*****************************************************************************/
00215 
00220 typedef struct
00221 {
00222     struct list_head list; 
00223     const ec_field_t *field; 
00224     size_t size; 
00225 }
00226 ec_varsize_t;
00227 
00228 /*****************************************************************************/
00229 
00234 struct ec_slave
00235 {
00236     struct list_head list; 
00237     struct kobject kobj; 
00238     ec_master_t *master; 
00240     // addresses
00241     uint16_t ring_position; 
00242     uint16_t station_address; 
00243     uint16_t coupler_index; 
00244     uint16_t coupler_subindex; 
00246     // base data
00247     uint8_t base_type; 
00248     uint8_t base_revision; 
00249     uint16_t base_build; 
00250     uint16_t base_fmmu_count; 
00251     uint16_t base_sync_count; 
00253     // data link status
00254     uint8_t dl_link[4]; 
00255     uint8_t dl_loop[4]; 
00256     uint8_t dl_signal[4]; 
00258     // slave information interface
00259     uint16_t sii_alias; 
00260     uint32_t sii_vendor_id; 
00261     uint32_t sii_product_code; 
00262     uint32_t sii_revision_number; 
00263     uint32_t sii_serial_number; 
00264     uint16_t sii_rx_mailbox_offset; 
00265     uint16_t sii_rx_mailbox_size; 
00266     uint16_t sii_tx_mailbox_offset; 
00267     uint16_t sii_tx_mailbox_size; 
00268     uint16_t sii_mailbox_protocols; 
00269     uint8_t sii_physical_layer[4]; 
00271     const ec_slave_type_t *type; 
00273     uint8_t registered; 
00275     ec_fmmu_t fmmus[EC_MAX_FMMUS]; 
00276     uint8_t fmmu_count; 
00278     uint8_t *eeprom_data; 
00279     uint16_t eeprom_size; 
00280     struct list_head eeprom_strings; 
00281     struct list_head eeprom_syncs; 
00282     struct list_head eeprom_pdos; 
00283     char *eeprom_group; 
00284     char *eeprom_image; 
00285     char *eeprom_order; 
00286     char *eeprom_name; 
00288     uint16_t *new_eeprom_data; 
00289     size_t new_eeprom_size; 
00291     struct list_head sdo_dictionary; 
00293     ec_slave_state_t requested_state; 
00294     ec_slave_state_t current_state; 
00295     unsigned int error_flag; 
00296     unsigned int online; 
00298     struct list_head varsize_fields; 
00300 };
00301 
00302 /*****************************************************************************/
00303 
00304 // slave construction/destruction
00305 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t);
00306 void ec_slave_clear(struct kobject *);
00307 
00308 // slave control
00309 int ec_slave_fetch(ec_slave_t *);
00310 int ec_slave_sii_read16(ec_slave_t *, uint16_t, uint16_t *);
00311 int ec_slave_sii_read32(ec_slave_t *, uint16_t, uint32_t *);
00312 int ec_slave_sii_write16(ec_slave_t *, uint16_t, uint16_t);
00313 int ec_slave_state_change(ec_slave_t *, uint8_t);
00314 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *,
00315                           const ec_sync_t *);
00316 
00317 // CoE
00318 int ec_slave_fetch_sdo_list(ec_slave_t *);
00319 
00320 // state machine
00321 int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *);
00322 int ec_slave_fetch_general(ec_slave_t *, const uint8_t *);
00323 int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t);
00324 int ec_slave_fetch_pdo(ec_slave_t *, const uint8_t *, size_t, ec_pdo_type_t);
00325 int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
00326 
00327 // misc.
00328 size_t ec_slave_calc_sync_size(const ec_slave_t *, const ec_sync_t *);
00329 uint16_t ec_slave_calc_eeprom_sync_size(const ec_slave_t *,
00330                                         const ec_eeprom_sync_t *);
00331 
00332 void ec_slave_print(const ec_slave_t *, unsigned int);
00333 int ec_slave_check_crc(ec_slave_t *);
00334 
00335 /*****************************************************************************/
00336 
00337 #endif

Generated on Wed Aug 2 18:41:43 2006 for IgH EtherCAT master by  doxygen 1.4.6