71 |
71 |
72 #define Beckhoff_EL2004 0x00000002, 0x07D43052 |
72 #define Beckhoff_EL2004 0x00000002, 0x07D43052 |
73 #define Beckhoff_EL3152 0x00000002, 0x0c503052 |
73 #define Beckhoff_EL3152 0x00000002, 0x0c503052 |
74 #define Beckhoff_EL4102 0x00000002, 0x10063052 |
74 #define Beckhoff_EL4102 0x00000002, 0x10063052 |
75 |
75 |
76 // offsets for Pdo entries |
76 // offsets for PDO entries |
77 static unsigned int off_ana_in; |
77 static unsigned int off_ana_in; |
78 static unsigned int off_ana_out; |
78 static unsigned int off_ana_out; |
79 static unsigned int off_dig_out; |
79 static unsigned int off_dig_out; |
80 |
80 |
81 const static ec_pdo_entry_reg_t domain1_regs[] = { |
81 const static ec_pdo_entry_reg_t domain1_regs[] = { |
247 break; |
247 break; |
248 case EC_SDO_REQUEST_BUSY: |
248 case EC_SDO_REQUEST_BUSY: |
249 printk(KERN_INFO PFX "Still busy...\n"); |
249 printk(KERN_INFO PFX "Still busy...\n"); |
250 break; |
250 break; |
251 case EC_SDO_REQUEST_SUCCESS: |
251 case EC_SDO_REQUEST_SUCCESS: |
252 printk(KERN_INFO PFX "Sdo value: 0x%04X\n", |
252 printk(KERN_INFO PFX "SDO value: 0x%04X\n", |
253 EC_READ_U16(ecrt_sdo_request_data(sdo))); |
253 EC_READ_U16(ecrt_sdo_request_data(sdo))); |
254 ecrt_sdo_request_read(sdo); // trigger next read |
254 ecrt_sdo_request_read(sdo); // trigger next read |
255 break; |
255 break; |
256 case EC_SDO_REQUEST_ERROR: |
256 case EC_SDO_REQUEST_ERROR: |
257 printk(KERN_INFO PFX "Failed to read Sdo!\n"); |
257 printk(KERN_INFO PFX "Failed to read SDO!\n"); |
258 ecrt_sdo_request_read(sdo); // retry reading |
258 ecrt_sdo_request_read(sdo); // retry reading |
259 break; |
259 break; |
260 } |
260 } |
261 } |
261 } |
262 #endif |
262 #endif |
354 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
354 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
355 goto out_release_master; |
355 goto out_release_master; |
356 } |
356 } |
357 |
357 |
358 #if CONFIGURE_PDOS |
358 #if CONFIGURE_PDOS |
359 printk(KERN_INFO PFX "Configuring Pdos...\n"); |
359 printk(KERN_INFO PFX "Configuring PDOs...\n"); |
360 if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) { |
360 if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) { |
361 printk(KERN_ERR PFX "Failed to configure Pdos.\n"); |
361 printk(KERN_ERR PFX "Failed to configure PDOs.\n"); |
362 goto out_release_master; |
362 goto out_release_master; |
363 } |
363 } |
364 |
364 |
365 if (!(sc = ecrt_master_slave_config( |
365 if (!(sc = ecrt_master_slave_config( |
366 master, AnaOutSlavePos, Beckhoff_EL4102))) { |
366 master, AnaOutSlavePos, Beckhoff_EL4102))) { |
367 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
367 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
368 goto out_release_master; |
368 goto out_release_master; |
369 } |
369 } |
370 |
370 |
371 if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) { |
371 if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) { |
372 printk(KERN_ERR PFX "Failed to configure Pdos.\n"); |
372 printk(KERN_ERR PFX "Failed to configure PDOs.\n"); |
373 goto out_release_master; |
373 goto out_release_master; |
374 } |
374 } |
375 |
375 |
376 if (!(sc = ecrt_master_slave_config( |
376 if (!(sc = ecrt_master_slave_config( |
377 master, DigOutSlavePos, Beckhoff_EL2004))) { |
377 master, DigOutSlavePos, Beckhoff_EL2004))) { |
378 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
378 printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
379 goto out_release_master; |
379 goto out_release_master; |
380 } |
380 } |
381 |
381 |
382 if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) { |
382 if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) { |
383 printk(KERN_ERR PFX "Failed to configure Pdos.\n"); |
383 printk(KERN_ERR PFX "Failed to configure PDOs.\n"); |
384 goto out_release_master; |
384 goto out_release_master; |
385 } |
385 } |
386 #endif |
386 #endif |
387 |
387 |
388 #if SDO_ACCESS |
388 #if SDO_ACCESS |
389 printk(KERN_INFO PFX "Creating Sdo requests...\n"); |
389 printk(KERN_INFO PFX "Creating SDO requests...\n"); |
390 if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) { |
390 if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) { |
391 printk(KERN_ERR PFX "Failed to create Sdo request.\n"); |
391 printk(KERN_ERR PFX "Failed to create SDO request.\n"); |
392 goto out_release_master; |
392 goto out_release_master; |
393 } |
393 } |
394 ecrt_sdo_request_timeout(sdo, 500); // ms |
394 ecrt_sdo_request_timeout(sdo, 500); // ms |
395 #endif |
395 #endif |
396 |
396 |
397 printk(KERN_INFO PFX "Registering Pdo entries...\n"); |
397 printk(KERN_INFO PFX "Registering PDO entries...\n"); |
398 if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
398 if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
399 printk(KERN_ERR PFX "Pdo entry registration failed!\n"); |
399 printk(KERN_ERR PFX "PDO entry registration failed!\n"); |
400 goto out_release_master; |
400 goto out_release_master; |
401 } |
401 } |
402 |
402 |
403 #if EXTERNAL_MEMORY |
403 #if EXTERNAL_MEMORY |
404 if ((size = ecrt_domain_size(domain1))) { |
404 if ((size = ecrt_domain_size(domain1))) { |