author | Florian Pose <fp@igh-essen.com> |
Thu, 05 Jan 2006 14:13:34 +0000 | |
changeset 44 | 68d5b57cf038 |
parent 43 | 35120a61d55e |
child 45 | f525f7db2d90 |
permissions | -rw-r--r-- |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
1 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
2 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
3 |
* msr_module.c |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
4 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
5 |
* Kernelmodul für 2.6 Kernel zur Meßdatenerfassung, Steuerung und Regelung. |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
6 |
* Zeitgeber ist der Timerinterrupt (tq) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
7 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
8 |
* Autor: Wilhelm Hagemeister |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
9 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
10 |
* (C) Copyright IgH 2002 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
11 |
* Ingenieurgemeinschaft IgH |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
12 |
* Heinz-Bäcker Str. 34 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
13 |
* D-45356 Essen |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
14 |
* Tel.: +49 201/61 99 31 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
15 |
* Fax.: +49 201/61 98 36 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
16 |
* E-mail: hm@igh-essen.com |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
17 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
18 |
* $Id$ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
19 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
20 |
*****************************************************************************/ |
28 | 21 |
|
22 |
#ifndef __KERNEL__ |
|
23 |
# define __KERNEL__ |
|
24 |
#endif |
|
25 |
#ifndef MODULE |
|
26 |
# define MODULE |
|
27 |
#endif |
|
28 |
||
29 |
#include <linux/config.h> |
|
30 |
#include <linux/module.h> |
|
31 |
||
32 |
#include <linux/sched.h> |
|
33 |
#include <linux/kernel.h> |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
34 |
#include <linux/vmalloc.h> |
28 | 35 |
#include <linux/fs.h> /* everything... */ |
36 |
#include <linux/proc_fs.h> |
|
37 |
#include <linux/time.h> |
|
38 |
#include <linux/timer.h> |
|
39 |
#include <linux/timex.h> /* fuer get_cycles */ |
|
40 |
#include <linux/errno.h> /* error codes */ |
|
41 |
#include <asm/msr.h> /* maschine-specific registers */ |
|
42 |
#include <linux/param.h> /* fuer HZ */ |
|
43 |
#include <linux/ipipe.h> |
|
44 |
||
45 |
#include "msr_param.h" //wird im Projektverzeichnis erwartet |
|
46 |
||
47 |
//#include <msr_control.h> |
|
48 |
#include <msr_lists.h> |
|
49 |
#include <msr_charbuf.h> |
|
50 |
#include <msr_reg.h> |
|
51 |
#include <msr_error_reg.h> |
|
52 |
#include <msr_messages.h> |
|
53 |
#include <msr_proc.h> |
|
54 |
#include <msr_utils.h> |
|
55 |
#include <msr_main.h> |
|
56 |
||
57 |
||
58 |
#include <msr_float.h> |
|
59 |
||
60 |
#include "../drivers/ec_master.h" |
|
61 |
#include "../drivers/ec_device.h" |
|
62 |
#include "../drivers/ec_types.h" |
|
63 |
#include "../drivers/ec_module.h" |
|
64 |
||
65 |
#include "msr_jitter.h" |
|
66 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
67 |
#define TSC2US(T) ((unsigned long) (T) * 1000UL / cpu_khz) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
68 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
69 |
/*--external data------------------------------------------------------------*/ |
28 | 70 |
|
71 |
#define HZREDUCTION (MSR_ABTASTFREQUENZ/HZ) |
|
72 |
||
73 |
extern wait_queue_head_t msr_read_waitqueue; |
|
74 |
||
75 |
extern struct msr_char_buf *msr_kanal_puffer; |
|
76 |
||
77 |
extern int proc_abtastfrequenz; |
|
78 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
79 |
/*--local data---------------------------------------------------------------*/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
80 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
81 |
extern struct timeval process_time; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
82 |
struct timeval msr_time_increment; // Increment per Interrupt |
28 | 83 |
|
84 |
//adeos |
|
85 |
||
86 |
static struct ipipe_domain this_domain; |
|
87 |
||
88 |
static struct ipipe_sysinfo sys_info; |
|
89 |
||
90 |
static EtherCAT_master_t *ecat_master = NULL; |
|
91 |
||
92 |
static EtherCAT_slave_t ecat_slaves[] = |
|
93 |
{ |
|
94 |
#if 1 |
|
95 |
// Block 1 |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
96 |
ECAT_INIT_SLAVE(Beckhoff_EK1100, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
97 |
ECAT_INIT_SLAVE(Beckhoff_EL4102, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
98 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
99 |
ECAT_INIT_SLAVE(Beckhoff_EL3162, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
100 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
101 |
ECAT_INIT_SLAVE(Beckhoff_EL3102, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
102 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
103 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
104 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
105 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 0), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
106 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 0), |
28 | 107 |
|
108 |
// Block 2 |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
109 |
ECAT_INIT_SLAVE(Beckhoff_EK1100, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
110 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
111 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
112 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
113 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
114 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
115 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
116 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
117 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
118 |
ECAT_INIT_SLAVE(Beckhoff_EL2004, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
119 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
120 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
121 |
ECAT_INIT_SLAVE(Beckhoff_EL1014, 1) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
122 |
#endif |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
123 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
124 |
#if 0 |
28 | 125 |
// Block 3 |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
126 |
,ECAT_INIT_SLAVE(Beckhoff_EK1100, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
127 |
ECAT_INIT_SLAVE(Beckhoff_EL3162, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
128 |
ECAT_INIT_SLAVE(Beckhoff_EL3162, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
129 |
ECAT_INIT_SLAVE(Beckhoff_EL3162, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
130 |
ECAT_INIT_SLAVE(Beckhoff_EL3162, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
131 |
ECAT_INIT_SLAVE(Beckhoff_EL3102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
132 |
ECAT_INIT_SLAVE(Beckhoff_EL3102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
133 |
ECAT_INIT_SLAVE(Beckhoff_EL3102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
134 |
ECAT_INIT_SLAVE(Beckhoff_EL4102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
135 |
ECAT_INIT_SLAVE(Beckhoff_EL4102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
136 |
ECAT_INIT_SLAVE(Beckhoff_EL4102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
137 |
ECAT_INIT_SLAVE(Beckhoff_EL4102, 2), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
138 |
ECAT_INIT_SLAVE(Beckhoff_EL4132, 2) |
28 | 139 |
#endif |
140 |
}; |
|
141 |
||
142 |
#define ECAT_SLAVES_COUNT (sizeof(ecat_slaves) / sizeof(EtherCAT_slave_t)) |
|
143 |
||
144 |
#define USE_MSR_LIB |
|
145 |
||
146 |
#ifdef USE_MSR_LIB |
|
147 |
double value; |
|
148 |
int dig1; |
|
149 |
#endif |
|
150 |
||
151 |
/****************************************************************************** |
|
152 |
* |
|
153 |
* Function: next2004 |
|
154 |
* |
|
155 |
*****************************************************************************/ |
|
156 |
||
157 |
static int next2004(int *wrap) |
|
158 |
{ |
|
159 |
static int i = 0; |
|
160 |
unsigned int j = 0; |
|
161 |
||
162 |
*wrap = 0; |
|
163 |
||
164 |
for (j = 0; j < ECAT_SLAVES_COUNT; j++) |
|
165 |
{ |
|
166 |
i++; |
|
167 |
||
168 |
i %= ECAT_SLAVES_COUNT; |
|
169 |
||
170 |
if (i == 0) *wrap = 1; |
|
171 |
||
172 |
if (ecat_slaves[i].desc == Beckhoff_EL2004) |
|
173 |
{ |
|
174 |
return i; |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
return -1; |
|
179 |
} |
|
180 |
||
181 |
||
182 |
/****************************************************************************** |
|
183 |
* |
|
184 |
* Function: msr_controller_run() |
|
185 |
* |
|
186 |
*****************************************************************************/ |
|
187 |
||
188 |
static void msr_controller_run(void) |
|
189 |
{ |
|
190 |
static int ms = 0; |
|
191 |
static int cnt = 0; |
|
192 |
static unsigned long int k = 0; |
|
193 |
static int firstrun = 1; |
|
194 |
||
195 |
static int klemme = 0; |
|
196 |
static int kanal = 0; |
|
197 |
static int up_down = 0; |
|
198 |
int wrap = 0; |
|
199 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
200 |
static unsigned int debug_counter = 0; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
201 |
unsigned long t1, t2, t3, t4, t5, t6, t7; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
202 |
static unsigned long lt = 0; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
203 |
unsigned int tr1, tr2; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
204 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
205 |
rdtscl(t1); |
28 | 206 |
|
207 |
// Prozessdaten lesen |
|
208 |
msr_jitter_run(MSR_ABTASTFREQUENZ); |
|
209 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
210 |
if (firstrun) klemme = next2004(&wrap); |
28 | 211 |
|
212 |
ms++; |
|
213 |
ms %= 1000; |
|
40 | 214 |
if (cnt++ > 200) |
28 | 215 |
{ |
216 |
cnt = 0; |
|
217 |
||
218 |
if (++kanal > 3) |
|
219 |
{ |
|
220 |
kanal = 0; |
|
221 |
klemme = next2004(&wrap); |
|
222 |
||
223 |
if (wrap == 1) |
|
224 |
{ |
|
225 |
if (up_down == 1) up_down = 0; |
|
226 |
else up_down = 1; |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
if (klemme >= 0) { |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
232 |
EtherCAT_write_value(&ecat_slaves[klemme], kanal, up_down); |
28 | 233 |
} |
234 |
||
235 |
#if 0 |
|
236 |
EtherCAT_write_value(&ecat_master->slaves[13], 1, ms > 500 ? 0 : 1); |
|
237 |
EtherCAT_write_value(&ecat_master->slaves[14], 2, ms > 500 ? 0 : 1); |
|
238 |
EtherCAT_write_value(&ecat_master->slaves[15], 3, ms > 500 ? 1 : 0); |
|
239 |
#endif |
|
240 |
||
241 |
// Prozessdaten schreiben |
|
242 |
rdtscl(k); |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
243 |
rdtscl(t2); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
244 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
245 |
EtherCAT_process_data_cycle(ecat_master, 0); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
246 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
247 |
t3 = ecat_master->tx_time; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
248 |
t4 = ecat_master->rx_time; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
249 |
tr1 = ecat_master->rx_tries; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
250 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
251 |
EtherCAT_process_data_cycle(ecat_master, 1); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
252 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
253 |
t5 = ecat_master->tx_time; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
254 |
t6 = ecat_master->rx_time; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
255 |
tr2 = ecat_master->rx_tries; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
256 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
257 |
//EtherCAT_process_data_cycle(ecat_master, 2); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
258 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
259 |
// Daten lesen und skalieren |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
260 |
#ifdef USE_MSR_LIB |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
261 |
value = EtherCAT_read_value(&ecat_slaves[5], 0) / 3276.0; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
262 |
dig1 = EtherCAT_read_value(&ecat_slaves[2], 0); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
263 |
#endif |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
264 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
265 |
rdtscl(t7); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
266 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
267 |
if (debug_counter == MSR_ABTASTFREQUENZ) { |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
268 |
printk(KERN_DEBUG "%lu: %luŽµs + %luŽµs + %luŽµs + %luŽµs + %luŽµs +" |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
269 |
" %luŽµs = %luŽµs (%u %u)\n", |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
270 |
TSC2US(t1 - lt), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
271 |
TSC2US(t2 - t1), TSC2US(t3 - t2), TSC2US(t4 - t3), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
272 |
TSC2US(t5 - t4), TSC2US(t6 - t5), TSC2US(t7 - t6), |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
273 |
TSC2US(t7 - t1), tr1, tr2); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
274 |
debug_counter = 0; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
275 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
276 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
277 |
lt = t1; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
278 |
|
28 | 279 |
firstrun = 0; |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
280 |
debug_counter++; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
281 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
282 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
283 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
284 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
285 |
* Function: msr_run(_interrupt) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
286 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
287 |
* Beschreibung: Routine wird zyklisch im Timerinterrupt ausgeführt |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
288 |
* (hier muß alles rein, was Echtzeit ist ...) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
289 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
290 |
* Parameter: Zeiger auf msr_data |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
291 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
292 |
* Rückgabe: |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
293 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
294 |
* Status: exp |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
295 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
296 |
*****************************************************************************/ |
28 | 297 |
|
298 |
void msr_run(unsigned irq) |
|
299 |
{ |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
300 |
static int counter = 0; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
301 |
#ifdef USE_MSR_LIB |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
302 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
303 |
timeval_add(&process_time,&process_time,&msr_time_increment); |
28 | 304 |
|
305 |
MSR_ADEOS_INTERRUPT_CODE( |
|
306 |
msr_controller_run(); |
|
307 |
msr_write_kanal_list(); |
|
308 |
); |
|
309 |
#else |
|
310 |
msr_controller_run(); |
|
311 |
#endif |
|
312 |
/* und wieder in die Timerliste eintragen */ |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
313 |
/* und neu in die Taskqueue eintragen */ |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
314 |
//timer.expires += 1; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
315 |
//add_timer(&timer); |
28 | 316 |
|
40 | 317 |
ipipe_control_irq(irq,0,IPIPE_ENABLE_MASK); //Interrupt bestŽätigen |
28 | 318 |
if(counter++ > HZREDUCTION) { |
40 | 319 |
ipipe_propagate_irq(irq); //und weiterreichen |
28 | 320 |
counter = 0; |
321 |
} |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
322 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
323 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
324 |
void domain_entry (void) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
325 |
{ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
326 |
printk("Domain %s started.\n", ipipe_current_domain->name); |
28 | 327 |
|
328 |
ipipe_get_sysinfo(&sys_info); |
|
329 |
ipipe_virtualize_irq(ipipe_current_domain,sys_info.archdep.tmirq, |
|
330 |
&msr_run, NULL, IPIPE_HANDLE_MASK); |
|
331 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
332 |
ipipe_tune_timer(1000000000UL/MSR_ABTASTFREQUENZ,0); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
333 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
334 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
335 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
336 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
337 |
* Function: msr_register_channels |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
338 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
339 |
* Beschreibung: KanŽäle registrieren |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
340 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
341 |
* Parameter: |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
342 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
343 |
* RŽückgabe: |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
344 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
345 |
* Status: exp |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
346 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
347 |
*****************************************************************************/ |
28 | 348 |
|
349 |
int msr_globals_register(void) |
|
350 |
{ |
|
351 |
#ifdef USE_MSR_LIB |
|
352 |
msr_reg_kanal("/value", "V", &value, TDBL); |
|
353 |
msr_reg_kanal("/dig1", "", &dig1, TINT); |
|
354 |
#endif |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
355 |
#if 0 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
356 |
msr_reg_kanal("/Taskinfo/Ecat/TX-Delay","us",&ecat_tx_delay,TUINT); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
357 |
msr_reg_kanal("/Taskinfo/Ecat/RX-Delay","us",&ecat_rx_delay,TUINT); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
358 |
msr_reg_kanal("/Taskinfo/Ecat/TX-Cnt","",&tx_intr,TUINT); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
359 |
msr_reg_kanal("/Taskinfo/Ecat/RX-Cnt","",&rx_intr,TUINT); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
360 |
msr_reg_kanal("/Taskinfo/Ecat/Total-Cnt","",&total_intr,TUINT); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
361 |
#endif |
28 | 362 |
return 0; |
363 |
} |
|
364 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
365 |
/****************************************************************************** |
28 | 366 |
* the init/clean material |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
367 |
*****************************************************************************/ |
28 | 368 |
|
369 |
int __init init_module() |
|
370 |
{ |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
371 |
unsigned int i; |
28 | 372 |
struct ipipe_domain_attr attr; //ipipe |
373 |
||
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
374 |
// Als allererstes die RT-lib initialisieren |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
375 |
#ifdef USE_MSR_LIB |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
376 |
if (msr_rtlib_init(1,MSR_ABTASTFREQUENZ,10,&msr_globals_register) < 0) { |
28 | 377 |
msr_print_warn("msr_modul: can't initialize rtlib!"); |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
378 |
goto out_return; |
28 | 379 |
} |
380 |
#endif |
|
381 |
||
382 |
msr_jitter_init(); |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
383 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
384 |
printk(KERN_INFO "=== Starting EtherCAT environment... ===\n"); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
385 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
386 |
if ((ecat_master = EtherCAT_request(0)) == NULL) { |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
387 |
printk(KERN_ERR "EtherCAT master 0 not available!\n"); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
388 |
goto out_msr_cleanup; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
389 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
390 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
391 |
printk("Checking EtherCAT slaves.\n"); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
392 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
393 |
if (EtherCAT_check_slaves(ecat_master, ecat_slaves, ECAT_SLAVES_COUNT) != 0) { |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
394 |
printk(KERN_ERR "EtherCAT: Could not init slaves!\n"); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
395 |
goto out_release_master; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
396 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
397 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
398 |
printk("Activating all EtherCAT slaves.\n"); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
399 |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
400 |
for (i = 0; i < ECAT_SLAVES_COUNT; i++) { |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
401 |
if (EtherCAT_activate_slave(ecat_master, ecat_slaves + i) < 0) { |
43 | 402 |
printk(KERN_ERR "EtherCAT: Could not activate slave %i!\n", i); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
403 |
goto out_release_master; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
404 |
} |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
405 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
406 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
407 |
do_gettimeofday(&process_time); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
408 |
msr_time_increment.tv_sec=0; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
409 |
msr_time_increment.tv_usec=(unsigned int)(1000000/MSR_ABTASTFREQUENZ); |
28 | 410 |
|
411 |
ipipe_init_attr (&attr); |
|
412 |
attr.name = "IPIPE-MSR-MODULE"; |
|
413 |
attr.priority = IPIPE_ROOT_PRIO + 1; |
|
414 |
attr.entry = &domain_entry; |
|
415 |
ipipe_register_domain(&this_domain,&attr); |
|
416 |
||
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
417 |
return 0; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
418 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
419 |
out_release_master: |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
420 |
EtherCAT_release(ecat_master); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
421 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
422 |
out_msr_cleanup: |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
423 |
msr_rtlib_cleanup(); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
424 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
425 |
out_return: |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
426 |
return -1; |
28 | 427 |
} |
428 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
429 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
430 |
|
28 | 431 |
void __exit cleanup_module() |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
432 |
{ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
433 |
unsigned int i; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
434 |
|
28 | 435 |
msr_print_info("msk_modul: unloading..."); |
436 |
||
437 |
ipipe_tune_timer(1000000000UL/HZ,0); //alten Timertakt wieder herstellen |
|
438 |
ipipe_unregister_domain(&this_domain); |
|
439 |
||
440 |
if (ecat_master) |
|
441 |
{ |
|
43 | 442 |
printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n"); |
443 |
||
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
444 |
printk(KERN_INFO "Deactivating slaves.\n"); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
445 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
446 |
for (i = 0; i < ECAT_SLAVES_COUNT; i++) { |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
447 |
if (EtherCAT_deactivate_slave(ecat_master, ecat_slaves + i) < 0) { |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
448 |
printk(KERN_WARNING "Warning - Could not deactivate slave!\n"); |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
449 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
450 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
451 |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
452 |
EtherCAT_release(ecat_master); |
43 | 453 |
|
454 |
printk(KERN_INFO "=== EtherCAT environment stopped. ===\n"); |
|
455 |
} |
|
28 | 456 |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
457 |
#ifdef USE_MSR_LIB |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
458 |
msr_rtlib_cleanup(); |
28 | 459 |
#endif |
460 |
} |
|
461 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
462 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
463 |
|
28 | 464 |
MODULE_LICENSE("GPL"); |
465 |
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>"); |
|
466 |
MODULE_DESCRIPTION ("EtherCAT test environment"); |
|
467 |
||
468 |
module_init(init_module); |
|
469 |
module_exit(cleanup_module); |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
470 |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
471 |
/*****************************************************************************/ |