31 #include "msr_param.h" |
31 #include "msr_param.h" |
32 #include "msr_jitter.h" |
32 #include "msr_jitter.h" |
33 |
33 |
34 // EtherCAT |
34 // EtherCAT |
35 #include "../include/EtherCAT_rt.h" |
35 #include "../include/EtherCAT_rt.h" |
36 #include "../eclib/eclib.h" |
36 #include "../libec/libec.h" |
37 |
37 |
38 // Defines/Makros |
38 // Defines/Makros |
39 #define TSC2US(T1, T2) ((T2 - T1) * 1000UL / cpu_khz) |
39 #define TSC2US(T1, T2) ((T2 - T1) * 1000UL / cpu_khz) |
40 #define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ) |
40 #define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ) |
41 |
41 |
49 // Adeos |
49 // Adeos |
50 static struct ipipe_domain this_domain; |
50 static struct ipipe_domain this_domain; |
51 static struct ipipe_sysinfo sys_info; |
51 static struct ipipe_sysinfo sys_info; |
52 |
52 |
53 // EtherCAT |
53 // EtherCAT |
54 |
|
55 ec_master_t *master = NULL; |
54 ec_master_t *master = NULL; |
56 static unsigned int ecat_bus_time = 0; |
|
57 static unsigned int ecat_timeouts = 0; |
|
58 |
|
59 ec_slave_t *s_in1, *s_out1, *s_out2, *s_out3; |
55 ec_slave_t *s_in1, *s_out1, *s_out2, *s_out3; |
60 |
56 |
61 double value; |
57 double value; |
62 int dig1; |
58 int dig1; |
63 |
59 |
88 if (counter) { |
84 if (counter) { |
89 counter--; |
85 counter--; |
90 } |
86 } |
91 else { |
87 else { |
92 // "Star Trek"-Effekte |
88 // "Star Trek"-Effekte |
93 *((unsigned char *) s_out1->process_data) = jiffies; |
89 LEC_write_EL20XX(s_out1, 0, jiffies & 1); |
94 *((unsigned char *) s_out2->process_data) = jiffies >> 4; |
90 LEC_write_EL20XX(s_out1, 1, (jiffies >> 1) & 1); |
95 *((unsigned char *) s_out3->process_data) = jiffies >> 8; |
91 LEC_write_EL20XX(s_out1, 2, (jiffies >> 2) & 1); |
|
92 LEC_write_EL20XX(s_out1, 3, (jiffies >> 3) & 1); |
|
93 LEC_write_EL20XX(s_out2, 0, (jiffies >> 4) & 1); |
|
94 LEC_write_EL20XX(s_out2, 1, (jiffies >> 3) & 1); |
|
95 LEC_write_EL20XX(s_out2, 2, (jiffies >> 2) & 1); |
|
96 LEC_write_EL20XX(s_out2, 3, (jiffies >> 6) & 1); |
|
97 LEC_write_EL20XX(s_out3, 0, (jiffies >> 7) & 1); |
|
98 LEC_write_EL20XX(s_out3, 1, (jiffies >> 2) & 1); |
|
99 LEC_write_EL20XX(s_out3, 2, (jiffies >> 8) & 1); |
96 |
100 |
97 counter = MSR_ABTASTFREQUENZ / 4; |
101 counter = MSR_ABTASTFREQUENZ / 4; |
98 } |
102 } |
99 |
103 |
100 if (((char *) s_in1->process_data)[2] < 0) |
104 LEC_write_EL20XX(s_out3, 3, LEC_read_EL31XX(s_in1, 0) < 0); |
101 ((unsigned char *) s_out3->process_data)[0] |= 8; |
|
102 else |
|
103 ((unsigned char *) s_out3->process_data)[0] &= ~8; |
|
104 |
|
105 |
105 |
106 // Prozessdaten lesen und schreiben |
106 // Prozessdaten lesen und schreiben |
107 EtherCAT_rt_domain_xio(master, 0, 40); |
107 EtherCAT_rt_domain_xio(master, 0, 40); |
108 } |
108 } |
109 |
109 |
165 |
165 |
166 int msr_globals_register(void) |
166 int msr_globals_register(void) |
167 { |
167 { |
168 msr_reg_kanal("/value", "V", &value, TDBL); |
168 msr_reg_kanal("/value", "V", &value, TDBL); |
169 msr_reg_kanal("/dig1", "", &dig1, TINT); |
169 msr_reg_kanal("/dig1", "", &dig1, TINT); |
170 |
|
171 msr_reg_kanal("/Taskinfo/EtherCAT/BusTime", "us", &ecat_bus_time, TUINT); |
|
172 msr_reg_kanal("/Taskinfo/EtherCAT/Timeouts", "", &ecat_timeouts, TUINT); |
|
173 |
170 |
174 return 0; |
171 return 0; |
175 } |
172 } |
176 |
173 |
177 /****************************************************************************** |
174 /****************************************************************************** |