mini/mini.c
changeset 140 b09658e50d6f
parent 138 7e743a61a991
child 147 a355b587b4bc
equal deleted inserted replaced
139:998215ab9b92 140:b09658e50d6f
    96     if ((master = ecrt_request_master(0)) == NULL) {
    96     if ((master = ecrt_request_master(0)) == NULL) {
    97         printk(KERN_ERR "Requesting master 0 failed!\n");
    97         printk(KERN_ERR "Requesting master 0 failed!\n");
    98         goto out_return;
    98         goto out_return;
    99     }
    99     }
   100 
   100 
   101     ecrt_master_print(master);
       
   102 
       
   103     printk(KERN_INFO "Registering domain...\n");
   101     printk(KERN_INFO "Registering domain...\n");
   104 
       
   105     if (!(domain1 = ecrt_master_create_domain(master)))
   102     if (!(domain1 = ecrt_master_create_domain(master)))
   106     {
   103     {
   107         printk(KERN_ERR "Domain creation failed!\n");
   104         printk(KERN_ERR "Domain creation failed!\n");
   108         goto out_release_master;
   105         goto out_release_master;
   109     }
   106     }
   110 
   107 
   111     printk(KERN_INFO "Registering domain fields...\n");
   108     printk(KERN_INFO "Registering domain fields...\n");
   112 
       
   113     if (ecrt_domain_register_field_list(domain1, domain1_fields)) {
   109     if (ecrt_domain_register_field_list(domain1, domain1_fields)) {
   114         printk(KERN_ERR "Field registration failed!\n");
   110         printk(KERN_ERR "Field registration failed!\n");
   115         goto out_release_master;
   111         goto out_release_master;
   116     }
   112     }
   117 
   113 
   118     printk(KERN_INFO "Activating master...\n");
   114     printk(KERN_INFO "Activating master...\n");
   119 
       
   120     if (ecrt_master_activate(master)) {
   115     if (ecrt_master_activate(master)) {
   121         printk(KERN_ERR "Failed to activate master!\n");
   116         printk(KERN_ERR "Failed to activate master!\n");
   122         goto out_release_master;
   117         goto out_release_master;
   123     }
   118     }
   124 
   119 
       
   120 #if 0
   125     if (ecrt_master_fetch_sdo_lists(master)) {
   121     if (ecrt_master_fetch_sdo_lists(master)) {
   126         printk(KERN_ERR "Failed to fetch SDO lists!\n");
   122         printk(KERN_ERR "Failed to fetch SDO lists!\n");
   127         goto out_deactivate;
   123         goto out_deactivate;
   128     }
   124     }
   129 
   125     ecrt_master_print(master, 2);
   130     //ecrt_master_debug(master, 2);
   126 #else
       
   127     ecrt_master_print(master, 0);
       
   128 #endif
       
   129 
   131 
   130 
   132 #if 0
   131 #if 0
   133     if (!(slave = ecrt_master_get_slave(master, "5"))) {
   132     if (!(slave = ecrt_master_get_slave(master, "5"))) {
   134         printk(KERN_ERR "Failed to get slave 5!\n");
   133         printk(KERN_ERR "Failed to get slave 5!\n");
   135         goto out_deactivate;
   134         goto out_deactivate;
   147         printk(KERN_ERR "Failed to configure SSI slave!\n");
   146         printk(KERN_ERR "Failed to configure SSI slave!\n");
   148         goto out_deactivate;
   147         goto out_deactivate;
   149     }
   148     }
   150 #endif
   149 #endif
   151 
   150 
   152     //ecrt_master_debug(master, 0);
       
   153 
       
   154 #if 0
   151 #if 0
   155     printk(KERN_INFO "Writing alias...\n");
   152     printk(KERN_INFO "Writing alias...\n");
   156     if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) {
   153     if (ecrt_slave_sdo_write_exp16(slave, 0xBEEF)) {
   157         printk(KERN_ERR "Failed to write alias!\n");
   154         printk(KERN_ERR "Failed to write alias!\n");
   158         goto out_deactivate;
   155         goto out_deactivate;
   163     // Einmal senden und warten...
   160     // Einmal senden und warten...
   164     ecrt_master_prepare_async_io(master);
   161     ecrt_master_prepare_async_io(master);
   165 #endif
   162 #endif
   166 
   163 
   167     printk("Starting cyclic sample thread.\n");
   164     printk("Starting cyclic sample thread.\n");
   168 
       
   169     init_timer(&timer);
   165     init_timer(&timer);
   170     timer.function = run;
   166     timer.function = run;
   171     timer.expires = jiffies + 10; // Das erste Mal sofort feuern
   167     timer.expires = jiffies + 10; // Das erste Mal sofort feuern
   172     add_timer(&timer);
   168     add_timer(&timer);
   173 
   169