master/domain.c
branchstable-1.0
changeset 1618 5cff10efb927
parent 195 674071846ee3
child 1619 0d4119024f55
equal deleted inserted replaced
1617:9f83a343ae75 1618:5cff10efb927
     1 /******************************************************************************
     1 /******************************************************************************
     2  *
     2  *
     3  *  d o m a i n . c
       
     4  *
       
     5  *  EtherCAT domain methods.
       
     6  *
       
     7  *  $Id$
     3  *  $Id$
     8  *
     4  *
       
     5  *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
       
     6  *
       
     7  *  This file is part of the IgH EtherCAT Master.
       
     8  *
       
     9  *  The IgH EtherCAT Master is free software; you can redistribute it
       
    10  *  and/or modify it under the terms of the GNU General Public License
       
    11  *  as published by the Free Software Foundation; version 2 of the License.
       
    12  *
       
    13  *  The IgH EtherCAT Master is distributed in the hope that it will be
       
    14  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16  *  GNU General Public License for more details.
       
    17  *
       
    18  *  You should have received a copy of the GNU General Public License
       
    19  *  along with the IgH EtherCAT Master; if not, write to the Free Software
       
    20  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    21  *
     9  *****************************************************************************/
    22  *****************************************************************************/
       
    23 
       
    24 /**
       
    25    \file
       
    26    EtherCAT domain methods.
       
    27 */
       
    28 
       
    29 /*****************************************************************************/
    10 
    30 
    11 #include "globals.h"
    31 #include "globals.h"
    12 #include "domain.h"
    32 #include "domain.h"
    13 #include "master.h"
    33 #include "master.h"
    14 
    34 
    16 
    36 
    17 void ec_domain_clear_field_regs(ec_domain_t *);
    37 void ec_domain_clear_field_regs(ec_domain_t *);
    18 ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *);
    38 ssize_t ec_show_domain_attribute(struct kobject *, struct attribute *, char *);
    19 
    39 
    20 /*****************************************************************************/
    40 /*****************************************************************************/
       
    41 
       
    42 /** \cond */
    21 
    43 
    22 EC_SYSFS_READ_ATTR(data_size);
    44 EC_SYSFS_READ_ATTR(data_size);
    23 
    45 
    24 static struct attribute *def_attrs[] = {
    46 static struct attribute *def_attrs[] = {
    25     &attr_data_size,
    47     &attr_data_size,
    34 static struct kobj_type ktype_ec_domain = {
    56 static struct kobj_type ktype_ec_domain = {
    35     .release = ec_domain_clear,
    57     .release = ec_domain_clear,
    36     .sysfs_ops = &sysfs_ops,
    58     .sysfs_ops = &sysfs_ops,
    37     .default_attrs = def_attrs
    59     .default_attrs = def_attrs
    38 };
    60 };
       
    61 
       
    62 /** \endcond */
    39 
    63 
    40 /*****************************************************************************/
    64 /*****************************************************************************/
    41 
    65 
    42 /**
    66 /**
    43    Domain constructor.
    67    Domain constructor.
   325    - 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
   326    registered.
   350    registered.
   327    - 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
   328    is an array of the respective size.
   352    is an array of the respective size.
   329    \return pointer to the slave on success, else NULL
   353    \return pointer to the slave on success, else NULL
       
   354    \ingroup RealtimeInterface
   330 */
   355 */
   331 
   356 
   332 ec_slave_t *ecrt_domain_register_field(ec_domain_t *domain,
   357 ec_slave_t *ecrt_domain_register_field(ec_domain_t *domain,
   333                                        /**< EtherCAT domain */
   358                                        /**< EtherCAT domain */
   334                                        const char *address,
   359                                        const char *address,
   416 
   441 
   417 /**
   442 /**
   418    Registeres a bunch of data fields.
   443    Registeres a bunch of data fields.
   419    Caution! The list has to be terminated with a NULL structure ({})!
   444    Caution! The list has to be terminated with a NULL structure ({})!
   420    \return 0 in case of success, else < 0
   445    \return 0 in case of success, else < 0
       
   446    \ingroup RealtimeInterface
   421 */
   447 */
   422 
   448 
   423 int ecrt_domain_register_field_list(ec_domain_t *domain,
   449 int ecrt_domain_register_field_list(ec_domain_t *domain,
   424                                     /**< EtherCAT domain */
   450                                     /**< EtherCAT domain */
   425                                     const ec_field_init_t *fields
   451                                     const ec_field_init_t *fields
   441 
   467 
   442 /*****************************************************************************/
   468 /*****************************************************************************/
   443 
   469 
   444 /**
   470 /**
   445    Places all process data commands in the masters command queue.
   471    Places all process data commands in the masters command queue.
       
   472    \ingroup RealtimeInterface
   446 */
   473 */
   447 
   474 
   448 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */)
   475 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */)
   449 {
   476 {
   450     ec_command_t *command;
   477     ec_command_t *command;
   456 
   483 
   457 /*****************************************************************************/
   484 /*****************************************************************************/
   458 
   485 
   459 /**
   486 /**
   460    Processes received process data.
   487    Processes received process data.
       
   488    \ingroup RealtimeInterface
   461 */
   489 */
   462 
   490 
   463 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */)
   491 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */)
   464 {
   492 {
   465     unsigned int working_counter_sum;
   493     unsigned int working_counter_sum;
   479 /*****************************************************************************/
   507 /*****************************************************************************/
   480 
   508 
   481 /**
   509 /**
   482    Returns the state of a domain.
   510    Returns the state of a domain.
   483    \return 0 if all commands were received, else -1.
   511    \return 0 if all commands were received, else -1.
       
   512    \ingroup RealtimeInterface
   484 */
   513 */
   485 
   514 
   486 int ecrt_domain_state(ec_domain_t *domain /**< EtherCAT domain */)
   515 int ecrt_domain_state(ec_domain_t *domain /**< EtherCAT domain */)
   487 {
   516 {
   488     ec_command_t *command;
   517     ec_command_t *command;
   493 
   522 
   494     return 0;
   523     return 0;
   495 }
   524 }
   496 
   525 
   497 /*****************************************************************************/
   526 /*****************************************************************************/
       
   527 
       
   528 /** \cond */
   498 
   529 
   499 EXPORT_SYMBOL(ecrt_domain_register_field);
   530 EXPORT_SYMBOL(ecrt_domain_register_field);
   500 EXPORT_SYMBOL(ecrt_domain_register_field_list);
   531 EXPORT_SYMBOL(ecrt_domain_register_field_list);
   501 EXPORT_SYMBOL(ecrt_domain_queue);
   532 EXPORT_SYMBOL(ecrt_domain_queue);
   502 EXPORT_SYMBOL(ecrt_domain_process);
   533 EXPORT_SYMBOL(ecrt_domain_process);
   503 EXPORT_SYMBOL(ecrt_domain_state);
   534 EXPORT_SYMBOL(ecrt_domain_state);
   504 
   535 
   505 /*****************************************************************************/
   536 /** \endcond */
       
   537 
       
   538 /*****************************************************************************/