examples/rtai/rtai_sample.c
changeset 2068 3001f6523e63
parent 2024 96e2ae6cce95
child 2589 2b9c78543663
--- a/examples/rtai/rtai_sample.c	Fri May 13 15:33:16 2011 +0200
+++ b/examples/rtai/rtai_sample.c	Fri May 13 15:34:20 2011 +0200
@@ -234,8 +234,8 @@
 
         rt_sem_wait(&master_sem);
         ecrt_domain_queue(domain1);
+        rt_sem_signal(&master_sem);
         ecrt_master_send(master);
-        rt_sem_signal(&master_sem);
 
         rt_task_wait_period();
     }
@@ -243,30 +243,18 @@
 
 /*****************************************************************************/
 
-void send_callback(void *cb_data)
+void request_lock_callback(void *cb_data)
 {
     ec_master_t *m = (ec_master_t *) cb_data;
-
-    // too close to the next real time cycle: deny access...
-    if (get_cycles() - t_last_cycle <= t_critical) {
-        rt_sem_wait(&master_sem);
-        ecrt_master_send_ext(m);
-        rt_sem_signal(&master_sem);
-    }
-}
-
-/*****************************************************************************/
-
-void receive_callback(void *cb_data)
+    rt_sem_wait(&master_sem);
+}
+
+/*****************************************************************************/
+
+void release_lock_callback(void *cb_data)
 {
     ec_master_t *m = (ec_master_t *) cb_data;
-
-    // too close to the next real time cycle: deny access...
-    if (get_cycles() - t_last_cycle <= t_critical) {
-        rt_sem_wait(&master_sem);
-        ecrt_master_receive(m);
-        rt_sem_signal(&master_sem);
-    }
+    rt_sem_signal(&master_sem);
 }
 
 /*****************************************************************************/
@@ -292,7 +280,7 @@
         goto out_return;
     }
 
-    ecrt_master_callbacks(master, send_callback, receive_callback, master);
+    ecrt_master_callbacks(master, request_lock_callback, release_lock_callback, master);
 
     printk(KERN_INFO PFX "Registering domain...\n");
     if (!(domain1 = ecrt_master_create_domain(master))) {