72 const ec_pdo_entry_info_t el3162_channel2[] = { |
73 const ec_pdo_entry_info_t el3162_channel2[] = { |
73 {0x3102, 1, 8}, // status |
74 {0x3102, 1, 8}, // status |
74 {0x3102, 2, 16} // value |
75 {0x3102, 2, 16} // value |
75 }; |
76 }; |
76 |
77 |
77 const ec_pdo_info_t mapping[] = { |
78 const ec_pdo_info_t el3162_mapping[] = { |
78 {EC_DIR_INPUT, 0x1A00, 2, el3162_channel1}, |
79 {EC_DIR_INPUT, 0x1A00, 2, el3162_channel1}, |
79 {EC_DIR_INPUT, 0x1A01, 2, el3162_channel2}, |
80 {EC_DIR_INPUT, 0x1A01, 2, el3162_channel2}, |
80 }; |
81 }; |
|
82 |
|
83 const ec_pdo_entry_info_t el2004_channels[] = { |
|
84 {0x3001, 1, 1}, // Value 1 |
|
85 {0x3001, 2, 1}, // Value 2 |
|
86 {0x3001, 3, 1}, // Value 3 |
|
87 {0x3001, 4, 1} // Value 4 |
|
88 }; |
|
89 |
|
90 const ec_pdo_info_t el2004_mapping[] = { |
|
91 {EC_DIR_OUTPUT, 0x1600, 1, &el2004_channels[0]}, |
|
92 {EC_DIR_OUTPUT, 0x1601, 1, &el2004_channels[1]}, |
|
93 {EC_DIR_OUTPUT, 0x1602, 1, &el2004_channels[2]}, |
|
94 {EC_DIR_OUTPUT, 0x1603, 1, &el2004_channels[3]}, |
|
95 }; |
81 #endif |
96 #endif |
82 |
97 |
83 #ifdef PDOS |
98 #ifdef PDOS |
84 static uint8_t off_ana_in; |
99 static uint8_t *pd; /**< Process data. */ |
85 //static uint8_t off_ana_out; |
100 static unsigned int off_ana_in; |
|
101 static unsigned int off_dig_out; |
86 |
102 |
87 const static ec_pdo_entry_reg_t domain1_regs[] = { |
103 const static ec_pdo_entry_reg_t domain1_regs[] = { |
88 {0, 1, Beckhoff_EL3162, 0x3101, 2, &off_ana_in}, |
104 {0, 1, Beckhoff_EL3162, 0x3101, 2, &off_ana_in}, |
89 //{0, 2, Beckhoff_EL4102, 0x3001, 1, &off_ana_out}, |
105 {0, 3, Beckhoff_EL2004, 0x3001, 1, &off_dig_out}, |
90 {} |
106 {} |
91 }; |
107 }; |
92 #endif |
108 #endif |
93 |
109 |
94 /*****************************************************************************/ |
110 /*****************************************************************************/ |
197 if (!(sc = ecrt_master_slave_config(master, 0, 1, Beckhoff_EL3162))) { |
215 if (!(sc = ecrt_master_slave_config(master, 0, 1, Beckhoff_EL3162))) { |
198 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
216 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
199 goto out_release_master; |
217 goto out_release_master; |
200 } |
218 } |
201 |
219 |
202 if (ecrt_slave_config_mapping(sc, 2, mapping)) { |
220 if (ecrt_slave_config_mapping(sc, 2, el3162_mapping)) { |
|
221 printk(KERN_ERR PFX "Failed to configure Pdo mapping.\n"); |
|
222 goto out_release_master; |
|
223 } |
|
224 |
|
225 if (!(sc = ecrt_master_slave_config(master, 0, 3, Beckhoff_EL2004))) { |
|
226 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
|
227 goto out_release_master; |
|
228 } |
|
229 |
|
230 if (ecrt_slave_config_mapping(sc, 4, el2004_mapping)) { |
203 printk(KERN_ERR PFX "Failed to configure Pdo mapping.\n"); |
231 printk(KERN_ERR PFX "Failed to configure Pdo mapping.\n"); |
204 goto out_release_master; |
232 goto out_release_master; |
205 } |
233 } |
206 #endif |
234 #endif |
207 |
235 |
211 printk(KERN_ERR PFX "PDO entry registration failed!\n"); |
239 printk(KERN_ERR PFX "PDO entry registration failed!\n"); |
212 goto out_release_master; |
240 goto out_release_master; |
213 } |
241 } |
214 #endif |
242 #endif |
215 |
243 |
|
244 #ifdef EXTERNAL_MEMORY |
|
245 if ((size = ecrt_domain_size(domain1))) { |
|
246 if (!(pd = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
|
247 printk(KERN_ERR PFX "Failed to allocate %u bytes of process data" |
|
248 " memory!\n", size); |
|
249 goto out_release_master; |
|
250 } |
|
251 ecrt_domain_external_memory(domain1, pd); |
|
252 } |
|
253 #endif |
|
254 |
216 printk(KERN_INFO PFX "Activating master...\n"); |
255 printk(KERN_INFO PFX "Activating master...\n"); |
217 if (ecrt_master_activate(master)) { |
256 if (ecrt_master_activate(master)) { |
218 printk(KERN_ERR PFX "Failed to activate master!\n"); |
257 printk(KERN_ERR PFX "Failed to activate master!\n"); |
219 goto out_release_master; |
258 #ifdef EXTERNAL_MEMORY |
220 } |
259 goto out_free_process_data; |
|
260 #else |
|
261 goto out_release_master; |
|
262 #endif |
|
263 } |
|
264 |
|
265 #ifndef EXTERNAL_MEMORY |
|
266 // Get internal process data for domain |
|
267 pd = ecrt_domain_data(domain1); |
|
268 #endif |
221 |
269 |
222 printk(KERN_INFO PFX "Starting cyclic sample thread.\n"); |
270 printk(KERN_INFO PFX "Starting cyclic sample thread.\n"); |
223 init_timer(&timer); |
271 init_timer(&timer); |
224 timer.function = run; |
272 timer.function = run; |
225 timer.expires = jiffies + 10; |
273 timer.expires = jiffies + 10; |
226 add_timer(&timer); |
274 add_timer(&timer); |
227 |
275 |
228 printk(KERN_INFO PFX "Started.\n"); |
276 printk(KERN_INFO PFX "Started.\n"); |
229 return 0; |
277 return 0; |
230 |
278 |
231 out_release_master: |
279 #ifdef EXTERNAL_MEMORY |
|
280 out_free_process_data: |
|
281 kfree(pd); |
|
282 #endif |
|
283 out_release_master: |
232 printk(KERN_ERR PFX "Releasing master...\n"); |
284 printk(KERN_ERR PFX "Releasing master...\n"); |
233 ecrt_release_master(master); |
285 ecrt_release_master(master); |
234 out_return: |
286 out_return: |
235 printk(KERN_ERR PFX "Failed to load. Aborting.\n"); |
287 printk(KERN_ERR PFX "Failed to load. Aborting.\n"); |
236 return -1; |
288 return -1; |
237 } |
289 } |
238 |
290 |
239 /*****************************************************************************/ |
291 /*****************************************************************************/ |