author | Florian Pose <fp@igh-essen.com> |
Tue, 06 Mar 2007 15:11:44 +0000 | |
changeset 623 | 4d64368f3a1e |
parent 612 | aede068f9a74 |
child 635 | d304ef4af542 |
permissions | -rw-r--r-- |
220 | 1 |
/****************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
6 |
* |
|
7 |
* This file is part of the IgH EtherCAT Master. |
|
8 |
* |
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
|
10 |
* 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:
226
diff
changeset
|
11 |
* 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:
226
diff
changeset
|
12 |
* License, or (at your option) any later version. |
220 | 13 |
* |
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
22 |
* |
|
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
226
diff
changeset
|
23 |
* 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:
226
diff
changeset
|
24 |
* 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:
226
diff
changeset
|
25 |
* 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:
226
diff
changeset
|
26 |
* 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:
226
diff
changeset
|
27 |
* 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:
226
diff
changeset
|
28 |
* 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:
226
diff
changeset
|
29 |
* 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:
226
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
226
diff
changeset
|
31 |
* |
220 | 32 |
*****************************************************************************/ |
33 |
||
34 |
#include <linux/module.h> |
|
35 |
#include <linux/timer.h> |
|
36 |
#include <linux/spinlock.h> |
|
37 |
#include <linux/interrupt.h> |
|
38 |
||
223
daa5e5656b35
Applied new path information to example modules.
Florian Pose <fp@igh-essen.com>
parents:
220
diff
changeset
|
39 |
#include "../../include/ecrt.h" // EtherCAT realtime interface |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
280
diff
changeset
|
40 |
#include "../../include/ecdb.h" // EtherCAT slave database |
220 | 41 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
42 |
#define PFX "ec_mini: " |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
43 |
|
220 | 44 |
#define FREQUENCY 100 |
45 |
||
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
46 |
//#define KBUS |
457
2b4ba84b6058
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
454
diff
changeset
|
47 |
|
220 | 48 |
/*****************************************************************************/ |
49 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
50 |
static struct timer_list timer; |
220 | 51 |
|
52 |
// EtherCAT |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
53 |
static ec_master_t *master = NULL; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
54 |
static ec_domain_t *domain1 = NULL; |
220 | 55 |
spinlock_t master_lock = SPIN_LOCK_UNLOCKED; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
56 |
static ec_master_status_t master_status, old_status = {}; |
220 | 57 |
|
58 |
// data fields |
|
457
2b4ba84b6058
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
454
diff
changeset
|
59 |
#ifdef KBUS |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
60 |
static void *r_inputs; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
61 |
static void *r_outputs; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
62 |
#endif |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
63 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
64 |
static void *r_dig_out; |
446 | 65 |
|
66 |
#if 1 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
280
diff
changeset
|
67 |
ec_pdo_reg_t domain1_pdos[] = { |
551
ac230bbd1d76
Minor: Adjusted minimal example to new testing hardware.
Florian Pose <fp@igh-essen.com>
parents:
516
diff
changeset
|
68 |
{"4", Beckhoff_EL2004_Outputs, &r_dig_out}, |
220 | 69 |
{} |
70 |
}; |
|
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
71 |
#endif |
220 | 72 |
|
73 |
/*****************************************************************************/ |
|
74 |
||
75 |
void run(unsigned long data) |
|
76 |
{ |
|
77 |
static unsigned int counter = 0; |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
78 |
static unsigned int blink = 0; |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
79 |
|
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
80 |
// receive |
220 | 81 |
spin_lock(&master_lock); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
280
diff
changeset
|
82 |
ecrt_master_receive(master); |
220 | 83 |
ecrt_domain_process(domain1); |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
84 |
spin_unlock(&master_lock); |
220 | 85 |
|
86 |
// process data |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
87 |
// k_pos = EC_READ_U32(r_ssi); |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
88 |
EC_WRITE_U8(r_dig_out, blink ? 0x0F : 0x00); |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
89 |
|
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
90 |
if (counter) { |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
91 |
counter--; |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
92 |
} |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
93 |
else { |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
94 |
counter = FREQUENCY; |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
95 |
blink = !blink; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
96 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
97 |
spin_lock(&master_lock); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
98 |
ecrt_master_get_status(master, &master_status); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
99 |
spin_unlock(&master_lock); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
100 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
101 |
if (master_status.bus_status != old_status.bus_status) { |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
102 |
printk(KERN_INFO PFX "bus status changed to %u.\n", |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
103 |
master_status.bus_status); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
104 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
105 |
if (master_status.bus_tainted != old_status.bus_tainted) { |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
106 |
printk(KERN_INFO PFX "tainted flag changed to %u.\n", |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
107 |
master_status.bus_tainted); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
108 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
109 |
if (master_status.slaves_responding != |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
110 |
old_status.slaves_responding) { |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
111 |
printk(KERN_INFO PFX "slaves_responding changed to %u.\n", |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
112 |
master_status.slaves_responding); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
113 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
114 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
115 |
old_status = master_status; |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
116 |
} |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
117 |
|
457
2b4ba84b6058
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
454
diff
changeset
|
118 |
#ifdef KBUS |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
119 |
EC_WRITE_U8(r_outputs + 2, blink ? 0xFF : 0x00); |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
120 |
#endif |
513
d91976aea8c8
Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
512
diff
changeset
|
121 |
|
220 | 122 |
// send |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
123 |
spin_lock(&master_lock); |
509
87baea61d0c7
Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents:
472
diff
changeset
|
124 |
ecrt_domain_queue(domain1); |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
125 |
spin_unlock(&master_lock); |
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
126 |
|
220 | 127 |
ecrt_master_run(master); |
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
128 |
|
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
129 |
spin_lock(&master_lock); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
280
diff
changeset
|
130 |
ecrt_master_send(master); |
220 | 131 |
spin_unlock(&master_lock); |
132 |
||
133 |
// restart timer |
|
134 |
timer.expires += HZ / FREQUENCY; |
|
135 |
add_timer(&timer); |
|
136 |
} |
|
137 |
||
138 |
/*****************************************************************************/ |
|
139 |
||
140 |
int request_lock(void *data) |
|
141 |
{ |
|
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
142 |
spin_lock(&master_lock); |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
223
diff
changeset
|
143 |
return 0; // access allowed |
220 | 144 |
} |
145 |
||
146 |
/*****************************************************************************/ |
|
147 |
||
148 |
void release_lock(void *data) |
|
149 |
{ |
|
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
150 |
spin_unlock(&master_lock); |
220 | 151 |
} |
152 |
||
153 |
/*****************************************************************************/ |
|
154 |
||
155 |
int __init init_mini_module(void) |
|
156 |
{ |
|
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
157 |
#if 0 |
454
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
452
diff
changeset
|
158 |
ec_slave_t *slave; |
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
452
diff
changeset
|
159 |
#endif |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
160 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
161 |
printk(KERN_INFO PFX "Starting...\n"); |
220 | 162 |
|
509
87baea61d0c7
Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents:
472
diff
changeset
|
163 |
if (!(master = ecrt_request_master(0))) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
164 |
printk(KERN_ERR PFX "Requesting master 0 failed!\n"); |
220 | 165 |
goto out_return; |
166 |
} |
|
167 |
||
168 |
ecrt_master_callbacks(master, request_lock, release_lock, NULL); |
|
169 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
170 |
printk(KERN_INFO PFX "Registering domain...\n"); |
509
87baea61d0c7
Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents:
472
diff
changeset
|
171 |
if (!(domain1 = ecrt_master_create_domain(master))) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
172 |
printk(KERN_ERR PFX "Domain creation failed!\n"); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
173 |
goto out_release_master; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
174 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
175 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
176 |
printk(KERN_INFO PFX "Registering PDOs...\n"); |
446 | 177 |
#if 1 |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
280
diff
changeset
|
178 |
if (ecrt_domain_register_pdo_list(domain1, domain1_pdos)) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
179 |
printk(KERN_ERR PFX "PDO registration failed!\n"); |
220 | 180 |
goto out_release_master; |
181 |
} |
|
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
182 |
#endif |
446 | 183 |
|
457
2b4ba84b6058
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
454
diff
changeset
|
184 |
#ifdef KBUS |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
185 |
if (!ecrt_domain_register_pdo_range(domain1, "0", Beckhoff_BK1120, |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
186 |
EC_DIR_OUTPUT, 0, 4, &r_outputs)) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
187 |
printk(KERN_ERR PFX "PDO registration failed!\n"); |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
188 |
goto out_release_master; |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
189 |
} |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
190 |
if (!ecrt_domain_register_pdo_range(domain1, "0", Beckhoff_BK1120, |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
191 |
EC_DIR_INPUT, 0, 4, &r_inputs)) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
192 |
printk(KERN_ERR PFX "PDO registration failed!\n"); |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
193 |
goto out_release_master; |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
194 |
} |
446 | 195 |
#endif |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
196 |
|
516
f703e33ee395
Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents:
513
diff
changeset
|
197 |
#if 0 |
463
938de5ebe1ca
minimal example with SDO configs.
Florian Pose <fp@igh-essen.com>
parents:
457
diff
changeset
|
198 |
if (!(slave = ecrt_master_get_slave(master, "2"))) |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
199 |
goto out_release_master; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
200 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
201 |
if (ecrt_slave_conf_sdo8(slave, 0x4061, 1, 0)) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
202 |
goto out_release_master; |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
348
diff
changeset
|
203 |
#endif |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
204 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
205 |
printk(KERN_INFO PFX "Activating master...\n"); |
220 | 206 |
if (ecrt_master_activate(master)) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
207 |
printk(KERN_ERR PFX "Failed to activate master!\n"); |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
208 |
goto out_release_master; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
209 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
210 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
211 |
printk(KERN_INFO PFX "Starting cyclic sample thread.\n"); |
220 | 212 |
init_timer(&timer); |
213 |
timer.function = run; |
|
214 |
timer.expires = jiffies + 10; |
|
215 |
add_timer(&timer); |
|
216 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
217 |
printk(KERN_INFO PFX "Started.\n"); |
220 | 218 |
return 0; |
219 |
||
220 |
out_release_master: |
|
221 |
ecrt_release_master(master); |
|
222 |
out_return: |
|
223 |
return -1; |
|
224 |
} |
|
225 |
||
226 |
/*****************************************************************************/ |
|
227 |
||
228 |
void __exit cleanup_mini_module(void) |
|
229 |
{ |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
230 |
printk(KERN_INFO PFX "Stopping...\n"); |
220 | 231 |
|
449
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
232 |
del_timer_sync(&timer); |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
233 |
printk(KERN_INFO PFX "Releasing master...\n"); |
449
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
234 |
ecrt_release_master(master); |
220 | 235 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
236 |
printk(KERN_INFO PFX "Stopped.\n"); |
220 | 237 |
} |
238 |
||
239 |
/*****************************************************************************/ |
|
240 |
||
241 |
MODULE_LICENSE("GPL"); |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
242 |
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>"); |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
243 |
MODULE_DESCRIPTION("EtherCAT minimal test environment"); |
220 | 244 |
|
245 |
module_init(init_mini_module); |
|
246 |
module_exit(cleanup_mini_module); |
|
247 |
||
248 |
/*****************************************************************************/ |