author | Florian Pose <fp@igh-essen.com> |
Mon, 15 May 2006 12:57:24 +0000 | |
changeset 237 | 7b3126cf6dab |
parent 233 | 31d327ce38d3 |
child 246 | 0bf7c769de06 |
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 |
||
233
31d327ce38d3
Smaller fixes on RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
230
diff
changeset
|
26 |
// Linux |
220 | 27 |
#include <linux/module.h> |
28 |
||
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
29 |
// RTAI |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
30 |
#include "rtai_sched.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
31 |
#include "rtai_sem.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
32 |
|
233
31d327ce38d3
Smaller fixes on RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
230
diff
changeset
|
33 |
// EtherCAT |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
34 |
#include "../../include/ecrt.h" |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
35 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
36 |
/*****************************************************************************/ |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
37 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
38 |
// comment this for synchronous IO |
220 | 39 |
#define ASYNC |
230
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 |
// RTAI task frequency in Hz |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
42 |
#define FREQUENCY 10000 |
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 |
#define TIMERTICKS (1000000000 / FREQUENCY) |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
45 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
46 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
47 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
48 |
// RTAI |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
49 |
RT_TASK task; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
50 |
SEM master_sem; |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
51 |
cycles_t t_last_start = 0; |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
52 |
cycles_t t_critical; |
220 | 53 |
|
54 |
// EtherCAT |
|
55 |
ec_master_t *master = NULL; |
|
56 |
ec_domain_t *domain1 = NULL; |
|
57 |
||
58 |
// data fields |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
59 |
void *r_ssi_input; |
220 | 60 |
|
61 |
// channels |
|
62 |
uint32_t k_pos; |
|
63 |
||
64 |
ec_field_init_t domain1_fields[] = { |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
65 |
{&r_ssi_input, "3", "Beckhoff", "EL5001", "InputValue", 0}, |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
66 |
{NULL, "2", "Beckhoff", "EL4132", "OutputValue", 0}, |
220 | 67 |
{} |
68 |
}; |
|
69 |
||
70 |
/*****************************************************************************/ |
|
71 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
72 |
void run(long data) |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
73 |
{ |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
74 |
while (1) |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
75 |
{ |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
76 |
t_last_start = get_cycles(); |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
77 |
rt_sem_wait(&master_sem); |
220 | 78 |
|
79 |
#ifdef ASYNC |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
80 |
// receive |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
81 |
ecrt_master_async_receive(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
82 |
ecrt_domain_process(domain1); |
220 | 83 |
#else |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
84 |
// send and receive |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
85 |
ecrt_domain_queue(domain1); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
86 |
ecrt_master_run(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
87 |
ecrt_master_sync_io(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
88 |
ecrt_domain_process(domain1); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
89 |
#endif |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
90 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
91 |
// process data |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
92 |
k_pos = EC_READ_U32(r_ssi_input); |
220 | 93 |
|
94 |
#ifdef ASYNC |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
95 |
// send |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
96 |
ecrt_domain_queue(domain1); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
97 |
ecrt_master_run(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
98 |
ecrt_master_async_send(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
99 |
#endif |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
100 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
101 |
rt_sem_signal(&master_sem); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
102 |
rt_task_wait_period(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
103 |
} |
220 | 104 |
} |
105 |
||
106 |
/*****************************************************************************/ |
|
107 |
||
108 |
int request_lock(void *data) |
|
109 |
{ |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
110 |
// 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
|
111 |
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
|
112 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
113 |
// allow access |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
114 |
rt_sem_wait(&master_sem); |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
115 |
return 0; |
220 | 116 |
} |
117 |
||
118 |
/*****************************************************************************/ |
|
119 |
||
120 |
void release_lock(void *data) |
|
121 |
{ |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
122 |
rt_sem_signal(&master_sem); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
123 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
124 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
125 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
126 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
127 |
int __init init_mod(void) |
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 |
RTIME tick_period, requested_ticks, now; |
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 |
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
|
132 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
133 |
rt_sem_init(&master_sem, 1); |
220 | 134 |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
135 |
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
|
136 |
|
220 | 137 |
if ((master = ecrt_request_master(0)) == NULL) { |
138 |
printk(KERN_ERR "Requesting master 0 failed!\n"); |
|
139 |
goto out_return; |
|
140 |
} |
|
141 |
||
142 |
ecrt_master_callbacks(master, request_lock, release_lock, NULL); |
|
143 |
||
144 |
printk(KERN_INFO "Registering domain...\n"); |
|
145 |
if (!(domain1 = ecrt_master_create_domain(master))) |
|
146 |
{ |
|
147 |
printk(KERN_ERR "Domain creation failed!\n"); |
|
148 |
goto out_release_master; |
|
149 |
} |
|
150 |
||
151 |
printk(KERN_INFO "Registering domain fields...\n"); |
|
152 |
if (ecrt_domain_register_field_list(domain1, domain1_fields)) { |
|
153 |
printk(KERN_ERR "Field registration failed!\n"); |
|
154 |
goto out_release_master; |
|
155 |
} |
|
156 |
||
157 |
printk(KERN_INFO "Activating master...\n"); |
|
158 |
if (ecrt_master_activate(master)) { |
|
159 |
printk(KERN_ERR "Failed to activate master!\n"); |
|
160 |
goto out_release_master; |
|
161 |
} |
|
162 |
||
163 |
#if 0 |
|
164 |
if (ecrt_master_fetch_sdo_lists(master)) { |
|
165 |
printk(KERN_ERR "Failed to fetch SDO lists!\n"); |
|
166 |
goto out_deactivate; |
|
167 |
} |
|
168 |
ecrt_master_print(master, 2); |
|
169 |
#else |
|
170 |
ecrt_master_print(master, 0); |
|
171 |
#endif |
|
172 |
||
173 |
#if 0 |
|
174 |
if (!(slave = ecrt_master_get_slave(master, "5"))) { |
|
175 |
printk(KERN_ERR "Failed to get slave 5!\n"); |
|
176 |
goto out_deactivate; |
|
177 |
} |
|
178 |
||
179 |
if (ecrt_slave_sdo_write_exp8(slave, 0x4061, 1, 0) || |
|
180 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 2, 1) || |
|
181 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 3, 1) || |
|
182 |
ecrt_slave_sdo_write_exp8(slave, 0x4066, 0, 0) || |
|
183 |
ecrt_slave_sdo_write_exp8(slave, 0x4067, 0, 4) || |
|
184 |
ecrt_slave_sdo_write_exp8(slave, 0x4068, 0, 0) || |
|
185 |
ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) || |
|
186 |
ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) || |
|
187 |
ecrt_slave_sdo_write_exp8(slave, 0x406B, 0, 50)) { |
|
188 |
printk(KERN_ERR "Failed to configure SSI slave!\n"); |
|
189 |
goto out_deactivate; |
|
190 |
} |
|
191 |
#endif |
|
192 |
||
193 |
#if 0 |
|
194 |
printk(KERN_INFO "Writing alias...\n"); |
|
195 |
if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) { |
|
196 |
printk(KERN_ERR "Failed to write alias!\n"); |
|
197 |
goto out_deactivate; |
|
198 |
} |
|
199 |
#endif |
|
200 |
||
201 |
#ifdef ASYNC |
|
202 |
// send once and wait... |
|
203 |
ecrt_master_prepare_async_io(master); |
|
204 |
#endif |
|
205 |
||
206 |
if (ecrt_master_start_eoe(master)) { |
|
207 |
printk(KERN_ERR "Failed to start EoE processing!\n"); |
|
208 |
goto out_deactivate; |
|
209 |
} |
|
210 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
211 |
printk("Starting cyclic sample thread...\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
212 |
requested_ticks = nano2count(TIMERTICKS); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
213 |
tick_period = start_rt_timer(requested_ticks); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
214 |
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
|
215 |
(int) tick_period, (int) requested_ticks); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
216 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
217 |
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
|
218 |
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
|
219 |
goto out_stop_timer; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
220 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
221 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
222 |
now = rt_get_time(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
223 |
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
|
224 |
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
|
225 |
goto out_stop_task; |
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 |
printk(KERN_INFO "=== EtherCAT RTAI sample module started. ===\n"); |
220 | 229 |
return 0; |
230 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
231 |
out_stop_task: |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
232 |
rt_task_delete(&task); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
233 |
out_stop_timer: |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
234 |
stop_rt_timer(); |
220 | 235 |
out_deactivate: |
236 |
ecrt_master_deactivate(master); |
|
237 |
out_release_master: |
|
238 |
ecrt_release_master(master); |
|
239 |
out_return: |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
240 |
rt_sem_delete(&master_sem); |
220 | 241 |
return -1; |
242 |
} |
|
243 |
||
244 |
/*****************************************************************************/ |
|
245 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
246 |
void __exit cleanup_mod(void) |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
247 |
{ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
248 |
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
|
249 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
250 |
rt_task_delete(&task); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
251 |
stop_rt_timer(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
252 |
ecrt_master_deactivate(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
253 |
ecrt_release_master(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
254 |
rt_sem_delete(&master_sem); |
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 "=== EtherCAT RTAI sample module stopped. ===\n"); |
220 | 257 |
} |
258 |
||
259 |
/*****************************************************************************/ |
|
260 |
||
261 |
MODULE_LICENSE("GPL"); |
|
262 |
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
|
263 |
MODULE_DESCRIPTION ("EtherCAT RTAI sample module"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
264 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
265 |
module_init(init_mod); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
266 |
module_exit(cleanup_mod); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
267 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
268 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
269 |