master/master.c
author Florian Pose <fp@igh-essen.com>
Tue, 11 Apr 2006 09:08:10 +0000
changeset 181 3e9155836bc7
parent 179 fb4c9dd11ca0
child 182 8c0bc99229a9
permissions -rw-r--r--
Install script for realtime software
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 35
diff changeset
     1
/******************************************************************************
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
     3
 *  m a s t e r . c
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Methoden für einen EtherCAT-Master.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 35
diff changeset
     7
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 35
diff changeset
     9
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    11
#include <linux/module.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
#include <linux/kernel.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#include <linux/string.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#include <linux/slab.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
#include <linux/delay.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
    17
#include "../include/ecrt.h"
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    18
#include "globals.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    19
#include "master.h"
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
    20
#include "slave.h"
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
    21
#include "types.h"
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    22
#include "device.h"
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    23
#include "command.h"
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    24
#include "ethernet.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 35
diff changeset
    26
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
179
fb4c9dd11ca0 Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    28
ssize_t ec_show_master_attribute(struct kobject *, struct attribute *, char *);
fb4c9dd11ca0 Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    29
fb4c9dd11ca0 Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    30
/*****************************************************************************/
fb4c9dd11ca0 Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    31
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    32
static struct attribute attr_slave_count = {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    33
    .name = "slave_count",
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    34
    .owner = THIS_MODULE,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    35
    .mode = S_IRUGO
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    36
};
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    37
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    38
static struct attribute *ec_def_attrs[] = {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    39
    &attr_slave_count,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    40
    NULL,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    41
};
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    42
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    43
static struct sysfs_ops ec_sysfs_ops = {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    44
    .show = &ec_show_master_attribute,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    45
    .store = NULL
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    46
};
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    47
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    48
static struct kobj_type ktype_ec_master = {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    49
    .release = ec_master_clear,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    50
    .sysfs_ops = &ec_sysfs_ops,
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    51
    .default_attrs = ec_def_attrs
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    52
};
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    53
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    54
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    55
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
   Konstruktor des EtherCAT-Masters.
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
    58
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
    59
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    60
int ec_master_init(ec_master_t *master, /**< EtherCAT-Master */
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    61
                   unsigned int index /**< Master-Index */
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    62
                   )
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    63
{
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    64
    EC_INFO("Initializing master %i.\n", index);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    65
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    66
    master->index = index;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    67
    master->slaves = NULL;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    68
    master->device = NULL;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    69
    master->reserved = 0;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    70
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    71
    INIT_LIST_HEAD(&master->command_queue);
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
    72
    INIT_LIST_HEAD(&master->domains);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    73
    INIT_LIST_HEAD(&master->eoe_slaves);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    74
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    75
    // Init kobject and add it to the hierarchy
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    76
    memset(&master->kobj, 0x00, sizeof(struct kobject));
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    77
    kobject_init(&master->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    78
    master->kobj.ktype = &ktype_ec_master;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    79
    if (kobject_set_name(&master->kobj, "ethercat%i", index)) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    80
        EC_ERR("Failed to set kobj name.\n");
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    81
        kobject_put(&master->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    82
        return -1;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    83
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    84
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    85
    ec_command_init(&master->simple_command);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    86
    ec_command_init(&master->watch_command);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    87
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    88
    ec_master_reset(master);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
    89
    return 0;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 35
diff changeset
    92
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
   Destruktor eines EtherCAT-Masters.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
   Entfernt alle Kommandos aus der Liste, löscht den Zeiger
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
   auf das Slave-Array und gibt die Prozessdaten frei.
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
    99
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   100
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   101
void ec_master_clear(struct kobject *kobj /**< KObject des Masters */)
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   102
{
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   103
    ec_master_t *master = container_of(kobj, ec_master_t, kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   104
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   105
    EC_INFO("Clearing master %i...\n", master->index);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   106
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   107
    ec_master_reset(master);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   108
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   109
    if (master->device) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   110
        ec_device_clear(master->device);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   111
        kfree(master->device);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   112
    }
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   113
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   114
    ec_command_clear(&master->simple_command);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   115
    ec_command_clear(&master->watch_command);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   116
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   117
    EC_INFO("Master %i cleared.\n", master->index);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   118
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   119
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   120
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   121
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   122
/**
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   123
   Setzt den Master zurück in den Ausgangszustand.
56
36d1fa37f5e1 Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   124
36d1fa37f5e1 Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   125
   Bei einem "release" sollte immer diese Funktion aufgerufen werden,
36d1fa37f5e1 Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   126
   da sonst Slave-Liste, Domains, etc. weiter existieren.
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   127
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   128
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   129
void ec_master_reset(ec_master_t *master
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   130
                     /**< Zeiger auf den zurückzusetzenden Master */
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   131
                     )
56
36d1fa37f5e1 Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   132
{
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   133
    unsigned int i;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   134
    ec_command_t *command, *next_c;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   135
    ec_domain_t *domain, *next_d;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   136
    ec_eoe_t *eoe, *next_eoe;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   137
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   138
    // Alle Slaves entfernen
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   139
    if (master->slaves) {
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   140
        for (i = 0; i < master->slave_count; i++)
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   141
            ec_slave_clear(master->slaves + i);
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   142
        kfree(master->slaves);
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   143
        master->slaves = NULL;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   144
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   145
    master->slave_count = 0;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   146
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   147
    // Kommando-Warteschlange leeren
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   148
    list_for_each_entry_safe(command, next_c, &master->command_queue, queue) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   149
        command->state = EC_CMD_ERROR;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   150
        list_del_init(&command->queue);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   151
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   152
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   153
    // Domain-Liste leeren
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   154
    list_for_each_entry_safe(domain, next_d, &master->domains, list) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   155
        list_del(&domain->list);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   156
        kobject_del(&domain->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   157
        kobject_put(&domain->kobj);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   158
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   159
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   160
    // EOE-Liste leeren
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   161
    list_for_each_entry_safe(eoe, next_eoe, &master->eoe_slaves, list) {
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   162
        list_del(&eoe->list);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   163
        ec_eoe_clear(eoe);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   164
        kfree(eoe);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   165
    }
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   166
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   167
    master->command_index = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   168
    master->debug_level = 0;
155
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   169
    master->timeout = 500; // 500us
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   170
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   171
    master->slaves_responding = 0;
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   172
    master->slave_states = EC_SLAVE_STATE_UNKNOWN;
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   173
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   174
    master->stats.timeouts = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   175
    master->stats.delayed = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   176
    master->stats.corrupted = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   177
    master->stats.unmatched = 0;
173
10e182a8bc4e Fixed bug concerning spuriously shown EoE-Errors.
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
   178
    master->stats.eoe_errors = 0;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   179
    master->stats.t_last = 0;
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   180
}
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   181
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   182
/*****************************************************************************/
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   183
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   184
/**
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   185
   Stellt ein Kommando in die Warteschlange.
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   186
*/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   187
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   188
void ec_master_queue_command(ec_master_t *master, /**< EtherCAT-Master */
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   189
                             ec_command_t *command /**< Kommando */
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   190
                             )
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   191
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   192
    ec_command_t *queued_command;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   193
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   194
    // Ist das Kommando schon in der Warteschlange?
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   195
    list_for_each_entry(queued_command, &master->command_queue, queue) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   196
        if (queued_command == command) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   197
            command->state = EC_CMD_QUEUED;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   198
            if (unlikely(master->debug_level))
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   199
                EC_WARN("command already queued.\n");
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   200
            return;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   201
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   202
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   203
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   204
    list_add_tail(&command->queue, &master->command_queue);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   205
    command->state = EC_CMD_QUEUED;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   206
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   207
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   208
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   209
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   210
/**
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   211
   Sendet die Kommandos in der Warteschlange.
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   212
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   213
   \return 0 bei Erfolg, sonst < 0
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   214
*/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   215
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   216
void ec_master_send_commands(ec_master_t *master /**< EtherCAT-Master */)
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   217
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   218
    ec_command_t *command;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   219
    size_t command_size;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   220
    uint8_t *frame_data, *cur_data;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   221
    void *follows_word;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   222
    cycles_t start = 0, end;
176
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   223
    unsigned int frame_count, more_commands_waiting;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   224
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   225
    frame_count = 0;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   226
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   227
    if (unlikely(master->debug_level > 0)) {
176
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   228
        EC_DBG("ec_master_send_commands\n");
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   229
        start = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   230
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   231
176
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   232
    do {
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   233
        // Zeiger auf Socket-Buffer holen
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   234
        frame_data = ec_device_tx_data(master->device);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   235
        cur_data = frame_data + EC_FRAME_HEADER_SIZE;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   236
        follows_word = NULL;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   237
        more_commands_waiting = 0;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   238
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   239
        // Aktuellen Frame mit Kommandos füllen
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   240
        list_for_each_entry(command, &master->command_queue, queue) {
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   241
            if (command->state != EC_CMD_QUEUED) continue;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   242
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   243
            // Passt das aktuelle Kommando noch in den aktuellen Rahmen?
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   244
            command_size = EC_COMMAND_HEADER_SIZE + command->data_size
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   245
                + EC_COMMAND_FOOTER_SIZE;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   246
            if (cur_data - frame_data + command_size > EC_MAX_FRAME_SIZE) {
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   247
                more_commands_waiting = 1;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   248
                break;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   249
            }
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   250
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   251
            command->state = EC_CMD_SENT;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   252
            command->index = master->command_index++;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   253
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   254
            if (unlikely(master->debug_level > 0))
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   255
                EC_DBG("adding command 0x%02X\n", command->index);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   256
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   257
            // Command-Following-Flag im letzten Kommando setzen
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   258
            if (follows_word)
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   259
                EC_WRITE_U16(follows_word, EC_READ_U16(follows_word) | 0x8000);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   260
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   261
            // EtherCAT command header
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   262
            EC_WRITE_U8 (cur_data,     command->type);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   263
            EC_WRITE_U8 (cur_data + 1, command->index);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   264
            EC_WRITE_U32(cur_data + 2, command->address.logical);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   265
            EC_WRITE_U16(cur_data + 6, command->data_size & 0x7FF);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   266
            EC_WRITE_U16(cur_data + 8, 0x0000);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   267
            follows_word = cur_data + 6;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   268
            cur_data += EC_COMMAND_HEADER_SIZE;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   269
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   270
            // EtherCAT command data
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   271
            memcpy(cur_data, command->data, command->data_size);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   272
            cur_data += command->data_size;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   273
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   274
            // EtherCAT command footer
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   275
            EC_WRITE_U16(cur_data, 0x0000); // Working counter
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   276
            cur_data += EC_COMMAND_FOOTER_SIZE;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   277
        }
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   278
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   279
        if (cur_data - frame_data == EC_FRAME_HEADER_SIZE) {
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   280
            if (unlikely(master->debug_level > 0))
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   281
                EC_DBG("nothing to send.\n");
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   282
            break;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   283
        }
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   284
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   285
        // EtherCAT frame header
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   286
        EC_WRITE_U16(frame_data, ((cur_data - frame_data
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   287
                                   - EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   288
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   289
        // Rahmen auffüllen
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   290
        while (cur_data - frame_data < EC_MIN_FRAME_SIZE)
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   291
            EC_WRITE_U8(cur_data++, 0x00);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   292
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   293
        if (unlikely(master->debug_level > 0))
176
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   294
            EC_DBG("frame size: %i\n", cur_data - frame_data);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   295
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   296
        // Send frame
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   297
        ec_device_send(master->device, cur_data - frame_data);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   298
        frame_count++;
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   299
    }
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   300
    while (more_commands_waiting);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   301
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   302
    if (unlikely(master->debug_level > 0)) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   303
        end = get_cycles();
176
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   304
        EC_DBG("ec_master_send_commands sent %i frames in %ius.\n",
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   305
               frame_count, (u32) (end - start) * 1000 / cpu_khz);
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   306
    }
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   307
}
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   308
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   309
/*****************************************************************************/
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   310
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   311
/**
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   312
   Processes a received frame.
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   313
1ac0fc378b95 Sending of multiple frames
Florian Pose <fp@igh-essen.com>
parents: 173
diff changeset
   314
   This function is called by the network driver for every received frame.
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   315
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   316
   \return 0 bei Erfolg, sonst < 0
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   317
*/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   318
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   319
void ec_master_receive(ec_master_t *master, /**< EtherCAT-Master */
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   320
                      const uint8_t *frame_data, /**< Empfangene Daten */
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   321
                      size_t size /**< Anzahl empfangene Datenbytes */
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   322
                      )
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   323
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   324
    size_t frame_size, data_size;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   325
    uint8_t command_type, command_index;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   326
    unsigned int cmd_follows, matched;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   327
    const uint8_t *cur_data;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   328
    ec_command_t *command;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   329
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   330
    if (unlikely(size < EC_FRAME_HEADER_SIZE)) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   331
        master->stats.corrupted++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   332
        ec_master_output_stats(master);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   333
        return;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   334
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   335
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   336
    cur_data = frame_data;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   337
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   338
    // Länge des gesamten Frames prüfen
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   339
    frame_size = EC_READ_U16(cur_data) & 0x07FF;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   340
    cur_data += EC_FRAME_HEADER_SIZE;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   341
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   342
    if (unlikely(frame_size > size)) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   343
        master->stats.corrupted++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   344
        ec_master_output_stats(master);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   345
        return;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   346
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   347
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   348
    cmd_follows = 1;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   349
    while (cmd_follows) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   350
        // Kommando-Header auswerten
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   351
        command_type  = EC_READ_U8 (cur_data);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   352
        command_index = EC_READ_U8 (cur_data + 1);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   353
        data_size     = EC_READ_U16(cur_data + 6) & 0x07FF;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   354
        cmd_follows   = EC_READ_U16(cur_data + 6) & 0x8000;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   355
        cur_data += EC_COMMAND_HEADER_SIZE;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   356
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   357
        if (unlikely(cur_data - frame_data
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   358
                     + data_size + EC_COMMAND_FOOTER_SIZE > size)) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   359
            master->stats.corrupted++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   360
            ec_master_output_stats(master);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   361
            return;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   362
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   363
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   364
        // Suche passendes Kommando in der Liste
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   365
        matched = 0;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   366
        list_for_each_entry(command, &master->command_queue, queue) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   367
            if (command->state == EC_CMD_SENT
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   368
                && command->type == command_type
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   369
                && command->index == command_index
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   370
                && command->data_size == data_size) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   371
                matched = 1;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   372
                break;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   373
            }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   374
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   375
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   376
        // Kein passendes Kommando in der Liste gefunden
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   377
        if (!matched) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   378
            master->stats.unmatched++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   379
            ec_master_output_stats(master);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   380
            cur_data += data_size + EC_COMMAND_FOOTER_SIZE;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   381
            continue;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   382
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   383
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   384
        // Empfangene Daten in Kommando-Datenspeicher kopieren
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   385
        memcpy(command->data, cur_data, data_size);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   386
        cur_data += data_size;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   387
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   388
        // Working-Counter setzen
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   389
        command->working_counter = EC_READ_U16(cur_data);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   390
        cur_data += EC_COMMAND_FOOTER_SIZE;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   391
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   392
        // Kommando aus der Warteschlange entfernen
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   393
        command->state = EC_CMD_RECEIVED;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   394
        list_del_init(&command->queue);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   395
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   396
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   397
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   398
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   399
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   400
/**
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   401
   Sendet ein einzelnes Kommando und wartet auf den Empfang.
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   402
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   403
   Wenn der Slave nicht antwortet, wird das Kommando
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   404
   nochmals gesendet.
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   405
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   406
   \return 0 bei Erfolg, sonst < 0
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   407
*/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   408
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   409
int ec_master_simple_io(ec_master_t *master, /**< EtherCAT-Master */
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   410
                        ec_command_t *command /**< Kommando */
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   411
                        )
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   412
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   413
    unsigned int response_tries_left;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   414
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   415
    response_tries_left = 10;
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   416
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   417
    while (1)
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   418
    {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   419
        ec_master_queue_command(master, command);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   420
        ecrt_master_sync_io(master);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   421
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   422
        if (command->state == EC_CMD_RECEIVED) {
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   423
            if (likely(command->working_counter))
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   424
                return 0;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   425
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   426
        else if (command->state == EC_CMD_TIMEOUT) {
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   427
            EC_ERR("Simple-IO TIMEOUT!\n");
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   428
            return -1;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   429
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   430
        else if (command->state == EC_CMD_ERROR) {
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   431
            EC_ERR("Simple-IO command error!\n");
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   432
            return -1;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   433
        }
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   434
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   435
        // Keine direkte Antwort. Dem Slave Zeit lassen...
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   436
        udelay(100);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   437
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   438
        if (unlikely(--response_tries_left)) {
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   439
            EC_ERR("No response in simple-IO!\n");
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   440
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   441
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   442
    }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   443
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   444
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   445
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   446
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   447
/**
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   448
   Durchsucht den EtherCAT-Bus nach Slaves.
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   449
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   450
   Erstellt ein Array mit allen Slave-Informationen die für den
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   451
   weiteren Betrieb notwendig sind.
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   452
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   453
   \return 0 bei Erfolg, sonst < 0
17
1b5aea4d5147 Code zum Senden/Empfangen mehrerer Kommandos in einem Frame vorerst ganz entfernt.
Florian Pose <fp@igh-essen.com>
parents: 15
diff changeset
   454
*/
1b5aea4d5147 Code zum Senden/Empfangen mehrerer Kommandos in einem Frame vorerst ganz entfernt.
Florian Pose <fp@igh-essen.com>
parents: 15
diff changeset
   455
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   456
int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   457
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   458
    ec_slave_t *slave;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   459
    ec_slave_ident_t *ident;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   460
    unsigned int i;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   461
    ec_command_t *command;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   462
    ec_eoe_t *eoe;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   463
90
044e97bce4bd Rahmen jetzt zustandslos.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   464
    if (master->slaves || master->slave_count) {
044e97bce4bd Rahmen jetzt zustandslos.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   465
        EC_ERR("Slave scan already done!\n");
044e97bce4bd Rahmen jetzt zustandslos.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   466
        return -1;
044e97bce4bd Rahmen jetzt zustandslos.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   467
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   468
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   469
    command = &master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   470
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   471
    // Determine number of slaves on bus
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   472
    if (ec_command_brd(command, 0x0000, 4)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   473
    if (unlikely(ec_master_simple_io(master, command))) return -1;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   474
    master->slave_count = command->working_counter;
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   475
    EC_INFO("Found %i slaves on bus.\n", master->slave_count);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   476
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   477
    if (!master->slave_count) return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   478
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   479
    if (!(master->slaves = (ec_slave_t *)
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   480
          kmalloc(master->slave_count * sizeof(ec_slave_t), GFP_KERNEL))) {
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   481
        EC_ERR("Failed to allocate slaves!\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   482
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   483
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   484
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   485
    // Init slaves
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   486
    for (i = 0; i < master->slave_count; i++) {
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   487
        slave = master->slaves + i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   488
        ec_slave_init(slave, master);
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   489
        slave->ring_position = i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   490
        slave->station_address = i + 1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   491
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   492
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   493
    // For every slave on the bus
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   494
    for (i = 0; i < master->slave_count; i++) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   495
        slave = master->slaves + i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   496
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   497
        // Write station address
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   498
        if (ec_command_apwr(command, slave->ring_position,
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   499
                            0x0010, sizeof(uint16_t))) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   500
        EC_WRITE_U16(command->data, slave->station_address);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   501
        if (unlikely(ec_master_simple_io(master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   502
            EC_ERR("Writing station address failed on slave %i!\n", i);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   503
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   504
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   505
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   506
        // Fetch all slave information
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   507
        if (ec_slave_fetch(slave)) return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   508
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   509
        // Search for identification in "database"
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   510
        ident = slave_idents;
129
67b6e534db4b Bugfix: Absturz bei unbekannter Klemme.
Florian Pose <fp@igh-essen.com>
parents: 120
diff changeset
   511
        while (ident->type) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   512
            if (unlikely(ident->vendor_id == slave->sii_vendor_id
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   513
                         && ident->product_code == slave->sii_product_code)) {
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   514
                slave->type = ident->type;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   515
                break;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   516
            }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   517
            ident++;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   518
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   519
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   520
        if (!slave->type)
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   521
            EC_WARN("Unknown slave device (vendor 0x%08X, code 0x%08X) at"
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   522
                    " position %i.\n", slave->sii_vendor_id,
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   523
                    slave->sii_product_code, i);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   524
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   525
        // Does the slave support EoE?
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   526
        if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   527
            if (!(eoe = (ec_eoe_t *) kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) {
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   528
                EC_ERR("Failed to allocate EoE-Object.\n");
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   529
                return -1;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   530
            }
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   531
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   532
            ec_eoe_init(eoe, slave);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   533
            list_add_tail(&eoe->list, &master->eoe_slaves);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   534
        }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   535
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   536
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   537
    return 0;
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   538
}
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   539
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   540
/*****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   541
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   542
/**
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   543
   Statistik-Ausgaben während des zyklischen Betriebs.
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   544
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   545
   Diese Funktion sorgt dafür, dass Statistiken während des zyklischen
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   546
   Betriebs bei Bedarf, aber nicht zu oft ausgegeben werden.
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   547
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   548
   Die Ausgabe erfolgt gesammelt höchstens einmal pro Sekunde.
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   549
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   550
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   551
void ec_master_output_stats(ec_master_t *master /**< EtherCAT-Master */)
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   552
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   553
    cycles_t t_now = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   554
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   555
    if (unlikely((u32) (t_now - master->stats.t_last) / cpu_khz > 1000)) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   556
        if (master->stats.timeouts) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   557
            EC_WARN("%i commands TIMED OUT!\n", master->stats.timeouts);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   558
            master->stats.timeouts = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   559
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   560
        if (master->stats.delayed) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   561
            EC_WARN("%i frame(s) DELAYED!\n", master->stats.delayed);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   562
            master->stats.delayed = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   563
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   564
        if (master->stats.corrupted) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   565
            EC_WARN("%i frame(s) CORRUPTED!\n", master->stats.corrupted);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   566
            master->stats.corrupted = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   567
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   568
        if (master->stats.unmatched) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   569
            EC_WARN("%i command(s) UNMATCHED!\n", master->stats.unmatched);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   570
            master->stats.unmatched = 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   571
        }
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   572
        if (master->stats.eoe_errors) {
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   573
            EC_WARN("%i EOE ERROR(S)!\n", master->stats.eoe_errors);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   574
            master->stats.eoe_errors = 0;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   575
        }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   576
        master->stats.t_last = t_now;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   577
    }
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   578
}
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   579
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   580
/*****************************************************************************/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   581
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   582
/**
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   583
   Wandelt eine ASCII-kodierte Bus-Adresse in einen Slave-Zeiger.
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   584
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   585
   Gültige Adress-Strings sind Folgende:
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   586
   - \a "X" = der X. Slave im Bus,
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   587
   - \a "X:Y" = der Y. Slave hinter dem X. Buskoppler,
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   588
   - \a "#X" = der Slave mit dem Alias X,
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   589
   - \a "#X:Y" = der Y. Slave hinter dem Buskoppler mit dem Alias X.
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   590
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   591
   X und Y fangen immer bei 0 an und können auch hexadezimal oder oktal
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   592
   angegeben werden (mit entsprechendem Prefix).
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   593
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   594
   \return Zeiger auf Slave bei Erfolg, sonst NULL
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   595
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   596
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
   597
ec_slave_t *ecrt_master_get_slave(const ec_master_t *master, /**< Master */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
   598
                                  const char *address /**< Address-String */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
   599
                                  )
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   600
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   601
    unsigned long first, second;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   602
    char *remainder, *remainder2;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   603
    unsigned int i, alias_requested, alias_slave_index, alias_found;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   604
    int coupler_idx, slave_idx;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   605
    ec_slave_t *slave;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   606
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   607
    if (!address || address[0] == 0) return NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   608
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   609
    alias_requested = 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   610
    alias_slave_index = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   611
    if (address[0] == '#') {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   612
        alias_requested = 1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   613
        address++;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   614
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   615
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   616
    first = simple_strtoul(address, &remainder, 0);
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   617
    if (remainder == address) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   618
        EC_ERR("Slave address \"%s\" - First number empty!\n", address);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   619
        return NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   620
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   621
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   622
    if (alias_requested) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   623
        alias_found = 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   624
        for (i = 0; i < master->slave_count; i++) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   625
            if (master->slaves[i].sii_alias == first) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   626
                alias_slave_index = i;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   627
                alias_found = 1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   628
                break;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   629
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   630
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   631
        if (!alias_found) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   632
            EC_ERR("Slave address \"%s\" - Alias not found!\n", address);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   633
            return NULL;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   634
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   635
    }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   636
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   637
    if (!remainder[0]) { // absolute position
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   638
        if (alias_requested) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   639
            return master->slaves + alias_slave_index;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   640
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   641
        else {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   642
            if (first < master->slave_count) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   643
                return master->slaves + first;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   644
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   645
            EC_ERR("Slave address \"%s\" - Absolute position invalid!\n",
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   646
                   address);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   647
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   648
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   649
    else if (remainder[0] == ':') { // field position
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   650
        remainder++;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   651
        second = simple_strtoul(remainder, &remainder2, 0);
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   652
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   653
        if (remainder2 == remainder) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   654
            EC_ERR("Slave address \"%s\" - Second number empty!\n", address);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   655
            return NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   656
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   657
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   658
        if (remainder2[0]) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   659
            EC_ERR("Slave address \"%s\" - Invalid trailer!\n", address);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   660
            return NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   661
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   662
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   663
        if (alias_requested) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   664
            for (i = alias_slave_index + 1; i < master->slave_count; i++) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   665
                slave = master->slaves + i;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   666
                if (!slave->type ||
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   667
                    slave->type->special == EC_TYPE_BUS_COUPLER) break;
116
231b22fc034b Slave-Alias korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   668
                if (i - alias_slave_index == second) return slave;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   669
            }
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   670
            EC_ERR("Slave address \"%s\" - Bus coupler %i has no %lu. slave"
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   671
                   " following!\n", address,
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   672
                   (master->slaves + alias_slave_index)->ring_position,
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   673
                   second);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   674
            return NULL;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   675
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   676
        else {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   677
            coupler_idx = -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   678
            slave_idx = 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   679
            for (i = 0; i < master->slave_count; i++, slave_idx++) {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   680
                slave = master->slaves + i;
116
231b22fc034b Slave-Alias korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   681
                if (!slave->type) continue;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   682
                if (slave->type->special == EC_TYPE_BUS_COUPLER) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   683
                    coupler_idx++;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   684
                    slave_idx = 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   685
                }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   686
                if (coupler_idx == first && slave_idx == second) return slave;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   687
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   688
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   689
    }
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   690
    else
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   691
        EC_ERR("Slave address \"%s\" - Invalid format!\n", address);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   692
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   693
    return NULL;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   694
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   695
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   696
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   697
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   698
/**
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   699
   Initialisiert eine Sync-Manager-Konfigurationsseite.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   700
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   701
   Der mit \a data referenzierte Speicher muss mindestens EC_SYNC_SIZE Bytes
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   702
   groß sein.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   703
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   704
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   705
void ec_sync_config(const ec_sync_t *sync, /**< Sync-Manager */
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   706
                    uint8_t *data /**> Zeiger auf Konfigurationsspeicher */
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   707
                    )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   708
{
77
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   709
    EC_WRITE_U16(data,     sync->physical_start_address);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   710
    EC_WRITE_U16(data + 2, sync->size);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   711
    EC_WRITE_U8 (data + 4, sync->control_byte);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   712
    EC_WRITE_U8 (data + 5, 0x00); // status byte (read only)
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   713
    EC_WRITE_U16(data + 6, 0x0001); // enable
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   714
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   715
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   716
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   717
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   718
/**
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   719
   Initialisiert eine Sync-Manager-Konfigurationsseite mit EEPROM-Daten.
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   720
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   721
   Der mit \a data referenzierte Speicher muss mindestens EC_SYNC_SIZE Bytes
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   722
   groß sein.
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   723
*/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   724
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   725
void ec_eeprom_sync_config(const ec_eeprom_sync_t *sync, /**< Sync-Manager */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   726
                           uint8_t *data /**> Zeiger auf Konfig.-Speicher */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   727
                           )
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   728
{
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   729
    EC_WRITE_U16(data,     sync->physical_start_address);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   730
    EC_WRITE_U16(data + 2, sync->length);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   731
    EC_WRITE_U8 (data + 4, sync->control_register);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   732
    EC_WRITE_U8 (data + 5, 0x00); // status byte (read only)
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   733
    EC_WRITE_U16(data + 6, sync->enable ? 0x0001 : 0x0000); // enable
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   734
}
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   735
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   736
/*****************************************************************************/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   737
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   738
/**
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   739
   Initialisiert eine FMMU-Konfigurationsseite.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   740
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   741
   Der mit \a data referenzierte Speicher muss mindestens EC_FMMU_SIZE Bytes
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   742
   groß sein.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   743
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   744
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   745
void ec_fmmu_config(const ec_fmmu_t *fmmu, /**< Sync-Manager */
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   746
                    uint8_t *data /**> Zeiger auf Konfigurationsspeicher */
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   747
                    )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   748
{
77
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   749
    EC_WRITE_U32(data,      fmmu->logical_start_address);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   750
    EC_WRITE_U16(data + 4,  fmmu->sync->size);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   751
    EC_WRITE_U8 (data + 6,  0x00); // Logical start bit
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   752
    EC_WRITE_U8 (data + 7,  0x07); // Logical end bit
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   753
    EC_WRITE_U16(data + 8,  fmmu->sync->physical_start_address);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   754
    EC_WRITE_U8 (data + 10, 0x00); // Physical start bit
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   755
    EC_WRITE_U8 (data + 11, (fmmu->sync->control_byte & 0x04) ? 0x02 : 0x01);
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   756
    EC_WRITE_U16(data + 12, 0x0001); // Enable
677967864795 EC_READ/WRITE-Makros verwenden Makros aud asm/byteorder.h und werden konsequent verwendet.
Florian Pose <fp@igh-essen.com>
parents: 74
diff changeset
   757
    EC_WRITE_U16(data + 14, 0x0000); // res.
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   758
}
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   759
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   760
/*****************************************************************************/
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   761
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   762
/**
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   763
   Formatiert Attribut-Daten für lesenden Zugriff im SysFS
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   764
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   765
   \return Anzahl Bytes im Speicher
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   766
*/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   767
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   768
ssize_t ec_show_master_attribute(struct kobject *kobj, /**< KObject */
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   769
                                 struct attribute *attr, /**< Attribut */
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   770
                                 char *buffer /**< Speicher für die Daten */
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   771
                                 )
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   772
{
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   773
    ec_master_t *master = container_of(kobj, ec_master_t, kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   774
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   775
    if (attr == &attr_slave_count) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   776
        return sprintf(buffer, "%i\n", master->slave_count);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   777
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   778
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   779
    return 0;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   780
}
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   781
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   782
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   783
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   784
/**
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   785
   Gibt Überwachungsinformationen aus.
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   786
*/
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   787
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   788
void ec_master_process_watch_command(ec_master_t *master
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   789
                                     /**< EtherCAT-Master */
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   790
                                     )
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   791
{
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   792
    unsigned int first;
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   793
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   794
    if (unlikely(master->watch_command.state == EC_CMD_INIT)) return;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   795
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   796
    first = 1;
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   797
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   798
    if (master->watch_command.working_counter != master->slaves_responding ||
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   799
        master->watch_command.data[0] != master->slave_states)
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   800
    {
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   801
        master->slaves_responding = master->watch_command.working_counter;
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   802
        master->slave_states = master->watch_command.data[0];
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   803
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   804
        EC_INFO("%i slave%s responding (", master->slaves_responding,
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   805
                master->slaves_responding == 1 ? "" : "s");
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   806
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   807
        if (master->slave_states & EC_SLAVE_STATE_INIT) {
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   808
            printk("INIT");
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   809
            first = 0;
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   810
        }
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   811
        if (master->slave_states & EC_SLAVE_STATE_PREOP) {
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: 130
diff changeset
   812
            if (!first) printk(", ");
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   813
            printk("PREOP");
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: 130
diff changeset
   814
            first = 0;
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   815
        }
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   816
        if (master->slave_states & EC_SLAVE_STATE_SAVEOP) {
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: 130
diff changeset
   817
            if (!first) printk(", ");
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   818
            printk("SAVEOP");
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: 130
diff changeset
   819
            first = 0;
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   820
        }
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   821
        if (master->slave_states & EC_SLAVE_STATE_OP) {
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: 130
diff changeset
   822
            if (!first) printk(", ");
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   823
            printk("OP");
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   824
        }
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   825
        printk(")\n");
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   826
    }
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   827
}
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
   828
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   829
/******************************************************************************
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   830
 *
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   831
 * Echtzeitschnittstelle
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   832
 *
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   833
 *****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   834
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   835
/**
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   836
   Erstellt eine neue Domäne.
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   837
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   838
   \return Zeiger auf die Domäne bei Erfolg, sonst NULL.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   839
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   840
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   841
ec_domain_t *ecrt_master_create_domain(ec_master_t *master /**< Master */)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   842
{
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   843
    ec_domain_t *domain, *last_domain;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   844
    unsigned int index;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   845
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   846
    if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   847
        EC_ERR("Error allocating domain memory!\n");
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   848
        goto out_return;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   849
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   850
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   851
    if (list_empty(&master->domains)) index = 0;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   852
    else {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   853
        last_domain = list_entry(master->domains.prev, ec_domain_t, list);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   854
        index = last_domain->index + 1;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   855
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   856
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   857
    if (ec_domain_init(domain, master, index)) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   858
        EC_ERR("Failed to init domain.\n");
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   859
        goto out_return;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   860
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   861
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   862
    if (kobject_add(&domain->kobj)) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   863
        EC_ERR("Failed to add domain kobject.\n");
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   864
        goto out_put;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   865
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   866
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
   867
    list_add_tail(&domain->list, &master->domains);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   868
    return domain;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   869
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   870
 out_put:
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   871
    kobject_put(&domain->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   872
 out_return:
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 176
diff changeset
   873
    return NULL;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   874
}
61
cd014255f94f register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   875
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   876
/*****************************************************************************/
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   877
61
cd014255f94f register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   878
/**
58
21b7342e2a90 Code-Dokumentation mit Doxygen aufgearbeitet.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
   879
   Konfiguriert alle Slaves und setzt den Operational-Zustand.
21b7342e2a90 Code-Dokumentation mit Doxygen aufgearbeitet.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
   880
21b7342e2a90 Code-Dokumentation mit Doxygen aufgearbeitet.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
   881
   Führt die komplette Konfiguration und Aktivierunge aller registrierten
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   882
   Slaves durch. Setzt Sync-Manager und FMMUs, führt die entsprechenden
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
   Zustandsübergänge durch, bis der Slave betriebsbereit ist.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   885
   \return 0 bei Erfolg, sonst < 0
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   886
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   887
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   888
int ecrt_master_activate(ec_master_t *master /**< EtherCAT-Master */)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   889
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   890
    unsigned int i, j;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   891
    ec_slave_t *slave;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   892
    ec_command_t *command;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   893
    const ec_sync_t *sync;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   894
    const ec_slave_type_t *type;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   895
    const ec_fmmu_t *fmmu;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   896
    uint32_t domain_offset;
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   897
    ec_domain_t *domain;
155
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   898
    ec_eeprom_sync_t *eeprom_sync, mbox_sync;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   899
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   900
    command = &master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   901
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   902
    if (ec_command_brd(&master->watch_command, 0x130, 2)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   903
        EC_ERR("Failed to allocate watchdog command!\n");
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   904
        return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   905
    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   906
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   907
    // Domains erstellen
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   908
    domain_offset = 0;
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
   909
    list_for_each_entry(domain, &master->domains, list) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   910
        if (ec_domain_alloc(domain, domain_offset)) {
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
   911
            EC_ERR("Failed to allocate domain %X!\n", (u32) domain);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   912
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   913
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   914
        domain_offset += domain->data_size;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   915
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   916
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   917
    // Slaves aktivieren
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   918
    for (i = 0; i < master->slave_count; i++) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   919
        slave = master->slaves + i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   920
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   921
        // Change state to INIT
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   922
        if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_INIT)))
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   923
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   924
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   925
        // Check if slave was registered...
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   926
        type = slave->type;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   927
        if (!type) EC_WARN("Slave %i has unknown type!\n", i);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   928
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   929
        // Check and reset CRC fault counters
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   930
        ec_slave_check_crc(slave);
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   931
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 90
diff changeset
   932
        // Resetting FMMUs
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   933
        if (slave->base_fmmu_count) {
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   934
            if (ec_command_npwr(command, slave->station_address, 0x0600,
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   935
                                EC_FMMU_SIZE * slave->base_fmmu_count))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   936
                return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   937
            memset(command->data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   938
            if (unlikely(ec_master_simple_io(master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   939
                EC_ERR("Resetting FMMUs failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   940
                       slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   941
                return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   942
            }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   943
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   944
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   945
        // Resetting Sync Manager channels
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   946
        if (slave->base_sync_count) {
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   947
            if (ec_command_npwr(command, slave->station_address, 0x0800,
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   948
                                EC_SYNC_SIZE * slave->base_sync_count))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   949
                return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   950
            memset(command->data, 0x00, EC_SYNC_SIZE * slave->base_sync_count);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   951
            if (unlikely(ec_master_simple_io(master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   952
                EC_ERR("Resetting sync managers failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
   953
                       slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   954
                return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   955
            }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   956
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   957
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   958
        // Set Sync Managers
155
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   959
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   960
        // Known slave type, take type's SM information
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   961
        if (type) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   962
            for (j = 0; type->sync_managers[j] && j < EC_MAX_SYNC; j++) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   963
                sync = type->sync_managers[j];
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   964
                if (ec_command_npwr(command, slave->station_address,
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   965
                                    0x0800 + j * EC_SYNC_SIZE, EC_SYNC_SIZE))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   966
                    return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   967
                ec_sync_config(sync, command->data);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   968
                if (unlikely(ec_master_simple_io(master, command))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   969
                    EC_ERR("Setting sync manager %i failed on slave %i!\n",
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   970
                           j, slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   971
                    return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   972
                }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   973
            }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   974
        }
155
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   975
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   976
        // Unknown slave type, but has mailbox
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   977
        else if (slave->sii_mailbox_protocols) {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   978
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   979
            // Does the device supply SM configurations in its EEPROM?
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   980
	    if (!list_empty(&slave->eeprom_syncs)) {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   981
		list_for_each_entry(eeprom_sync, &slave->eeprom_syncs, list) {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   982
		    EC_INFO("Sync manager %i...\n", eeprom_sync->index);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   983
		    if (ec_command_npwr(command, slave->station_address,
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   984
					0x800 + eeprom_sync->index *
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   985
					EC_SYNC_SIZE,
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   986
					EC_SYNC_SIZE)) return -1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   987
		    ec_eeprom_sync_config(eeprom_sync, command->data);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   988
		    if (unlikely(ec_master_simple_io(master, command))) {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   989
			EC_ERR("Setting sync manager %i failed on slave %i!\n",
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   990
			       eeprom_sync->index, slave->ring_position);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   991
			return -1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   992
		    }
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   993
		}
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   994
            }
155
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   995
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   996
            // No sync manager information; guess mailbox settings
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   997
	    else {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   998
		mbox_sync.physical_start_address =
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   999
                    slave->sii_rx_mailbox_offset;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1000
		mbox_sync.length = slave->sii_rx_mailbox_size;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1001
		mbox_sync.control_register = 0x26;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1002
		mbox_sync.enable = 1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1003
		if (ec_command_npwr(command, slave->station_address,
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1004
				    0x800,EC_SYNC_SIZE)) return -1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1005
		ec_eeprom_sync_config(&mbox_sync, command->data);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1006
		if (unlikely(ec_master_simple_io(master, command))) {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1007
		    EC_ERR("Setting sync manager 0 failed on slave %i!\n",
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1008
			   slave->ring_position);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1009
		    return -1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1010
		}
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1011
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1012
		mbox_sync.physical_start_address =
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1013
                    slave->sii_tx_mailbox_offset;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1014
		mbox_sync.length = slave->sii_tx_mailbox_size;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1015
		mbox_sync.control_register = 0x22;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1016
		mbox_sync.enable = 1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1017
		if (ec_command_npwr(command, slave->station_address,
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1018
				    0x808, EC_SYNC_SIZE)) return -1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1019
		ec_eeprom_sync_config(&mbox_sync, command->data);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1020
		if (unlikely(ec_master_simple_io(master, command))) {
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1021
		    EC_ERR("Setting sync manager 1 failed on slave %i!\n",
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1022
			   slave->ring_position);
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1023
		    return -1;
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1024
		}
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1025
	    }
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1026
	    EC_INFO("Mailbox configured for unknown slave %i\n",
ff65679b65fe Plugfest: Configure mailbox for unknown slaves.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
  1027
		    slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1028
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1029
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1030
        // Change state to PREOP
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1031
        if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_PREOP)))
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1032
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1033
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
  1034
        // Stop activation here for slaves without type
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
  1035
        if (!type) continue;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
  1036
81
28b1defdcc88 Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1037
        // Slaves that are not registered are only brought into PREOP
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1038
        // state -> nice blinking and mailbox communication possible
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1039
        if (!slave->registered && !slave->type->special) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
  1040
            EC_WARN("Slave %i was not registered!\n", slave->ring_position);
81
28b1defdcc88 Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1041
            continue;
28b1defdcc88 Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1042
        }
28b1defdcc88 Nicht registrierte Slaves in PREOP schalten.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1043
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1044
        // Set FMMUs
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
  1045
        for (j = 0; j < slave->fmmu_count; j++) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1046
            fmmu = &slave->fmmus[j];
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1047
            if (ec_command_npwr(command, slave->station_address,
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1048
                                0x0600 + j * EC_FMMU_SIZE, EC_FMMU_SIZE))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1049
                return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1050
            ec_fmmu_config(fmmu, command->data);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1051
            if (unlikely(ec_master_simple_io(master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
  1052
                EC_ERR("Setting FMMU %i failed on slave %i!\n",
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
  1053
                       j, slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1054
                return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1055
            }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1056
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1057
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1058
        // Change state to SAVEOP
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1059
        if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_SAVEOP)))
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1060
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1061
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1062
        // Change state to OP
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1063
        if (unlikely(ec_slave_state_change(slave, EC_SLAVE_STATE_OP)))
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1064
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1065
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1066
166
29b19a90ff3f Better outputs concerning responding slaves.
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
  1067
    master->slaves_responding = 0;
29b19a90ff3f Better outputs concerning responding slaves.
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
  1068
    master->slave_states = EC_SLAVE_STATE_INIT;
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 129
diff changeset
  1069
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1070
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1071
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1072
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1073
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1074
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1075
/**
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1076
   Setzt alle Slaves zurück in den Init-Zustand.
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1077
*/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1078
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1079
void ecrt_master_deactivate(ec_master_t *master /**< EtherCAT-Master */)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1080
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1081
    ec_slave_t *slave;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1082
    unsigned int i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1083
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1084
    for (i = 0; i < master->slave_count; i++)
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
    {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1086
        slave = master->slaves + i;
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1087
        ec_slave_check_crc(slave);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1088
        ec_slave_state_change(slave, EC_SLAVE_STATE_INIT);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1089
    }
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1090
}
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1091
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1092
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1093
/*****************************************************************************/
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1094
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1095
/**
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1096
   Lädt die SDO-Dictionaries aller Slaves.
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1097
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1098
   Slaves, die kein CoE unterstützen, werden ausgelassen.
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1099
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1100
   \return 0 wenn alles ok, sonst < 0
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1101
*/
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1102
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1103
int ecrt_master_fetch_sdo_lists(ec_master_t *master /**< EtherCAT-Master */)
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1104
{
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1105
    ec_slave_t *slave;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1106
    unsigned int i;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1107
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1108
    for (i = 0; i < master->slave_count; i++) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1109
        slave = master->slaves + i;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1110
        if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1111
            if (unlikely(ec_slave_fetch_sdo_list(slave))) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1112
                EC_ERR("Failed to fetch SDO list on slave %i!\n",
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1113
                       slave->ring_position);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1114
                return -1;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1115
            }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1116
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1117
    }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1118
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1119
    return 0;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1120
}
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1121
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1122
/*****************************************************************************/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1123
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1124
/**
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1125
   Sendet und empfängt Kommandos synchron.
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1126
*/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1127
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1128
void ecrt_master_sync_io(ec_master_t *master)
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1129
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1130
    ec_command_t *command, *n;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1131
    unsigned int commands_sent;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1132
    cycles_t t_start, t_end, t_timeout;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1133
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1134
    // Kommandos senden
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1135
    ecrt_master_async_send(master);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1136
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1137
    t_start = get_cycles(); // Sendezeit nehmen
120
e713e7420c4d 64bit-Division vermieden.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
  1138
    t_timeout = (cycles_t) master->timeout * (cpu_khz / 1000);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1139
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1140
    while (1) // Aktiv auf Empfang warten
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1141
    {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1142
        ec_device_call_isr(master->device);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1143
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1144
        t_end = get_cycles(); // Aktuelle Zeit nehmen
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1145
        if (t_end - t_start >= t_timeout) break; // Timeout
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1146
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1147
        commands_sent = 0;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1148
        list_for_each_entry_safe(command, n, &master->command_queue, queue) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1149
            if (command->state == EC_CMD_RECEIVED)
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1150
                list_del_init(&command->queue);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1151
            else if (command->state == EC_CMD_SENT)
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1152
                commands_sent++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1153
        }
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1154
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1155
        if (!commands_sent) break;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1156
    }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1157
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1158
    // Zeit abgelaufen. Alle verbleibenden Kommandos entfernen.
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1159
    list_for_each_entry_safe(command, n, &master->command_queue, queue) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1160
        switch (command->state) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1161
            case EC_CMD_SENT:
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1162
            case EC_CMD_QUEUED:
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1163
                command->state = EC_CMD_TIMEOUT;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1164
                master->stats.timeouts++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1165
                ec_master_output_stats(master);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1166
                break;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1167
            case EC_CMD_RECEIVED:
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1168
                master->stats.delayed++;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1169
                ec_master_output_stats(master);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1170
                break;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1171
            default:
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1172
                break;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1173
        }
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1174
        list_del_init(&command->queue);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1175
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1176
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1177
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1178
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1179
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1180
/**
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1181
   Sendet Kommandos asynchron.
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1182
*/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1183
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1184
void ecrt_master_async_send(ec_master_t *master)
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1185
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1186
    ec_command_t *command, *n;
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1187
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1188
    if (unlikely(!master->device->link_state)) {
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1189
        // Link DOWN, keines der Kommandos kann gesendet werden.
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1190
        list_for_each_entry_safe(command, n, &master->command_queue, queue) {
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1191
            command->state = EC_CMD_ERROR;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1192
            list_del_init(&command->queue);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1193
        }
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1194
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1195
        // Device-Zustand abfragen
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1196
        ec_device_call_isr(master->device);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1197
        return;
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1198
    }
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1199
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1200
    // Rahmen senden
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1201
    ec_master_send_commands(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1202
}
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1203
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1204
/*****************************************************************************/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1205
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1206
/**
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1207
   Empfängt Kommandos asynchron.
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1208
*/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1209
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1210
void ecrt_master_async_receive(ec_master_t *master)
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1211
{
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1212
    ec_command_t *command, *next;
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1213
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1214
    ec_device_call_isr(master->device);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1215
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1216
    // Alle empfangenen Kommandos aus der Liste entfernen
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1217
    list_for_each_entry_safe(command, next, &master->command_queue, queue)
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1218
        if (command->state == EC_CMD_RECEIVED) list_del_init(&command->queue);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1219
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1220
    // Alle verbleibenden Kommandos entfernen.
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1221
    list_for_each_entry_safe(command, next, &master->command_queue, queue) {
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1222
        switch (command->state) {
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1223
            case EC_CMD_SENT:
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1224
            case EC_CMD_QUEUED:
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1225
                command->state = EC_CMD_TIMEOUT;
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1226
                master->stats.timeouts++;
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1227
                ec_master_output_stats(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1228
                break;
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1229
            default:
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1230
                break;
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1231
        }
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1232
        list_del_init(&command->queue);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1233
    }
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1234
}
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1235
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1236
/*****************************************************************************/
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1237
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1238
/**
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1239
   Bereitet Synchronen Datenverkehr vor.
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1240
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1241
   Fürgt einmal die Kommandos aller Domains zur Warteschlange hinzu, sendet
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1242
   diese ab und wartet so lange, bis diese anschließend problemlos empfangen
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1243
   werden können.
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1244
*/
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1245
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1246
void ecrt_master_prepare_async_io(ec_master_t *master)
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1247
{
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1248
    ec_domain_t *domain;
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1249
    cycles_t t_start, t_end, t_timeout;
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1250
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1251
    // Kommandos aller Domains in die Warteschlange setzen
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1252
    list_for_each_entry(domain, &master->domains, list)
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1253
        ecrt_domain_queue(domain);
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1254
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1255
    ecrt_master_async_send(master);
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1256
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1257
    t_start = get_cycles(); // Sendezeit nehmen
120
e713e7420c4d 64bit-Division vermieden.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
  1258
    t_timeout = (cycles_t) master->timeout * (cpu_khz / 1000);
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1259
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1260
    // Aktiv warten!
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1261
    while (1) {
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1262
        t_end = get_cycles();
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1263
        if (t_end - t_start >= t_timeout) break;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
  1264
    }
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1265
}
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1266
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1267
/*****************************************************************************/
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1268
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
  1269
/**
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1270
   Führt Routinen im zyklischen Betrieb aus.
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1271
*/
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1272
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1273
void ecrt_master_run(ec_master_t *master /**< EtherCAT-Master */)
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1274
{
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1275
    // Statistiken ausgeben
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1276
    ec_master_output_stats(master);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1277
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1278
    // Watchdog-Kommando
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1279
    ec_master_process_watch_command(master);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1280
    ec_master_queue_command(master, &master->watch_command);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1281
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1282
    // Ethernet-over-EtherCAT
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1283
    ec_master_run_eoe(master);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1284
}
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1285
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1286
/*****************************************************************************/
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1287
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1288
/**
56
36d1fa37f5e1 Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1289
   Setzt die Debug-Ebene des Masters.
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
  1290
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1291
   Folgende Debug-Level sind definiert:
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
  1292
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
  1293
   - 1: Nur Positionsmarken in bestimmten Funktionen
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
  1294
   - 2: Komplette Frame-Inhalte
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
  1295
*/
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
  1296
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1297
void ecrt_master_debug(ec_master_t *master, /**< EtherCAT-Master */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1298
                       int level /**< Debug-Level */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1299
                       )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1300
{
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1301
    if (level != master->debug_level) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1302
        master->debug_level = level;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1303
        EC_INFO("Master debug level set to %i.\n", level);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
  1304
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1305
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1306
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1307
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1308
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1309
/**
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1310
   Gibt alle Informationen zum Master aus.
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1311
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1312
   Verbosity:
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1313
     0 - Nur Slavetypen und Adressen
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1314
     1 - mit EEPROM-Informationen
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1315
    >1 - mit SDO-Dictionaries
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1316
*/
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1317
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1318
void ecrt_master_print(const ec_master_t *master, /**< EtherCAT-Master */
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1319
                       unsigned int verbosity /**< Geschwätzigkeit */
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1320
                       )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1321
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1322
    unsigned int i;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1323
    ec_eoe_t *eoe;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1324
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
  1325
    EC_INFO("*** Begin master information ***\n");
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1326
    if (master->slave_count) {
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1327
        EC_INFO("Slave list:\n");
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1328
        for (i = 0; i < master->slave_count; i++)
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1329
            ec_slave_print(&master->slaves[i], verbosity);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1330
    }
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1331
    if (!list_empty(&master->eoe_slaves)) {
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1332
        EC_INFO("Ethernet-over-EtherCAT (EoE) objects:\n");
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1333
        list_for_each_entry(eoe, &master->eoe_slaves, list) {
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1334
            ec_eoe_print(eoe);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1335
        }
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1336
    }
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 82
diff changeset
  1337
    EC_INFO("*** End master information ***\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1338
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1339
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1340
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1341
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1342
void ec_master_run_eoe(ec_master_t *master /**< EtherCAT-Master */)
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1343
{
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1344
    ec_eoe_t *eoe;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1345
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1346
    list_for_each_entry(eoe, &master->eoe_slaves, list) {
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1347
        ec_eoe_run(eoe);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1348
    }
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1349
}
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1350
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1351
/*****************************************************************************/
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1352
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1353
EXPORT_SYMBOL(ecrt_master_create_domain);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1354
EXPORT_SYMBOL(ecrt_master_activate);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1355
EXPORT_SYMBOL(ecrt_master_deactivate);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1356
EXPORT_SYMBOL(ecrt_master_fetch_sdo_lists);
109
c6766baead5e Bugfix: EXPORT_SYMBOL f?r ec_master_prepare_async_io() vergessen.
Florian Pose <fp@igh-essen.com>
parents: 106
diff changeset
  1357
EXPORT_SYMBOL(ecrt_master_prepare_async_io);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1358
EXPORT_SYMBOL(ecrt_master_sync_io);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1359
EXPORT_SYMBOL(ecrt_master_async_send);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1360
EXPORT_SYMBOL(ecrt_master_async_receive);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1361
EXPORT_SYMBOL(ecrt_master_run);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1362
EXPORT_SYMBOL(ecrt_master_debug);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
  1363
EXPORT_SYMBOL(ecrt_master_print);
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1364
EXPORT_SYMBOL(ecrt_master_get_slave);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1365
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1366
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1367
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1368
/* Emacs-Konfiguration
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1369
;;; Local Variables: ***
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
  1370
;;; c-basic-offset:4 ***
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1371
;;; End: ***
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1372
*/