author | Florian Pose <fp@igh-essen.com> |
Mon, 10 Apr 2006 14:25:02 +0000 | |
changeset 178 | b84f69db8566 |
parent 170 | 357dd6f677fd |
permissions | -rw-r--r-- |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
1 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
2 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
3 |
* msr_module.c |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
4 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
5 |
* Kernelmodul für 2.6 Kernel zur Meßdatenerfassung, Steuerung und Regelung. |
47
ad5f969f263b
Prozessdatentimeout, Buszeit und weniger Klemmen.
Florian Pose <fp@igh-essen.com>
parents:
45
diff
changeset
|
6 |
* |
ad5f969f263b
Prozessdatentimeout, Buszeit und weniger Klemmen.
Florian Pose <fp@igh-essen.com>
parents:
45
diff
changeset
|
7 |
* Autor: Wilhelm Hagemeister, Florian Pose |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
8 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
9 |
* (C) Copyright IgH 2002 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
10 |
* Ingenieurgemeinschaft IgH |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
11 |
* Heinz-Bäcker Str. 34 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
12 |
* D-45356 Essen |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
13 |
* Tel.: +49 201/61 99 31 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
14 |
* Fax.: +49 201/61 98 36 |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
15 |
* E-mail: hm@igh-essen.com |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
16 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
17 |
* $Id$ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
18 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
19 |
*****************************************************************************/ |
28 | 20 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
21 |
// Linux |
28 | 22 |
#include <linux/module.h> |
23 |
#include <linux/ipipe.h> |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
24 |
#include <linux/slab.h> |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
25 |
#include <linux/vmalloc.h> |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
26 |
#include <linux/delay.h> |
28 | 27 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
28 |
// RT_lib |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
29 |
#include <msr_main.h> |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
30 |
#include <msr_utils.h> |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
31 |
#include <msr_messages.h> |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
32 |
#include <msr_float.h> |
28 | 33 |
#include <msr_reg.h> |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
34 |
#include <msr_time.h> |
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
35 |
#include "msr_param.h" |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
36 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
37 |
// EtherCAT |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
38 |
#include "../include/ecrt.h" |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
39 |
|
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
40 |
#define ASYNC |
28 | 41 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
42 |
// Defines/Makros |
47
ad5f969f263b
Prozessdatentimeout, Buszeit und weniger Klemmen.
Florian Pose <fp@igh-essen.com>
parents:
45
diff
changeset
|
43 |
#define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ) |
28 | 44 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
45 |
/*****************************************************************************/ |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
46 |
/* Globale Variablen */ |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
47 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
48 |
// Adeos |
28 | 49 |
static struct ipipe_domain this_domain; |
50 |
static struct ipipe_sysinfo sys_info; |
|
51 |
||
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
52 |
// EtherCAT |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
53 |
ec_master_t *master = NULL; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
54 |
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
|
55 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
56 |
// Prozessdaten |
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
57 |
void *r_ssi; |
170 | 58 |
void *r_ssi_st; |
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
59 |
|
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
60 |
// KanŽäle |
170 | 61 |
uint32_t k_ssi; |
62 |
uint32_t k_ssi_st; |
|
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
63 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
64 |
ec_field_init_t domain1_fields[] = { |
170 | 65 |
{&r_ssi, "5", "Beckhoff", "EL5001", "InputValue", 0}, |
66 |
{&r_ssi_st, "5", "Beckhoff", "EL5001", "Status", 0}, |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
67 |
{} |
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
68 |
}; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
69 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
70 |
/*****************************************************************************/ |
28 | 71 |
|
72 |
static void msr_controller_run(void) |
|
73 |
{ |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
74 |
#ifdef ASYNC |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
75 |
// Empfangen |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
76 |
ecrt_master_async_receive(master); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
77 |
ecrt_domain_process(domain1); |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
78 |
#else |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
79 |
// Senden und empfangen |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
80 |
ecrt_domain_queue(domain1); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
142
diff
changeset
|
81 |
ecrt_master_run(master); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
82 |
ecrt_master_sync_io(master); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
83 |
ecrt_domain_process(domain1); |
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
84 |
#endif |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
85 |
|
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
86 |
// Prozessdaten verarbeiten |
170 | 87 |
k_ssi = EC_READ_U32(r_ssi); |
88 |
k_ssi_st = EC_READ_U8 (r_ssi_st); |
|
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
89 |
|
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
90 |
#ifdef ASYNC |
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
91 |
// Senden |
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
92 |
ecrt_domain_queue(domain1); |
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
93 |
ecrt_master_run(master); |
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
94 |
ecrt_master_async_send(master); |
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
95 |
#endif |
82
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
96 |
} |
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
97 |
|
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
98 |
/*****************************************************************************/ |
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
99 |
|
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
100 |
int msr_globals_register(void) |
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
101 |
{ |
170 | 102 |
msr_reg_kanal("/ssi_position", "", &k_ssi, TUINT); |
103 |
msr_reg_kanal("/ssi_status", "", &k_ssi_st, TUINT); |
|
82
30d0708229b9
Buskoppler werden jetzt gesondert behandelt.
Florian Pose <fp@igh-essen.com>
parents:
81
diff
changeset
|
104 |
return 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
105 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
106 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
107 |
/*****************************************************************************/ |
28 | 108 |
|
109 |
void msr_run(unsigned irq) |
|
110 |
{ |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
111 |
static int counter = 0; |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
112 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
113 |
MSR_ADEOS_INTERRUPT_CODE(msr_controller_run(); msr_write_kanal_list();); |
28 | 114 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
115 |
ipipe_control_irq(irq, 0, IPIPE_ENABLE_MASK); // Interrupt bestŽätigen |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
116 |
if (++counter >= HZREDUCTION) { |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
117 |
ipipe_propagate_irq(irq); // und weiterreichen |
28 | 118 |
counter = 0; |
119 |
} |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
120 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
121 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
122 |
/*****************************************************************************/ |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
123 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
124 |
void domain_entry(void) |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
125 |
{ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
126 |
printk("Domain %s started.\n", ipipe_current_domain->name); |
28 | 127 |
|
128 |
ipipe_get_sysinfo(&sys_info); |
|
129 |
ipipe_virtualize_irq(ipipe_current_domain,sys_info.archdep.tmirq, |
|
130 |
&msr_run, NULL, IPIPE_HANDLE_MASK); |
|
131 |
||
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
132 |
ipipe_tune_timer(1000000000UL / MSR_ABTASTFREQUENZ, 0); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
133 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
134 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
135 |
/*****************************************************************************/ |
28 | 136 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
137 |
int __init init_rt_module(void) |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
138 |
{ |
28 | 139 |
struct ipipe_domain_attr attr; //ipipe |
170 | 140 |
#if 1 |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
141 |
ec_slave_t *slave; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
142
diff
changeset
|
142 |
#endif |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
143 |
|
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
144 |
// Als allererstes die RT-Lib initialisieren |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
145 |
if (msr_rtlib_init(1, MSR_ABTASTFREQUENZ, 10, &msr_globals_register) < 0) { |
28 | 146 |
msr_print_warn("msr_modul: can't initialize rtlib!"); |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
147 |
goto out_return; |
28 | 148 |
} |
149 |
||
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
150 |
if ((master = ecrt_request_master(0)) == NULL) { |
158 | 151 |
printk(KERN_ERR "Failed to request master 0!\n"); |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
152 |
goto out_msr_cleanup; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
153 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
154 |
|
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
155 |
//ecrt_master_print(master, 2); |
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
156 |
|
158 | 157 |
printk(KERN_INFO "Creating domains...\n"); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
158 |
if (!(domain1 = ecrt_master_create_domain(master))) { |
158 | 159 |
printk(KERN_ERR "Failed to create domains!\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
160 |
goto out_release_master; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
161 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
162 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
163 |
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
|
164 |
if (ecrt_domain_register_field_list(domain1, domain1_fields)) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
165 |
printk(KERN_ERR "Failed to register domain fields.\n"); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
166 |
goto out_release_master; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
167 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
168 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
169 |
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
|
170 |
if (ecrt_master_activate(master)) { |
80
8cd08d73b560
CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
171 |
printk(KERN_ERR "Could not activate master!\n"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
172 |
goto out_release_master; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
173 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
174 |
|
158 | 175 |
#if 0 |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
176 |
if (ecrt_master_fetch_sdo_lists(master)) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
177 |
printk(KERN_ERR "Failed to fetch SDO lists!\n"); |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
178 |
goto out_deactivate; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
179 |
} |
140
b09658e50d6f
Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
180 |
ecrt_master_print(master, 2); |
b09658e50d6f
Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
181 |
#else |
142 | 182 |
ecrt_master_print(master, 1); |
140
b09658e50d6f
Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
183 |
#endif |
b09658e50d6f
Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
184 |
|
170 | 185 |
#if 1 |
186 |
if (!(slave = ecrt_master_get_slave(master, "5"))) { |
|
187 |
printk(KERN_ERR "Failed to get slave!\n"); |
|
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
188 |
goto out_deactivate; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
189 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
190 |
|
170 | 191 |
if ( |
192 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 1, 1) || // disable frame error bit |
|
193 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 2, 0) || // power failure bit |
|
194 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 3, 1) || // inhibit time |
|
195 |
ecrt_slave_sdo_write_exp8(slave, 0x4061, 4, 0) || // test mode |
|
196 |
ecrt_slave_sdo_write_exp8(slave, 0x4066, 0, 1) || // dualcode |
|
197 |
ecrt_slave_sdo_write_exp8(slave, 0x4067, 0, 5) || // 125kbaud |
|
198 |
ecrt_slave_sdo_write_exp8(slave, 0x4068, 0, 0) || // single-turn |
|
199 |
ecrt_slave_sdo_write_exp8(slave, 0x4069, 0, 25) || // frame size |
|
200 |
ecrt_slave_sdo_write_exp8(slave, 0x406A, 0, 25) || // data length |
|
201 |
ecrt_slave_sdo_write_exp16(slave, 0x406B, 0, 30000) // inhibit time in us |
|
202 |
) { |
|
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
203 |
printk(KERN_ERR "Failed to configure SSI slave!\n"); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
204 |
goto out_deactivate; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
205 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
206 |
#endif |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
207 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
208 |
#ifdef ASYNC |
106
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
209 |
// Einmal senden und warten... |
d6679c77ad3f
ecrt_master_prepare_async_io() hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
210 |
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
|
211 |
#endif |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
212 |
|
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
213 |
ipipe_init_attr(&attr); |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
214 |
attr.name = "IPIPE-MSR-MODULE"; |
28 | 215 |
attr.priority = IPIPE_ROOT_PRIO + 1; |
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
216 |
attr.entry = &domain_entry; |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
217 |
ipipe_register_domain(&this_domain, &attr); |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
218 |
return 0; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
219 |
|
170 | 220 |
#if 1 |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
221 |
out_deactivate: |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
112
diff
changeset
|
222 |
ecrt_master_deactivate(master); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
142
diff
changeset
|
223 |
#endif |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
224 |
out_release_master: |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
225 |
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
|
226 |
out_msr_cleanup: |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
227 |
msr_rtlib_cleanup(); |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
228 |
out_return: |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
229 |
return -1; |
28 | 230 |
} |
231 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
232 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
233 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
234 |
void __exit cleanup_rt_module(void) |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
235 |
{ |
28 | 236 |
msr_print_info("msk_modul: unloading..."); |
237 |
||
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
238 |
ipipe_tune_timer(1000000000UL / HZ, 0); //alten Timertakt wieder herstellen |
28 | 239 |
ipipe_unregister_domain(&this_domain); |
240 |
||
156
43d7d714679f
Plugfest: rt und mini angepasst.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
241 |
if (master) { |
43 | 242 |
printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n"); |
243 |
||
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
244 |
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
|
245 |
ecrt_master_deactivate(master); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
98
diff
changeset
|
246 |
ecrt_release_master(master); |
43 | 247 |
|
248 |
printk(KERN_INFO "=== EtherCAT environment stopped. ===\n"); |
|
249 |
} |
|
28 | 250 |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
251 |
msr_rtlib_cleanup(); |
28 | 252 |
} |
253 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
254 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
255 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
256 |
#define EC_LIT(X) #X |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
257 |
#define EC_STR(X) EC_LIT(X) |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
258 |
#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
|
259 |
", compiled by " EC_STR(USER) \ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
260 |
" at " __DATE__ " " __TIME__ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
261 |
|
28 | 262 |
MODULE_LICENSE("GPL"); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
263 |
MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>"); |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
264 |
MODULE_DESCRIPTION ("EtherCAT real-time test environment"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
265 |
MODULE_VERSION(COMPILE_INFO); |
28 | 266 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
267 |
module_init(init_rt_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
268 |
module_exit(cleanup_rt_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
269 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
270 |
/*****************************************************************************/ |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
271 |
|
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
272 |
/* Emacs-Konfiguration |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
273 |
;;; Local Variables: *** |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
274 |
;;; c-basic-offset:4 *** |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
275 |
;;; End: *** |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
276 |
*/ |