master/domain.h
author Florian Pose <fp@igh-essen.com>
Thu, 06 Sep 2012 14:47:42 +0200
branchredundancy
changeset 2418 8cbb68315d29
parent 2368 dd84ef164869
child 2453 d461b1f07296
permissions -rw-r--r--
Fixed all mangled hg keywords.
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
197
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
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    11
 *  published by the Free Software Foundation.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    12
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    16
 *  Public License for more details.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    17
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 993
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  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
    21
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    27
 *
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    30
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    31
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    32
   EtherCAT domain structure.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    33
*/
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
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    36
883
4963e22a267a Equalized defines against duplicated header inclusion.
Florian Pose <fp@igh-essen.com>
parents: 818
diff changeset
    37
#ifndef __EC_DOMAIN_H__
4963e22a267a Equalized defines against duplicated header inclusion.
Florian Pose <fp@igh-essen.com>
parents: 818
diff changeset
    38
#define __EC_DOMAIN_H__
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
    40
#include <linux/list.h>
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
    41
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    42
#include "globals.h"
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
    43
#include "datagram.h"
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    44
#include "master.h"
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
    45
#include "fmmu_config.h"
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    49
/** EtherCAT domain.
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    50
 *
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    51
 * Handles the process data and the therefore needed datagrams of a certain
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    52
 * group of slaves.
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    53
 */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
    54
struct ec_domain
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
{
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    56
    struct list_head list; /**< List item. */
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    57
    ec_master_t *master; /**< EtherCAT master owning the domain. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    58
    unsigned int index; /**< Index (just a number). */
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    59
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    60
    struct list_head fmmu_configs; /**< FMMU configurations contained. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    61
    size_t data_size; /**< Size of the process data. */
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    62
    uint8_t *data; /**< Memory for the process data. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    63
    ec_origin_t data_origin; /**< Origin of the \a data memory. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    64
    uint32_t logical_base_address; /**< Logical offset address of the
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    65
                                     process data. */
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    66
    struct list_head datagram_pairs; /**< Datagrams pairs (main/backup) for
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    67
                                       process data exchange. */
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    68
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2269
diff changeset
    69
    uint16_t working_counter[EC_NUM_DEVICES]; /**< Last working counter
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2269
diff changeset
    70
                                                values. */
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    71
    uint16_t expected_working_counter; /**< Expected working counter. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    72
    unsigned int working_counter_changes; /**< Working counter changes
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    73
                                             since last notification. */
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2269
diff changeset
    74
    unsigned int redundancy_active; /**< Non-zero, if redundancy is in use. */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    75
    unsigned long notify_jiffies; /**< Time of last notification. */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
    76
};
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    80
void ec_domain_init(ec_domain_t *, ec_master_t *, unsigned int);
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    81
void ec_domain_clear(ec_domain_t *);
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 404
diff changeset
    82
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
    83
void ec_domain_add_fmmu_config(ec_domain_t *, ec_fmmu_config_t *);
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 495
diff changeset
    84
int ec_domain_finish(ec_domain_t *, uint32_t);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
    86
unsigned int ec_domain_fmmu_count(const ec_domain_t *);
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
    87
const ec_fmmu_config_t *ec_domain_find_fmmu(const ec_domain_t *, unsigned int);
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
    88
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
#endif