author | Florian Pose <fp@igh-essen.com> |
Wed, 19 Jul 2006 15:28:34 +0000 | |
changeset 308 | d50b139c8601 |
parent 306 | 45886de3db87 |
child 313 | ba324d82dfd3 |
permissions | -rw-r--r-- |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
1 |
/****************************************************************************** |
0 | 2 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
3 |
* $Id$ |
0 | 4 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
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:
239
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:
239
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
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:
239
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:
239
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:
239
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:
239
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:
239
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:
239
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:
239
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
32 |
*****************************************************************************/ |
0 | 33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
EtherCAT master methods. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
41 |
#include <linux/module.h> |
0 | 42 |
#include <linux/kernel.h> |
43 |
#include <linux/string.h> |
|
44 |
#include <linux/slab.h> |
|
45 |
#include <linux/delay.h> |
|
46 |
||
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
47 |
#include "../include/ecrt.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
48 |
#include "globals.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
49 |
#include "master.h" |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
50 |
#include "slave.h" |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
51 |
#include "types.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
52 |
#include "device.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
53 |
#include "datagram.h" |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
54 |
#include "ethernet.h" |
0 | 55 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
56 |
/*****************************************************************************/ |
0 | 57 |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
58 |
void ec_master_idle(void *); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
59 |
void ec_master_eoe_run(unsigned long); |
179
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
60 |
ssize_t ec_show_master_attribute(struct kobject *, struct attribute *, char *); |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
61 |
ssize_t ec_store_master_attribute(struct kobject *, struct attribute *, |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
62 |
const char *, size_t); |
179
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
63 |
|
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
64 |
/*****************************************************************************/ |
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
65 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
66 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
67 |
|
184
2fc86cec12df
Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
68 |
EC_SYSFS_READ_ATTR(slave_count); |
191 | 69 |
EC_SYSFS_READ_ATTR(mode); |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
70 |
EC_SYSFS_READ_WRITE_ATTR(eeprom_write_enable); |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
71 |
EC_SYSFS_READ_WRITE_ATTR(debug_level); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
72 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
73 |
static struct attribute *ec_def_attrs[] = { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
74 |
&attr_slave_count, |
191 | 75 |
&attr_mode, |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
76 |
&attr_eeprom_write_enable, |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
77 |
&attr_debug_level, |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
78 |
NULL, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
79 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
80 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
81 |
static struct sysfs_ops ec_sysfs_ops = { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
82 |
.show = &ec_show_master_attribute, |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
83 |
.store = ec_store_master_attribute |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
84 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
85 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
86 |
static struct kobj_type ktype_ec_master = { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
87 |
.release = ec_master_clear, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
88 |
.sysfs_ops = &ec_sysfs_ops, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
89 |
.default_attrs = ec_def_attrs |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
90 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
91 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
92 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
93 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
94 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
95 |
|
0 | 96 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
97 |
Master constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
98 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
99 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
100 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
101 |
int ec_master_init(ec_master_t *master, /**< EtherCAT master */ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
102 |
unsigned int index, /**< master index */ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
103 |
unsigned int eoe_devices /**< number of EoE devices */ |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
104 |
) |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
105 |
{ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
106 |
ec_eoe_t *eoe, *next_eoe; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
107 |
unsigned int i; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
108 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
109 |
EC_INFO("Initializing master %i.\n", index); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
110 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
111 |
master->index = index; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
112 |
master->device = NULL; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
113 |
master->reserved = 0; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
114 |
INIT_LIST_HEAD(&master->slaves); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
115 |
INIT_LIST_HEAD(&master->datagram_queue); |
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
116 |
INIT_LIST_HEAD(&master->domains); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
117 |
INIT_LIST_HEAD(&master->eoe_handlers); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
118 |
ec_datagram_init(&master->simple_datagram); |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
119 |
INIT_WORK(&master->idle_work, ec_master_idle, (void *) master); |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
120 |
init_timer(&master->eoe_timer); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
121 |
master->eoe_timer.function = ec_master_eoe_run; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
122 |
master->eoe_timer.data = (unsigned long) master; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
123 |
master->internal_lock = SPIN_LOCK_UNLOCKED; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
124 |
master->eoe_running = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
125 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
126 |
// create workqueue |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
127 |
if (!(master->workqueue = create_singlethread_workqueue("EtherCAT"))) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
128 |
EC_ERR("Failed to create master workqueue.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
129 |
goto out_return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
130 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
131 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
132 |
// create EoE handlers |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
133 |
for (i = 0; i < eoe_devices; i++) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
134 |
if (!(eoe = (ec_eoe_t *) kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
135 |
EC_ERR("Failed to allocate EoE-Object.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
136 |
goto out_clear_eoe; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
137 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
138 |
if (ec_eoe_init(eoe)) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
139 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
140 |
goto out_clear_eoe; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
141 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
142 |
list_add_tail(&eoe->list, &master->eoe_handlers); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
143 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
144 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
145 |
// create state machine object |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
146 |
if (ec_fsm_init(&master->fsm, master)) goto out_clear_eoe; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
147 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
148 |
// init kobject and add it to the hierarchy |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
149 |
memset(&master->kobj, 0x00, sizeof(struct kobject)); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
150 |
kobject_init(&master->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
151 |
master->kobj.ktype = &ktype_ec_master; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
152 |
if (kobject_set_name(&master->kobj, "ethercat%i", index)) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
153 |
EC_ERR("Failed to set kobj name.\n"); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
154 |
kobject_put(&master->kobj); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
155 |
return -1; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
156 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
157 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
158 |
ec_master_reset(master); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
159 |
return 0; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
160 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
161 |
out_clear_eoe: |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
162 |
list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
163 |
list_del(&eoe->list); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
164 |
ec_eoe_clear(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
165 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
166 |
} |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
167 |
destroy_workqueue(master->workqueue); |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
168 |
out_return: |
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
169 |
return -1; |
0 | 170 |
} |
171 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
172 |
/*****************************************************************************/ |
0 | 173 |
|
174 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
175 |
Master destructor. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
176 |
Removes all pending datagrams, clears the slave list, clears all domains |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
177 |
and frees the device. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
178 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
179 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
180 |
void ec_master_clear(struct kobject *kobj /**< kobject of the master */) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
181 |
{ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
182 |
ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
183 |
ec_eoe_t *eoe, *next_eoe; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
184 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
185 |
EC_INFO("Clearing master %i...\n", master->index); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
186 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
187 |
ec_master_reset(master); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
188 |
ec_fsm_clear(&master->fsm); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
189 |
ec_datagram_clear(&master->simple_datagram); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
190 |
destroy_workqueue(master->workqueue); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
191 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
192 |
// clear EoE objects |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
193 |
list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
194 |
list_del(&eoe->list); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
195 |
ec_eoe_clear(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
196 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
197 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
198 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
199 |
if (master->device) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
200 |
ec_device_clear(master->device); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
201 |
kfree(master->device); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
202 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
203 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
204 |
EC_INFO("Master %i cleared.\n", master->index); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
205 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
206 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
207 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
208 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
209 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
210 |
Resets the master. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
211 |
Note: This function has to be called, everytime ec_master_release() is |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
212 |
called, to free the slave list, domains etc. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
213 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
214 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
215 |
void ec_master_reset(ec_master_t *master /**< EtherCAT master */) |
56
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
216 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
217 |
ec_datagram_t *datagram, *next_c; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
218 |
ec_domain_t *domain, *next_d; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
219 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
220 |
ec_master_eoe_stop(master); |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
221 |
ec_master_idle_stop(master); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
222 |
ec_master_clear_slaves(master); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
223 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
224 |
// empty datagram queue |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
225 |
list_for_each_entry_safe(datagram, next_c, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
226 |
&master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
227 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
228 |
datagram->state = EC_CMD_ERROR; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
229 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
230 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
231 |
// clear domains |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
232 |
list_for_each_entry_safe(domain, next_d, &master->domains, list) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
233 |
list_del(&domain->list); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
234 |
kobject_del(&domain->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
235 |
kobject_put(&domain->kobj); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
236 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
237 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
238 |
master->datagram_index = 0; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
239 |
master->debug_level = 0; |
155
ff65679b65fe
Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents:
151
diff
changeset
|
240 |
master->timeout = 500; // 500us |
130 | 241 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
242 |
master->stats.timeouts = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
243 |
master->stats.delayed = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
244 |
master->stats.corrupted = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
245 |
master->stats.unmatched = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
246 |
master->stats.t_last = 0; |
191 | 247 |
|
305
03aab3068f08
Renamed IDLE mode to ORPHANED mode.
Florian Pose <fp@igh-essen.com>
parents:
303
diff
changeset
|
248 |
master->mode = EC_MASTER_MODE_ORPHANED; |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
249 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
250 |
master->request_cb = NULL; |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
251 |
master->release_cb = NULL; |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
252 |
master->cb_data = NULL; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
253 |
|
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
254 |
master->eeprom_write_enable = 0; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
255 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
256 |
ec_fsm_reset(&master->fsm); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
257 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
258 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
259 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
260 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
261 |
/** |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
262 |
Clears all slaves. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
263 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
264 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
265 |
void ec_master_clear_slaves(ec_master_t *master) |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
266 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
267 |
ec_slave_t *slave, *next_slave; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
268 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
269 |
list_for_each_entry_safe(slave, next_slave, &master->slaves, list) { |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
270 |
list_del(&slave->list); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
271 |
kobject_del(&slave->kobj); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
272 |
kobject_put(&slave->kobj); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
273 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
274 |
master->slave_count = 0; |
74
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
275 |
} |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
276 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
277 |
/*****************************************************************************/ |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
278 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
279 |
/** |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
280 |
Places a datagram in the datagram queue. |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
281 |
*/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
282 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
283 |
void ec_master_queue_datagram(ec_master_t *master, /**< EtherCAT master */ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
284 |
ec_datagram_t *datagram /**< datagram */ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
285 |
) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
286 |
{ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
287 |
ec_datagram_t *queued_datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
288 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
289 |
// check, if the datagram is already queued |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
290 |
list_for_each_entry(queued_datagram, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
291 |
if (queued_datagram == datagram) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
292 |
datagram->state = EC_CMD_QUEUED; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
293 |
if (unlikely(master->debug_level)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
294 |
EC_WARN("datagram already queued.\n"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
295 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
296 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
297 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
298 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
299 |
list_add_tail(&datagram->queue, &master->datagram_queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
300 |
datagram->state = EC_CMD_QUEUED; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
301 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
302 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
303 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
304 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
305 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
306 |
Sends the datagrams in the queue. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
307 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
308 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
309 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
310 |
void ec_master_send_datagrams(ec_master_t *master /**< EtherCAT master */) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
311 |
{ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
312 |
ec_datagram_t *datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
313 |
size_t datagram_size; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
314 |
uint8_t *frame_data, *cur_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
315 |
void *follows_word; |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
316 |
cycles_t t_start, t_end; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
317 |
unsigned int frame_count, more_datagrams_waiting; |
176 | 318 |
|
319 |
frame_count = 0; |
|
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
320 |
t_start = get_cycles(); |
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
321 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
322 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
323 |
EC_DBG("ec_master_send_datagrams\n"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
324 |
|
176 | 325 |
do { |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
326 |
// fetch pointer to transmit socket buffer |
176 | 327 |
frame_data = ec_device_tx_data(master->device); |
328 |
cur_data = frame_data + EC_FRAME_HEADER_SIZE; |
|
329 |
follows_word = NULL; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
330 |
more_datagrams_waiting = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
331 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
332 |
// fill current frame with datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
333 |
list_for_each_entry(datagram, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
334 |
if (datagram->state != EC_CMD_QUEUED) continue; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
335 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
336 |
// does the current datagram fit in the frame? |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
337 |
datagram_size = EC_DATAGRAM_HEADER_SIZE + datagram->data_size |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
338 |
+ EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
339 |
if (cur_data - frame_data + datagram_size > ETH_DATA_LEN) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
340 |
more_datagrams_waiting = 1; |
176 | 341 |
break; |
342 |
} |
|
343 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
344 |
datagram->state = EC_CMD_SENT; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
345 |
datagram->t_sent = t_start; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
346 |
datagram->index = master->datagram_index++; |
176 | 347 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
348 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
349 |
EC_DBG("adding datagram 0x%02X\n", datagram->index); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
350 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
351 |
// set "datagram following" flag in previous frame |
176 | 352 |
if (follows_word) |
353 |
EC_WRITE_U16(follows_word, EC_READ_U16(follows_word) | 0x8000); |
|
354 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
355 |
// EtherCAT datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
356 |
EC_WRITE_U8 (cur_data, datagram->type); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
357 |
EC_WRITE_U8 (cur_data + 1, datagram->index); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
358 |
EC_WRITE_U32(cur_data + 2, datagram->address.logical); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
359 |
EC_WRITE_U16(cur_data + 6, datagram->data_size & 0x7FF); |
176 | 360 |
EC_WRITE_U16(cur_data + 8, 0x0000); |
361 |
follows_word = cur_data + 6; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
362 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
363 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
364 |
// EtherCAT datagram data |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
365 |
memcpy(cur_data, datagram->data, datagram->data_size); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
366 |
cur_data += datagram->data_size; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
367 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
368 |
// EtherCAT datagram footer |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
369 |
EC_WRITE_U16(cur_data, 0x0000); // reset working counter |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
370 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
176 | 371 |
} |
372 |
||
373 |
if (cur_data - frame_data == EC_FRAME_HEADER_SIZE) { |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
374 |
if (unlikely(master->debug_level > 1)) |
176 | 375 |
EC_DBG("nothing to send.\n"); |
376 |
break; |
|
377 |
} |
|
378 |
||
379 |
// EtherCAT frame header |
|
380 |
EC_WRITE_U16(frame_data, ((cur_data - frame_data |
|
381 |
- EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000); |
|
382 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
383 |
// pad frame |
211
c684b6b7adaf
Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
384 |
while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN) |
176 | 385 |
EC_WRITE_U8(cur_data++, 0x00); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
386 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
387 |
if (unlikely(master->debug_level > 1)) |
176 | 388 |
EC_DBG("frame size: %i\n", cur_data - frame_data); |
389 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
390 |
// send frame |
176 | 391 |
ec_device_send(master->device, cur_data - frame_data); |
392 |
frame_count++; |
|
393 |
} |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
394 |
while (more_datagrams_waiting); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
395 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
396 |
if (unlikely(master->debug_level > 1)) { |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
397 |
t_end = get_cycles(); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
398 |
EC_DBG("ec_master_send_datagrams sent %i frames in %ius.\n", |
295
934ec4051dd4
Removed warnings acc. to patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
399 |
frame_count, (unsigned int) (t_end - t_start) * 1000 / cpu_khz); |
176 | 400 |
} |
401 |
} |
|
402 |
||
403 |
/*****************************************************************************/ |
|
404 |
||
405 |
/** |
|
406 |
Processes a received frame. |
|
407 |
This function is called by the network driver for every received frame. |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
408 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
409 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
410 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
411 |
void ec_master_receive(ec_master_t *master, /**< EtherCAT master */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
412 |
const uint8_t *frame_data, /**< received data */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
413 |
size_t size /**< size of the received data */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
414 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
415 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
416 |
size_t frame_size, data_size; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
417 |
uint8_t datagram_type, datagram_index; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
418 |
unsigned int cmd_follows, matched; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
419 |
const uint8_t *cur_data; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
420 |
ec_datagram_t *datagram; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
421 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
422 |
if (unlikely(size < EC_FRAME_HEADER_SIZE)) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
423 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
424 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
425 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
426 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
427 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
428 |
cur_data = frame_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
429 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
430 |
// check length of entire frame |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
431 |
frame_size = EC_READ_U16(cur_data) & 0x07FF; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
432 |
cur_data += EC_FRAME_HEADER_SIZE; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
433 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
434 |
if (unlikely(frame_size > size)) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
435 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
436 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
437 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
438 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
439 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
440 |
cmd_follows = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
441 |
while (cmd_follows) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
442 |
// process datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
443 |
datagram_type = EC_READ_U8 (cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
444 |
datagram_index = EC_READ_U8 (cur_data + 1); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
445 |
data_size = EC_READ_U16(cur_data + 6) & 0x07FF; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
446 |
cmd_follows = EC_READ_U16(cur_data + 6) & 0x8000; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
447 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
448 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
449 |
if (unlikely(cur_data - frame_data |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
450 |
+ data_size + EC_DATAGRAM_FOOTER_SIZE > size)) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
451 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
452 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
453 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
454 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
455 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
456 |
// search for matching datagram in the queue |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
457 |
matched = 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
458 |
list_for_each_entry(datagram, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
459 |
if (datagram->state == EC_CMD_SENT |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
460 |
&& datagram->type == datagram_type |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
461 |
&& datagram->index == datagram_index |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
462 |
&& datagram->data_size == data_size) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
463 |
matched = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
464 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
465 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
466 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
467 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
468 |
// no matching datagram was found |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
469 |
if (!matched) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
470 |
master->stats.unmatched++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
471 |
ec_master_output_stats(master); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
472 |
cur_data += data_size + EC_DATAGRAM_FOOTER_SIZE; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
473 |
continue; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
474 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
475 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
476 |
// copy received data in the datagram memory |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
477 |
memcpy(datagram->data, cur_data, data_size); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
478 |
cur_data += data_size; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
479 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
480 |
// set the datagram's working counter |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
481 |
datagram->working_counter = EC_READ_U16(cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
482 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
483 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
484 |
// dequeue the received datagram |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
485 |
datagram->state = EC_CMD_RECEIVED; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
486 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
487 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
488 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
489 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
490 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
491 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
492 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
493 |
Sends a single datagram and waits for its reception. |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
494 |
If the slave doesn't respond, the datagram is sent again. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
495 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
496 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
497 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
498 |
int ec_master_simple_io(ec_master_t *master, /**< EtherCAT master */ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
499 |
ec_datagram_t *datagram /**< datagram */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
500 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
501 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
502 |
unsigned int response_tries_left; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
503 |
|
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
504 |
response_tries_left = 10000; |
113 | 505 |
|
506 |
while (1) |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
507 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
508 |
ec_master_queue_datagram(master, datagram); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
509 |
ecrt_master_sync_io(master); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
510 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
511 |
if (datagram->state == EC_CMD_RECEIVED) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
512 |
if (likely(datagram->working_counter)) |
113 | 513 |
return 0; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
514 |
} |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
515 |
else if (datagram->state == EC_CMD_TIMEOUT) { |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
516 |
EC_ERR("Simple-IO TIMEOUT!\n"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
517 |
return -1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
518 |
} |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
519 |
else if (datagram->state == EC_CMD_ERROR) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
520 |
EC_ERR("Simple-IO datagram error!\n"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
521 |
return -1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
522 |
} |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
523 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
524 |
// no direct response, wait a little bit... |
130 | 525 |
udelay(100); |
113 | 526 |
|
527 |
if (unlikely(--response_tries_left)) { |
|
528 |
EC_ERR("No response in simple-IO!\n"); |
|
529 |
return -1; |
|
530 |
} |
|
531 |
} |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
532 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
533 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
534 |
/*****************************************************************************/ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
535 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
536 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
537 |
Scans the EtherCAT bus for slaves. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
538 |
Creates a list of slave structures for further processing. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
539 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
540 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
541 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
542 |
int ec_master_bus_scan(ec_master_t *master /**< EtherCAT master */) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
543 |
{ |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
544 |
ec_slave_t *slave; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
545 |
ec_slave_ident_t *ident; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
546 |
ec_datagram_t *datagram; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
547 |
unsigned int i; |
188
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
548 |
uint16_t coupler_index, coupler_subindex; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
549 |
uint16_t reverse_coupler_index, current_coupler_index; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
550 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
551 |
if (!list_empty(&master->slaves)) { |
90 | 552 |
EC_ERR("Slave scan already done!\n"); |
553 |
return -1; |
|
554 |
} |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
555 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
556 |
datagram = &master->simple_datagram; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
557 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
558 |
// determine number of slaves on bus |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
559 |
if (ec_datagram_brd(datagram, 0x0000, 4)) return -1; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
560 |
if (unlikely(ec_master_simple_io(master, datagram))) return -1; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
561 |
master->slave_count = datagram->working_counter; |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
562 |
EC_INFO("Found %i slaves on bus.\n", master->slave_count); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
563 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
564 |
if (!master->slave_count) return 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
565 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
566 |
// init slaves |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
567 |
for (i = 0; i < master->slave_count; i++) { |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
568 |
if (!(slave = |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
569 |
(ec_slave_t *) kmalloc(sizeof(ec_slave_t), GFP_KERNEL))) { |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
570 |
EC_ERR("Failed to allocate slave %i!\n", i); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
571 |
goto out_free; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
572 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
573 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
574 |
if (ec_slave_init(slave, master, i, i + 1)) goto out_free; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
575 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
576 |
if (kobject_add(&slave->kobj)) { |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
577 |
EC_ERR("Failed to add kobject.\n"); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
578 |
kobject_put(&slave->kobj); // free |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
579 |
goto out_free; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
580 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
581 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
582 |
list_add_tail(&slave->list, &master->slaves); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
583 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
584 |
|
188
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
585 |
coupler_index = 0; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
586 |
reverse_coupler_index = 0xFFFF; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
587 |
current_coupler_index = 0x3FFF; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
588 |
coupler_subindex = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
589 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
590 |
// for every slave on the bus |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
591 |
list_for_each_entry(slave, &master->slaves, list) { |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
592 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
593 |
// write station address |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
594 |
if (ec_datagram_apwr(datagram, slave->ring_position, 0x0010, |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
595 |
sizeof(uint16_t))) goto out_free; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
596 |
EC_WRITE_U16(datagram->data, slave->station_address); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
597 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
598 |
EC_ERR("Writing station address failed on slave %i!\n", |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
599 |
slave->ring_position); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
600 |
goto out_free; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
601 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
602 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
603 |
// fetch all slave information |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
604 |
if (ec_slave_fetch(slave)) goto out_free; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
605 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
606 |
// search for identification in "database" |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
607 |
ident = slave_idents; |
129
67b6e534db4b
Bugfix: Absturz bei unbekannter Klemme.
Florian Pose <fp@igh-essen.com>
parents:
120
diff
changeset
|
608 |
while (ident->type) { |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
609 |
if (unlikely(ident->vendor_id == slave->sii_vendor_id |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
610 |
&& ident->product_code == slave->sii_product_code)) { |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
611 |
slave->type = ident->type; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
612 |
break; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
613 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
614 |
ident++; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
615 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
616 |
|
188
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
617 |
if (!slave->type) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
618 |
EC_WARN("Unknown slave device (vendor 0x%08X, code 0x%08X) at" |
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
619 |
" position %i.\n", slave->sii_vendor_id, |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
620 |
slave->sii_product_code, slave->ring_position); |
188
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
621 |
} |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
622 |
else if (slave->type->special == EC_TYPE_BUS_COUPLER) { |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
623 |
if (slave->sii_alias) |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
624 |
current_coupler_index = reverse_coupler_index--; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
625 |
else |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
626 |
current_coupler_index = coupler_index++; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
627 |
coupler_subindex = 0; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
628 |
} |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
629 |
|
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
630 |
slave->coupler_index = current_coupler_index; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
631 |
slave->coupler_subindex = coupler_subindex; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
632 |
coupler_subindex++; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
633 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
634 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
635 |
return 0; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
636 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
637 |
out_free: |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
638 |
ec_master_clear_slaves(master); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
639 |
return -1; |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
640 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
641 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
642 |
/*****************************************************************************/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
643 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
644 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
645 |
Output statistics in cyclic mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
646 |
This function outputs statistical data on demand, but not more often than |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
647 |
necessary. The output happens at most once a second. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
648 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
649 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
650 |
void ec_master_output_stats(ec_master_t *master /**< EtherCAT master */) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
651 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
652 |
cycles_t t_now = get_cycles(); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
653 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
654 |
if (unlikely((u32) (t_now - master->stats.t_last) / cpu_khz > 1000)) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
655 |
if (master->stats.timeouts) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
656 |
EC_WARN("%i datagrams TIMED OUT!\n", master->stats.timeouts); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
657 |
master->stats.timeouts = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
658 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
659 |
if (master->stats.delayed) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
660 |
EC_WARN("%i frame(s) DELAYED!\n", master->stats.delayed); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
661 |
master->stats.delayed = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
662 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
663 |
if (master->stats.corrupted) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
664 |
EC_WARN("%i frame(s) CORRUPTED!\n", master->stats.corrupted); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
665 |
master->stats.corrupted = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
666 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
667 |
if (master->stats.unmatched) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
668 |
EC_WARN("%i datagram(s) UNMATCHED!\n", master->stats.unmatched); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
669 |
master->stats.unmatched = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
670 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
671 |
master->stats.t_last = t_now; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
672 |
} |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
673 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
674 |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
675 |
/*****************************************************************************/ |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
676 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
677 |
/** |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
678 |
Starts the Idle mode. |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
679 |
*/ |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
680 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
681 |
void ec_master_idle_start(ec_master_t *master /**< EtherCAT master */) |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
682 |
{ |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
683 |
if (master->mode == EC_MASTER_MODE_IDLE) return; |
191 | 684 |
|
685 |
if (master->mode == EC_MASTER_MODE_RUNNING) { |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
686 |
EC_ERR("ec_master_idle_start: Master already running!\n"); |
191 | 687 |
return; |
688 |
} |
|
689 |
||
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
690 |
EC_INFO("Starting Idle mode.\n"); |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
691 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
692 |
master->mode = EC_MASTER_MODE_IDLE; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
693 |
ec_fsm_reset(&master->fsm); |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
694 |
queue_delayed_work(master->workqueue, &master->idle_work, 1); |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
695 |
} |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
696 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
697 |
/*****************************************************************************/ |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
698 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
699 |
/** |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
700 |
Stops the Idle mode. |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
701 |
*/ |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
702 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
703 |
void ec_master_idle_stop(ec_master_t *master /**< EtherCAT master */) |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
704 |
{ |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
705 |
if (master->mode != EC_MASTER_MODE_IDLE) return; |
191 | 706 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
707 |
ec_master_eoe_stop(master); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
708 |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
709 |
EC_INFO("Stopping Idle mode.\n"); |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
710 |
master->mode = EC_MASTER_MODE_ORPHANED; // this is important for the |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
711 |
// IDLE work function to not |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
712 |
// queue itself again |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
713 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
714 |
if (!cancel_delayed_work(&master->idle_work)) { |
236
34d7ce41e9db
Started freerun state machine development.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
715 |
flush_workqueue(master->workqueue); |
34d7ce41e9db
Started freerun state machine development.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
716 |
} |
34d7ce41e9db
Started freerun state machine development.
Florian Pose <fp@igh-essen.com>
parents:
235
diff
changeset
|
717 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
718 |
ec_master_clear_slaves(master); |
191 | 719 |
} |
720 |
||
721 |
/*****************************************************************************/ |
|
722 |
||
723 |
/** |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
724 |
Idle mode function. |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
725 |
*/ |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
726 |
|
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
727 |
void ec_master_idle(void *data /**< master pointer */) |
191 | 728 |
{ |
729 |
ec_master_t *master = (ec_master_t *) data; |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
730 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
731 |
// aquire master lock |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
732 |
spin_lock_bh(&master->internal_lock); |
191 | 733 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
734 |
ecrt_master_async_receive(master); |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
735 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
736 |
// execute master state machine |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
737 |
ec_fsm_execute(&master->fsm); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
738 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
739 |
ecrt_master_async_send(master); |
191 | 740 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
741 |
// release master lock |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
742 |
spin_unlock_bh(&master->internal_lock); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
743 |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
744 |
if (master->mode == EC_MASTER_MODE_IDLE) |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
745 |
queue_delayed_work(master->workqueue, &master->idle_work, 1); |
191 | 746 |
} |
747 |
||
748 |
/*****************************************************************************/ |
|
749 |
||
750 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
751 |
Initializes a sync manager configuration page. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
752 |
The referenced memory (\a data) must be at least EC_SYNC_SIZE bytes. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
753 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
754 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
755 |
void ec_sync_config(const ec_sync_t *sync, /**< sync manager */ |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
756 |
const ec_slave_t *slave, /**< EtherCAT slave */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
757 |
uint8_t *data /**> configuration memory */ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
758 |
) |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
759 |
{ |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
760 |
size_t sync_size; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
761 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
762 |
sync_size = ec_slave_calc_sync_size(slave, sync); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
763 |
|
77
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
764 |
EC_WRITE_U16(data, sync->physical_start_address); |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
765 |
EC_WRITE_U16(data + 2, sync_size); |
77
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
766 |
EC_WRITE_U8 (data + 4, sync->control_byte); |
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
767 |
EC_WRITE_U8 (data + 5, 0x00); // status byte (read only) |
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
768 |
EC_WRITE_U16(data + 6, 0x0001); // enable |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
769 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
770 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
771 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
772 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
773 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
774 |
Initializes a sync manager configuration page with EEPROM data. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
775 |
The referenced memory (\a data) must be at least EC_SYNC_SIZE bytes. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
776 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
777 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
778 |
void ec_eeprom_sync_config(const ec_eeprom_sync_t *sync, /**< sync manager */ |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
779 |
const ec_slave_t *slave, /**< EtherCAT slave */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
780 |
uint8_t *data /**> configuration memory */ |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
781 |
) |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
782 |
{ |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
783 |
size_t sync_size; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
784 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
785 |
sync_size = ec_slave_calc_eeprom_sync_size(slave, sync); |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
786 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
787 |
if (slave->master->debug_level) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
788 |
EC_INFO("Slave %i, sync manager %i:\n", slave->ring_position, |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
789 |
sync->index); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
790 |
EC_INFO(" Address: 0x%04X\n", sync->physical_start_address); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
791 |
EC_INFO(" Size: %i\n", sync_size); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
792 |
EC_INFO(" Control: 0x%02X\n", sync->control_register); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
793 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
794 |
|
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
795 |
EC_WRITE_U16(data, sync->physical_start_address); |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
796 |
EC_WRITE_U16(data + 2, sync_size); |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
797 |
EC_WRITE_U8 (data + 4, sync->control_register); |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
798 |
EC_WRITE_U8 (data + 5, 0x00); // status byte (read only) |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
799 |
EC_WRITE_U16(data + 6, sync->enable ? 0x0001 : 0x0000); // enable |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
800 |
} |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
801 |
|
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
802 |
/*****************************************************************************/ |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
803 |
|
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
804 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
805 |
Initializes an FMMU configuration page. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
806 |
The referenced memory (\a data) must be at least EC_FMMU_SIZE bytes. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
807 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
808 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
809 |
void ec_fmmu_config(const ec_fmmu_t *fmmu, /**< FMMU */ |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
810 |
const ec_slave_t *slave, /**< EtherCAT slave */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
811 |
uint8_t *data /**> configuration memory */ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
812 |
) |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
813 |
{ |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
814 |
size_t sync_size; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
815 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
816 |
sync_size = ec_slave_calc_sync_size(slave, fmmu->sync); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
817 |
|
77
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
818 |
EC_WRITE_U32(data, fmmu->logical_start_address); |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
274
diff
changeset
|
819 |
EC_WRITE_U16(data + 4, sync_size); // size of fmmu |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
820 |
EC_WRITE_U8 (data + 6, 0x00); // logical start bit |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
821 |
EC_WRITE_U8 (data + 7, 0x07); // logical end bit |
77
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
822 |
EC_WRITE_U16(data + 8, fmmu->sync->physical_start_address); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
823 |
EC_WRITE_U8 (data + 10, 0x00); // physical start bit |
77
677967864795
EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents:
74
diff
changeset
|
824 |
EC_WRITE_U8 (data + 11, (fmmu->sync->control_byte & 0x04) ? 0x02 : 0x01); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
825 |
EC_WRITE_U16(data + 12, 0x0001); // enable |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
826 |
EC_WRITE_U16(data + 14, 0x0000); // reserved |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
827 |
} |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
828 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
829 |
/*****************************************************************************/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
830 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
831 |
/** |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
832 |
Formats attribute data for SysFS read access. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
833 |
\return number of bytes to read |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
834 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
835 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
836 |
ssize_t ec_show_master_attribute(struct kobject *kobj, /**< kobject */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
837 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
838 |
char *buffer /**< memory to store data */ |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
839 |
) |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
840 |
{ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
841 |
ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
842 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
843 |
if (attr == &attr_slave_count) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
844 |
return sprintf(buffer, "%i\n", master->slave_count); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
845 |
} |
191 | 846 |
else if (attr == &attr_mode) { |
847 |
switch (master->mode) { |
|
305
03aab3068f08
Renamed IDLE mode to ORPHANED mode.
Florian Pose <fp@igh-essen.com>
parents:
303
diff
changeset
|
848 |
case EC_MASTER_MODE_ORPHANED: |
03aab3068f08
Renamed IDLE mode to ORPHANED mode.
Florian Pose <fp@igh-essen.com>
parents:
303
diff
changeset
|
849 |
return sprintf(buffer, "ORPHANED\n"); |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
850 |
case EC_MASTER_MODE_IDLE: |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
851 |
return sprintf(buffer, "IDLE\n"); |
191 | 852 |
case EC_MASTER_MODE_RUNNING: |
853 |
return sprintf(buffer, "RUNNING\n"); |
|
854 |
} |
|
855 |
} |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
856 |
else if (attr == &attr_debug_level) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
857 |
return sprintf(buffer, "%i\n", master->debug_level); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
858 |
} |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
859 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
860 |
return 0; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
861 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
862 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
863 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
864 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
865 |
/** |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
866 |
Formats attribute data for SysFS write access. |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
867 |
\return number of bytes processed, or negative error code |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
868 |
*/ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
869 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
870 |
ssize_t ec_store_master_attribute(struct kobject *kobj, /**< slave's kobject */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
871 |
struct attribute *attr, /**< attribute */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
872 |
const char *buffer, /**< memory with data */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
873 |
size_t size /**< size of data to store */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
874 |
) |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
875 |
{ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
876 |
ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
877 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
878 |
if (attr == &attr_eeprom_write_enable) { |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
879 |
if (!strcmp(buffer, "1\n")) { |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
880 |
master->eeprom_write_enable = 1; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
881 |
EC_INFO("Slave EEPROM writing enabled.\n"); |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
882 |
return size; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
883 |
} |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
884 |
else if (!strcmp(buffer, "0\n")) { |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
885 |
master->eeprom_write_enable = 0; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
886 |
EC_INFO("Slave EEPROM writing disabled.\n"); |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
887 |
return size; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
888 |
} |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
889 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
890 |
EC_ERR("Invalid value for eeprom_write_enable!\n"); |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
891 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
892 |
if (master->eeprom_write_enable) { |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
893 |
master->eeprom_write_enable = 0; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
894 |
EC_INFO("Slave EEPROM writing disabled.\n"); |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
895 |
} |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
896 |
} |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
897 |
else if (attr == &attr_debug_level) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
898 |
if (!strcmp(buffer, "0\n")) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
899 |
master->debug_level = 0; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
900 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
901 |
else if (!strcmp(buffer, "1\n")) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
902 |
master->debug_level = 1; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
903 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
904 |
else if (!strcmp(buffer, "2\n")) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
905 |
master->debug_level = 2; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
906 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
907 |
else { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
908 |
EC_ERR("Invalid debug level value!\n"); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
909 |
return -EINVAL; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
910 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
911 |
|
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
912 |
EC_INFO("Master debug level set to %i.\n", master->debug_level); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
913 |
return size; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
914 |
} |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
915 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
916 |
return -EINVAL; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
917 |
} |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
918 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
919 |
/*****************************************************************************/ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
920 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
921 |
/** |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
922 |
Starts Ethernet-over-EtherCAT processing for all EoE-capable slaves. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
923 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
924 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
925 |
void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
926 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
927 |
ec_eoe_t *eoe; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
928 |
ec_slave_t *slave; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
929 |
unsigned int coupled, found; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
930 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
931 |
if (master->eoe_running) return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
932 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
933 |
// decouple all EoE handlers |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
934 |
list_for_each_entry(eoe, &master->eoe_handlers, list) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
935 |
eoe->slave = NULL; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
936 |
coupled = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
937 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
938 |
// couple a free EoE handler to every EoE-capable slave |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
939 |
list_for_each_entry(slave, &master->slaves, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
940 |
if (!(slave->sii_mailbox_protocols & EC_MBOX_EOE)) continue; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
941 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
942 |
found = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
943 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
944 |
if (eoe->slave) continue; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
945 |
eoe->slave = slave; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
946 |
found = 1; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
947 |
coupled++; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
948 |
EC_INFO("Coupling device %s to slave %i.\n", |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
949 |
eoe->dev->name, slave->ring_position); |
261
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
950 |
if (eoe->opened) { |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
951 |
slave->requested_state = EC_SLAVE_STATE_OP; |
261
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
952 |
} |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
953 |
else { |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
954 |
slave->requested_state = EC_SLAVE_STATE_INIT; |
44a3a5833c49
Better state-dependent behaviour for EoE-capable slaves.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
955 |
} |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
278
diff
changeset
|
956 |
slave->error_flag = 0; |
253
6dd3e49dbb85
Fixed bug with coupling multiple EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
252
diff
changeset
|
957 |
break; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
958 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
959 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
960 |
if (!found) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
961 |
EC_WARN("No EoE handler for slave %i!\n", slave->ring_position); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
962 |
slave->requested_state = EC_SLAVE_STATE_INIT; |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
278
diff
changeset
|
963 |
slave->error_flag = 0; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
964 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
965 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
966 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
967 |
if (!coupled) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
968 |
EC_INFO("No EoE handlers coupled.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
969 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
970 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
971 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
972 |
EC_INFO("Starting EoE processing.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
973 |
master->eoe_running = 1; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
974 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
975 |
// start EoE processing |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
976 |
master->eoe_timer.expires = jiffies + 10; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
977 |
add_timer(&master->eoe_timer); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
978 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
979 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
980 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
981 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
982 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
983 |
/** |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
984 |
Stops the Ethernet-over-EtherCAT processing. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
985 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
986 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
987 |
void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
988 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
989 |
ec_eoe_t *eoe; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
990 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
991 |
if (!master->eoe_running) return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
992 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
993 |
EC_INFO("Stopping EoE processing.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
994 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
995 |
del_timer_sync(&master->eoe_timer); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
996 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
997 |
// decouple all EoE handlers |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
998 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
999 |
if (eoe->slave) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1000 |
eoe->slave->requested_state = EC_SLAVE_STATE_INIT; |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
278
diff
changeset
|
1001 |
eoe->slave->error_flag = 0; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1002 |
eoe->slave = NULL; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1003 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1004 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1005 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1006 |
master->eoe_running = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1007 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1008 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1009 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1010 |
/** |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1011 |
Does the Ethernet-over-EtherCAT processing. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1012 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1013 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1014 |
void ec_master_eoe_run(unsigned long data /**< master pointer */) |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1015 |
{ |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1016 |
ec_master_t *master = (ec_master_t *) data; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1017 |
ec_eoe_t *eoe; |
235
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
228
diff
changeset
|
1018 |
unsigned int active = 0; |
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
228
diff
changeset
|
1019 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1020 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
235
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
228
diff
changeset
|
1021 |
if (ec_eoe_active(eoe)) active++; |
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
228
diff
changeset
|
1022 |
} |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1023 |
if (!active) goto queue_timer; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1024 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1025 |
// aquire master lock... |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1026 |
if (master->mode == EC_MASTER_MODE_RUNNING) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1027 |
// request_cb must return 0, if the lock has been aquired! |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1028 |
if (master->request_cb(master->cb_data)) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1029 |
goto queue_timer; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1030 |
} |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
1031 |
else if (master->mode == EC_MASTER_MODE_IDLE) { |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1032 |
spin_lock(&master->internal_lock); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1033 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1034 |
else |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1035 |
goto queue_timer; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1036 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1037 |
// actual EoE stuff |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1038 |
ecrt_master_async_receive(master); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1039 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1040 |
ec_eoe_run(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1041 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1042 |
ecrt_master_async_send(master); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1043 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1044 |
// release lock... |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1045 |
if (master->mode == EC_MASTER_MODE_RUNNING) { |
228 | 1046 |
master->release_cb(master->cb_data); |
1047 |
} |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
305
diff
changeset
|
1048 |
else if (master->mode == EC_MASTER_MODE_IDLE) { |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1049 |
spin_unlock(&master->internal_lock); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1050 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1051 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1052 |
queue_timer: |
228 | 1053 |
master->eoe_timer.expires += HZ / EC_EOE_FREQUENCY; |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1054 |
add_timer(&master->eoe_timer); |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1055 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1056 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1057 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1058 |
* Realtime interface |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1059 |
*****************************************************************************/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1060 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1061 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1062 |
Creates a domain. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1063 |
\return pointer to new domain on success, else NULL |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1064 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1065 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1066 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1067 |
ec_domain_t *ecrt_master_create_domain(ec_master_t *master /**< master */) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1068 |
{ |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1069 |
ec_domain_t *domain, *last_domain; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1070 |
unsigned int index; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1071 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1072 |
if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1073 |
EC_ERR("Error allocating domain memory!\n"); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1074 |
goto out_return; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1075 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1076 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1077 |
if (list_empty(&master->domains)) index = 0; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1078 |
else { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1079 |
last_domain = list_entry(master->domains.prev, ec_domain_t, list); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1080 |
index = last_domain->index + 1; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1081 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1082 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1083 |
if (ec_domain_init(domain, master, index)) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1084 |
EC_ERR("Failed to init domain.\n"); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1085 |
goto out_return; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1086 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1087 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1088 |
if (kobject_add(&domain->kobj)) { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1089 |
EC_ERR("Failed to add domain kobject.\n"); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1090 |
goto out_put; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1091 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1092 |
|
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
1093 |
list_add_tail(&domain->list, &master->domains); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1094 |
return domain; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1095 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1096 |
out_put: |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1097 |
kobject_put(&domain->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1098 |
out_return: |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1099 |
return NULL; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1100 |
} |
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
1101 |
|
74
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
1102 |
/*****************************************************************************/ |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
1103 |
|
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
1104 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1105 |
Configures all slaves and leads them to the OP state. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1106 |
Does the complete configuration and activation for all slaves. Sets sync |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1107 |
managers and FMMUs, and does the appropriate transitions, until the slave |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1108 |
is operational. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1109 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1110 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1111 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1112 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1113 |
int ecrt_master_activate(ec_master_t *master /**< EtherCAT master */) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1114 |
{ |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1115 |
unsigned int j; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1116 |
ec_slave_t *slave; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1117 |
ec_datagram_t *datagram; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1118 |
const ec_sync_t *sync; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1119 |
const ec_slave_type_t *type; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1120 |
const ec_fmmu_t *fmmu; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1121 |
uint32_t domain_offset; |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1122 |
ec_domain_t *domain; |
155
ff65679b65fe
Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents:
151
diff
changeset
|
1123 |
ec_eeprom_sync_t *eeprom_sync, mbox_sync; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1124 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1125 |
datagram = &master->simple_datagram; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1126 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1127 |
// allocate all domains |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1128 |
domain_offset = 0; |
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
1129 |
list_for_each_entry(domain, &master->domains, list) { |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1130 |
if (ec_domain_alloc(domain, domain_offset)) { |
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
1131 |
EC_ERR("Failed to allocate domain %X!\n", (u32) domain); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1132 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1133 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1134 |
domain_offset += domain->data_size; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1135 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1136 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1137 |
// configure and activate slaves |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1138 |
list_for_each_entry(slave, &master->slaves, list) { |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1139 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1140 |
// change state to INIT |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1141 |
if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_INIT))) |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1142 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1143 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1144 |
// check for slave registration |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1145 |
type = slave->type; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1146 |
if (!type) |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1147 |
EC_WARN("Slave %i has unknown type!\n", slave->ring_position); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1148 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1149 |
// check and reset CRC fault counters |
74
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
1150 |
ec_slave_check_crc(slave); |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
1151 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1152 |
// reset FMMUs |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1153 |
if (slave->base_fmmu_count) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1154 |
if (ec_datagram_npwr(datagram, slave->station_address, 0x0600, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1155 |
EC_FMMU_SIZE * slave->base_fmmu_count)) |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1156 |
return -1; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1157 |
memset(datagram->data, 0x00, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1158 |
EC_FMMU_SIZE * slave->base_fmmu_count); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1159 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
89
e91ef35c36db
Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
1160 |
EC_ERR("Resetting FMMUs failed on slave %i!\n", |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1161 |
slave->ring_position); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1162 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1163 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1164 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1165 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1166 |
// reset sync managers |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1167 |
if (slave->base_sync_count) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1168 |
if (ec_datagram_npwr(datagram, slave->station_address, 0x0800, |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1169 |
EC_SYNC_SIZE * slave->base_sync_count)) |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1170 |
return -1; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1171 |
memset(datagram->data, 0x00, |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1172 |
EC_SYNC_SIZE * slave->base_sync_count); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1173 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
89
e91ef35c36db
Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
1174 |
EC_ERR("Resetting sync managers failed on slave %i!\n", |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1175 |
slave->ring_position); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1176 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1177 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1178 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1179 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1180 |
// configure sync managers |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1181 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1182 |
// does the slave provide sync manager information? |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1183 |
if (!list_empty(&slave->eeprom_syncs)) { |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1184 |
list_for_each_entry(eeprom_sync, &slave->eeprom_syncs, list) { |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1185 |
if (ec_datagram_npwr(datagram, slave->station_address, |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1186 |
0x800 + eeprom_sync->index * |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1187 |
EC_SYNC_SIZE, |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1188 |
EC_SYNC_SIZE)) return -1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1189 |
ec_eeprom_sync_config(eeprom_sync, slave, datagram->data); |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1190 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1191 |
EC_ERR("Setting sync manager %i failed on slave %i!\n", |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1192 |
eeprom_sync->index, slave->ring_position); |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1193 |
return -1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1194 |
} |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1195 |
} |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1196 |
} |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1197 |
|
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1198 |
else if (type) { // known slave type, take type's SM information |
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
1199 |
for (j = 0; type->sync_managers[j] && j < EC_MAX_SYNC; j++) { |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1200 |
sync = type->sync_managers[j]; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1201 |
if (ec_datagram_npwr(datagram, slave->station_address, |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1202 |
0x0800 + j * EC_SYNC_SIZE, EC_SYNC_SIZE)) |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1203 |
return -1; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1204 |
ec_sync_config(sync, slave, datagram->data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1205 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1206 |
EC_ERR("Setting sync manager %i failed on slave %i!\n", |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1207 |
j, slave->ring_position); |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1208 |
return -1; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1209 |
} |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1210 |
} |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1211 |
} |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1212 |
|
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1213 |
// no sync manager information; guess mailbox settings |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1214 |
else if (slave->sii_mailbox_protocols) { |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1215 |
mbox_sync.physical_start_address = |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1216 |
slave->sii_rx_mailbox_offset; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1217 |
mbox_sync.length = slave->sii_rx_mailbox_size; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1218 |
mbox_sync.control_register = 0x26; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1219 |
mbox_sync.enable = 1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1220 |
if (ec_datagram_npwr(datagram, slave->station_address, |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1221 |
0x800,EC_SYNC_SIZE)) return -1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1222 |
ec_eeprom_sync_config(&mbox_sync, slave, datagram->data); |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1223 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1224 |
EC_ERR("Setting sync manager 0 failed on slave %i!\n", |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1225 |
slave->ring_position); |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1226 |
return -1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1227 |
} |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1228 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1229 |
mbox_sync.physical_start_address = |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1230 |
slave->sii_tx_mailbox_offset; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1231 |
mbox_sync.length = slave->sii_tx_mailbox_size; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1232 |
mbox_sync.control_register = 0x22; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1233 |
mbox_sync.enable = 1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1234 |
if (ec_datagram_npwr(datagram, slave->station_address, |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1235 |
0x808, EC_SYNC_SIZE)) return -1; |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1236 |
ec_eeprom_sync_config(&mbox_sync, slave, datagram->data); |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1237 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
155
ff65679b65fe
Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents:
151
diff
changeset
|
1238 |
EC_ERR("Setting sync manager 1 failed on slave %i!\n", |
ff65679b65fe
Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents:
151
diff
changeset
|
1239 |
slave->ring_position); |
ff65679b65fe
Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents:
151
diff
changeset
|
1240 |
return -1; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
295
diff
changeset
|
1241 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1242 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1243 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1244 |
// change state to PREOP |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1245 |
if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_PREOP))) |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1246 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1247 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1248 |
// stop activation here for slaves without type |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1249 |
if (!type) continue; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
1250 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1251 |
// slaves that are not registered are only brought into PREOP |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1252 |
// state -> nice blinking and mailbox communication possible |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1253 |
if (!slave->registered && !slave->type->special) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1254 |
EC_WARN("Slave %i was not registered!\n", slave->ring_position); |
81
28b1defdcc88
Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
1255 |
continue; |
28b1defdcc88
Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
1256 |
} |
28b1defdcc88
Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
1257 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1258 |
// configure FMMUs |
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
1259 |
for (j = 0; j < slave->fmmu_count; j++) { |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1260 |
fmmu = &slave->fmmus[j]; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1261 |
if (ec_datagram_npwr(datagram, slave->station_address, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1262 |
0x0600 + j * EC_FMMU_SIZE, EC_FMMU_SIZE)) |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1263 |
return -1; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1264 |
ec_fmmu_config(fmmu, slave, datagram->data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1265 |
if (unlikely(ec_master_simple_io(master, datagram))) { |
89
e91ef35c36db
Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
1266 |
EC_ERR("Setting FMMU %i failed on slave %i!\n", |
e91ef35c36db
Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents:
84
diff
changeset
|
1267 |
j, slave->ring_position); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1268 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1269 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1270 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1271 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1272 |
// change state to SAVEOP |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1273 |
if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_SAVEOP))) |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1274 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1275 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1276 |
// change state to OP |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1277 |
if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_OP))) |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1278 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1279 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1280 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1281 |
return 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1282 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1283 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1284 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1285 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1286 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1287 |
Resets all slaves to INIT state. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1288 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1289 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1290 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1291 |
void ecrt_master_deactivate(ec_master_t *master /**< EtherCAT master */) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1292 |
{ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1293 |
ec_slave_t *slave; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1294 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1295 |
list_for_each_entry(slave, &master->slaves, list) { |
74
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
1296 |
ec_slave_check_crc(slave); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1297 |
ec_slave_state_change(slave, EC_SLAVE_STATE_INIT); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1298 |
} |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1299 |
} |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1300 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1301 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1302 |
/*****************************************************************************/ |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1303 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1304 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1305 |
Fetches the SDO dictionaries of all slaves. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1306 |
Slaves that do not support the CoE protocol are left out. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1307 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1308 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1309 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1310 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1311 |
int ecrt_master_fetch_sdo_lists(ec_master_t *master /**< EtherCAT master */) |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1312 |
{ |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1313 |
ec_slave_t *slave; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1314 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1315 |
list_for_each_entry(slave, &master->slaves, list) { |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1316 |
if (slave->sii_mailbox_protocols & EC_MBOX_COE) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1317 |
if (unlikely(ec_slave_fetch_sdo_list(slave))) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1318 |
EC_ERR("Failed to fetch SDO list on slave %i!\n", |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1319 |
slave->ring_position); |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1320 |
return -1; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1321 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1322 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1323 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1324 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1325 |
return 0; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1326 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1327 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1328 |
/*****************************************************************************/ |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1329 |
|
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1330 |
/** |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1331 |
Sends queued datagrams and waits for their reception. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1332 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1333 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1334 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1335 |
void ecrt_master_sync_io(ec_master_t *master /**< EtherCAT master */) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1336 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1337 |
ec_datagram_t *datagram, *n; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1338 |
unsigned int datagrams_sent; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1339 |
cycles_t t_start, t_end, t_timeout; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1340 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1341 |
// send datagrams |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1342 |
ecrt_master_async_send(master); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1343 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1344 |
t_start = get_cycles(); // measure io time |
120 | 1345 |
t_timeout = (cycles_t) master->timeout * (cpu_khz / 1000); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1346 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1347 |
while (1) { // active waiting |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1348 |
ec_device_call_isr(master->device); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1349 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1350 |
t_end = get_cycles(); // take current time |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1351 |
if (t_end - t_start >= t_timeout) break; // timeout! |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1352 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1353 |
datagrams_sent = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1354 |
list_for_each_entry_safe(datagram, n, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1355 |
if (datagram->state == EC_CMD_RECEIVED) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1356 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1357 |
else if (datagram->state == EC_CMD_SENT) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1358 |
datagrams_sent++; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1359 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1360 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1361 |
if (!datagrams_sent) break; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1362 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1363 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1364 |
// timeout; dequeue all datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1365 |
list_for_each_entry_safe(datagram, n, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1366 |
switch (datagram->state) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1367 |
case EC_CMD_SENT: |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1368 |
case EC_CMD_QUEUED: |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1369 |
datagram->state = EC_CMD_TIMEOUT; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1370 |
master->stats.timeouts++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1371 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1372 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1373 |
case EC_CMD_RECEIVED: |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1374 |
master->stats.delayed++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1375 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1376 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1377 |
default: |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1378 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1379 |
} |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1380 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1381 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1382 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1383 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1384 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1385 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1386 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1387 |
Asynchronous sending of datagrams. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1388 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1389 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1390 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1391 |
void ecrt_master_async_send(ec_master_t *master /**< EtherCAT master */) |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1392 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1393 |
ec_datagram_t *datagram, *n; |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1394 |
|
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1395 |
if (unlikely(!master->device->link_state)) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1396 |
// link is down, no datagram can be sent |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1397 |
list_for_each_entry_safe(datagram, n, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1398 |
datagram->state = EC_CMD_ERROR; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1399 |
list_del_init(&datagram->queue); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1400 |
} |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1401 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1402 |
// query link state |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1403 |
ec_device_call_isr(master->device); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1404 |
return; |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1405 |
} |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1406 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1407 |
// send frames |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1408 |
ec_master_send_datagrams(master); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1409 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1410 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1411 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1412 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1413 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1414 |
Asynchronous receiving of datagrams. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1415 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1416 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1417 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1418 |
void ecrt_master_async_receive(ec_master_t *master /**< EtherCAT master */) |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1419 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1420 |
ec_datagram_t *datagram, *next; |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1421 |
cycles_t t_received, t_timeout; |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1422 |
|
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1423 |
ec_device_call_isr(master->device); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1424 |
|
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1425 |
t_received = get_cycles(); |
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1426 |
t_timeout = (cycles_t) master->timeout * (cpu_khz / 1000); |
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1427 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1428 |
// dequeue all received datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1429 |
list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1430 |
if (datagram->state == EC_CMD_RECEIVED) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1431 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1432 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1433 |
// dequeue all datagrams that timed out |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1434 |
list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1435 |
switch (datagram->state) { |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1436 |
case EC_CMD_SENT: |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1437 |
case EC_CMD_QUEUED: |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1438 |
if (t_received - datagram->t_sent > t_timeout) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1439 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1440 |
datagram->state = EC_CMD_TIMEOUT; |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1441 |
master->stats.timeouts++; |
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1442 |
ec_master_output_stats(master); |
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1443 |
} |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1444 |
break; |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1445 |
default: |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1446 |
break; |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1447 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1448 |
} |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1449 |
} |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1450 |
|
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1451 |
/*****************************************************************************/ |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1452 |
|
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1453 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1454 |
Prepares synchronous IO. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1455 |
Queues all domain datagrams and sends them. Then waits a certain time, so |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1456 |
that ecrt_master_sasync_receive() can be called securely. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1457 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1458 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1459 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1460 |
void ecrt_master_prepare_async_io(ec_master_t *master /**< EtherCAT master */) |
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1461 |
{ |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1462 |
ec_domain_t *domain; |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1463 |
cycles_t t_start, t_end, t_timeout; |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1464 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1465 |
// queue datagrams of all domains |
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1466 |
list_for_each_entry(domain, &master->domains, list) |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1467 |
ecrt_domain_queue(domain); |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1468 |
|
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1469 |
ecrt_master_async_send(master); |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1470 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1471 |
t_start = get_cycles(); // take sending time |
120 | 1472 |
t_timeout = (cycles_t) master->timeout * (cpu_khz / 1000); |
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1473 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1474 |
// active waiting |
113 | 1475 |
while (1) { |
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1476 |
t_end = get_cycles(); |
113 | 1477 |
if (t_end - t_start >= t_timeout) break; |
1478 |
} |
|
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1479 |
} |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1480 |
|
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1481 |
/*****************************************************************************/ |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1482 |
|
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
1483 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1484 |
Does all cyclic master work. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1485 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1486 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1487 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1488 |
void ecrt_master_run(ec_master_t *master /**< EtherCAT master */) |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1489 |
{ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1490 |
// output statistics |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1491 |
ec_master_output_stats(master); |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1492 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
1493 |
// execute master state machine |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
1494 |
ec_fsm_execute(&master->fsm); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1495 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1496 |
|
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1497 |
/*****************************************************************************/ |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1498 |
|
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1499 |
/** |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1500 |
Translates an ASCII coded bus-address to a slave pointer. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1501 |
These are the valid addressing schemes: |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1502 |
- \a "X" = the X. slave on the bus, |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1503 |
- \a "X:Y" = the Y. slave after the X. branch (bus coupler), |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1504 |
- \a "#X" = the slave with alias X, |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1505 |
- \a "#X:Y" = the Y. slave after the branch (bus coupler) with alias X. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1506 |
X and Y are zero-based indices and may be provided in hexadecimal or octal |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1507 |
notation (with respective prefix). |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1508 |
\return pointer to the slave on success, else NULL |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1509 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1510 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1511 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1512 |
ec_slave_t *ecrt_master_get_slave(const ec_master_t *master, /**< Master */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1513 |
const char *address /**< address string */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1514 |
) |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1515 |
{ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1516 |
unsigned long first, second; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1517 |
char *remainder, *remainder2; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1518 |
unsigned int alias_requested, alias_found; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1519 |
ec_slave_t *alias_slave = NULL, *slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1520 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1521 |
if (!address || address[0] == 0) return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1522 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1523 |
alias_requested = 0; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1524 |
if (address[0] == '#') { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1525 |
alias_requested = 1; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1526 |
address++; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1527 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1528 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1529 |
first = simple_strtoul(address, &remainder, 0); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1530 |
if (remainder == address) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1531 |
EC_ERR("Slave address \"%s\" - First number empty!\n", address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1532 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1533 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1534 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1535 |
if (alias_requested) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1536 |
alias_found = 0; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1537 |
list_for_each_entry(alias_slave, &master->slaves, list) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1538 |
if (alias_slave->sii_alias == first) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1539 |
alias_found = 1; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1540 |
break; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1541 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1542 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1543 |
if (!alias_found) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1544 |
EC_ERR("Slave address \"%s\" - Alias not found!\n", address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1545 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1546 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1547 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1548 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1549 |
if (!remainder[0]) { // absolute position |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1550 |
if (alias_requested) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1551 |
return alias_slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1552 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1553 |
else { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1554 |
list_for_each_entry(slave, &master->slaves, list) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1555 |
if (slave->ring_position == first) return slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1556 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1557 |
EC_ERR("Slave address \"%s\" - Absolute position invalid!\n", |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1558 |
address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1559 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1560 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1561 |
else if (remainder[0] == ':') { // field position |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1562 |
remainder++; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1563 |
second = simple_strtoul(remainder, &remainder2, 0); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1564 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1565 |
if (remainder2 == remainder) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1566 |
EC_ERR("Slave address \"%s\" - Second number empty!\n", address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1567 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1568 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1569 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1570 |
if (remainder2[0]) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1571 |
EC_ERR("Slave address \"%s\" - Invalid trailer!\n", address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1572 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1573 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1574 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1575 |
if (alias_requested) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1576 |
if (!alias_slave->type || |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1577 |
alias_slave->type->special != EC_TYPE_BUS_COUPLER) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1578 |
EC_ERR("Slave address \"%s\": Alias slave must be bus coupler" |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1579 |
" in colon mode.\n", address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1580 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1581 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1582 |
list_for_each_entry(slave, &master->slaves, list) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1583 |
if (slave->coupler_index == alias_slave->coupler_index |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1584 |
&& slave->coupler_subindex == second) |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1585 |
return slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1586 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1587 |
EC_ERR("Slave address \"%s\" - Bus coupler %i has no %lu. slave" |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1588 |
" following!\n", address, alias_slave->ring_position, |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1589 |
second); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1590 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1591 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1592 |
else { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1593 |
list_for_each_entry(slave, &master->slaves, list) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1594 |
if (slave->coupler_index == first |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1595 |
&& slave->coupler_subindex == second) return slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1596 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1597 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1598 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1599 |
else |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1600 |
EC_ERR("Slave address \"%s\" - Invalid format!\n", address); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1601 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1602 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1603 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1604 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1605 |
/*****************************************************************************/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1606 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1607 |
/** |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1608 |
Sets the locking callbacks. |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
1609 |
The request_cb function must return zero, to allow another instance |
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
1610 |
(the EoE process for example) to access the master. Non-zero means, |
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
1611 |
that access is forbidden at this time. |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1612 |
\ingroup RealtimeInterface |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1613 |
*/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1614 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1615 |
void ecrt_master_callbacks(ec_master_t *master, /**< EtherCAT master */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1616 |
int (*request_cb)(void *), /**< request lock CB */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1617 |
void (*release_cb)(void *), /**< release lock CB */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1618 |
void *cb_data /**< data parameter */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1619 |
) |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1620 |
{ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1621 |
master->request_cb = request_cb; |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1622 |
master->release_cb = release_cb; |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1623 |
master->cb_data = cb_data; |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1624 |
} |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1625 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1626 |
/*****************************************************************************/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1627 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1628 |
/** |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1629 |
Starts Ethernet-over-EtherCAT processing for all EoE-capable slaves. |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1630 |
\ingroup RealtimeInterface |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1631 |
*/ |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1632 |
|
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1633 |
int ecrt_master_start_eoe(ec_master_t *master /**< EtherCAT master */) |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1634 |
{ |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1635 |
if (!master->request_cb || !master->release_cb) { |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1636 |
EC_ERR("EoE requires master callbacks to be set!\n"); |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1637 |
return -1; |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1638 |
} |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1639 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1640 |
ec_master_eoe_start(master); |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1641 |
return 0; |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1642 |
} |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1643 |
|
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1644 |
/*****************************************************************************/ |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1645 |
|
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1646 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1647 |
Sets the debug level of the master. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1648 |
The following levels are valid: |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1649 |
- 1: only output positions marks and basic data |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1650 |
- 2: additional frame data output |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1651 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1652 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1653 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1654 |
void ecrt_master_debug(ec_master_t *master, /**< EtherCAT master */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1655 |
int level /**< debug level */ |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1656 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1657 |
{ |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1658 |
if (level != master->debug_level) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1659 |
master->debug_level = level; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1660 |
EC_INFO("Master debug level set to %i.\n", level); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1661 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1662 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1663 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1664 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1665 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1666 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1667 |
Outputs all master information. |
140
b09658e50d6f
Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
1668 |
Verbosity: |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1669 |
- 0: Only slave types and positions |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1670 |
- 1: with EEPROM contents |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1671 |
- >1: with SDO dictionaries |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1672 |
\ingroup RealtimeInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1673 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1674 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1675 |
void ecrt_master_print(const ec_master_t *master, /**< EtherCAT master */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1676 |
unsigned int verbosity /**< verbosity level */ |
140
b09658e50d6f
Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
1677 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1678 |
{ |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1679 |
ec_slave_t *slave; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1680 |
ec_eoe_t *eoe; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1681 |
|
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1682 |
EC_INFO("*** Begin master information ***\n"); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1683 |
if (master->slave_count) { |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1684 |
EC_INFO("Slave list:\n"); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1685 |
list_for_each_entry(slave, &master->slaves, list) |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
1686 |
ec_slave_print(slave, verbosity); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1687 |
} |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1688 |
if (!list_empty(&master->eoe_handlers)) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1689 |
EC_INFO("Ethernet-over-EtherCAT (EoE) objects:\n"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1690 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1691 |
ec_eoe_print(eoe); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1692 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
1693 |
} |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
82
diff
changeset
|
1694 |
EC_INFO("*** End master information ***\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1695 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1696 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1697 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1698 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1699 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1700 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1701 |
EXPORT_SYMBOL(ecrt_master_create_domain); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1702 |
EXPORT_SYMBOL(ecrt_master_activate); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1703 |
EXPORT_SYMBOL(ecrt_master_deactivate); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
1704 |
EXPORT_SYMBOL(ecrt_master_fetch_sdo_lists); |
109
c6766baead5e
Bugfix: EXPORT_SYMBOL f?r ec_master_prepare_async_io() vergessen.
Florian Pose <fp@igh-essen.com>
parents:
106
diff
changeset
|
1705 |
EXPORT_SYMBOL(ecrt_master_prepare_async_io); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1706 |
EXPORT_SYMBOL(ecrt_master_sync_io); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1707 |
EXPORT_SYMBOL(ecrt_master_async_send); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1708 |
EXPORT_SYMBOL(ecrt_master_async_receive); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
1709 |
EXPORT_SYMBOL(ecrt_master_run); |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1710 |
EXPORT_SYMBOL(ecrt_master_callbacks); |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1711 |
EXPORT_SYMBOL(ecrt_master_start_eoe); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1712 |
EXPORT_SYMBOL(ecrt_master_debug); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1713 |
EXPORT_SYMBOL(ecrt_master_print); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
1714 |
EXPORT_SYMBOL(ecrt_master_get_slave); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
39
diff
changeset
|
1715 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1716 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1717 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1718 |
/*****************************************************************************/ |