mini/mini.c
author Florian Pose <fp@igh-essen.com>
Fri, 05 May 2006 14:45:02 +0000
changeset 216 e7f3e485c5b8
parent 208 b7797f8a813d
permissions -rw-r--r--
EoE: Corrected faulty MAC address.
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
     3
 *  m i n i . c
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
     4
 *
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
     5
 *  Minimal module for EtherCAT.
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
     6
 *
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
     7
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     9
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    10
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    11
 *  This file is part of the IgH EtherCAT Master.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    12
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    13
 *  The IgH EtherCAT Master is free software; you can redistribute it
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    14
 *  and/or modify it under the terms of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    15
 *  as published by the Free Software Foundation; version 2 of the License.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    16
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    17
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    18
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    19
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    21
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    22
 *  You should have received a copy of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    23
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    24
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    25
 *
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
    26
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
#include <linux/module.h>
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    29
#include <linux/delay.h>
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    30
#include <linux/timer.h>
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    31
#include <linux/spinlock.h>
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    32
#include <linux/interrupt.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    34
#include "../include/ecrt.h" // EtherCAT realtime interface
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    35
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
    36
#define ASYNC
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    37
#define FREQUENCY 100
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    38
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    39
/*****************************************************************************/
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    40
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    41
struct timer_list timer;
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    42
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    43
// EtherCAT
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    44
ec_master_t *master = NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    45
ec_domain_t *domain1 = NULL;
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    46
spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    47
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    48
// data fields
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
    49
//void *r_ssi_input, *r_ssi_status, *r_4102[3];
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    50
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    51
// channels
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    52
uint32_t k_pos;
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
    53
uint8_t k_stat;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    54
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    55
ec_field_init_t domain1_fields[] = {
202
d5141123a5af new topology in mini.c
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    56
    {NULL, "3", "Beckhoff", "EL5001", "InputValue",   0},
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    57
    {NULL, "2", "Beckhoff", "EL4132", "OutputValue",  0},
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    58
    {}
61
cd014255f94f register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents: 60
diff changeset
    59
};
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    61
/*****************************************************************************/
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    62
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    63
void run(unsigned long data)
5
6f2508af550c Alle ?nderungen aus den Branches no_rtai und no_int nach Trunk portiert.
Florian Pose <fp@igh-essen.com>
parents: 0
diff changeset
    64
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    65
    static unsigned int counter = 0;
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    66
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    67
    spin_lock(&master_lock);
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    68
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    69
#ifdef ASYNC
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    70
    // receive
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    71
    ecrt_master_async_receive(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    72
    ecrt_domain_process(domain1);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    73
#else
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    74
    // send and receive
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    75
    ecrt_domain_queue(domain1);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    76
    ecrt_master_run(master);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    77
    ecrt_master_sync_io(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    78
    ecrt_domain_process(domain1);
156
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    79
#endif
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    80
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    81
    // process data
156
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    82
    //k_pos = EC_READ_U32(r_ssi);
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    83
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    84
#ifdef ASYNC
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    85
    // send
156
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    86
    ecrt_domain_queue(domain1);
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    87
    ecrt_master_run(master);
43d7d714679f Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents: 147
diff changeset
    88
    ecrt_master_async_send(master);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    89
#endif
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    90
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    91
    spin_unlock(&master_lock);
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
    92
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    93
    if (counter) {
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    94
        counter--;
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    95
    }
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    96
    else {
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
    97
        counter = FREQUENCY;
117
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    98
        //printk(KERN_INFO "k_pos    = %i\n", k_pos);
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    99
        //printk(KERN_INFO "k_stat   = 0x%02X\n", k_stat);
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
   100
    }
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
   101
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
   102
    // restart timer
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
   103
    timer.expires += HZ / FREQUENCY;
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   104
    add_timer(&timer);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
}
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   106
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   107
/*****************************************************************************/
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   108
206
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   109
int request_lock(void *data)
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   110
{
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   111
    unsigned int tries = 0;
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   112
    while (1) {
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   113
        if (spin_trylock(&master_lock)) {
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   114
            if (tries) printk(KERN_INFO "lock: %i tries needed.\n", tries);
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   115
            return 1;
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   116
        }
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   117
        tries++;
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   118
    }
206
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   119
}
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   120
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   121
/*****************************************************************************/
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   122
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   123
void release_lock(void *data)
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   124
{
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   125
    spin_unlock(&master_lock);
206
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   126
}
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   127
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   128
/*****************************************************************************/
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   129
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   130
int __init init_mini_module(void)
5
6f2508af550c Alle ?nderungen aus den Branches no_rtai und no_int nach Trunk portiert.
Florian Pose <fp@igh-essen.com>
parents: 0
diff changeset
   131
{
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   132
    printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   133
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   134
    if ((master = ecrt_request_master(0)) == NULL) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   135
        printk(KERN_ERR "Requesting master 0 failed!\n");
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   136
        goto out_return;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   137
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   138
206
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   139
    ecrt_master_callbacks(master, request_lock, release_lock, NULL);
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   140
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   141
    printk(KERN_INFO "Registering domain...\n");
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   142
    if (!(domain1 = ecrt_master_create_domain(master)))
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   143
    {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   144
        printk(KERN_ERR "Domain creation failed!\n");
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   145
        goto out_release_master;
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   146
    }
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   147
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   148
    printk(KERN_INFO "Registering domain fields...\n");
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   149
    if (ecrt_domain_register_field_list(domain1, domain1_fields)) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   150
        printk(KERN_ERR "Field registration failed!\n");
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   151
        goto out_release_master;
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   152
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   153
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   154
    printk(KERN_INFO "Activating master...\n");
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   155
    if (ecrt_master_activate(master)) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   156
        printk(KERN_ERR "Failed to activate master!\n");
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
   157
        goto out_release_master;
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
   158
    }
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents: 62
diff changeset
   159
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   160
#if 0
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   161
    if (ecrt_master_fetch_sdo_lists(master)) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   162
        printk(KERN_ERR "Failed to fetch SDO lists!\n");
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   163
        goto out_deactivate;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   164
    }
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   165
    ecrt_master_print(master, 2);
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   166
#else
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   167
    ecrt_master_print(master, 0);
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   168
#endif
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   169
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
   170
#if 0
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   171
    if (!(slave = ecrt_master_get_slave(master, "5"))) {
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   172
        printk(KERN_ERR "Failed to get slave 5!\n");
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   173
        goto out_deactivate;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   174
    }
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   175
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   176
    if (ecrt_slave_sdo_write_exp8(slave, 0x4061, 1,  0) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   177
        ecrt_slave_sdo_write_exp8(slave, 0x4061, 2,  1) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   178
        ecrt_slave_sdo_write_exp8(slave, 0x4061, 3,  1) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   179
        ecrt_slave_sdo_write_exp8(slave, 0x4066, 0,  0) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   180
        ecrt_slave_sdo_write_exp8(slave, 0x4067, 0,  4) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   181
        ecrt_slave_sdo_write_exp8(slave, 0x4068, 0,  0) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   182
        ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   183
        ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   184
        ecrt_slave_sdo_write_exp8(slave, 0x406B, 0, 50)) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   185
        printk(KERN_ERR "Failed to configure SSI slave!\n");
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   186
        goto out_deactivate;
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   187
    }
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
   188
#endif
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   189
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   190
#if 0
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   191
    printk(KERN_INFO "Writing alias...\n");
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   192
    if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   193
        printk(KERN_ERR "Failed to write alias!\n");
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   194
        goto out_deactivate;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   195
    }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   196
#endif
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   197
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   198
#ifdef ASYNC
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
   199
    // send once and wait...
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   200
    ecrt_master_prepare_async_io(master);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   201
#endif
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   202
208
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   203
#if 1
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   204
    if (ecrt_master_start_eoe(master)) {
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   205
        printk(KERN_ERR "Failed to start EoE processing!\n");
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   206
        goto out_deactivate;
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   207
    }
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   208
#endif
b7797f8a813d command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents: 206
diff changeset
   209
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   210
    printk("Starting cyclic sample thread.\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   211
    init_timer(&timer);
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   212
    timer.function = run;
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 156
diff changeset
   213
    timer.expires = jiffies + 10;
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   214
    add_timer(&timer);
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   215
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   216
    printk(KERN_INFO "=== Minimal EtherCAT environment started. ===\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   217
    return 0;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   218
206
60a10d85c20b Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents: 202
diff changeset
   219
#if 1
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   220
 out_deactivate:
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   221
    ecrt_master_deactivate(master);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   222
#endif
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   223
 out_release_master:
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   224
    ecrt_release_master(master);
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   225
 out_return:
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   226
    return -1;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   229
/*****************************************************************************/
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   230
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   231
void __exit cleanup_mini_module(void)
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
{
26
60435f959e5c Serial-Debugger entfernt.
Florian Pose <fp@igh-essen.com>
parents: 24
diff changeset
   233
    printk(KERN_INFO "=== Stopping Minimal EtherCAT environment... ===\n");
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   235
    if (master) {
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   236
        del_timer_sync(&timer);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   237
        printk(KERN_INFO "Deactivating master...\n");
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   238
        ecrt_master_deactivate(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   239
        ecrt_release_master(master);
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   240
    }
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   241
26
60435f959e5c Serial-Debugger entfernt.
Florian Pose <fp@igh-essen.com>
parents: 24
diff changeset
   242
    printk(KERN_INFO "=== Minimal EtherCAT environment stopped. ===\n");
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
/*****************************************************************************/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
MODULE_LICENSE("GPL");
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   249
MODULE_DESCRIPTION ("EtherCAT minimal test environment");
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   251
module_init(init_mini_module);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   252
module_exit(cleanup_mini_module);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
/*****************************************************************************/
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   255