examples/mini/mini.c
changeset 454 25cc4a3b9e0a
parent 452 d8ae13a5a910
child 457 2b4ba84b6058
equal deleted inserted replaced
453:2ecaa53c6291 454:25cc4a3b9e0a
    50 ec_master_t *master = NULL;
    50 ec_master_t *master = NULL;
    51 ec_domain_t *domain1 = NULL;
    51 ec_domain_t *domain1 = NULL;
    52 spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
    52 spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
    53 
    53 
    54 // data fields
    54 // data fields
    55 #if 0
    55 #if 1
    56 void *r_inputs;
    56 void *r_inputs;
    57 void *r_outputs;
    57 void *r_outputs;
    58 #endif
    58 #endif
    59 
    59 
    60 void *r_ana_in;
    60 void *r_ana_in;
    79     ecrt_master_receive(master);
    79     ecrt_master_receive(master);
    80     ecrt_domain_process(domain1);
    80     ecrt_domain_process(domain1);
    81 
    81 
    82     // process data
    82     // process data
    83     //k_pos = EC_READ_U32(r_ssi);
    83     //k_pos = EC_READ_U32(r_ssi);
    84     //EC_WRITE_U8(r_outputs + 2, einaus ? 0xFF : 0x00);
    84     EC_WRITE_U8(r_outputs + 2, einaus ? 0xFF : 0x00);
    85 
    85 
    86     // send
    86     // send
    87     ecrt_master_run(master);
    87     ecrt_master_run(master);
    88     ecrt_master_send(master);
    88     ecrt_master_send(master);
    89 
    89 
   119 
   119 
   120 /*****************************************************************************/
   120 /*****************************************************************************/
   121 
   121 
   122 int __init init_mini_module(void)
   122 int __init init_mini_module(void)
   123 {
   123 {
   124     //    ec_slave_t *slave;
   124 #if 0
       
   125     ec_slave_t *slave;
       
   126 #endif
   125 
   127 
   126     printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n");
   128     printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n");
   127 
   129 
   128     if ((master = ecrt_request_master(0)) == NULL) {
   130     if ((master = ecrt_request_master(0)) == NULL) {
   129         printk(KERN_ERR "Requesting master 0 failed!\n");
   131         printk(KERN_ERR "Requesting master 0 failed!\n");
   145         printk(KERN_ERR "PDO registration failed!\n");
   147         printk(KERN_ERR "PDO registration failed!\n");
   146         goto out_release_master;
   148         goto out_release_master;
   147     }
   149     }
   148 #endif
   150 #endif
   149 
   151 
   150 #if 0
   152 #if 1
   151     if (!ecrt_domain_register_pdo_range(domain1, "0", Beckhoff_BK1120,
   153     if (!ecrt_domain_register_pdo_range(domain1, "0", Beckhoff_BK1120,
   152                                         EC_DIR_OUTPUT, 0, 4, &r_outputs)) {
   154                                         EC_DIR_OUTPUT, 0, 4, &r_outputs)) {
   153         printk(KERN_ERR "PDO registration failed!\n");
   155         printk(KERN_ERR "PDO registration failed!\n");
   154         goto out_release_master;
   156         goto out_release_master;
   155     }
   157     }