equal
deleted
inserted
replaced
3 * d o m a i n . c |
3 * d o m a i n . c |
4 * |
4 * |
5 * EtherCAT domain methods. |
5 * EtherCAT domain methods. |
6 * |
6 * |
7 * $Id$ |
7 * $Id$ |
|
8 * |
|
9 * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
10 * |
|
11 * This file is part of the IgH EtherCAT Master. |
|
12 * |
|
13 * The IgH EtherCAT Master is free software; you can redistribute it |
|
14 * and/or modify it under the terms of the GNU General Public License |
|
15 * as published by the Free Software Foundation; version 2 of the License. |
|
16 * |
|
17 * The IgH EtherCAT Master is distributed in the hope that it will be |
|
18 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 * GNU General Public License for more details. |
|
21 * |
|
22 * You should have received a copy of the GNU General Public License |
|
23 * along with the IgH EtherCAT Master; if not, write to the Free Software |
|
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
8 * |
25 * |
9 *****************************************************************************/ |
26 *****************************************************************************/ |
10 |
27 |
11 #include "globals.h" |
28 #include "globals.h" |
12 #include "domain.h" |
29 #include "domain.h" |
40 /*****************************************************************************/ |
57 /*****************************************************************************/ |
41 |
58 |
42 /** |
59 /** |
43 Domain constructor. |
60 Domain constructor. |
44 \return 0 in case of success, else < 0 |
61 \return 0 in case of success, else < 0 |
|
62 \ingroup Domain |
45 */ |
63 */ |
46 |
64 |
47 int ec_domain_init(ec_domain_t *domain, /**< EtherCAT domain */ |
65 int ec_domain_init(ec_domain_t *domain, /**< EtherCAT domain */ |
48 ec_master_t *master, /**< owning master */ |
66 ec_master_t *master, /**< owning master */ |
49 unsigned int index /**< domain index */ |
67 unsigned int index /**< domain index */ |
73 |
91 |
74 /*****************************************************************************/ |
92 /*****************************************************************************/ |
75 |
93 |
76 /** |
94 /** |
77 Domain destructor. |
95 Domain destructor. |
|
96 \ingroup Domain |
78 */ |
97 */ |
79 |
98 |
80 void ec_domain_clear(struct kobject *kobj /**< kobject of the domain */) |
99 void ec_domain_clear(struct kobject *kobj /**< kobject of the domain */) |
81 { |
100 { |
82 ec_command_t *command, *next; |
101 ec_command_t *command, *next; |
99 /*****************************************************************************/ |
118 /*****************************************************************************/ |
100 |
119 |
101 /** |
120 /** |
102 Registeres a data field in a domain. |
121 Registeres a data field in a domain. |
103 \return 0 in case of success, else < 0 |
122 \return 0 in case of success, else < 0 |
|
123 \ingroup Domain |
104 */ |
124 */ |
105 |
125 |
106 int ec_domain_reg_field(ec_domain_t *domain, /**< EtherCAT domain */ |
126 int ec_domain_reg_field(ec_domain_t *domain, /**< EtherCAT domain */ |
107 ec_slave_t *slave, /**< slave */ |
127 ec_slave_t *slave, /**< slave */ |
108 const ec_sync_t *sync, /**< sync manager */ |
128 const ec_sync_t *sync, /**< sync manager */ |
136 |
156 |
137 /*****************************************************************************/ |
157 /*****************************************************************************/ |
138 |
158 |
139 /** |
159 /** |
140 Clears the list of the registered data fields. |
160 Clears the list of the registered data fields. |
|
161 \ingroup Domain |
141 */ |
162 */ |
142 |
163 |
143 void ec_domain_clear_field_regs(ec_domain_t *domain /**< EtherCAT domain */) |
164 void ec_domain_clear_field_regs(ec_domain_t *domain /**< EtherCAT domain */) |
144 { |
165 { |
145 ec_field_reg_t *field_reg, *next; |
166 ec_field_reg_t *field_reg, *next; |
153 /*****************************************************************************/ |
174 /*****************************************************************************/ |
154 |
175 |
155 /** |
176 /** |
156 Allocates a process data command and appends it to the list. |
177 Allocates a process data command and appends it to the list. |
157 \return 0 in case of success, else < 0 |
178 \return 0 in case of success, else < 0 |
|
179 \ingroup Domain |
158 */ |
180 */ |
159 |
181 |
160 int ec_domain_add_command(ec_domain_t *domain, /**< EtherCAT domain */ |
182 int ec_domain_add_command(ec_domain_t *domain, /**< EtherCAT domain */ |
161 uint32_t offset, /**< logical offset */ |
183 uint32_t offset, /**< logical offset */ |
162 size_t data_size /**< size of the command data */ |
184 size_t data_size /**< size of the command data */ |
186 Creates a domain. |
208 Creates a domain. |
187 Reserves domain memory, calculates the logical addresses of the |
209 Reserves domain memory, calculates the logical addresses of the |
188 corresponding FMMUs and sets the process data pointer of the registered |
210 corresponding FMMUs and sets the process data pointer of the registered |
189 data fields. |
211 data fields. |
190 \return 0 in case of success, else < 0 |
212 \return 0 in case of success, else < 0 |
|
213 \ingroup Domain |
191 */ |
214 */ |
192 |
215 |
193 int ec_domain_alloc(ec_domain_t *domain, /**< EtherCAT domain */ |
216 int ec_domain_alloc(ec_domain_t *domain, /**< EtherCAT domain */ |
194 uint32_t base_address /**< Logische Basisadresse */ |
217 uint32_t base_address /**< Logische Basisadresse */ |
195 ) |
218 ) |
279 /** |
302 /** |
280 Sets the number of responding slaves and outputs it on demand. |
303 Sets the number of responding slaves and outputs it on demand. |
281 This number isn't really the number of responding slaves, but the sum of |
304 This number isn't really the number of responding slaves, but the sum of |
282 the working counters of all domain commands. Some slaves increase the |
305 the working counters of all domain commands. Some slaves increase the |
283 working counter by 2, some by 1. |
306 working counter by 2, some by 1. |
|
307 \ingroup Domain |
284 */ |
308 */ |
285 |
309 |
286 void ec_domain_response_count(ec_domain_t *domain, /**< EtherCAT domain */ |
310 void ec_domain_response_count(ec_domain_t *domain, /**< EtherCAT domain */ |
287 unsigned int count /**< new WC sum */ |
311 unsigned int count /**< new WC sum */ |
288 ) |
312 ) |
297 /*****************************************************************************/ |
321 /*****************************************************************************/ |
298 |
322 |
299 /** |
323 /** |
300 Formats attribute data for SysFS reading. |
324 Formats attribute data for SysFS reading. |
301 \return number of bytes to read |
325 \return number of bytes to read |
|
326 \ingroup Domain |
302 */ |
327 */ |
303 |
328 |
304 ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */ |
329 ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */ |
305 struct attribute *attr, /**< attribute */ |
330 struct attribute *attr, /**< attribute */ |
306 char *buffer /**< memory to store data in */ |
331 char *buffer /**< memory to store data in */ |
325 - If \a field_count is 0, it is assumed that one data field is to be |
350 - If \a field_count is 0, it is assumed that one data field is to be |
326 registered. |
351 registered. |
327 - If \a field_count is greater then 1, it is assumed that \a data_ptr |
352 - If \a field_count is greater then 1, it is assumed that \a data_ptr |
328 is an array of the respective size. |
353 is an array of the respective size. |
329 \return pointer to the slave on success, else NULL |
354 \return pointer to the slave on success, else NULL |
|
355 \ingroup Domain |
330 */ |
356 */ |
331 |
357 |
332 ec_slave_t *ecrt_domain_register_field(ec_domain_t *domain, |
358 ec_slave_t *ecrt_domain_register_field(ec_domain_t *domain, |
333 /**< EtherCAT domain */ |
359 /**< EtherCAT domain */ |
334 const char *address, |
360 const char *address, |
416 |
442 |
417 /** |
443 /** |
418 Registeres a bunch of data fields. |
444 Registeres a bunch of data fields. |
419 Caution! The list has to be terminated with a NULL structure ({})! |
445 Caution! The list has to be terminated with a NULL structure ({})! |
420 \return 0 in case of success, else < 0 |
446 \return 0 in case of success, else < 0 |
|
447 \ingroup Domain |
421 */ |
448 */ |
422 |
449 |
423 int ecrt_domain_register_field_list(ec_domain_t *domain, |
450 int ecrt_domain_register_field_list(ec_domain_t *domain, |
424 /**< EtherCAT domain */ |
451 /**< EtherCAT domain */ |
425 const ec_field_init_t *fields |
452 const ec_field_init_t *fields |
441 |
468 |
442 /*****************************************************************************/ |
469 /*****************************************************************************/ |
443 |
470 |
444 /** |
471 /** |
445 Places all process data commands in the masters command queue. |
472 Places all process data commands in the masters command queue. |
|
473 \ingroup Domain |
446 */ |
474 */ |
447 |
475 |
448 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */) |
476 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */) |
449 { |
477 { |
450 ec_command_t *command; |
478 ec_command_t *command; |
456 |
484 |
457 /*****************************************************************************/ |
485 /*****************************************************************************/ |
458 |
486 |
459 /** |
487 /** |
460 Processes received process data. |
488 Processes received process data. |
|
489 \ingroup Domain |
461 */ |
490 */ |
462 |
491 |
463 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) |
492 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) |
464 { |
493 { |
465 unsigned int working_counter_sum; |
494 unsigned int working_counter_sum; |
479 /*****************************************************************************/ |
508 /*****************************************************************************/ |
480 |
509 |
481 /** |
510 /** |
482 Returns the state of a domain. |
511 Returns the state of a domain. |
483 \return 0 if all commands were received, else -1. |
512 \return 0 if all commands were received, else -1. |
|
513 \ingroup Domain |
484 */ |
514 */ |
485 |
515 |
486 int ecrt_domain_state(ec_domain_t *domain /**< EtherCAT domain */) |
516 int ecrt_domain_state(ec_domain_t *domain /**< EtherCAT domain */) |
487 { |
517 { |
488 ec_command_t *command; |
518 ec_command_t *command; |