equal
deleted
inserted
replaced
39 #include "../../include/ecrt.h" // EtherCAT realtime interface |
39 #include "../../include/ecrt.h" // EtherCAT realtime interface |
40 #include "../../include/ecdb.h" // EtherCAT slave database |
40 #include "../../include/ecdb.h" // EtherCAT slave database |
41 |
41 |
42 #define FREQUENCY 100 |
42 #define FREQUENCY 100 |
43 |
43 |
44 #define KBUS |
44 //#define KBUS |
45 |
45 |
46 /*****************************************************************************/ |
46 /*****************************************************************************/ |
47 |
47 |
48 struct timer_list timer; |
48 struct timer_list timer; |
49 |
49 |
56 #ifdef KBUS |
56 #ifdef KBUS |
57 void *r_inputs; |
57 void *r_inputs; |
58 void *r_outputs; |
58 void *r_outputs; |
59 #endif |
59 #endif |
60 |
60 |
61 void *r_ana_in; |
61 void *r_dig_out; |
62 |
62 |
63 #if 1 |
63 #if 1 |
64 ec_pdo_reg_t domain1_pdos[] = { |
64 ec_pdo_reg_t domain1_pdos[] = { |
65 {"2", Beckhoff_EL3102_Input1, &r_ana_in}, |
65 {"2", Beckhoff_EL2004_Outputs, &r_dig_out}, |
66 {} |
66 {} |
67 }; |
67 }; |
68 #endif |
68 #endif |
69 |
69 |
70 /*****************************************************************************/ |
70 /*****************************************************************************/ |
80 ecrt_domain_process(domain1); |
80 ecrt_domain_process(domain1); |
81 spin_unlock(&master_lock); |
81 spin_unlock(&master_lock); |
82 |
82 |
83 // process data |
83 // process data |
84 // k_pos = EC_READ_U32(r_ssi); |
84 // k_pos = EC_READ_U32(r_ssi); |
|
85 EC_WRITE_U8(r_dig_out, blink ? 0x0F : 0x00); |
85 |
86 |
86 if (counter) { |
87 if (counter) { |
87 counter--; |
88 counter--; |
88 } |
89 } |
89 else { |
90 else { |
96 #endif |
97 #endif |
97 |
98 |
98 // send |
99 // send |
99 spin_lock(&master_lock); |
100 spin_lock(&master_lock); |
100 ecrt_domain_queue(domain1); |
101 ecrt_domain_queue(domain1); |
|
102 spin_unlock(&master_lock); |
|
103 |
101 ecrt_master_run(master); |
104 ecrt_master_run(master); |
|
105 |
|
106 spin_lock(&master_lock); |
102 ecrt_master_send(master); |
107 ecrt_master_send(master); |
103 spin_unlock(&master_lock); |
108 spin_unlock(&master_lock); |
104 |
109 |
105 // restart timer |
110 // restart timer |
106 timer.expires += HZ / FREQUENCY; |
111 timer.expires += HZ / FREQUENCY; |
109 |
114 |
110 /*****************************************************************************/ |
115 /*****************************************************************************/ |
111 |
116 |
112 int request_lock(void *data) |
117 int request_lock(void *data) |
113 { |
118 { |
114 spin_lock_bh(&master_lock); |
119 spin_lock(&master_lock); |
115 return 0; // access allowed |
120 return 0; // access allowed |
116 } |
121 } |
117 |
122 |
118 /*****************************************************************************/ |
123 /*****************************************************************************/ |
119 |
124 |
120 void release_lock(void *data) |
125 void release_lock(void *data) |
121 { |
126 { |
122 spin_unlock_bh(&master_lock); |
127 spin_unlock(&master_lock); |
123 } |
128 } |
124 |
129 |
125 /*****************************************************************************/ |
130 /*****************************************************************************/ |
126 |
131 |
127 int __init init_mini_module(void) |
132 int __init init_mini_module(void) |
128 { |
133 { |
129 #if 1 |
134 #if 0 |
130 ec_slave_t *slave; |
135 ec_slave_t *slave; |
131 #endif |
136 #endif |
132 |
137 |
133 printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n"); |
138 printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n"); |
134 |
139 |
164 printk(KERN_ERR "PDO registration failed!\n"); |
169 printk(KERN_ERR "PDO registration failed!\n"); |
165 goto out_release_master; |
170 goto out_release_master; |
166 } |
171 } |
167 #endif |
172 #endif |
168 |
173 |
169 #if 1 |
174 #if 0 |
170 if (!(slave = ecrt_master_get_slave(master, "2"))) |
175 if (!(slave = ecrt_master_get_slave(master, "2"))) |
171 goto out_release_master; |
176 goto out_release_master; |
172 |
177 |
173 if (ecrt_slave_conf_sdo8(slave, 0x4061, 1, 0)) |
178 if (ecrt_slave_conf_sdo8(slave, 0x4061, 1, 0)) |
174 goto out_release_master; |
179 goto out_release_master; |