mini/mini.c
author Florian Pose <fp@igh-essen.com>
Wed, 29 Mar 2006 15:10:00 +0000
changeset 139 998215ab9b92
parent 138 7e743a61a991
child 140 b09658e50d6f
permissions -rw-r--r--
Laden der SDO-Subindizes.
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
 *
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
     3
 * m i n i . c
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 * Minimalmodul für EtherCAT
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 5
diff changeset
     6
 *
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 * $Id$
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
     9
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
#include <linux/module.h>
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    12
#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
    13
#include <linux/timer.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    15
#include "../include/ecrt.h" // Echtzeitschnittstelle
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    16
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
    17
#define ASYNC
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
    18
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
    19
/*****************************************************************************/
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
    20
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 83
diff changeset
    21
#define ABTASTFREQUENZ 100
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    23
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
    24
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    25
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    26
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    27
// EtherCAT
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    28
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
    29
ec_domain_t *domain1 = NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    30
83
e8b76a509bc9 Beispiel-Echtzeitcode angepasst.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    31
// Datenfelder
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
    32
//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
    33
83
e8b76a509bc9 Beispiel-Echtzeitcode angepasst.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    34
// Kanäle
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    35
uint32_t k_pos;
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
    36
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
    37
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    38
ec_field_init_t domain1_fields[] = {
117
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    39
    {NULL, "1", "Beckhoff", "EL1014", "InputValue",  0},
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
    40
    {NULL, "2", "Beckhoff", "EL2004", "OutputValue", 0},
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
    41
    //{NULL, "3", "Beckhoff", "EL3162", "InputValue",  0},
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
    42
    {NULL, "4", "Beckhoff", "EL4132", "OutputValue",  0},
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
    43
    {NULL, "6", "Beckhoff", "EL5001", "InputValue", 0},
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    44
    {}
61
cd014255f94f register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents: 60
diff changeset
    45
};
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    47
/*****************************************************************************/
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    48
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    49
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
    50
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    51
    static unsigned int counter = 0;
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    52
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    53
#ifdef ASYNC
112
eec7639c7be9 Feldregistrierung: NULL als data_ptr m?glich, field_count 0 = 1.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
    54
    // Prozessdaten empfangen
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    55
    ecrt_master_async_receive(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    56
    ecrt_domain_process(domain1);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    57
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    58
    // Prozessdaten verarbeiten
117
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    59
    //k_pos   = EC_READ_U32(r_ssi_input);
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    60
    //k_stat  = EC_READ_U8(r_ssi_status);
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    61
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    62
    // Prozessdaten senden
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    63
    ecrt_domain_queue(domain1);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    64
    ecrt_master_async_send(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    65
#else
112
eec7639c7be9 Feldregistrierung: NULL als data_ptr m?glich, field_count 0 = 1.
Florian Pose <fp@igh-essen.com>
parents: 111
diff changeset
    66
    // Prozessdaten senden und empfangen
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    67
    ecrt_domain_queue(domain1);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    68
    ecrt_master_sync_io(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    69
    ecrt_domain_process(domain1);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    70
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    71
    // Prozessdaten verarbeiten
117
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    72
    //k_pos   = EC_READ_U32(r_ssi_input);
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    73
    //k_stat  = EC_READ_U8(r_ssi_status);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    74
#endif
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    75
68
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    76
    if (counter) {
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    77
        counter--;
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    78
    }
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    79
    else {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    80
        counter = ABTASTFREQUENZ;
117
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    81
        //printk(KERN_INFO "k_pos    = %i\n", k_pos);
b9976a5281e0 Neue Mini-Konfiguration.
Florian Pose <fp@igh-essen.com>
parents: 116
diff changeset
    82
        //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
    83
    }
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
    84
62
0fb2a690f4d0 Kleinere Korrekturen an rt und mini.
Florian Pose <fp@igh-essen.com>
parents: 61
diff changeset
    85
    // Timer neu starten
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
    86
    timer.expires += HZ / ABTASTFREQUENZ;
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    87
    add_timer(&timer);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
}
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    89
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
    90
/*****************************************************************************/
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
    91
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
    92
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
    93
{
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    94
    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
    95
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
    96
    if ((master = ecrt_request_master(0)) == NULL) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
    97
        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
    98
        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
    99
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   100
109
c6766baead5e Bugfix: EXPORT_SYMBOL f?r ec_master_prepare_async_io() vergessen.
Florian Pose <fp@igh-essen.com>
parents: 106
diff changeset
   101
    ecrt_master_print(master);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   102
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   103
    printk(KERN_INFO "Registering domain...\n");
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   104
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   105
    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
   106
    {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   107
        printk(KERN_ERR "Domain creation failed!\n");
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   108
        goto out_release_master;
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   109
    }
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   110
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   111
    printk(KERN_INFO "Registering domain fields...\n");
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   112
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   113
    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
   114
        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
   115
        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
   116
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   117
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 68
diff changeset
   118
    printk(KERN_INFO "Activating master...\n");
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents: 62
diff changeset
   119
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   120
    if (ecrt_master_activate(master)) {
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   121
        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
   122
        goto out_release_master;
a452700db994 Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents: 65
diff changeset
   123
    }
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents: 62
diff changeset
   124
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   125
    if (ecrt_master_fetch_sdo_lists(master)) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   126
        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
   127
        goto out_deactivate;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   128
    }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   129
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   130
    //ecrt_master_debug(master, 2);
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   131
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
   132
#if 0
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   133
    if (!(slave = ecrt_master_get_slave(master, "5"))) {
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   134
        printk(KERN_ERR "Failed to get slave 5!\n");
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   135
        goto out_deactivate;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   136
    }
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   137
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   138
    if (ecrt_slave_sdo_write_exp8(slave, 0x4061, 1,  0) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   139
        ecrt_slave_sdo_write_exp8(slave, 0x4061, 2,  1) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   140
        ecrt_slave_sdo_write_exp8(slave, 0x4061, 3,  1) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   141
        ecrt_slave_sdo_write_exp8(slave, 0x4066, 0,  0) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   142
        ecrt_slave_sdo_write_exp8(slave, 0x4067, 0,  4) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   143
        ecrt_slave_sdo_write_exp8(slave, 0x4068, 0,  0) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   144
        ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   145
        ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) ||
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   146
        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
   147
        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
   148
        goto out_deactivate;
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   149
    }
130
69c2645300ee Watch-Kommando
Florian Pose <fp@igh-essen.com>
parents: 117
diff changeset
   150
#endif
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   151
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   152
    //ecrt_master_debug(master, 0);
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   153
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   154
#if 0
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   155
    printk(KERN_INFO "Writing alias...\n");
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   156
    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
   157
        printk(KERN_ERR "Failed to write alias!\n");
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   158
        goto out_deactivate;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   159
    }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   160
#endif
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 112
diff changeset
   161
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   162
#ifdef ASYNC
106
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   163
    // Einmal senden und warten...
d6679c77ad3f ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   164
    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
   165
#endif
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   166
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   167
    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
   168
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   169
    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
   170
    timer.function = run;
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   171
    timer.expires = jiffies + 10; // Das erste Mal sofort feuern
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   172
    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
   173
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   174
    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
   175
    return 0;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   176
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   177
 out_deactivate:
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   178
    ecrt_master_deactivate(master);
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   179
 out_release_master:
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   180
    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
   181
 out_return:
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 109
diff changeset
   182
    return -1;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
60
2d2b120ba734 Neue Schnittstellen in Mini ?bertragen.
Florian Pose <fp@igh-essen.com>
parents: 57
diff changeset
   185
/*****************************************************************************/
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   186
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   187
void __exit cleanup_mini_module(void)
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
{
26
60435f959e5c Serial-Debugger entfernt.
Florian Pose <fp@igh-essen.com>
parents: 24
diff changeset
   189
    printk(KERN_INFO "=== Stopping Minimal EtherCAT environment... ===\n");
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 130
diff changeset
   191
    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
   192
        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
   193
        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
   194
        ecrt_master_deactivate(master);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 98
diff changeset
   195
        ecrt_release_master(master);
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   196
    }
22
e8c2cd004e0b Portierung der Module in drivers/ und mini/ nach Kernel 2.6.
Florian Pose <fp@igh-essen.com>
parents: 13
diff changeset
   197
26
60435f959e5c Serial-Debugger entfernt.
Florian Pose <fp@igh-essen.com>
parents: 24
diff changeset
   198
    printk(KERN_INFO "=== Minimal EtherCAT environment stopped. ===\n");
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
/*****************************************************************************/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
MODULE_LICENSE("GPL");
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
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
   205
MODULE_DESCRIPTION ("EtherCAT minimal test environment");
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   207
module_init(init_mini_module);
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 47
diff changeset
   208
module_exit(cleanup_mini_module);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
/*****************************************************************************/
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   211
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   212
/* Emacs-Konfiguration
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   213
;;; Local Variables: ***
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   214
;;; c-basic-offset:4 ***
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   215
;;; End: ***
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 36
diff changeset
   216
*/