master.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: master.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_MASTER_H_
00042 #define _EC_MASTER_H_
00043 
00044 #include <linux/list.h>
00045 #include <linux/sysfs.h>
00046 #include <linux/timer.h>
00047 
00048 #include "device.h"
00049 #include "domain.h"
00050 #include "fsm.h"
00051 
00052 /*****************************************************************************/
00053 
00058 typedef enum
00059 {
00060     EC_MASTER_MODE_ORPHANED,
00061     EC_MASTER_MODE_IDLE,
00062     EC_MASTER_MODE_RUNNING
00063 }
00064 ec_master_mode_t;
00065 
00066 /*****************************************************************************/
00067 
00072 typedef struct
00073 {
00074     unsigned int timeouts; 
00075     unsigned int delayed; 
00076     unsigned int corrupted; 
00077     unsigned int unmatched; 
00078     cycles_t t_last; 
00079 }
00080 ec_stats_t;
00081 
00082 /*****************************************************************************/
00083 
00089 struct ec_master
00090 {
00091     struct list_head list; 
00092     unsigned int reserved; 
00093     unsigned int index; 
00095     struct kobject kobj; 
00097     struct list_head slaves; 
00098     unsigned int slave_count; 
00100     ec_device_t *device; 
00102     struct list_head datagram_queue; 
00103     uint8_t datagram_index; 
00105     struct list_head domains; 
00107     ec_datagram_t simple_datagram; 
00109     unsigned int timeout; 
00111     int debug_level; 
00112     ec_stats_t stats; 
00114     struct workqueue_struct *workqueue; 
00115     struct work_struct idle_work; 
00116     ec_fsm_t fsm; 
00117     ec_master_mode_t mode; 
00119     struct timer_list eoe_timer; 
00120     unsigned int eoe_running; 
00121     struct list_head eoe_handlers; 
00122     spinlock_t internal_lock; 
00123     int (*request_cb)(void *); 
00124     void (*release_cb)(void *); 
00125     void *cb_data; 
00127     uint8_t eeprom_write_enable; 
00128 };
00129 
00130 /*****************************************************************************/
00131 
00132 // master creation and deletion
00133 int ec_master_init(ec_master_t *, unsigned int, unsigned int);
00134 void ec_master_clear(struct kobject *);
00135 void ec_master_reset(ec_master_t *);
00136 
00137 // free run
00138 void ec_master_idle_start(ec_master_t *);
00139 void ec_master_idle_stop(ec_master_t *);
00140 
00141 // EoE
00142 void ec_master_eoe_start(ec_master_t *);
00143 void ec_master_eoe_stop(ec_master_t *);
00144 
00145 // IO
00146 void ec_master_receive(ec_master_t *, const uint8_t *, size_t);
00147 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
00148 int ec_master_simple_io(ec_master_t *, ec_datagram_t *);
00149 
00150 // slave management
00151 int ec_master_bus_scan(ec_master_t *);
00152 
00153 // misc.
00154 void ec_master_clear_slaves(ec_master_t *);
00155 void ec_sync_config(const ec_sync_t *, const ec_slave_t *, uint8_t *);
00156 void ec_eeprom_sync_config(const ec_eeprom_sync_t *, const ec_slave_t *,
00157                            uint8_t *);
00158 void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *);
00159 void ec_master_output_stats(ec_master_t *);
00160 
00161 /*****************************************************************************/
00162 
00163 #endif

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