master.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: master.h 533 2006-09-01 12:35:41Z 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_OPERATION
00063 }
00064 ec_master_mode_t;
00065 
00066 /*****************************************************************************/
00067 
00072 typedef struct
00073 {
00074     unsigned int timeouts; 
00075     unsigned int corrupted; 
00076     unsigned int skipped; 
00078     unsigned int unmatched; 
00080     unsigned long output_jiffies; 
00081 }
00082 ec_stats_t;
00083 
00084 /*****************************************************************************/
00085 
00091 struct ec_master
00092 {
00093     struct list_head list; 
00094     unsigned int reserved; 
00095     unsigned int index; 
00097     struct kobject kobj; 
00099     ec_device_t *device; 
00101     ec_fsm_t fsm; 
00102     ec_master_mode_t mode; 
00104     struct list_head slaves; 
00105     unsigned int slave_count; 
00107     struct list_head datagram_queue; 
00108     uint8_t datagram_index; 
00110     struct list_head domains; 
00112     int debug_level; 
00113     ec_stats_t stats; 
00115     struct workqueue_struct *workqueue; 
00116     struct work_struct idle_work; 
00117     uint32_t idle_cycle_times[HZ]; 
00118     unsigned int idle_cycle_time_pos; 
00120     struct timer_list eoe_timer; 
00121     uint32_t eoe_cycle_times[HZ]; 
00122     unsigned int eoe_cycle_time_pos; 
00123     unsigned int eoe_running; 
00124     unsigned int eoe_checked; 
00126     struct list_head eoe_handlers; 
00128     spinlock_t internal_lock; 
00129     int (*request_cb)(void *); 
00130     void (*release_cb)(void *); 
00131     void *cb_data; 
00133     uint8_t eeprom_write_enable; 
00134 };
00135 
00136 /*****************************************************************************/
00137 
00138 // master creation and deletion
00139 int ec_master_init(ec_master_t *, unsigned int, unsigned int);
00140 void ec_master_clear(struct kobject *);
00141 void ec_master_reset(ec_master_t *);
00142 
00143 // free run
00144 void ec_master_idle_start(ec_master_t *);
00145 void ec_master_idle_stop(ec_master_t *);
00146 
00147 // EoE
00148 void ec_master_eoe_start(ec_master_t *);
00149 void ec_master_eoe_stop(ec_master_t *);
00150 
00151 // IO
00152 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
00153 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
00154 
00155 // slave management
00156 int ec_master_bus_scan(ec_master_t *);
00157 
00158 // misc.
00159 void ec_master_output_stats(ec_master_t *);
00160 void ec_master_clear_slaves(ec_master_t *);
00161 void ec_master_measure_bus_time(ec_master_t *);
00162 
00163 // other methods
00164 void ec_sync_config(const ec_sii_sync_t *, const ec_slave_t *, uint8_t *);
00165 void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *);
00166 void ec_master_calc_addressing(ec_master_t *);
00167 
00168 /*****************************************************************************/
00169 
00170 #endif

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