master/slave.c
author Florian Pose <fp@igh-essen.com>
Wed, 17 May 2006 09:28:43 +0000
changeset 242 1161d9e7a959
parent 238 b4960499098f
child 246 0bf7c769de06
permissions -rw-r--r--
Set permissions in install script.
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
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: 26
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
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    11
 *  as published by the Free Software Foundation; version 2 of the License.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    12
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    13
 *  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
    14
 *  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
    15
 *  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
    16
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    17
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    18
 *  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
    19
 *  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
    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
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    22
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    24
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    25
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    26
   EtherCAT slave methods.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    27
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    28
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    29
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    30
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    31
#include <linux/module.h>
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    32
#include <linux/delay.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    34
#include "globals.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    35
#include "slave.h"
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    36
#include "command.h"
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    37
#include "master.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    39
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    41
int ec_slave_fetch_categories(ec_slave_t *);
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    42
ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    43
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    44
/*****************************************************************************/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    45
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    46
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    47
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    48
EC_SYSFS_READ_ATTR(ring_position);
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
    49
EC_SYSFS_READ_ATTR(coupler_address);
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    50
EC_SYSFS_READ_ATTR(vendor_name);
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    51
EC_SYSFS_READ_ATTR(product_name);
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    52
EC_SYSFS_READ_ATTR(product_desc);
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    53
EC_SYSFS_READ_ATTR(sii_desc);
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    54
EC_SYSFS_READ_ATTR(type);
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    55
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    56
static struct attribute *def_attrs[] = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    57
    &attr_ring_position,
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
    58
    &attr_coupler_address,
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    59
    &attr_vendor_name,
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    60
    &attr_product_name,
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    61
    &attr_product_desc,
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    62
    &attr_sii_desc,
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    63
    &attr_type,
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    64
    NULL,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    65
};
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    66
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    67
static struct sysfs_ops sysfs_ops = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    68
    .show = &ec_show_slave_attribute,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    69
    .store = NULL
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    70
};
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    71
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    72
static struct kobj_type ktype_ec_slave = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    73
    .release = ec_slave_clear,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    74
    .sysfs_ops = &sysfs_ops,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    75
    .default_attrs = def_attrs
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    76
};
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    77
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    78
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    79
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    80
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    81
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    82
const ec_code_msg_t al_status_messages[];
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    83
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    84
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    85
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    87
   Slave constructor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    88
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    89
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    90
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    91
int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    92
                  ec_master_t *master, /**< EtherCAT master */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    93
                  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
    94
                  uint16_t station_address /**< station address to configure */
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    95
                  )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    96
{
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    97
    unsigned int i;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    98
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    99
    slave->ring_position = ring_position;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   100
    slave->station_address = station_address;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   101
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   102
    // init kobject and add it to the hierarchy
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   103
    memset(&slave->kobj, 0x00, sizeof(struct kobject));
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   104
    kobject_init(&slave->kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   105
    slave->kobj.ktype = &ktype_ec_slave;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   106
    slave->kobj.parent = &master->kobj;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   107
    if (kobject_set_name(&slave->kobj, "slave%03i", slave->ring_position)) {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   108
        EC_ERR("Failed to set kobject name.\n");
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   109
        kobject_put(&slave->kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   110
        return -1;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   111
    }
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   112
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   113
    slave->master = master;
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
   114
    slave->coupler_index = 0;
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
   115
    slave->coupler_subindex = 0xFFFF;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   116
    slave->base_type = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   117
    slave->base_revision = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   118
    slave->base_build = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   119
    slave->base_fmmu_count = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   120
    slave->base_sync_count = 0;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   121
    slave->sii_alias = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   122
    slave->sii_vendor_id = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   123
    slave->sii_product_code = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   124
    slave->sii_revision_number = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   125
    slave->sii_serial_number = 0;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   126
    slave->sii_rx_mailbox_offset = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   127
    slave->sii_rx_mailbox_size = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   128
    slave->sii_tx_mailbox_offset = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   129
    slave->sii_tx_mailbox_size = 0;
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: 132
diff changeset
   130
    slave->sii_mailbox_protocols = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   131
    slave->type = NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   132
    slave->registered = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   133
    slave->fmmu_count = 0;
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   134
    slave->eeprom_name = NULL;
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   135
    slave->eeprom_group = NULL;
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   136
    slave->eeprom_desc = NULL;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   137
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   138
    ec_command_init(&slave->mbox_command);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   139
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   140
    INIT_LIST_HEAD(&slave->eeprom_strings);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   141
    INIT_LIST_HEAD(&slave->eeprom_syncs);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   142
    INIT_LIST_HEAD(&slave->eeprom_pdos);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   143
    INIT_LIST_HEAD(&slave->sdo_dictionary);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   144
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   145
    for (i = 0; i < 4; i++) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   146
        slave->dl_link[i] = 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   147
        slave->dl_loop[i] = 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   148
        slave->dl_signal[i] = 0;
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   149
        slave->sii_physical_layer[i] = 0xFF;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   150
    }
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   151
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   152
    return 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   153
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   154
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   155
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   156
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   157
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   158
   Slave destructor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   159
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   160
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   161
void ec_slave_clear(struct kobject *kobj /**< kobject of the slave */)
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   162
{
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   163
    ec_slave_t *slave;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   164
    ec_eeprom_string_t *string, *next_str;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   165
    ec_eeprom_sync_t *sync, *next_sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   166
    ec_eeprom_pdo_t *pdo, *next_pdo;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   167
    ec_eeprom_pdo_entry_t *entry, *next_ent;
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   168
    ec_sdo_t *sdo, *next_sdo;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   169
    ec_sdo_entry_t *en, *next_en;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   170
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   171
    slave = container_of(kobj, ec_slave_t, kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   172
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   173
    // free all string objects
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   174
    list_for_each_entry_safe(string, next_str, &slave->eeprom_strings, list) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   175
        list_del(&string->list);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   176
        kfree(string);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   177
    }
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   178
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   179
    // free all sync managers
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   180
    list_for_each_entry_safe(sync, next_sync, &slave->eeprom_syncs, list) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   181
        list_del(&sync->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   182
        kfree(sync);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   183
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   184
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   185
    // free all PDOs
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   186
    list_for_each_entry_safe(pdo, next_pdo, &slave->eeprom_pdos, list) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   187
        list_del(&pdo->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   188
        if (pdo->name) kfree(pdo->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   189
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   190
        // free all PDO entries
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   191
        list_for_each_entry_safe(entry, next_ent, &pdo->entries, list) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   192
            list_del(&entry->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   193
            if (entry->name) kfree(entry->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   194
            kfree(entry);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   195
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   196
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   197
        kfree(pdo);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   198
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   199
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   200
    if (slave->eeprom_name) kfree(slave->eeprom_name);
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   201
    if (slave->eeprom_group) kfree(slave->eeprom_group);
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   202
    if (slave->eeprom_desc) kfree(slave->eeprom_desc);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   203
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   204
    // free all SDOs
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   205
    list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   206
        list_del(&sdo->list);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   207
        if (sdo->name) kfree(sdo->name);
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 160
diff changeset
   208
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   209
        // free all SDO entries
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   210
        list_for_each_entry_safe(en, next_en, &sdo->entries, list) {
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   211
            list_del(&en->list);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   212
            kfree(en);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   213
        }
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   214
        kfree(sdo);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   215
    }
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   216
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   217
    ec_command_clear(&slave->mbox_command);
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   218
}
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   219
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   220
/*****************************************************************************/
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   221
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   222
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   223
   Reads all necessary information from a slave.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   224
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   225
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   226
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   227
int ec_slave_fetch(ec_slave_t *slave /**< EtherCAT slave */)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   228
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   229
    ec_command_t *command;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   230
    unsigned int i;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   231
    uint16_t dl_status;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   232
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   233
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   234
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   235
    // read base data
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   236
    if (ec_command_nprd(command, slave->station_address, 0x0000, 6)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   237
    if (unlikely(ec_master_simple_io(slave->master, command))) {
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   238
        EC_ERR("Reading base data from slave %i failed!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   239
               slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   240
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   241
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   242
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   243
    slave->base_type =       EC_READ_U8 (command->data);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   244
    slave->base_revision =   EC_READ_U8 (command->data + 1);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   245
    slave->base_build =      EC_READ_U16(command->data + 2);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   246
    slave->base_fmmu_count = EC_READ_U8 (command->data + 4);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   247
    slave->base_sync_count = EC_READ_U8 (command->data + 5);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   248
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   249
    if (slave->base_fmmu_count > EC_MAX_FMMUS)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   250
        slave->base_fmmu_count = EC_MAX_FMMUS;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   251
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   252
    // read data link status
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   253
    if (ec_command_nprd(command, slave->station_address, 0x0110, 2)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   254
    if (unlikely(ec_master_simple_io(slave->master, command))) {
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   255
        EC_ERR("Reading DL status from slave %i failed!\n",
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   256
               slave->ring_position);
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   257
        return -1;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   258
    }
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   259
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   260
    dl_status = EC_READ_U16(command->data);
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   261
    for (i = 0; i < 4; i++) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   262
        slave->dl_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   263
        slave->dl_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   264
        slave->dl_signal[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   265
    }
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   266
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   267
    // read EEPROM data
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   268
    if (ec_slave_sii_read16(slave, 0x0004, &slave->sii_alias))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   269
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   270
    if (ec_slave_sii_read32(slave, 0x0008, &slave->sii_vendor_id))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   271
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   272
    if (ec_slave_sii_read32(slave, 0x000A, &slave->sii_product_code))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   273
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   274
    if (ec_slave_sii_read32(slave, 0x000C, &slave->sii_revision_number))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   275
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   276
    if (ec_slave_sii_read32(slave, 0x000E, &slave->sii_serial_number))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   277
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   278
    if (ec_slave_sii_read16(slave, 0x0018, &slave->sii_rx_mailbox_offset))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   279
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   280
    if (ec_slave_sii_read16(slave, 0x0019, &slave->sii_rx_mailbox_size))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   281
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   282
    if (ec_slave_sii_read16(slave, 0x001A, &slave->sii_tx_mailbox_offset))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   283
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   284
    if (ec_slave_sii_read16(slave, 0x001B, &slave->sii_tx_mailbox_size))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   285
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   286
    if (ec_slave_sii_read16(slave, 0x001C, &slave->sii_mailbox_protocols))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   287
        return -1;
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: 132
diff changeset
   288
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   289
    if (unlikely(ec_slave_fetch_categories(slave))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   290
        EC_ERR("Failed to fetch category data!\n");
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   291
        return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   292
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   293
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   294
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   295
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   296
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   297
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   298
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   299
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   300
   Reads 16 bit from the slave information interface (SII).
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   301
   \return 0 in case of success, else < 0
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   302
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   303
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   304
int ec_slave_sii_read16(ec_slave_t *slave,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   305
                        /**< EtherCAT slave */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   306
                        uint16_t offset,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   307
                        /**< address of the SII register to read */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   308
                        uint16_t *target
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   309
                        /**< target memory */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   310
                        )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   311
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   312
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   313
    cycles_t start, end, timeout;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   314
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   315
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   316
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   317
    // initiate read operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   318
    if (ec_command_npwr(command, slave->station_address, 0x502, 6)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   319
    EC_WRITE_U8 (command->data,     0x00); // read-only access
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   320
    EC_WRITE_U8 (command->data + 1, 0x01); // request read operation
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   321
    EC_WRITE_U32(command->data + 2, offset);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   322
    if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   323
        EC_ERR("SII-read failed on slave %i!\n", slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   324
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   325
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   326
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   327
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   328
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   329
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   330
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   331
    {
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   332
        udelay(10);
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   333
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   334
        if (ec_command_nprd(command, slave->station_address, 0x502, 10))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   335
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   336
        if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   337
            EC_ERR("Getting SII-read status failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   338
                   slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   339
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   340
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   341
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   342
        end = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   343
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   344
        // check for "busy bit"
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   345
        if (likely((EC_READ_U8(command->data + 1) & 0x81) == 0)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   346
            *target = EC_READ_U16(command->data + 6);
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   347
            return 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   348
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   349
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   350
        if (unlikely((end - start) >= timeout)) {
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   351
            EC_ERR("SII-read. Slave %i timed out!\n", slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   352
            return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   353
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   354
    }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   355
}
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   356
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   357
/*****************************************************************************/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   358
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   359
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   360
   Reads 32 bit from the slave information interface (SII).
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   361
   \return 0 in case of success, else < 0
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   362
*/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   363
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   364
int ec_slave_sii_read32(ec_slave_t *slave,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   365
                        /**< EtherCAT slave */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   366
                        uint16_t offset,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   367
                        /**< address of the SII register to read */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   368
                        uint32_t *target
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   369
                        /**< target memory */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   370
                        )
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   371
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   372
    ec_command_t *command;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   373
    cycles_t start, end, timeout;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   374
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   375
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   376
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   377
    // initiate read operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   378
    if (ec_command_npwr(command, slave->station_address, 0x502, 6)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   379
    EC_WRITE_U8 (command->data,     0x00); // read-only access
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   380
    EC_WRITE_U8 (command->data + 1, 0x01); // request read operation
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   381
    EC_WRITE_U32(command->data + 2, offset);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   382
    if (unlikely(ec_master_simple_io(slave->master, command))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   383
        EC_ERR("SII-read failed on slave %i!\n", slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   384
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   385
    }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   386
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   387
    start = get_cycles();
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   388
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   389
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   390
    while (1)
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   391
    {
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   392
        udelay(10);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   393
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   394
        if (ec_command_nprd(command, slave->station_address, 0x502, 10))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   395
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   396
        if (unlikely(ec_master_simple_io(slave->master, command))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   397
            EC_ERR("Getting SII-read status failed on slave %i!\n",
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   398
                   slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   399
            return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   400
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   401
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   402
        end = get_cycles();
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   403
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   404
        // check "busy bit"
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   405
        if (likely((EC_READ_U8(command->data + 1) & 0x81) == 0)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   406
            *target = EC_READ_U32(command->data + 6);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   407
            return 0;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   408
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   409
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   410
        if (unlikely((end - start) >= timeout)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   411
            EC_ERR("SII-read. Slave %i timed out!\n", slave->ring_position);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   412
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   413
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   414
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   415
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   416
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   417
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   418
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   419
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   420
   Writes 16 bit of data to the slave information interface (SII).
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   421
   \return 0 in case of success, else < 0
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   422
*/
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   423
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   424
int ec_slave_sii_write16(ec_slave_t *slave,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   425
                         /**< EtherCAT slave */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   426
                         uint16_t offset,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   427
                         /**< address of the SII register to write */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   428
                         uint16_t value
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   429
                         /**< new value */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   430
                         )
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   431
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   432
    ec_command_t *command;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   433
    cycles_t start, end, timeout;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   434
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   435
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   436
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   437
    EC_INFO("SII-write (slave %i, offset 0x%04X, value 0x%04X)\n",
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   438
            slave->ring_position, offset, value);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   439
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   440
    // initiate write operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   441
    if (ec_command_npwr(command, slave->station_address, 0x502, 8)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   442
    EC_WRITE_U8 (command->data,     0x01); // enable write access
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   443
    EC_WRITE_U8 (command->data + 1, 0x02); // request write operation
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   444
    EC_WRITE_U32(command->data + 2, offset);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   445
    EC_WRITE_U16(command->data + 6, value);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   446
    if (unlikely(ec_master_simple_io(slave->master, command))) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   447
        EC_ERR("SII-write failed on slave %i!\n", slave->ring_position);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   448
        return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   449
    }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   450
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   451
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   452
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   453
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   454
    while (1)
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   455
    {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   456
        udelay(10);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   457
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   458
        if (ec_command_nprd(command, slave->station_address, 0x502, 2))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   459
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   460
        if (unlikely(ec_master_simple_io(slave->master, command))) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   461
            EC_ERR("Getting SII-write status failed on slave %i!\n",
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   462
                   slave->ring_position);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   463
            return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   464
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   465
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   466
        end = get_cycles();
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   467
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   468
        // check "busy bit"
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   469
        if (likely((EC_READ_U8(command->data + 1) & 0x82) == 0)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   470
            if (EC_READ_U8(command->data + 1) & 0x40) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   471
                EC_ERR("SII-write failed!\n");
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   472
                return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   473
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   474
            else {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   475
                EC_INFO("SII-write succeeded!\n");
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   476
                return 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   477
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   478
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   479
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   480
        if (unlikely((end - start) >= timeout)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   481
            EC_ERR("SII-write: Slave %i timed out!\n", slave->ring_position);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   482
            return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   483
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   484
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   485
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   486
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   487
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   488
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   489
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   490
   Fetches data from slave's EEPROM.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   491
   \return 0 in case of success, else < 0
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
   492
   \todo memory allocation
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   493
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   494
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   495
int ec_slave_fetch_categories(ec_slave_t *slave /**< EtherCAT slave */)
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   496
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   497
    uint16_t word_offset, cat_type, word_count;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   498
    uint32_t value;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   499
    uint8_t *cat_data;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   500
    unsigned int i;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   501
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   502
    word_offset = 0x0040;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   503
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   504
    if (!(cat_data = (uint8_t *) kmalloc(0x10000, GFP_KERNEL))) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   505
        EC_ERR("Failed to allocate 64k bytes for category data.\n");
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   506
        return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   507
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   508
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   509
    while (1) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   510
        // read category type
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   511
        if (ec_slave_sii_read32(slave, word_offset, &value)) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   512
            EC_ERR("Unable to read category header.\n");
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   513
            goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   514
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   515
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   516
        // last category?
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   517
        if ((value & 0xFFFF) == 0xFFFF) break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   518
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   519
        cat_type = value & 0x7FFF;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   520
        word_count = (value >> 16) & 0xFFFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   521
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   522
        // fetch category data
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   523
        for (i = 0; i < word_count; i++) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   524
            if (ec_slave_sii_read32(slave, word_offset + 2 + i, &value)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   525
                EC_ERR("Unable to read category data word %i.\n", i);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   526
                goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   527
            }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   528
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   529
            cat_data[i * 2]     = (value >> 0) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   530
            cat_data[i * 2 + 1] = (value >> 8) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   531
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   532
            // read second word "on the fly"
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   533
            if (i + 1 < word_count) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   534
                i++;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   535
                cat_data[i * 2]     = (value >> 16) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   536
                cat_data[i * 2 + 1] = (value >> 24) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   537
            }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   538
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   539
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   540
        switch (cat_type)
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   541
        {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   542
            case 0x000A:
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   543
                if (ec_slave_fetch_strings(slave, cat_data))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   544
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   545
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   546
            case 0x001E:
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   547
                if (ec_slave_fetch_general(slave, cat_data))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   548
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   549
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   550
            case 0x0028:
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   551
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   552
            case 0x0029:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   553
                if (ec_slave_fetch_sync(slave, cat_data, word_count))
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   554
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   555
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   556
            case 0x0032:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   557
                if (ec_slave_fetch_pdo(slave, cat_data, word_count, EC_TX_PDO))
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   558
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   559
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   560
            case 0x0033:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   561
                if (ec_slave_fetch_pdo(slave, cat_data, word_count, EC_RX_PDO))
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   562
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   563
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   564
            default:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   565
                EC_WARN("Unknown category type 0x%04X in slave %i.\n",
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   566
                        cat_type, slave->ring_position);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   567
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   568
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   569
        word_offset += 2 + word_count;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   570
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   571
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   572
    kfree(cat_data);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   573
    return 0;
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   574
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   575
 out_free:
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   576
    kfree(cat_data);
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   577
    return -1;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   578
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   579
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   580
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   581
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   582
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   583
   Fetches data from a STRING category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   584
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   585
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   586
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   587
int ec_slave_fetch_strings(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   588
                           const uint8_t *data /**< category data */
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   589
                           )
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   590
{
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   591
    unsigned int string_count, i;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   592
    size_t size;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   593
    off_t offset;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   594
    ec_eeprom_string_t *string;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   595
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   596
    string_count = data[0];
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   597
    offset = 1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   598
    for (i = 0; i < string_count; i++) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   599
        size = data[offset];
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   600
        // allocate memory for string structure and data at a single blow
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   601
        if (!(string = (ec_eeprom_string_t *)
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   602
              kmalloc(sizeof(ec_eeprom_string_t) + size + 1, GFP_KERNEL))) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   603
            EC_ERR("Failed to allocate string memory.\n");
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   604
            return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   605
        }
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   606
        string->size = size;
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 160
diff changeset
   607
        // string memory appended to string structure
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   608
        string->data = (char *) string + sizeof(ec_eeprom_string_t);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   609
        memcpy(string->data, data + offset + 1, size);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   610
        string->data[size] = 0x00;
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   611
        list_add_tail(&string->list, &slave->eeprom_strings);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   612
        offset += 1 + size;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   613
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   614
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   615
    return 0;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   616
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   617
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   618
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   619
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   620
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   621
   Fetches data from a GENERAL category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   622
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   623
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   624
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   625
int ec_slave_fetch_general(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   626
                           const uint8_t *data /**< category data */
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   627
                           )
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   628
{
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   629
    unsigned int i;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   630
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   631
    if (ec_slave_locate_string(slave, data[0], &slave->eeprom_group))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   632
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   633
    if (ec_slave_locate_string(slave, data[1], &slave->eeprom_name))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   634
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   635
    if (ec_slave_locate_string(slave, data[3], &slave->eeprom_desc))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   636
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   637
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   638
    for (i = 0; i < 4; i++)
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   639
        slave->sii_physical_layer[i] =
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   640
            (data[4] & (0x03 << (i * 2))) >> (i * 2);
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   641
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   642
    return 0;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   643
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   644
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   645
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   646
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   647
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   648
   Fetches data from a SYNC MANAGER category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   649
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   650
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   651
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   652
int ec_slave_fetch_sync(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   653
                        const uint8_t *data, /**< category data */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   654
                        size_t word_count /**< number of words */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   655
                        )
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   656
{
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   657
    unsigned int sync_count, i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   658
    ec_eeprom_sync_t *sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   659
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   660
    sync_count = word_count / 4; // sync manager struct is 4 words long
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   661
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   662
    for (i = 0; i < sync_count; i++, data += 8) {
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   663
        if (!(sync = (ec_eeprom_sync_t *)
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   664
              kmalloc(sizeof(ec_eeprom_sync_t), GFP_KERNEL))) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   665
            EC_ERR("Failed to allocate Sync-Manager memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   666
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   667
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   668
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   669
        sync->index = i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   670
        sync->physical_start_address = *((uint16_t *) (data + 0));
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   671
        sync->length                 = *((uint16_t *) (data + 2));
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   672
        sync->control_register       = data[4];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   673
        sync->enable                 = data[6];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   674
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   675
        list_add_tail(&sync->list, &slave->eeprom_syncs);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   676
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   677
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   678
    return 0;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   679
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   680
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   681
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   682
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   683
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   684
   Fetches data from a [RT]XPDO category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   685
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   686
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   687
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   688
int ec_slave_fetch_pdo(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   689
                       const uint8_t *data, /**< category data */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   690
                       size_t word_count, /**< number of words */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   691
                       ec_pdo_type_t pdo_type /**< PDO type */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   692
                       )
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   693
{
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   694
    ec_eeprom_pdo_t *pdo;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   695
    ec_eeprom_pdo_entry_t *entry;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   696
    unsigned int entry_count, i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   697
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   698
    while (word_count >= 4) {
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   699
        if (!(pdo = (ec_eeprom_pdo_t *)
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   700
              kmalloc(sizeof(ec_eeprom_pdo_t), GFP_KERNEL))) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   701
            EC_ERR("Failed to allocate PDO memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   702
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   703
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   704
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   705
        INIT_LIST_HEAD(&pdo->entries);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   706
        pdo->type = pdo_type;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   707
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   708
        pdo->index = *((uint16_t *) data);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   709
        entry_count = data[2];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   710
        pdo->sync_manager = data[3];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   711
        pdo->name = NULL;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   712
        ec_slave_locate_string(slave, data[5], &pdo->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   713
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   714
        list_add_tail(&pdo->list, &slave->eeprom_pdos);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   715
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   716
        word_count -= 4;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   717
        data += 8;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   718
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   719
        for (i = 0; i < entry_count; i++) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   720
            if (!(entry = (ec_eeprom_pdo_entry_t *)
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   721
                  kmalloc(sizeof(ec_eeprom_pdo_entry_t), GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   722
                EC_ERR("Failed to allocate PDO entry memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   723
                return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   724
            }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   725
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   726
            entry->index = *((uint16_t *) data);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   727
            entry->subindex = data[2];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   728
            entry->name = NULL;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   729
            ec_slave_locate_string(slave, data[3], &entry->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   730
            entry->bit_length = data[5];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   731
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   732
            list_add_tail(&entry->list, &pdo->entries);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   733
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   734
            word_count -= 4;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   735
            data += 8;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   736
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   737
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   738
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   739
    return 0;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   740
}
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   741
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   742
/*****************************************************************************/
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   743
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   744
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   745
   Searches the string list for an index and allocates a new string.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   746
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   747
   \todo documentation
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   748
*/
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   749
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   750
int ec_slave_locate_string(ec_slave_t *slave, /**< EtherCAT slave */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   751
                           unsigned int index, /**< string index */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   752
                           char **ptr /**< Address of the string pointer */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   753
                           )
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   754
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   755
    ec_eeprom_string_t *string;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   756
    char *err_string;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   757
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   758
    // Erst alten Speicher freigeben
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   759
    if (*ptr) {
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   760
        kfree(*ptr);
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   761
        *ptr = NULL;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   762
    }
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   763
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   764
    // Index 0 bedeutet "nicht belegt"
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   765
    if (!index) return 0;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   766
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   767
    // EEPROM-String mit Index finden und kopieren
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   768
    list_for_each_entry(string, &slave->eeprom_strings, list) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   769
        if (--index) continue;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   770
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   771
        if (!(*ptr = (char *) kmalloc(string->size + 1, GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   772
            EC_ERR("Unable to allocate string memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   773
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   774
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   775
        memcpy(*ptr, string->data, string->size + 1);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   776
        return 0;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   777
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   778
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   779
    EC_WARN("String %i not found in slave %i.\n", index, slave->ring_position);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   780
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   781
    err_string = "(string not found)";
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   782
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   783
    if (!(*ptr = (char *) kmalloc(strlen(err_string) + 1, GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   784
        EC_ERR("Unable to allocate string memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   785
        return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   786
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   787
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   788
    memcpy(*ptr, err_string, strlen(err_string) + 1);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   789
    return 0;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   790
}
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   791
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   792
/*****************************************************************************/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   793
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   794
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   795
   Acknowledges an error after a state transition.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   796
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   797
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   798
void ec_slave_state_ack(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   799
                        uint8_t state /**< previous state */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   800
                        )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   801
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   802
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   803
    cycles_t start, end, timeout;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   804
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   805
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   806
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   807
    if (ec_command_npwr(command, slave->station_address, 0x0120, 2)) return;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   808
    EC_WRITE_U16(command->data, state | EC_ACK);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   809
    if (unlikely(ec_master_simple_io(slave->master, command))) {
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   810
        EC_WARN("Acknowledge sending failed on slave %i!\n",
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   811
                slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   812
        return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   813
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   814
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   815
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   816
    timeout = (cycles_t) 10 * cpu_khz; // 10ms
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   817
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   818
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   819
    {
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   820
        udelay(100); // wait a little bit...
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   821
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   822
        if (ec_command_nprd(command, slave->station_address, 0x0130, 2))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   823
            return;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   824
        if (unlikely(ec_master_simple_io(slave->master, command))) {
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   825
            EC_WARN("Acknowledge checking failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   826
                    slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   827
            return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   828
        }
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   829
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   830
        end = get_cycles();
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   831
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   832
        if (likely(EC_READ_U8(command->data) == state)) {
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   833
            EC_INFO("Acknowleged state 0x%02X on slave %i.\n", state,
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   834
                    slave->ring_position);
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   835
            return;
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   836
        }
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   837
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   838
        if (unlikely((end - start) >= timeout)) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   839
            EC_WARN("Failed to acknowledge state 0x%02X on slave %i"
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   840
                    " - Timeout!\n", state, slave->ring_position);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   841
            return;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   842
        }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   843
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   844
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   845
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   846
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   847
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   848
/**
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   849
   Reads the AL status code of a slave and displays it.
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   850
   If the AL status code is not supported, or if no error occurred (both
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   851
   resulting in code = 0), nothing is displayed.
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   852
*/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   853
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   854
void ec_slave_read_al_status_code(ec_slave_t *slave /**< EtherCAT slave */)
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   855
{
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   856
    ec_command_t *command;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   857
    uint16_t code;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   858
    const ec_code_msg_t *al_msg;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   859
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   860
    command = &slave->master->simple_command;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   861
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   862
    if (ec_command_nprd(command, slave->station_address, 0x0134, 2)) return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   863
    if (unlikely(ec_master_simple_io(slave->master, command))) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   864
        EC_WARN("Failed to read AL status code on slave %i!\n",
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   865
                slave->ring_position);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   866
        return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   867
    }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   868
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   869
    if (!(code = EC_READ_U16(command->data))) return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   870
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   871
    for (al_msg = al_status_messages; al_msg->code; al_msg++) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   872
        if (al_msg->code == code) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   873
            EC_ERR("AL status message 0x%04X: \"%s\".\n",
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   874
                   al_msg->code, al_msg->message);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   875
            return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   876
        }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   877
    }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   878
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   879
    EC_ERR("Unknown AL status code 0x%04X.\n", code);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   880
}
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   881
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   882
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   883
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   884
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   885
   Does a state transition.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   886
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   887
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   888
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   889
int ec_slave_state_change(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   890
                          uint8_t state /**< new state */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   891
                          )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   892
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   893
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   894
    cycles_t start, end, timeout;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   895
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   896
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   897
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   898
    if (ec_command_npwr(command, slave->station_address, 0x0120, 2)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   899
    EC_WRITE_U16(command->data, state);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   900
    if (unlikely(ec_master_simple_io(slave->master, command))) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   901
        EC_ERR("Failed to set state 0x%02X on slave %i!\n",
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   902
               state, slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   903
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   904
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   905
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   906
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   907
    timeout = (cycles_t) 10 * cpu_khz; // 10ms
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   908
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   909
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   910
    {
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   911
        udelay(100); // wait a little bit
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   912
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   913
        if (ec_command_nprd(command, slave->station_address, 0x0130, 2))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   914
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   915
        if (unlikely(ec_master_simple_io(slave->master, command))) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   916
            EC_ERR("Failed to check state 0x%02X on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   917
                   state, slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   918
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   919
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   920
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   921
        end = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   922
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   923
        if (unlikely(EC_READ_U8(command->data) & 0x10)) { // state change error
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   924
            EC_ERR("Failed to set state 0x%02X - Slave %i refused state change"
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   925
                   " (code 0x%02X)!\n", state, slave->ring_position,
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   926
                   EC_READ_U8(command->data));
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   927
            state = EC_READ_U8(command->data) & 0x0F;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   928
            ec_slave_read_al_status_code(slave);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   929
            ec_slave_state_ack(slave, state);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   930
            return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   931
        }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   932
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   933
        if (likely(EC_READ_U8(command->data) == (state & 0x0F)))
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   934
            return 0; // state change successful
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   935
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   936
        if (unlikely((end - start) >= timeout)) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   937
            EC_ERR("Failed to check state 0x%02X of slave %i - Timeout!\n",
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   938
                   state, slave->ring_position);
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   939
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   940
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   941
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   942
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   943
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   944
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   945
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   946
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   947
   Prepares an FMMU configuration.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   948
   Configuration data for the FMMU is saved in the slave structure and is
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   949
   written to the slave in ecrt_master_activate().
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   950
   The FMMU configuration is done in a way, that the complete data range
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   951
   of the corresponding sync manager is covered. Seperate FMMUs arce configured
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   952
   for each domain.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   953
   If the FMMU configuration is already prepared, the function returns with
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   954
   success.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   955
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   956
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   957
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   958
int ec_slave_prepare_fmmu(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   959
                          const ec_domain_t *domain, /**< domain */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   960
                          const ec_sync_t *sync  /**< sync manager */
160
7ddf8367196a Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
   961
                          )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   962
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   963
    unsigned int i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   964
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   965
    // FMMU configuration already prepared?
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   966
    for (i = 0; i < slave->fmmu_count; i++)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   967
        if (slave->fmmus[i].domain == domain && slave->fmmus[i].sync == sync)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   968
            return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   969
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   970
    // reserve new FMMU...
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   971
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   972
    if (slave->fmmu_count >= slave->base_fmmu_count) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   973
        EC_ERR("Slave %i FMMU limit reached!\n", slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   974
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   975
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   976
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   977
    slave->fmmus[slave->fmmu_count].domain = domain;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   978
    slave->fmmus[slave->fmmu_count].sync = sync;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   979
    slave->fmmus[slave->fmmu_count].logical_start_address = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   980
    slave->fmmu_count++;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   981
    slave->registered = 1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   982
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   983
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   984
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   985
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   986
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   987
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   988
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   989
   Outputs all information about a certain slave.
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   990
   Verbosity:
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   991
   - 0: Only slave types and addresses
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   992
   - 1: with EEPROM information
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   993
   - >1: with SDO dictionaries
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   994
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   995
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   996
void ec_slave_print(const ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   997
                    unsigned int verbosity /**< verbosity level */
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   998
                    )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   999
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
  1000
    ec_eeprom_sync_t *sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
  1001
    ec_eeprom_pdo_t *pdo;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1002
    ec_eeprom_pdo_entry_t *pdo_entry;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1003
    ec_sdo_t *sdo;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1004
    ec_sdo_entry_t *sdo_entry;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1005
    int first, i;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
  1006
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1007
    if (slave->type) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1008
        EC_INFO("%i) %s %s: %s\n", slave->ring_position,
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1009
                slave->type->vendor_name, slave->type->product_name,
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1010
                slave->type->description);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1011
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1012
    else {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1013
        EC_INFO("%i) UNKNOWN SLAVE: vendor 0x%08X, product 0x%08X\n",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1014
                slave->ring_position, slave->sii_vendor_id,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1015
                slave->sii_product_code);
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1016
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1017
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1018
    if (!verbosity) return;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1019
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1020
    EC_INFO("  Station address: 0x%04X\n", slave->station_address);
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1021
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1022
    EC_INFO("  Data link status:\n");
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1023
    for (i = 0; i < 4; i++) {
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1024
        EC_INFO("    Port %i (", i);
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1025
        switch (slave->sii_physical_layer[i]) {
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1026
            case 0x00:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1027
                printk("EBUS");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1028
                break;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1029
            case 0x01:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1030
                printk("100BASE-TX");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1031
                break;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1032
            case 0x02:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1033
                printk("100BASE-FX");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1034
                break;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1035
            default:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1036
                printk("unknown");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1037
        }
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1038
        printk(")\n");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1039
        EC_INFO("      link %s, loop %s, %s\n",
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1040
                slave->dl_link[i] ? "up" : "down",
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1041
                slave->dl_loop[i] ? "closed" : "open",
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1042
                slave->dl_signal[i] ? "signal detected" : "no signal");
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1043
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1044
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1045
    EC_INFO("  Base information:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1046
    EC_INFO("    Type %u, revision %i, build %i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1047
            slave->base_type, slave->base_revision, slave->base_build);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1048
    EC_INFO("    Supported FMMUs: %i, sync managers: %i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1049
            slave->base_fmmu_count, slave->base_sync_count);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1050
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1051
    if (slave->sii_mailbox_protocols) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1052
        EC_INFO("  Mailbox communication:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1053
        EC_INFO("    RX mailbox: 0x%04X/%i, TX mailbox: 0x%04X/%i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1054
                slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1055
                slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1056
        EC_INFO("    Supported protocols: ");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1057
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1058
        first = 1;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1059
        if (slave->sii_mailbox_protocols & EC_MBOX_AOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1060
            printk("AoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1061
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1062
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1063
        if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1064
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1065
            printk("EoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1066
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1067
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1068
        if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1069
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1070
            printk("CoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1071
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1072
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1073
        if (slave->sii_mailbox_protocols & EC_MBOX_FOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1074
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1075
            printk("FoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1076
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1077
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1078
        if (slave->sii_mailbox_protocols & EC_MBOX_SOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1079
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1080
            printk("SoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1081
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1082
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1083
        if (slave->sii_mailbox_protocols & EC_MBOX_VOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1084
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1085
            printk("VoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1086
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1087
        printk("\n");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1088
    }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1089
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1090
    EC_INFO("  EEPROM data:\n");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1091
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1092
    if (slave->sii_alias)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1093
        EC_INFO("    Configured station alias: 0x%04X (%i)\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1094
                slave->sii_alias, slave->sii_alias);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1095
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1096
    EC_INFO("    Vendor-ID: 0x%08X, Product code: 0x%08X\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1097
            slave->sii_vendor_id, slave->sii_product_code);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1098
    EC_INFO("    Revision number: 0x%08X, Serial number: 0x%08X\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1099
            slave->sii_revision_number, slave->sii_serial_number);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1100
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1101
    if (slave->eeprom_name)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1102
        EC_INFO("    Name: %s\n", slave->eeprom_name);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1103
    if (slave->eeprom_group)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1104
        EC_INFO("    Group: %s\n", slave->eeprom_group);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1105
    if (slave->eeprom_desc)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1106
        EC_INFO("    Description: %s\n", slave->eeprom_desc);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1107
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1108
    if (!list_empty(&slave->eeprom_syncs)) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1109
        EC_INFO("    Sync-Managers:\n");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1110
        list_for_each_entry(sync, &slave->eeprom_syncs, list) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1111
            EC_INFO("      %i: 0x%04X, length %i, control 0x%02X, %s\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1112
                    sync->index, sync->physical_start_address,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1113
                    sync->length, sync->control_register,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1114
                    sync->enable ? "enable" : "disable");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1115
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1116
    }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1117
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1118
    list_for_each_entry(pdo, &slave->eeprom_pdos, list) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1119
        EC_INFO("    %s \"%s\" (0x%04X), -> Sync-Manager %i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1120
                pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1121
                pdo->name ? pdo->name : "???",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1122
                pdo->index, pdo->sync_manager);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1123
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1124
        list_for_each_entry(pdo_entry, &pdo->entries, list) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1125
            EC_INFO("      \"%s\" 0x%04X:%X, %i Bit\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1126
                    pdo_entry->name ? pdo_entry->name : "???",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1127
                    pdo_entry->index, pdo_entry->subindex,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1128
                    pdo_entry->bit_length);
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1129
        }
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1130
    }
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1131
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1132
    if (verbosity < 2) return;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1133
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1134
    if (!list_empty(&slave->sdo_dictionary)) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1135
        EC_INFO("    SDO-Dictionary:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1136
        list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1137
            EC_INFO("      0x%04X \"%s\"\n", sdo->index,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1138
                    sdo->name ? sdo->name : "");
175
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
  1139
            EC_INFO("        Object code: 0x%02X\n", sdo->object_code);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1140
            list_for_each_entry(sdo_entry, &sdo->entries, list) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1141
                EC_INFO("        0x%04X:%i \"%s\", type 0x%04X, %i bits\n",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1142
                        sdo->index, sdo_entry->subindex,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1143
                        sdo_entry->name ? sdo_entry->name : "",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1144
                        sdo_entry->data_type, sdo_entry->bit_length);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1145
            }
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1146
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1147
    }
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1148
}
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1149
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1150
/*****************************************************************************/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1151
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1152
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1153
   Outputs the values of the CRC faoult counters and resets them.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1154
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1155
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1156
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1157
int ec_slave_check_crc(ec_slave_t *slave /**< EtherCAT slave */)
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1158
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1159
    ec_command_t *command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1160
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1161
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1162
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1163
    if (ec_command_nprd(command, slave->station_address, 0x0300, 4)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1164
    if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
  1165
        EC_WARN("Reading CRC fault counters failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1166
                slave->ring_position);
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1167
        return -1;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1168
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1169
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1170
    if (!EC_READ_U32(command->data)) return 0; // no CRC faults
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1171
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1172
    if (EC_READ_U8(command->data))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1173
        EC_WARN("%3i RX-error%s on slave %i, channel A.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1174
                EC_READ_U8(command->data),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1175
                EC_READ_U8(command->data) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1176
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1177
    if (EC_READ_U8(command->data + 1))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1178
        EC_WARN("%3i invalid frame%s on slave %i, channel A.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1179
                EC_READ_U8(command->data + 1),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1180
                EC_READ_U8(command->data + 1) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1181
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1182
    if (EC_READ_U8(command->data + 2))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1183
        EC_WARN("%3i RX-error%s on slave %i, channel B.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1184
                EC_READ_U8(command->data + 2),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1185
                EC_READ_U8(command->data + 2) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1186
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1187
    if (EC_READ_U8(command->data + 3))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1188
        EC_WARN("%3i invalid frame%s on slave %i, channel B.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1189
                EC_READ_U8(command->data + 3),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1190
                EC_READ_U8(command->data + 3) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1191
                slave->ring_position);
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1192
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1193
    // reset CRC counters
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1194
    if (ec_command_npwr(command, slave->station_address, 0x0300, 4)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1195
    EC_WRITE_U32(command->data, 0x00000000);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1196
    if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
  1197
        EC_WARN("Resetting CRC fault counters failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1198
                slave->ring_position);
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1199
        return -1;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1200
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1201
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1202
    return 0;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1203
}
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1204
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1205
/*****************************************************************************/
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1206
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: 132
diff changeset
  1207
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1208
   Formats attribute data for SysFS read access.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1209
   \return number of bytes to read
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1210
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1211
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1212
ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< slave's kobject */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1213
                                struct attribute *attr, /**< attribute */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1214
                                char *buffer /**< memory to store data */
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1215
                                )
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1216
{
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1217
    ec_slave_t *slave = container_of(kobj, ec_slave_t, kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1218
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1219
    if (attr == &attr_ring_position) {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1220
        return sprintf(buffer, "%i\n", slave->ring_position);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1221
    }
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
  1222
    else if (attr == &attr_coupler_address) {
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
  1223
        return sprintf(buffer, "%i:%i\n", slave->coupler_index,
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
  1224
                       slave->coupler_subindex);
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1225
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1226
    else if (attr == &attr_vendor_name) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1227
        if (slave->type)
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1228
            return sprintf(buffer, "%s\n", slave->type->vendor_name);
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1229
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1230
    else if (attr == &attr_product_name) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1231
        if (slave->type)
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1232
            return sprintf(buffer, "%s\n", slave->type->product_name);
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1233
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1234
    else if (attr == &attr_product_desc) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1235
        if (slave->type)
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1236
            return sprintf(buffer, "%s\n", slave->type->description);
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1237
    }
238
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
  1238
    else if (attr == &attr_sii_desc) {
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
  1239
        if (slave->eeprom_desc)
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
  1240
            return sprintf(buffer, "%s\n", slave->eeprom_desc);
b4960499098f Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
  1241
    }
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1242
    else if (attr == &attr_type) {
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1243
        if (slave->type) {
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1244
            if (slave->type->special == EC_TYPE_BUS_COUPLER)
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1245
                return sprintf(buffer, "coupler\n");
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1246
            else
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1247
                return sprintf(buffer, "normal\n");
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1248
        }
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1249
    }
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1250
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1251
    return 0;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1252
}
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1253
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1254
/*****************************************************************************/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1255
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1256
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1257
   Application layer status messages.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1258
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1259
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1260
const ec_code_msg_t al_status_messages[] = {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1261
    {0x0001, "Unspecified error"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1262
    {0x0011, "Invalud requested state change"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1263
    {0x0012, "Unknown requested state"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1264
    {0x0013, "Bootstrap not supported"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1265
    {0x0014, "No valid firmware"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1266
    {0x0015, "Invalid mailbox configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1267
    {0x0016, "Invalid mailbox configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1268
    {0x0017, "Invalid sync manager configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1269
    {0x0018, "No valid inputs available"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1270
    {0x0019, "No valid outputs"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1271
    {0x001A, "Synchronisation error"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1272
    {0x001B, "Sync manager watchdog"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1273
    {0x0020, "Slave needs cold start"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1274
    {0x0021, "Slave needs INIT"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1275
    {0x0022, "Slave needs PREOP"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1276
    {0x0023, "Slave needs SAVEOP"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1277
    {}
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1278
};
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1279
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1280
/******************************************************************************
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1281
 *  Realtime interface
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1282
 *****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1283
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1284
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1285
   Writes the "configured station alias" to the slave's EEPROM.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1286
   \return 0 in case of success, else < 0
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1287
   \ingroup RealtimeInterface
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1288
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1289
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1290
int ecrt_slave_write_alias(ec_slave_t *slave, /**< EtherCAT slave */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1291
                           uint16_t alias /**< new alias */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1292
                           )
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1293
{
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1294
    return ec_slave_sii_write16(slave, 0x0004, alias);
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1295
}
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1296
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1297
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1298
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1299
/**< \cond */
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1300
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1301
EXPORT_SYMBOL(ecrt_slave_write_alias);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1302
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1303
/**< \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1304
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
  1305
/*****************************************************************************/