master/slave.h
author Florian Pose <fp@igh-essen.com>
Thu, 13 Mar 2008 12:42:48 +0000
changeset 868 aaf175ef0171
parent 847 92266462d411
child 870 fbd5924690ee
permissions -rw-r--r--
Added documentation.
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 5
diff changeset
     1
/******************************************************************************
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 5
diff changeset
     3
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     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: 238
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: 238
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: 238
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: 238
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: 238
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: 238
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: 238
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: 238
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: 238
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: 238
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 238
diff changeset
    31
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 5
diff changeset
    32
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
791
3b81d074735c Fixed typo.
Florian Pose <fp@igh-essen.com>
parents: 758
diff changeset
    36
   EtherCAT slave structure.
199
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
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#ifndef _EC_SLAVE_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#define _EC_SLAVE_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    44
#include <linux/list.h>
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    45
#include <linux/kobject.h>
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    46
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 298
diff changeset
    47
#include "../include/ecrt.h"
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 298
diff changeset
    48
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    49
#include "globals.h"
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 291
diff changeset
    50
#include "datagram.h"
627
4793ca94f082 Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents: 626
diff changeset
    51
#include "pdo.h"
628
e94a16bc52ce Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents: 627
diff changeset
    52
#include "sync.h"
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 836
diff changeset
    53
#include "sdo.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 5
diff changeset
    55
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
831
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    57
/** Slave state mask.
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    58
 *
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    59
 * Apply this mask to a slave state byte to get the slave state without
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    60
 * the error flag.
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    61
 */
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    62
#define EC_SLAVE_STATE_MASK 0x0F
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    63
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    64
/*****************************************************************************/
ded9519c8d6e Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    65
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    66
/** State of an EtherCAT slave.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
    67
 */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    68
typedef enum {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 123
diff changeset
    69
    EC_SLAVE_STATE_UNKNOWN = 0x00,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    70
    /**< unknown state */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 123
diff changeset
    71
    EC_SLAVE_STATE_INIT = 0x01,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    72
    /**< INIT state (no mailbox communication, no IO) */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 123
diff changeset
    73
    EC_SLAVE_STATE_PREOP = 0x02,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    74
    /**< PREOP state (mailbox communication, no IO) */
813
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    75
    EC_SLAVE_STATE_SAFEOP = 0x04,
bfc3f1ab52de Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    76
    /**< SAFEOP (mailbox communication and input update) */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 123
diff changeset
    77
    EC_SLAVE_STATE_OP = 0x08,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    78
    /**< OP (mailbox communication and input/output update) */
402
03e31ac14047 Renamed EC_ACK to EC_SLAVE_STATE_ACK_ERR
Florian Pose <fp@igh-essen.com>
parents: 401
diff changeset
    79
    EC_SLAVE_STATE_ACK_ERR = 0x10
406
e4f531d0d62d Fixed typo.
Florian Pose <fp@igh-essen.com>
parents: 404
diff changeset
    80
    /**< Acknowledge/Error bit (no actual state) */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    81
} ec_slave_state_t;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
    82
626
a5e838c30733 Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents: 625
diff changeset
    83
/*****************************************************************************/
a5e838c30733 Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents: 625
diff changeset
    84
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    85
/** EtherCAT slave online state.
626
a5e838c30733 Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents: 625
diff changeset
    86
 */
610
29489a43ecee Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents: 601
diff changeset
    87
typedef enum {
29489a43ecee Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents: 601
diff changeset
    88
    EC_SLAVE_OFFLINE,
29489a43ecee Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents: 601
diff changeset
    89
    EC_SLAVE_ONLINE
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    90
} ec_slave_online_state_t;
610
29489a43ecee Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents: 601
diff changeset
    91
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
    92
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
    93
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    94
/** Supported mailbox protocols.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
    95
 */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
    96
enum {
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    97
    EC_MBOX_AOE = 0x01, /**< ADS-over-EtherCAT */
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    98
    EC_MBOX_EOE = 0x02, /**< Ethernet-over-EtherCAT */
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    99
    EC_MBOX_COE = 0x04, /**< CANopen-over-EtherCAT */
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   100
    EC_MBOX_FOE = 0x08, /**< File-Access-over-EtherCAT */
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   101
    EC_MBOX_SOE = 0x10, /**< Servo-Profile-over-EtherCAT */
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   102
    EC_MBOX_VOE = 0x20  /**< Vendor specific */
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   103
};
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   104
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   105
/*****************************************************************************/
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   106
836
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   107
/** Slave information interface CANopen-over-EtherCAT details flags.
835
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   108
 */
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   109
typedef struct {
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   110
    uint8_t enable_sdo : 1; /**< Enable Sdo access. */
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   111
    uint8_t enable_sdo_info : 1; /**< SDO information service available. */
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   112
    uint8_t enable_pdo_assign : 1; /**< Pdo mapping configurable. */
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   113
    uint8_t enable_pdo_configuration : 1; /**< Pdo configuration possible. */
836
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   114
    uint8_t enable_upload_at_startup : 1; /**< ?. */
835
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   115
    uint8_t enable_sdo_complete_access : 1; /**< Complete access possible. */
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   116
} ec_sii_coe_details_t;
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   117
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   118
/*****************************************************************************/
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   119
836
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   120
/** Slave information interface general flags.
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   121
 */
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   122
typedef struct {
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   123
    uint8_t enable_safeop : 1; /**< ?. */
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   124
    uint8_t enable_not_lrw : 1; /**< Slave does not support LRW. */
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   125
} ec_sii_general_flags_t;
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   126
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   127
/*****************************************************************************/
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   128
834
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   129
/** Slave information interface data.
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   130
 */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   131
typedef struct {
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   132
    // Non-category data 
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   133
    uint16_t alias; /**< Configured station alias. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   134
    uint32_t vendor_id; /**< Vendor ID. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   135
    uint32_t product_code; /**< Vendor-specific product code. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   136
    uint32_t revision_number; /**< Revision number. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   137
    uint32_t serial_number; /**< Serial number. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   138
    uint16_t rx_mailbox_offset; /**< Mailbox address (master to slave). */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   139
    uint16_t rx_mailbox_size; /**< Mailbox size (master to slave). */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   140
    uint16_t tx_mailbox_offset; /**< Mailbox address (slave to master). */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   141
    uint16_t tx_mailbox_size; /**< Mailbox size (slave to master). */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   142
    uint16_t mailbox_protocols; /**< Supported mailbox protocols. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   143
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   144
    // Strings
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   145
    char **strings; /**< Strings in EEPROM categories. */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   146
    unsigned int string_count; /**< number of EEPROM strings */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   147
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   148
    // General
835
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   149
    unsigned int has_general; /**< General category present. */
834
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   150
    char *group; /**< slave group acc. to EEPROM */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   151
    char *image; /**< slave image name acc. to EEPROM */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   152
    char *order; /**< slave order number acc. to EEPROM */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   153
    char *name; /**< slave name acc. to EEPROM */
835
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   154
    uint8_t physical_layer[4]; /**< port media */
23fd8b510803 Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents: 834
diff changeset
   155
    ec_sii_coe_details_t coe_details; /**< CoE detail flags. */
836
860a5bacea6a Display notLRW flag.
Florian Pose <fp@igh-essen.com>
parents: 835
diff changeset
   156
    ec_sii_general_flags_t general_flags; /**< General flags. */
834
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   157
    int16_t current_on_ebus; /**< power consumption */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   158
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   159
    // SyncM
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   160
    ec_sync_t *syncs; /**< EEPROM SYNC MANAGER categories */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   161
    unsigned int sync_count; /**< number of sync managers in EEPROM */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   162
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   163
    // [RT]XPDO
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   164
    struct list_head pdos; /**< EEPROM [RT]XPDO categories */
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   165
} ec_sii_t;
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   166
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   167
/*****************************************************************************/
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   168
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   169
/** EtherCAT slave.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   170
 */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   171
struct ec_slave
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   172
{
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   173
    struct list_head list; /**< list item */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   174
    struct kobject kobj; /**< kobject */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   175
    ec_master_t *master; /**< master owning the slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   176
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   177
    // addresses
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   178
    uint16_t ring_position; /**< ring position */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   179
    uint16_t station_address; /**< configured station address */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   180
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   181
    // configuration
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   182
    ec_slave_config_t *config; /**< Current configuration. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   183
    ec_slave_state_t requested_state; /**< Requested application state. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   184
    ec_slave_state_t current_state; /**< Current application state. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   185
    ec_slave_online_state_t online_state; /**< online state */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   186
    unsigned int self_configured; /**< Slave was configured by this master. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   187
    unsigned int error_flag; /**< Stop processing after an error. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   188
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   189
    // base data
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   190
    uint8_t base_type; /**< slave type */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   191
    uint8_t base_revision; /**< revision */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   192
    uint16_t base_build; /**< build number */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   193
    uint16_t base_fmmu_count; /**< number of supported FMMUs */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   194
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   195
    // data link status
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   196
    uint8_t dl_link[4]; /**< link detected */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   197
    uint8_t dl_loop[4]; /**< loop closed */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   198
    uint8_t dl_signal[4]; /**< detected signal on RX port */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   199
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 298
diff changeset
   200
    // EEPROM
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 298
diff changeset
   201
    uint8_t *eeprom_data; /**< Complete EEPROM image */
601
d6d951b766e3 Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents: 556
diff changeset
   202
    size_t eeprom_size; /**< size of the EEPROM contents in bytes */
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 298
diff changeset
   203
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   204
    // slave information interface
834
0791aac03180 Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
   205
    ec_sii_t sii; /**< SII data. */
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   206
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   207
    struct kobject sdo_kobj; /**< kobject for Sdos */
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 813
diff changeset
   208
    struct list_head sdo_dictionary; /**< Sdo dictionary list */
419
cf724fc82a00 Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents: 416
diff changeset
   209
    uint8_t sdo_dictionary_fetched; /**< dictionary has been fetched */
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   210
    unsigned long jiffies_preop; /**< time, the slave went to PREOP */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   211
};
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   212
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   213
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   214
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   215
// slave construction/destruction
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   216
int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t);
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   217
void ec_slave_destroy(ec_slave_t *);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   218
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 423
diff changeset
   219
void ec_slave_request_state(ec_slave_t *, ec_slave_state_t);
610
29489a43ecee Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents: 601
diff changeset
   220
void ec_slave_set_state(ec_slave_t *, ec_slave_state_t);
29489a43ecee Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents: 601
diff changeset
   221
void ec_slave_set_online_state(ec_slave_t *, ec_slave_online_state_t);
446
8fede404c01f Persistent slave lists.
Florian Pose <fp@igh-essen.com>
parents: 423
diff changeset
   222
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 298
diff changeset
   223
// SII categories
742
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   224
int ec_slave_fetch_sii_strings(ec_slave_t *, const uint8_t *, size_t);
03d2fe3d4a93 Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents: 741
diff changeset
   225
int ec_slave_fetch_sii_general(ec_slave_t *, const uint8_t *, size_t);
620
4f76acbf54a0 Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents: 619
diff changeset
   226
int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t);
4f76acbf54a0 Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents: 619
diff changeset
   227
int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t,
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 791
diff changeset
   228
        ec_direction_t);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   229
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   230
// misc.
626
a5e838c30733 Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents: 625
diff changeset
   231
ec_sync_t *ec_slave_get_pdo_sync(ec_slave_t *, ec_direction_t); 
410
3b8e94d623ab Added ec_slave_validate()
Florian Pose <fp@igh-essen.com>
parents: 409
diff changeset
   232
int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t);
423
862ff892cf18 Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents: 421
diff changeset
   233
void ec_slave_sdo_dict_info(const ec_slave_t *,
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 630
diff changeset
   234
        unsigned int *, unsigned int *);
740
68d83b45dfa2 Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents: 643
diff changeset
   235
ec_sdo_t *ec_slave_get_sdo(ec_slave_t *, uint16_t);
799
068a58b96965 Pdo configuration.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   236
const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);
423
862ff892cf18 Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents: 421
diff changeset
   237
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 5
diff changeset
   238
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
#endif