author | Florian Pose <fp@igh-essen.com> |
Wed, 22 Feb 2006 17:36:28 +0000 | |
changeset 72 | 7c986b717411 |
parent 68 | a452700db994 |
child 73 | 9f4ea66d89a3 |
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> |
|
24 |
||
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
25 |
// RT_lib |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
26 |
#include <msr_main.h> |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
27 |
#include <msr_utils.h> |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
28 |
#include <msr_messages.h> |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
29 |
#include <msr_float.h> |
28 | 30 |
#include <msr_reg.h> |
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
31 |
#include "msr_param.h" |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
32 |
#include "msr_jitter.h" |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
33 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
34 |
// EtherCAT |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
35 |
#include "../include/EtherCAT_rt.h" |
59
c8bd4fe3b38c
EtherCAT-Slave-Interface als Makros implementiert.
Florian Pose <fp@igh-essen.com>
parents:
57
diff
changeset
|
36 |
#include "../include/EtherCAT_si.h" |
28 | 37 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
38 |
// Defines/Makros |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
39 |
#define TSC2US(T1, T2) ((T2 - T1) * 1000UL / cpu_khz) |
47
ad5f969f263b
Prozessdatentimeout, Buszeit und weniger Klemmen.
Florian Pose <fp@igh-essen.com>
parents:
45
diff
changeset
|
40 |
#define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ) |
28 | 41 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
42 |
/*****************************************************************************/ |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
43 |
/* Globale Variablen */ |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
44 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
45 |
// RT_lib |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
46 |
extern struct timeval process_time; |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
47 |
struct timeval msr_time_increment; // Increment per Interrupt |
28 | 48 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
49 |
// Adeos |
28 | 50 |
static struct ipipe_domain this_domain; |
51 |
static struct ipipe_sysinfo sys_info; |
|
52 |
||
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
53 |
// EtherCAT |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
54 |
ec_master_t *master = NULL; |
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
55 |
ec_slave_t *s_in1, *s_out1, *s_ssi, *s_inc; |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
56 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
57 |
uint16_t angle0; |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
58 |
|
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
59 |
ec_slave_init_t slaves[] = { |
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
60 |
{&s_in1, "1", "Beckhoff", "EL3102", 0}, |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
61 |
{&s_out1, "2", "Beckhoff", "EL2004", 0}, |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
62 |
{&s_ssi, "3", "Beckhoff", "EL5001", 0}, |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
63 |
{&s_inc, "0:4", "Beckhoff", "EL5101", 0} |
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
64 |
}; |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
65 |
|
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
66 |
#define SLAVE_COUNT (sizeof(slaves) / sizeof(ec_slave_init_t)) |
28 | 67 |
|
68 |
/****************************************************************************** |
|
69 |
* |
|
70 |
* Function: msr_controller_run() |
|
71 |
* |
|
72 |
*****************************************************************************/ |
|
73 |
||
74 |
static void msr_controller_run(void) |
|
75 |
{ |
|
56
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
76 |
static unsigned int counter = 0; |
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
77 |
|
28 | 78 |
msr_jitter_run(MSR_ABTASTFREQUENZ); |
79 |
||
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
80 |
EC_WRITE_EL20XX(s_out1, 3, EC_READ_EL31XX(s_in1, 0) < 0); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
81 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
82 |
if (!counter) { |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
83 |
EtherCAT_rt_debug_level(master, 2); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
84 |
} |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
85 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
86 |
// Prozessdaten lesen und schreiben |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
87 |
EtherCAT_rt_domain_xio(master, 0, 40); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
88 |
|
56
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
89 |
if (counter) { |
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
90 |
counter--; |
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
91 |
} |
36d1fa37f5e1
Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
92 |
else { |
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
93 |
EtherCAT_rt_debug_level(master, 0); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
94 |
printk("SSI status=0x%X value=%u\n", |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
95 |
EC_READ_EL5001_STATE(s_ssi), EC_READ_EL5001_VALUE(s_ssi)); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
96 |
printk("INC status=0x%X value=%u\n", |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
97 |
EC_READ_EL5101_STATE(s_inc), EC_READ_EL5101_VALUE(s_inc)); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
98 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
99 |
counter = MSR_ABTASTFREQUENZ * 5; |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
100 |
} |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
101 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
102 |
angle0 = EC_READ_EL5101_VALUE(s_inc); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
103 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
104 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
105 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
106 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
107 |
* Function: msr_run(_interrupt) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
108 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
109 |
* Beschreibung: Routine wird zyklisch im Timerinterrupt ausgeführt |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
110 |
* (hier muß alles rein, was Echtzeit ist ...) |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
111 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
112 |
* Parameter: Zeiger auf msr_data |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
113 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
114 |
* Rückgabe: |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
115 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
116 |
* Status: exp |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
117 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
118 |
*****************************************************************************/ |
28 | 119 |
|
120 |
void msr_run(unsigned irq) |
|
121 |
{ |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
122 |
static int counter = 0; |
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 |
timeval_add(&process_time, &process_time, &msr_time_increment); |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
125 |
MSR_ADEOS_INTERRUPT_CODE(msr_controller_run(); msr_write_kanal_list();); |
28 | 126 |
|
40 | 127 |
ipipe_control_irq(irq,0,IPIPE_ENABLE_MASK); //Interrupt bestŽätigen |
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
128 |
if (counter++ > HZREDUCTION) { |
40 | 129 |
ipipe_propagate_irq(irq); //und weiterreichen |
28 | 130 |
counter = 0; |
131 |
} |
|
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
132 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
133 |
|
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
134 |
/*****************************************************************************/ |
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
135 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
136 |
void domain_entry(void) |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
137 |
{ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
138 |
printk("Domain %s started.\n", ipipe_current_domain->name); |
28 | 139 |
|
140 |
ipipe_get_sysinfo(&sys_info); |
|
141 |
ipipe_virtualize_irq(ipipe_current_domain,sys_info.archdep.tmirq, |
|
142 |
&msr_run, NULL, IPIPE_HANDLE_MASK); |
|
143 |
||
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
144 |
ipipe_tune_timer(1000000000UL / MSR_ABTASTFREQUENZ, 0); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
145 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
146 |
|
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
147 |
/****************************************************************************** |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
148 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
149 |
* Function: msr_register_channels |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
150 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
151 |
* Beschreibung: KanŽäle registrieren |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
152 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
153 |
* Parameter: |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
154 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
155 |
* RŽückgabe: |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
156 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
157 |
* Status: exp |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
158 |
* |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
159 |
*****************************************************************************/ |
28 | 160 |
|
161 |
int msr_globals_register(void) |
|
162 |
{ |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
163 |
//msr_reg_kanal("/value", "V", &value, TDBL); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
164 |
//msr_reg_kanal("/dig1", "", &dig1, TINT); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
165 |
msr_reg_kanal("/angle0", "", &angle0, TINT); |
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
166 |
|
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
167 |
return 0; |
28 | 168 |
} |
169 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
170 |
/****************************************************************************** |
28 | 171 |
* the init/clean material |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
172 |
*****************************************************************************/ |
28 | 173 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
174 |
int __init init_rt_module(void) |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
175 |
{ |
28 | 176 |
struct ipipe_domain_attr attr; //ipipe |
177 |
||
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
178 |
// Als allererstes die RT-lib initialisieren |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
179 |
if (msr_rtlib_init(1,MSR_ABTASTFREQUENZ,10,&msr_globals_register) < 0) { |
28 | 180 |
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
|
181 |
goto out_return; |
28 | 182 |
} |
183 |
||
184 |
msr_jitter_init(); |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
185 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
186 |
printk(KERN_INFO "=== Starting 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
|
187 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
188 |
if ((master = EtherCAT_rt_request_master(0)) == NULL) { |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
189 |
printk(KERN_ERR "Error requesting 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
|
190 |
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
|
191 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
192 |
|
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
193 |
if (EtherCAT_rt_register_slave_list(master, slaves, SLAVE_COUNT)) { |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
194 |
printk(KERN_ERR "EtherCAT: Could not register slaves!\n"); |
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
195 |
goto out_release_master; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
196 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
197 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
198 |
if (EtherCAT_rt_activate_slaves(master) < 0) { |
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
199 |
printk(KERN_ERR "EtherCAT: Could not activate slaves!\n"); |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
200 |
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
|
201 |
} |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
202 |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
203 |
if (EtherCAT_rt_canopen_sdo_write(master, s_ssi, 0x4067, 0, 1, 2)) { |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
204 |
printk(KERN_ERR "EtherCAT: Could not set SSI baud rate!\n"); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
205 |
goto out_release_master; |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
206 |
} |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
207 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
208 |
if (EtherCAT_rt_canopen_sdo_write(master, s_ssi, 0x4061, 4, 1, 1)) { |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
209 |
printk(KERN_ERR "EtherCAT: Could not set SSI feature bit!\n"); |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
210 |
goto out_release_master; |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
211 |
} |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
62
diff
changeset
|
212 |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
213 |
do_gettimeofday(&process_time); |
61
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
214 |
msr_time_increment.tv_sec = 0; |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
215 |
msr_time_increment.tv_usec = (unsigned int) (1000000 / MSR_ABTASTFREQUENZ); |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
216 |
|
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
217 |
ipipe_init_attr(&attr); |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
218 |
attr.name = "IPIPE-MSR-MODULE"; |
28 | 219 |
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
|
220 |
attr.entry = &domain_entry; |
cd014255f94f
register_slave_list() und Bugfix in deactivate_slaves()
Florian Pose <fp@igh-essen.com>
parents:
59
diff
changeset
|
221 |
ipipe_register_domain(&this_domain, &attr); |
28 | 222 |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
223 |
return 0; |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
224 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
225 |
out_release_master: |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
226 |
EtherCAT_rt_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
|
227 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
228 |
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
|
229 |
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
|
230 |
|
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
231 |
out_return: |
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
232 |
return -1; |
28 | 233 |
} |
234 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
235 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
236 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
237 |
void __exit cleanup_rt_module(void) |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
238 |
{ |
28 | 239 |
msr_print_info("msk_modul: unloading..."); |
240 |
||
45
f525f7db2d90
Verbesserte Makefiles (MODPOST-Warnungen entfernt).
Florian Pose <fp@igh-essen.com>
parents:
43
diff
changeset
|
241 |
ipipe_tune_timer(1000000000UL / HZ, 0); //alten Timertakt wieder herstellen |
28 | 242 |
ipipe_unregister_domain(&this_domain); |
243 |
||
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
244 |
if (master) |
28 | 245 |
{ |
43 | 246 |
printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n"); |
247 |
||
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
248 |
printk(KERN_INFO "Deactivating slaves.\n"); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
249 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
250 |
if (EtherCAT_rt_deactivate_slaves(master) < 0) { |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
251 |
printk(KERN_WARNING "Warning - Could not deactivate slaves!\n"); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
252 |
} |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
253 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
254 |
EtherCAT_rt_release_master(master); |
43 | 255 |
|
256 |
printk(KERN_INFO "=== EtherCAT environment stopped. ===\n"); |
|
257 |
} |
|
28 | 258 |
|
36
6e9de6fbf74c
EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents:
33
diff
changeset
|
259 |
msr_rtlib_cleanup(); |
28 | 260 |
} |
261 |
||
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
262 |
/*****************************************************************************/ |
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
40
diff
changeset
|
263 |
|
28 | 264 |
MODULE_LICENSE("GPL"); |
265 |
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>"); |
|
266 |
MODULE_DESCRIPTION ("EtherCAT test environment"); |
|
267 |
||
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
268 |
module_init(init_rt_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
269 |
module_exit(cleanup_rt_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
270 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
51
diff
changeset
|
271 |
/*****************************************************************************/ |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
272 |
|
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
273 |
/* Emacs-Konfiguration |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
274 |
;;; Local Variables: *** |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
275 |
;;; c-basic-offset:4 *** |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
276 |
;;; End: *** |
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
277 |
*/ |