23 * along with the IgH EtherCAT Master; if not, write to the Free Software |
19 * 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 |
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
25 * |
21 * |
26 *****************************************************************************/ |
22 *****************************************************************************/ |
27 |
23 |
|
24 /** |
|
25 \file |
|
26 EtherCAT domain methods. |
|
27 */ |
|
28 |
|
29 /*****************************************************************************/ |
|
30 |
28 #include "globals.h" |
31 #include "globals.h" |
29 #include "domain.h" |
32 #include "domain.h" |
30 #include "master.h" |
33 #include "master.h" |
31 |
34 |
32 /*****************************************************************************/ |
35 /*****************************************************************************/ |
33 |
36 |
34 void ec_domain_clear_field_regs(ec_domain_t *); |
37 void ec_domain_clear_field_regs(ec_domain_t *); |
35 ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *); |
38 ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *); |
36 |
39 |
37 /*****************************************************************************/ |
40 /*****************************************************************************/ |
|
41 |
|
42 /** \cond */ |
38 |
43 |
39 EC_SYSFS_READ_ATTR(data_size); |
44 EC_SYSFS_READ_ATTR(data_size); |
40 |
45 |
41 static struct attribute *def_attrs[] = { |
46 static struct attribute *def_attrs[] = { |
42 &attr_data_size, |
47 &attr_data_size, |
52 .release = ec_domain_clear, |
57 .release = ec_domain_clear, |
53 .sysfs_ops = &sysfs_ops, |
58 .sysfs_ops = &sysfs_ops, |
54 .default_attrs = def_attrs |
59 .default_attrs = def_attrs |
55 }; |
60 }; |
56 |
61 |
|
62 /** \endcond */ |
|
63 |
57 /*****************************************************************************/ |
64 /*****************************************************************************/ |
58 |
65 |
59 /** |
66 /** |
60 Domain constructor. |
67 Domain constructor. |
61 \return 0 in case of success, else < 0 |
68 \return 0 in case of success, else < 0 |
62 \ingroup Domain |
|
63 */ |
69 */ |
64 |
70 |
65 int ec_domain_init(ec_domain_t *domain, /**< EtherCAT domain */ |
71 int ec_domain_init(ec_domain_t *domain, /**< EtherCAT domain */ |
66 ec_master_t *master, /**< owning master */ |
72 ec_master_t *master, /**< owning master */ |
67 unsigned int index /**< domain index */ |
73 unsigned int index /**< domain index */ |
118 /*****************************************************************************/ |
123 /*****************************************************************************/ |
119 |
124 |
120 /** |
125 /** |
121 Registeres a data field in a domain. |
126 Registeres a data field in a domain. |
122 \return 0 in case of success, else < 0 |
127 \return 0 in case of success, else < 0 |
123 \ingroup Domain |
|
124 */ |
128 */ |
125 |
129 |
126 int ec_domain_reg_field(ec_domain_t *domain, /**< EtherCAT domain */ |
130 int ec_domain_reg_field(ec_domain_t *domain, /**< EtherCAT domain */ |
127 ec_slave_t *slave, /**< slave */ |
131 ec_slave_t *slave, /**< slave */ |
128 const ec_sync_t *sync, /**< sync manager */ |
132 const ec_sync_t *sync, /**< sync manager */ |
156 |
160 |
157 /*****************************************************************************/ |
161 /*****************************************************************************/ |
158 |
162 |
159 /** |
163 /** |
160 Clears the list of the registered data fields. |
164 Clears the list of the registered data fields. |
161 \ingroup Domain |
|
162 */ |
165 */ |
163 |
166 |
164 void ec_domain_clear_field_regs(ec_domain_t *domain /**< EtherCAT domain */) |
167 void ec_domain_clear_field_regs(ec_domain_t *domain /**< EtherCAT domain */) |
165 { |
168 { |
166 ec_field_reg_t *field_reg, *next; |
169 ec_field_reg_t *field_reg, *next; |
174 /*****************************************************************************/ |
177 /*****************************************************************************/ |
175 |
178 |
176 /** |
179 /** |
177 Allocates a process data command and appends it to the list. |
180 Allocates a process data command and appends it to the list. |
178 \return 0 in case of success, else < 0 |
181 \return 0 in case of success, else < 0 |
179 \ingroup Domain |
|
180 */ |
182 */ |
181 |
183 |
182 int ec_domain_add_command(ec_domain_t *domain, /**< EtherCAT domain */ |
184 int ec_domain_add_command(ec_domain_t *domain, /**< EtherCAT domain */ |
183 uint32_t offset, /**< logical offset */ |
185 uint32_t offset, /**< logical offset */ |
184 size_t data_size /**< size of the command data */ |
186 size_t data_size /**< size of the command data */ |
208 Creates a domain. |
210 Creates a domain. |
209 Reserves domain memory, calculates the logical addresses of the |
211 Reserves domain memory, calculates the logical addresses of the |
210 corresponding FMMUs and sets the process data pointer of the registered |
212 corresponding FMMUs and sets the process data pointer of the registered |
211 data fields. |
213 data fields. |
212 \return 0 in case of success, else < 0 |
214 \return 0 in case of success, else < 0 |
213 \ingroup Domain |
|
214 */ |
215 */ |
215 |
216 |
216 int ec_domain_alloc(ec_domain_t *domain, /**< EtherCAT domain */ |
217 int ec_domain_alloc(ec_domain_t *domain, /**< EtherCAT domain */ |
217 uint32_t base_address /**< Logische Basisadresse */ |
218 uint32_t base_address /**< Logische Basisadresse */ |
218 ) |
219 ) |
302 /** |
303 /** |
303 Sets the number of responding slaves and outputs it on demand. |
304 Sets the number of responding slaves and outputs it on demand. |
304 This number isn't really the number of responding slaves, but the sum of |
305 This number isn't really the number of responding slaves, but the sum of |
305 the working counters of all domain commands. Some slaves increase the |
306 the working counters of all domain commands. Some slaves increase the |
306 working counter by 2, some by 1. |
307 working counter by 2, some by 1. |
307 \ingroup Domain |
|
308 */ |
308 */ |
309 |
309 |
310 void ec_domain_response_count(ec_domain_t *domain, /**< EtherCAT domain */ |
310 void ec_domain_response_count(ec_domain_t *domain, /**< EtherCAT domain */ |
311 unsigned int count /**< new WC sum */ |
311 unsigned int count /**< new WC sum */ |
312 ) |
312 ) |
321 /*****************************************************************************/ |
321 /*****************************************************************************/ |
322 |
322 |
323 /** |
323 /** |
324 Formats attribute data for SysFS reading. |
324 Formats attribute data for SysFS reading. |
325 \return number of bytes to read |
325 \return number of bytes to read |
326 \ingroup Domain |
|
327 */ |
326 */ |
328 |
327 |
329 ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */ |
328 ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */ |
330 struct attribute *attr, /**< attribute */ |
329 struct attribute *attr, /**< attribute */ |
331 char *buffer /**< memory to store data in */ |
330 char *buffer /**< memory to store data in */ |
350 - If \a field_count is 0, it is assumed that one data field is to be |
349 - If \a field_count is 0, it is assumed that one data field is to be |
351 registered. |
350 registered. |
352 - If \a field_count is greater then 1, it is assumed that \a data_ptr |
351 - If \a field_count is greater then 1, it is assumed that \a data_ptr |
353 is an array of the respective size. |
352 is an array of the respective size. |
354 \return pointer to the slave on success, else NULL |
353 \return pointer to the slave on success, else NULL |
355 \ingroup Domain |
354 \ingroup RealtimeInterface |
356 */ |
355 */ |
357 |
356 |
358 ec_slave_t *ecrt_domain_register_field(ec_domain_t *domain, |
357 ec_slave_t *ecrt_domain_register_field(ec_domain_t *domain, |
359 /**< EtherCAT domain */ |
358 /**< EtherCAT domain */ |
360 const char *address, |
359 const char *address, |
442 |
441 |
443 /** |
442 /** |
444 Registeres a bunch of data fields. |
443 Registeres a bunch of data fields. |
445 Caution! The list has to be terminated with a NULL structure ({})! |
444 Caution! The list has to be terminated with a NULL structure ({})! |
446 \return 0 in case of success, else < 0 |
445 \return 0 in case of success, else < 0 |
447 \ingroup Domain |
446 \ingroup RealtimeInterface |
448 */ |
447 */ |
449 |
448 |
450 int ecrt_domain_register_field_list(ec_domain_t *domain, |
449 int ecrt_domain_register_field_list(ec_domain_t *domain, |
451 /**< EtherCAT domain */ |
450 /**< EtherCAT domain */ |
452 const ec_field_init_t *fields |
451 const ec_field_init_t *fields |
468 |
467 |
469 /*****************************************************************************/ |
468 /*****************************************************************************/ |
470 |
469 |
471 /** |
470 /** |
472 Places all process data commands in the masters command queue. |
471 Places all process data commands in the masters command queue. |
473 \ingroup Domain |
472 \ingroup RealtimeInterface |
474 */ |
473 */ |
475 |
474 |
476 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */) |
475 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */) |
477 { |
476 { |
478 ec_command_t *command; |
477 ec_command_t *command; |
484 |
483 |
485 /*****************************************************************************/ |
484 /*****************************************************************************/ |
486 |
485 |
487 /** |
486 /** |
488 Processes received process data. |
487 Processes received process data. |
489 \ingroup Domain |
488 \ingroup RealtimeInterface |
490 */ |
489 */ |
491 |
490 |
492 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) |
491 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) |
493 { |
492 { |
494 unsigned int working_counter_sum; |
493 unsigned int working_counter_sum; |
508 /*****************************************************************************/ |
507 /*****************************************************************************/ |
509 |
508 |
510 /** |
509 /** |
511 Returns the state of a domain. |
510 Returns the state of a domain. |
512 \return 0 if all commands were received, else -1. |
511 \return 0 if all commands were received, else -1. |
513 \ingroup Domain |
512 \ingroup RealtimeInterface |
514 */ |
513 */ |
515 |
514 |
516 int ecrt_domain_state(ec_domain_t *domain /**< EtherCAT domain */) |
515 int ecrt_domain_state(ec_domain_t *domain /**< EtherCAT domain */) |
517 { |
516 { |
518 ec_command_t *command; |
517 ec_command_t *command; |
523 |
522 |
524 return 0; |
523 return 0; |
525 } |
524 } |
526 |
525 |
527 /*****************************************************************************/ |
526 /*****************************************************************************/ |
|
527 |
|
528 /** \cond */ |
528 |
529 |
529 EXPORT_SYMBOL(ecrt_domain_register_field); |
530 EXPORT_SYMBOL(ecrt_domain_register_field); |
530 EXPORT_SYMBOL(ecrt_domain_register_field_list); |
531 EXPORT_SYMBOL(ecrt_domain_register_field_list); |
531 EXPORT_SYMBOL(ecrt_domain_queue); |
532 EXPORT_SYMBOL(ecrt_domain_queue); |
532 EXPORT_SYMBOL(ecrt_domain_process); |
533 EXPORT_SYMBOL(ecrt_domain_process); |
533 EXPORT_SYMBOL(ecrt_domain_state); |
534 EXPORT_SYMBOL(ecrt_domain_state); |
534 |
535 |
535 /*****************************************************************************/ |
536 /** \endcond */ |
|
537 |
|
538 /*****************************************************************************/ |