examples/rtai/rtai_sample.c
changeset 1580 1baac79a40cf
parent 1513 60ca68d853b8
child 1935 8ea1033bd4c2
equal deleted inserted replaced
1579:326d47aa986c 1580:1baac79a40cf
   241     }
   241     }
   242 }
   242 }
   243 
   243 
   244 /*****************************************************************************/
   244 /*****************************************************************************/
   245 
   245 
   246 void send_callback(ec_master_t *master)
   246 void send_callback(void *cb_data)
   247 {
   247 {
       
   248     ec_master_t *m = (ec_master_t *) cb_data;
       
   249 
   248     // too close to the next real time cycle: deny access...
   250     // too close to the next real time cycle: deny access...
   249     if (get_cycles() - t_last_cycle <= t_critical) {
   251     if (get_cycles() - t_last_cycle <= t_critical) {
   250         rt_sem_wait(&master_sem);
   252         rt_sem_wait(&master_sem);
   251         ecrt_master_send_ext(master);
   253         ecrt_master_send_ext(m);
   252         rt_sem_signal(&master_sem);
   254         rt_sem_signal(&master_sem);
   253     }
   255     }
   254 }
   256 }
   255 
   257 
   256 /*****************************************************************************/
   258 /*****************************************************************************/
   257 
   259 
   258 void receive_callback(ec_master_t *master)
   260 void receive_callback(void *cb_data)
   259 {
   261 {
       
   262     ec_master_t *m = (ec_master_t *) cb_data;
       
   263 
   260     // too close to the next real time cycle: deny access...
   264     // too close to the next real time cycle: deny access...
   261     if (get_cycles() - t_last_cycle <= t_critical) {
   265     if (get_cycles() - t_last_cycle <= t_critical) {
   262         rt_sem_wait(&master_sem);
   266         rt_sem_wait(&master_sem);
   263         ecrt_master_receive(master);
   267         ecrt_master_receive(m);
   264         rt_sem_signal(&master_sem);
   268         rt_sem_signal(&master_sem);
   265     }
   269     }
   266 }
   270 }
   267 
   271 
   268 /*****************************************************************************/
   272 /*****************************************************************************/
   286         ret = PTR_ERR(master); 
   290         ret = PTR_ERR(master); 
   287         printk(KERN_ERR PFX "Requesting master 0 failed!\n");
   291         printk(KERN_ERR PFX "Requesting master 0 failed!\n");
   288         goto out_return;
   292         goto out_return;
   289     }
   293     }
   290 
   294 
   291     ecrt_master_callbacks(master, send_callback, receive_callback);
   295     ecrt_master_callbacks(master, send_callback, receive_callback, master);
   292 
   296 
   293     printk(KERN_INFO PFX "Registering domain...\n");
   297     printk(KERN_INFO PFX "Registering domain...\n");
   294     if (!(domain1 = ecrt_master_create_domain(master))) {
   298     if (!(domain1 = ecrt_master_create_domain(master))) {
   295         printk(KERN_ERR PFX "Domain creation failed!\n");
   299         printk(KERN_ERR PFX "Domain creation failed!\n");
   296         goto out_release_master;
   300         goto out_release_master;