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

master.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  *  $Id: master.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_MASTER_H_
00042 #define _EC_MASTER_H_
00043 
00044 #include <linux/list.h>
00045 #include <linux/sysfs.h>
00046 #include <linux/timer.h>
00047 #include <asm/atomic.h>
00048 #include <asm/semaphore.h>
00049 
00050 #include "device.h"
00051 #include "domain.h"
00052 #include "fsm.h"
00053 
00054 /*****************************************************************************/
00055 
00060 typedef enum
00061 {
00062     EC_MASTER_MODE_ORPHANED,
00063     EC_MASTER_MODE_IDLE,
00064     EC_MASTER_MODE_OPERATION
00065 }
00066 ec_master_mode_t;
00067 
00068 /*****************************************************************************/
00069 
00074 typedef struct
00075 {
00076     unsigned int timeouts; 
00077     unsigned int corrupted; 
00078     unsigned int skipped; 
00080     unsigned int unmatched; 
00082     unsigned long output_jiffies; 
00083 }
00084 ec_stats_t;
00085 
00086 /*****************************************************************************/
00087 
00093 struct ec_master
00094 {
00095     struct list_head list; 
00096     atomic_t available; 
00097     unsigned int index; 
00099     struct kobject kobj; 
00101     ec_device_t *device; 
00102     struct semaphore device_sem; 
00104     ec_fsm_t fsm; 
00105     ec_master_mode_t mode; 
00107     struct list_head slaves; 
00108     unsigned int slave_count; 
00110     struct list_head datagram_queue; 
00111     uint8_t datagram_index; 
00113     struct list_head domains; 
00115     int debug_level; 
00116     ec_stats_t stats; 
00118     struct workqueue_struct *workqueue; 
00119     struct work_struct idle_work; 
00120     uint32_t idle_cycle_times[HZ]; 
00121     unsigned int idle_cycle_time_pos; 
00123     struct timer_list eoe_timer; 
00124     uint32_t eoe_cycle_times[HZ]; 
00125     unsigned int eoe_cycle_time_pos; 
00126     unsigned int eoe_running; 
00127     unsigned int eoe_checked; 
00129     struct list_head eoe_handlers; 
00131     spinlock_t internal_lock; 
00132     int (*request_cb)(void *); 
00133     void (*release_cb)(void *); 
00134     void *cb_data; 
00136     uint8_t eeprom_write_enable; 
00138     ec_sdo_request_t *sdo_request; 
00139     unsigned int sdo_seq_user; 
00140     unsigned int sdo_seq_master; 
00141     struct semaphore sdo_sem; 
00142     struct timer_list sdo_timer; 
00143     struct completion sdo_complete; 
00144 };
00145 
00146 /*****************************************************************************/
00147 
00148 // master creation/deletion
00149 int ec_master_init(ec_master_t *, unsigned int, unsigned int);
00150 void ec_master_destroy(ec_master_t *);
00151 
00152 // mode transitions
00153 int ec_master_enter_idle_mode(ec_master_t *);
00154 void ec_master_leave_idle_mode(ec_master_t *);
00155 int ec_master_enter_operation_mode(ec_master_t *);
00156 void ec_master_leave_operation_mode(ec_master_t *);
00157 
00158 // EoE
00159 void ec_master_eoe_start(ec_master_t *);
00160 void ec_master_eoe_stop(ec_master_t *);
00161 
00162 // datagram IO
00163 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
00164 void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
00165 
00166 // misc.
00167 void ec_master_output_stats(ec_master_t *);
00168 void ec_master_destroy_slaves(ec_master_t *);
00169 void ec_master_calc_addressing(ec_master_t *);
00170 
00171 // helper functions
00172 void ec_sync_config(const ec_sii_sync_t *, const ec_slave_t *, uint8_t *);
00173 void ec_fmmu_config(const ec_fmmu_t *, const ec_slave_t *, uint8_t *);
00174 
00175 /*****************************************************************************/
00176 
00177 #endif

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