author | Florian Pose <fp@igh-essen.com> |
Tue, 13 Feb 2007 12:44:11 +0000 | |
changeset 559 | 63c5791a02a5 |
parent 516 | f703e33ee395 |
child 637 | d5d04c868e0e |
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 |
|
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
13 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
14 |
* License, or (at your option) any later version. |
220 | 15 |
* |
16 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
|
17 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
24 |
* |
|
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
25 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
26 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
27 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
28 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
29 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
30 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
31 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
32 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
233
diff
changeset
|
33 |
* |
220 | 34 |
*****************************************************************************/ |
35 |
||
233
31d327ce38d3
Smaller fixes on RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
230
diff
changeset
|
36 |
// Linux |
220 | 37 |
#include <linux/module.h> |
38 |
||
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
39 |
// RTAI |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
40 |
#include "rtai_sched.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
41 |
#include "rtai_sem.h" |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
42 |
|
233
31d327ce38d3
Smaller fixes on RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
230
diff
changeset
|
43 |
// EtherCAT |
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
44 |
#include "../../include/ecrt.h" |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
45 |
#include "../../include/ecdb.h" |
230
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 |
/*****************************************************************************/ |
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
48 |
|
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
49 |
// RTAI task frequency in Hz |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
50 |
#define FREQUENCY 4000 |
342
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
51 |
#define INHIBIT_TIME 20 |
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
52 |
|
230
382bdb9138ec
RTAI sample with optimized jitter.
Florian Pose <fp@igh-essen.com>
parents:
227
diff
changeset
|
53 |
#define TIMERTICKS (1000000000 / FREQUENCY) |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
54 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
55 |
/*****************************************************************************/ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
56 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
57 |
// RTAI |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
58 |
RT_TASK task; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
59 |
SEM master_sem; |
342
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
60 |
cycles_t t_last_cycle = 0, t_critical; |
220 | 61 |
|
62 |
// EtherCAT |
|
63 |
ec_master_t *master = NULL; |
|
64 |
ec_domain_t *domain1 = NULL; |
|
65 |
||
66 |
// data fields |
|
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
67 |
void *r_dig_out; |
220 | 68 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
69 |
ec_pdo_reg_t domain1_pdos[] = { |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
70 |
{"2", Beckhoff_EL2004_Outputs, &r_dig_out}, |
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 |
{ |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
78 |
static unsigned int blink = 0; |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
79 |
static unsigned int counter = 0; |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
80 |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
81 |
while (1) { |
342
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
82 |
t_last_cycle = get_cycles(); |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
83 |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
84 |
rt_sem_wait(&master_sem); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
85 |
ecrt_master_receive(master); |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
86 |
ecrt_domain_process(domain1); |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
87 |
rt_sem_signal(&master_sem); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
88 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
89 |
// process data |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
90 |
EC_WRITE_U8(r_dig_out, blink ? 0x0F : 0x00); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
91 |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
92 |
rt_sem_wait(&master_sem); |
509
87baea61d0c7
Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents:
449
diff
changeset
|
93 |
ecrt_domain_queue(domain1); |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
94 |
ecrt_master_run(master); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
95 |
ecrt_master_send(master); |
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
96 |
rt_sem_signal(&master_sem); |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
97 |
|
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
98 |
if (counter) { |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
99 |
counter--; |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
100 |
} |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
101 |
else { |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
102 |
counter = FREQUENCY; |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
103 |
blink = !blink; |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
104 |
} |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
105 |
|
225
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 |
{ |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
114 |
// too close to the next real time cycle: deny access... |
342
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
115 |
if (get_cycles() - t_last_cycle > t_critical) return -1; |
230
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 |
|
342
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
139 |
t_critical = cpu_khz * 1000 / FREQUENCY - cpu_khz * INHIBIT_TIME / 1000; |
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
140 |
|
cbcff2f19e99
RTAI example with INHIBIT time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
141 |
if (!(master = ecrt_request_master(0))) { |
220 | 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 |
||
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
148 |
printk(KERN_INFO "Creating domain...\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
149 |
if (!(domain1 = ecrt_master_create_domain(master))) { |
220 | 150 |
printk(KERN_ERR "Domain creation failed!\n"); |
151 |
goto out_release_master; |
|
152 |
} |
|
153 |
||
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
154 |
printk(KERN_INFO "Registering PDOs...\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
155 |
if (ecrt_domain_register_pdo_list(domain1, domain1_pdos)) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
156 |
printk(KERN_ERR "PDO registration failed!\n"); |
220 | 157 |
goto out_release_master; |
158 |
} |
|
159 |
||
160 |
printk(KERN_INFO "Activating master...\n"); |
|
161 |
if (ecrt_master_activate(master)) { |
|
162 |
printk(KERN_ERR "Failed to activate master!\n"); |
|
163 |
goto out_release_master; |
|
164 |
} |
|
165 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
166 |
printk("Starting cyclic sample thread...\n"); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
167 |
requested_ticks = nano2count(TIMERTICKS); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
168 |
tick_period = start_rt_timer(requested_ticks); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
169 |
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
|
170 |
(int) tick_period, (int) requested_ticks); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
171 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
172 |
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
|
173 |
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
|
174 |
goto out_stop_timer; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
175 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
176 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
177 |
now = rt_get_time(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
178 |
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
|
179 |
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
|
180 |
goto out_stop_task; |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
181 |
} |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
182 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
183 |
printk(KERN_INFO "=== EtherCAT RTAI sample module started. ===\n"); |
220 | 184 |
return 0; |
185 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
186 |
out_stop_task: |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
187 |
rt_task_delete(&task); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
188 |
out_stop_timer: |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
189 |
stop_rt_timer(); |
220 | 190 |
out_release_master: |
191 |
ecrt_release_master(master); |
|
192 |
out_return: |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
193 |
rt_sem_delete(&master_sem); |
220 | 194 |
return -1; |
195 |
} |
|
196 |
||
197 |
/*****************************************************************************/ |
|
198 |
||
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
199 |
void __exit cleanup_mod(void) |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
200 |
{ |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
201 |
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
|
202 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
203 |
rt_task_delete(&task); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
204 |
stop_rt_timer(); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
205 |
ecrt_release_master(master); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
206 |
rt_sem_delete(&master_sem); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
207 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
208 |
printk(KERN_INFO "=== EtherCAT RTAI sample module stopped. ===\n"); |
220 | 209 |
} |
210 |
||
211 |
/*****************************************************************************/ |
|
212 |
||
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
213 |
MODULE_LICENSE("GPL"); |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
214 |
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>"); |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
215 |
MODULE_DESCRIPTION("EtherCAT RTAI sample module"); |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
216 |
|
225
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
217 |
module_init(init_mod); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
218 |
module_exit(cleanup_mod); |
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
219 |
|
9e8150db6fc8
Applied RTAI interface to RTAI example.
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
220 |
/*****************************************************************************/ |