author | Florian Pose <fp@igh-essen.com> |
Fri, 12 May 2006 10:12:14 +0000 | |
changeset 232 | f6594a07cdda |
parent 230 | 382bdb9138ec |
child 233 | 31d327ce38d3 |
permissions | -rw-r--r-- |
220 | 1 |
/****************************************************************************** |
2 |
* |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
3 |
* RTAI sample for the IgH EtherCAT master. |
220 | 4 |
* |
5 |
* $Id$ |
|
6 |
* |
|
7 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
8 |
* |
|
9 |
* This file is part of the IgH EtherCAT Master. |
|
10 |
* |
|
11 |
* The IgH EtherCAT Master is free software; you can redistribute it |
|
12 |
* and/or modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; version 2 of the License. |
|
14 |
* |
|
15 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
|
16 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
23 |
* |
|
24 |
*****************************************************************************/ |
|
25 |
||
26 |
#include <linux/module.h> |
|
27 |
#include <linux/delay.h> |
|
28 |
#include <linux/timer.h> |
|
29 |
#include <linux/interrupt.h> |
|
30 |
||
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
31 |
// RTAI |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
32 |
#include "rtai.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
33 |
#include "rtai_sched.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
34 |
#include "rtai_sem.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
35 |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
36 |
// EtherCAT realtime interface |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
37 |
#include "../../include/ecrt.h" |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
38 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
39 |
/*****************************************************************************/ |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
40 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
41 |
// comment this for synchronous IO |
220 | 42 |
#define ASYNC |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
43 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
44 |
// RTAI task frequency in Hz |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
45 |
#define FREQUENCY 10000 |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
46 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
47 |
#define TIMERTICKS (1000000000 / FREQUENCY) |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
48 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
49 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
50 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
51 |
// RTAI |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
52 |
RT_TASK task; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
53 |
SEM master_sem; |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
54 |
cycles_t t_last_start = 0; |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
55 |
cycles_t t_critical; |
220 | 56 |
|
57 |
// EtherCAT |
|
58 |
ec_master_t *master = NULL; |
|
59 |
ec_domain_t *domain1 = NULL; |
|
60 |
||
61 |
// data fields |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
62 |
void *r_ssi_input; |
220 | 63 |
|
64 |
// channels |
|
65 |
uint32_t k_pos; |
|
66 |
uint8_t k_stat; |
|
67 |
||
68 |
ec_field_init_t domain1_fields[] = { |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
69 |
{&r_ssi_input, "3", "Beckhoff", "EL5001", "InputValue", 0}, |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
70 |
{NULL, "2", "Beckhoff", "EL4132", "OutputValue", 0}, |
220 | 71 |
{} |
72 |
}; |
|
73 |
||
74 |
/*****************************************************************************/ |
|
75 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
76 |
void run(long data) |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
77 |
{ |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
78 |
while (1) |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
79 |
{ |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
80 |
t_last_start = get_cycles(); |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
81 |
rt_sem_wait(&master_sem); |
220 | 82 |
|
83 |
#ifdef ASYNC |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
84 |
// receive |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
85 |
ecrt_master_async_receive(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
86 |
ecrt_domain_process(domain1); |
220 | 87 |
#else |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
88 |
// send and receive |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
89 |
ecrt_domain_queue(domain1); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
90 |
ecrt_master_run(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
91 |
ecrt_master_sync_io(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
92 |
ecrt_domain_process(domain1); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
93 |
#endif |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
94 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
95 |
// process data |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
96 |
k_pos = EC_READ_U32(r_ssi_input); |
220 | 97 |
|
98 |
#ifdef ASYNC |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
99 |
// send |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
100 |
ecrt_domain_queue(domain1); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
101 |
ecrt_master_run(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
102 |
ecrt_master_async_send(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
103 |
#endif |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
104 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
105 |
rt_sem_signal(&master_sem); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
106 |
rt_task_wait_period(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
107 |
} |
220 | 108 |
} |
109 |
||
110 |
/*****************************************************************************/ |
|
111 |
||
112 |
int request_lock(void *data) |
|
113 |
{ |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
114 |
// too close to the next RT cycle: deny access... |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
115 |
if (get_cycles() - t_last_start > t_critical) return -1; |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
116 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
117 |
// allow access |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
118 |
rt_sem_wait(&master_sem); |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
119 |
return 0; |
220 | 120 |
} |
121 |
||
122 |
/*****************************************************************************/ |
|
123 |
||
124 |
void release_lock(void *data) |
|
125 |
{ |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
126 |
rt_sem_signal(&master_sem); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
127 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
128 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
129 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
130 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
131 |
int __init init_mod(void) |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
132 |
{ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
133 |
RTIME tick_period, requested_ticks, now; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
134 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
135 |
printk(KERN_INFO "=== Starting EtherCAT RTAI sample module... ===\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
136 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
137 |
rt_sem_init(&master_sem, 1); |
220 | 138 |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
139 |
t_critical = cpu_khz * 800 / FREQUENCY; // ticks for 80% |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
140 |
|
220 | 141 |
if ((master = ecrt_request_master(0)) == NULL) { |
142 |
printk(KERN_ERR "Requesting master 0 failed!\n"); |
|
143 |
goto out_return; |
|
144 |
} |
|
145 |
||
146 |
ecrt_master_callbacks(master, request_lock, release_lock, NULL); |
|
147 |
||
148 |
printk(KERN_INFO "Registering domain...\n"); |
|
149 |
if (!(domain1 = ecrt_master_create_domain(master))) |
|
150 |
{ |
|
151 |
printk(KERN_ERR "Domain creation failed!\n"); |
|
152 |
goto out_release_master; |
|
153 |
} |
|
154 |
||
155 |
printk(KERN_INFO "Registering domain fields...\n"); |
|
156 |
if (ecrt_domain_register_field_list(domain1, domain1_fields)) { |
|
157 |
printk(KERN_ERR "Field registration failed!\n"); |
|
158 |
goto out_release_master; |
|
159 |
} |
|
160 |
||
161 |
printk(KERN_INFO "Activating master...\n"); |
|
162 |
if (ecrt_master_activate(master)) { |
|
163 |
printk(KERN_ERR "Failed to activate master!\n"); |
|
164 |
goto out_release_master; |
|
165 |
} |
|
166 |
||
167 |
#if 0 |
|
168 |
if (ecrt_master_fetch_sdo_lists(master)) { |
|
169 |
printk(KERN_ERR "Failed to fetch SDO lists!\n"); |
|
170 |
goto out_deactivate; |
|
171 |
} |
|
172 |
ecrt_master_print(master, 2); |
|
173 |
#else |
|
174 |
ecrt_master_print(master, 0); |
|
175 |
#endif |
|
176 |
||
177 |
#if 0 |
|
178 |
if (!(slave = ecrt_master_get_slave(master, "5"))) { |
|
179 |
printk(KERN_ERR "Failed to get slave 5!\n"); |
|
180 |
goto out_deactivate; |
|
181 |
} |
|
182 |
||
183 |
if (ecrt_slave_sdo_write_exp8(slave, 0x4061, 1, 0) || |
|
184 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 2, 1) || |
|
185 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 3, 1) || |
|
186 |
ecrt_slave_sdo_write_exp8(slave, 0x4066, 0, 0) || |
|
187 |
ecrt_slave_sdo_write_exp8(slave, 0x4067, 0, 4) || |
|
188 |
ecrt_slave_sdo_write_exp8(slave, 0x4068, 0, 0) || |
|
189 |
ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) || |
|
190 |
ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) || |
|
191 |
ecrt_slave_sdo_write_exp8(slave, 0x406B, 0, 50)) { |
|
192 |
printk(KERN_ERR "Failed to configure SSI slave!\n"); |
|
193 |
goto out_deactivate; |
|
194 |
} |
|
195 |
#endif |
|
196 |
||
197 |
#if 0 |
|
198 |
printk(KERN_INFO "Writing alias...\n"); |
|
199 |
if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) { |
|
200 |
printk(KERN_ERR "Failed to write alias!\n"); |
|
201 |
goto out_deactivate; |
|
202 |
} |
|
203 |
#endif |
|
204 |
||
205 |
#ifdef ASYNC |
|
206 |
// send once and wait... |
|
207 |
ecrt_master_prepare_async_io(master); |
|
208 |
#endif |
|
209 |
||
227 | 210 |
#if 1 |
220 | 211 |
if (ecrt_master_start_eoe(master)) { |
212 |
printk(KERN_ERR "Failed to start EoE processing!\n"); |
|
213 |
goto out_deactivate; |
|
214 |
} |
|
215 |
#endif |
|
216 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
217 |
printk("Starting cyclic sample thread...\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
218 |
requested_ticks = nano2count(TIMERTICKS); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
219 |
tick_period = start_rt_timer(requested_ticks); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
220 |
printk(KERN_INFO "RT timer started with %i/%i ticks.\n", |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
221 |
(int) tick_period, (int) requested_ticks); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
222 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
223 |
if (rt_task_init(&task, run, 0, 2000, 0, 1, NULL)) { |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
224 |
printk(KERN_ERR "Failed to init RTAI task!\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
225 |
goto out_stop_timer; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
226 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
227 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
228 |
now = rt_get_time(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
229 |
if (rt_task_make_periodic(&task, now + tick_period, tick_period)) { |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
230 |
printk(KERN_ERR "Failed to run RTAI task!\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
231 |
goto out_stop_task; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
232 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
233 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
234 |
printk(KERN_INFO "=== EtherCAT RTAI sample module started. ===\n"); |
220 | 235 |
return 0; |
236 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
237 |
out_stop_task: |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
238 |
rt_task_delete(&task); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
239 |
out_stop_timer: |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
240 |
stop_rt_timer(); |
220 | 241 |
out_deactivate: |
242 |
ecrt_master_deactivate(master); |
|
243 |
out_release_master: |
|
244 |
ecrt_release_master(master); |
|
245 |
out_return: |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
246 |
rt_sem_delete(&master_sem); |
220 | 247 |
return -1; |
248 |
} |
|
249 |
||
250 |
/*****************************************************************************/ |
|
251 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
252 |
void __exit cleanup_mod(void) |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
253 |
{ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
254 |
printk(KERN_INFO "=== Stopping EtherCAT RTAI sample module... ===\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
255 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
256 |
printk(KERN_INFO "Stopping RT task...\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
257 |
rt_task_delete(&task); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
258 |
stop_rt_timer(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
259 |
printk(KERN_INFO "Deactivating EtherCAT master...\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
260 |
ecrt_master_deactivate(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
261 |
ecrt_release_master(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
262 |
rt_sem_delete(&master_sem); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
263 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
264 |
printk(KERN_INFO "=== EtherCAT RTAI sample module stopped. ===\n"); |
220 | 265 |
} |
266 |
||
267 |
/*****************************************************************************/ |
|
268 |
||
269 |
MODULE_LICENSE("GPL"); |
|
270 |
MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>"); |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
271 |
MODULE_DESCRIPTION ("EtherCAT RTAI sample module"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
272 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
273 |
module_init(init_mod); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
274 |
module_exit(cleanup_mod); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
275 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
276 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
277 |