master/module.c
author Florian Pose <fp@igh-essen.com>
Wed, 12 Apr 2006 12:04:27 +0000
changeset 192 8d7bd5082ed5
parent 191 ca805255a935
child 195 674071846ee3
permissions -rw-r--r--
Fixed devices Makefile.
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
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 o d u l e . c
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  EtherCAT-Master-Treiber
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  Autoren: Wilhelm Hagemeister, Florian Pose
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  $Id$
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  (C) Copyright IgH 2005
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *  Ingenieurgemeinschaft IgH
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *  Heinz-Bäcker Str. 34
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  D-45356 Essen
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  Tel.: +49 201/61 99 31
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  Fax.: +49 201/61 98 36
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  E-mail: sp@igh-essen.com
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    19
 *****************************************************************************/
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
#include <linux/module.h>
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
#include <linux/kernel.h>
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
#include <linux/init.h>
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 178
diff changeset
    25
#include "globals.h"
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    26
#include "master.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    27
#include "device.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    28
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    29
/*****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    30
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    31
int __init ec_init_module(void);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    32
void __exit ec_cleanup_module(void);
52
c0405659a74a Neues Interface.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
    33
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    34
/*****************************************************************************/
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    35
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    36
#define COMPILE_INFO "Revision " EC_STR(SVNREV) \
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    37
                     ", compiled by " EC_STR(USER) \
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    38
                     " at " __DATE__ " " __TIME__
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    40
/*****************************************************************************/
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    42
static int ec_master_count = 1;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    43
static struct list_head ec_masters;
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    45
/*****************************************************************************/
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    46
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    47
MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>");
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
MODULE_DESCRIPTION ("EtherCAT master driver module");
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
MODULE_LICENSE("GPL");
34
c1e8d61fa395 Compile-Informationen hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    50
MODULE_VERSION(COMPILE_INFO);
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    52
module_param(ec_master_count, int, 1);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    53
MODULE_PARM_DESC(ec_master_count, "Number of EtherCAT master to initialize.");
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
    55
/*****************************************************************************/
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
/**
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
   Init-Funktion des EtherCAT-Master-Treibermodules
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    60
   Initialisiert soviele Master, wie im Parameter ec_master_count
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
   angegeben wurde (Default ist 1).
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
    63
   \return 0 wenn alles ok, < 0 bei ungültiger Anzahl Master
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
    64
           oder zu wenig Speicher.
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    65
*/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    66
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    67
int __init ec_init_module(void)
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    69
    unsigned int i;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    70
    ec_master_t *master, *next;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    71
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
    72
    EC_INFO("Master driver, %s\n", COMPILE_INFO);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    74
    if (ec_master_count < 1) {
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
    75
        EC_ERR("Error - Invalid ec_master_count: %i\n", ec_master_count);
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
    76
        goto out_return;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    77
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    78
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
    79
    EC_INFO("Initializing %i EtherCAT master(s)...\n", ec_master_count);
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
    80
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    81
    INIT_LIST_HEAD(&ec_masters);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    82
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
    83
    for (i = 0; i < ec_master_count; i++) {
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    84
        if (!(master =
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    85
              (ec_master_t *) kmalloc(sizeof(ec_master_t), GFP_KERNEL))) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    86
            EC_ERR("Failed to allocate memory for EtherCAT master %i.\n", i);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    87
            goto out_free;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    88
        }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    89
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    90
        if (ec_master_init(master, i)) // kobject_put is done inside...
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    91
            goto out_free;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    92
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    93
        if (kobject_add(&master->kobj)) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    94
            EC_ERR("Failed to add kobj.\n");
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    95
            kobject_put(&master->kobj); // free master
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    96
            goto out_free;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    97
        }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    98
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    99
        list_add_tail(&master->list, &ec_masters);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   100
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   101
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   102
    EC_INFO("Master driver initialized.\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   103
    return 0;
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   104
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   105
 out_free:
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   106
    list_for_each_entry_safe(master, next, &ec_masters, list) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   107
        list_del(&master->list);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   108
        kobject_del(&master->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   109
        kobject_put(&master->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   110
    }
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   111
 out_return:
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   112
    return -1;
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
}
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
   115
/*****************************************************************************/
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
/**
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
   Cleanup-Funktion des EtherCAT-Master-Treibermoduls
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
   Entfernt alle Master-Instanzen.
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
*/
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   123
void __exit ec_cleanup_module(void)
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
{
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   125
    ec_master_t *master, *next;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   126
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   127
    EC_INFO("Cleaning up master driver...\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   128
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   129
    list_for_each_entry_safe(master, next, &ec_masters, list) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   130
        list_del(&master->list);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   131
        kobject_del(&master->kobj);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   132
        kobject_put(&master->kobj); // free master
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   133
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   134
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   135
    EC_INFO("Master driver cleaned up.\n");
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
}
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   138
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   139
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   140
/**
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   141
   Gets a handle to a certain master.
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   142
   \returns pointer to master
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   143
*/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   144
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   145
ec_master_t *ec_find_master(unsigned int master_index)
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   146
{
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   147
    ec_master_t *master;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   148
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   149
    list_for_each_entry(master, &ec_masters, list) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   150
        if (master->index == master_index) return master;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   151
    }
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   152
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   153
    EC_ERR("Master %i does not exist!\n", master_index);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   154
    return NULL;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   155
}
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   156
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   157
/******************************************************************************
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   158
 *
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   159
 * Treiberschnittstelle
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   160
 *
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   161
 *****************************************************************************/
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   162
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   163
/**
58
21b7342e2a90 Code-Dokumentation mit Doxygen aufgearbeitet.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
   164
   Registeriert das EtherCAT-Geraet fuer einen EtherCAT-Master.
21b7342e2a90 Code-Dokumentation mit Doxygen aufgearbeitet.
Florian Pose <fp@igh-essen.com>
parents: 56
diff changeset
   165
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   166
   \return 0 wenn alles ok, oder < 0 wenn bereits ein Gerät registriert
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   167
           oder das Geraet nicht geöffnet werden konnte.
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   168
*/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   169
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   170
ec_device_t *ecdev_register(unsigned int master_index,
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   171
                            /**< Index des EtherCAT-Masters */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   172
                            struct net_device *net_dev,
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   173
                            /**< net_device des EtherCAT-Gerätes */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   174
                            ec_isr_t isr,
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   175
                            /**< Interrupt-Service-Routine */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   176
                            struct module *module
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   177
                            /**< Zeiger auf das Modul */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   178
                            )
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   179
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   180
    ec_master_t *master;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   181
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   182
    if (!net_dev) {
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   183
        EC_WARN("Device is NULL!\n");
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   184
        goto out_return;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   185
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   186
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   187
    if (!(master = ec_find_master(master_index))) return NULL;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   188
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   189
    // critical section start
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   190
    if (master->device) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   191
        EC_ERR("Master %i already has a device!\n", master_index);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   192
        // critical section leave
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   193
        goto out_return;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   194
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   195
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   196
    if (!(master->device =
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   197
          (ec_device_t *) kmalloc(sizeof(ec_device_t), GFP_KERNEL))) {
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   198
        EC_ERR("Failed to allocate device!\n");
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   199
        // critical section leave
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   200
        goto out_return;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   201
    }
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   202
    // critical section end
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   203
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   204
    if (ec_device_init(master->device, master, net_dev, isr, module)) {
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   205
        EC_ERR("Failed to init device!\n");
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   206
        goto out_free;
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
   207
    }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   208
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   209
    return master->device;
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   210
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   211
 out_free:
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   212
    kfree(master->device);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   213
    master->device = NULL;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   214
 out_return:
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   215
    return NULL;
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   216
}
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   217
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   218
/*****************************************************************************/
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   219
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   220
/**
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   221
   Hebt die Registrierung eines EtherCAT-Gerätes auf.
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   222
*/
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   223
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   224
void ecdev_unregister(unsigned int master_index,
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   225
                      /**< Index des EtherCAT-Masters */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   226
                      ec_device_t *device
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   227
                      /**< EtherCAT-Geraet */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   228
                      )
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   229
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   230
    ec_master_t *master;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   231
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   232
    if (!(master = ec_find_master(master_index))) return;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   233
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   234
    if (!master->device || master->device != device) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   235
        EC_WARN("Unable to unregister device!\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   236
        return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   237
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   238
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   239
    ec_device_clear(master->device);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   240
    kfree(master->device);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   241
    master->device = NULL;
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   242
}
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   243
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   244
/*****************************************************************************/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   245
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   246
/**
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   247
   Starts the master.
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   248
*/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   249
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   250
int ecdev_start(unsigned int master_index
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   251
                /**< Index des EtherCAT-Masters */
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   252
                )
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   253
{
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   254
    ec_master_t *master;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   255
    if (!(master = ec_find_master(master_index))) return -1;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   256
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   257
    if (ec_device_open(master->device)) {
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   258
        EC_ERR("Failed to open device!\n");
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   259
        return -1;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   260
    }
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   261
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   262
    ec_master_freerun_start(master);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   263
    return 0;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   264
}
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   265
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   266
/*****************************************************************************/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   267
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   268
/**
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   269
   Stops the master.
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   270
*/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   271
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   272
void ecdev_stop(unsigned int master_index
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   273
                /**< Index des EtherCAT-Masters */
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   274
                )
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   275
{
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   276
    ec_master_t *master;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   277
    if (!(master = ec_find_master(master_index))) return;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   278
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   279
    ec_master_freerun_stop(master);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   280
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   281
    if (ec_device_close(master->device))
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   282
        EC_WARN("Failed to close device!\n");
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   283
}
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   284
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   285
/******************************************************************************
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   286
 *
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   287
 * Echtzeitschnittstelle
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   288
 *
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   289
 *****************************************************************************/
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   290
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   291
/**
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   292
   Reserviert einen bestimmten EtherCAT-Master und das zugehörige Gerät.
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   293
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   294
   Gibt einen Zeiger auf den reservierten EtherCAT-Master zurueck.
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   296
   \return Zeiger auf EtherCAT-Master oder NULL, wenn Parameter ungueltig.
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   297
*/
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   298
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   299
ec_master_t *ecrt_request_master(unsigned int master_index
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   300
                                 /**< EtherCAT-Master-Index */
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   301
                                 )
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   302
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   303
    ec_master_t *master;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   304
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   305
    EC_INFO("Requesting master %i...\n", master_index);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   306
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   307
    if (!(master = ec_find_master(master_index))) goto out_return;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   308
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   309
    // begin critical section
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   310
    if (master->reserved) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   311
        EC_ERR("Master %i is already in use!\n", master_index);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   312
        goto out_return;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   313
    }
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   314
    master->reserved = 1;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   315
    // end critical section
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   316
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   317
    if (!master->device) {
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   318
        EC_ERR("Master %i has no assigned device!\n", master_index);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   319
        goto out_release;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   320
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   321
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   322
    if (!try_module_get(master->device->module)) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   323
        EC_ERR("Failed to reserve device module!\n");
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   324
        goto out_release;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   325
    }
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   326
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   327
    ec_master_freerun_stop(master);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   328
    ec_master_reset(master);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   329
    master->mode = EC_MASTER_MODE_RUNNING;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   330
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   331
    if (!master->device->link_state) EC_WARN("Link is DOWN.\n");
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   332
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   333
    if (ec_master_bus_scan(master)) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 79
diff changeset
   334
        EC_ERR("Bus scan failed!\n");
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   335
        goto out_module_put;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   336
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   337
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   338
    EC_INFO("Master %i is ready.\n", master_index);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   339
    return master;
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   340
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   341
 out_module_put:
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   342
    module_put(master->device->module);
85
eb24637883ef Master wird nach nicht erfolgreichem Request resettet.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   343
    ec_master_reset(master);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   344
 out_release:
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   345
    master->reserved = 0;
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   346
 out_return:
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   347
    EC_ERR("Failed requesting master %i.\n", master_index);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   348
    return NULL;
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
}
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
   351
/*****************************************************************************/
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   352
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   353
/**
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
   354
   Gibt einen zuvor angeforderten EtherCAT-Master wieder frei.
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   355
*/
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 88
diff changeset
   356
151
1961b674466c Plugfest: master_open()/close() ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
   357
void ecrt_release_master(ec_master_t *master /**< EtherCAT-Master */)
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   358
{
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   359
    EC_INFO("Releasing master %i...\n", master->index);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   360
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   361
    if (!master->reserved) {
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   362
        EC_ERR("Master %i was never requested!\n", master->index);
88
98335157e54e Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents: 85
diff changeset
   363
        return;
98335157e54e Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents: 85
diff changeset
   364
    }
98335157e54e Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents: 85
diff changeset
   365
98335157e54e Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents: 85
diff changeset
   366
    ec_master_reset(master);
98335157e54e Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents: 85
diff changeset
   367
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   368
    master->mode = EC_MASTER_MODE_IDLE;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   369
    ec_master_freerun_start(master);
151
1961b674466c Plugfest: master_open()/close() ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
   370
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   371
    module_put(master->device->module);
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   372
    master->reserved = 0;
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   373
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   374
    EC_INFO("Released master %i.\n", master->index);
88
98335157e54e Bessere Ausgaben beim Starten und beenden.
Florian Pose <fp@igh-essen.com>
parents: 85
diff changeset
   375
    return;
33
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   376
}
f4171b8aadf8 Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents: 27
diff changeset
   377
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 34
diff changeset
   378
/*****************************************************************************/
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   379
152
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   380
/**
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   381
   Gibt Frame-Inhalte zwecks Debugging aus.
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   382
*/
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   383
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   384
void ec_print_data(const uint8_t *data, size_t size)
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   385
{
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   386
    unsigned int i;
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   387
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   388
    EC_DBG("");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   389
    for (i = 0; i < size; i++) {
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   390
        printk("%02X ", data[i]);
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   391
        if ((i + 1) % 16 == 0) {
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   392
            printk("\n");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   393
            EC_DBG("");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   394
        }
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   395
    }
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   396
    printk("\n");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   397
}
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   398
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   399
/*****************************************************************************/
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   400
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   401
/**
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   402
   Gibt Frame-Inhalte zwecks Debugging aus, differentiell.
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   403
*/
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   404
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   405
void ec_print_data_diff(const uint8_t *d1, /**< Daten 1 */
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   406
                        const uint8_t *d2, /**< Daten 2 */
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   407
                        size_t size /** Anzahl Bytes */
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   408
                        )
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   409
{
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   410
    unsigned int i;
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   411
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   412
    EC_DBG("");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   413
    for (i = 0; i < size; i++) {
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   414
        if (d1[i] == d2[i]) printk(".. ");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   415
        else printk("%02X ", d2[i]);
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   416
        if ((i + 1) % 16 == 0) {
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   417
            printk("\n");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   418
            EC_DBG("");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   419
        }
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   420
    }
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   421
    printk("\n");
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   422
}
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   423
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   424
/*****************************************************************************/
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
   425
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   426
module_init(ec_init_module);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   427
module_exit(ec_cleanup_module);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   428
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   429
EXPORT_SYMBOL(ecdev_register);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   430
EXPORT_SYMBOL(ecdev_unregister);
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   431
EXPORT_SYMBOL(ecdev_start);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   432
EXPORT_SYMBOL(ecdev_stop);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   433
EXPORT_SYMBOL(ecrt_request_master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   434
EXPORT_SYMBOL(ecrt_release_master);
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   435
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
   436
/*****************************************************************************/
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   437
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   438
/* Emacs-Konfiguration
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   439
;;; Local Variables: ***
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 64
diff changeset
   440
;;; c-basic-offset:4 ***
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   441
;;; End: ***
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
   442
*/