Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
authorFlorian Pose <fp@igh-essen.com>
Fri, 27 Oct 2006 09:29:46 +0000
changeset 449 3caf8ff4d8a2
parent 448 e4b76dc7910c
child 450 03523dfc4dff
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
examples/mini/mini.c
examples/msr/msr_sample.c
examples/rtai/rtai_sample.c
include/ecrt.h
master/master.c
--- a/examples/mini/mini.c	Fri Oct 27 09:19:58 2006 +0000
+++ b/examples/mini/mini.c	Fri Oct 27 09:29:46 2006 +0000
@@ -201,12 +201,9 @@
 {
     printk(KERN_INFO "=== Stopping Minimal EtherCAT environment... ===\n");
 
-    if (master) {
-        del_timer_sync(&timer);
-        printk(KERN_INFO "Deactivating master...\n");
-        ecrt_master_deactivate(master);
-        ecrt_release_master(master);
-    }
+    del_timer_sync(&timer);
+    printk(KERN_INFO "Releasing master...\n");
+    ecrt_release_master(master);
 
     printk(KERN_INFO "=== Minimal EtherCAT environment stopped. ===\n");
 }
--- a/examples/msr/msr_sample.c	Fri Oct 27 09:19:58 2006 +0000
+++ b/examples/msr/msr_sample.c	Fri Oct 27 09:29:46 2006 +0000
@@ -214,7 +214,6 @@
 
     rt_task_delete(&task);
     stop_rt_timer();
-    ecrt_master_deactivate(master);
     ecrt_release_master(master);
     rt_sem_delete(&master_sem);
     msr_rtlib_cleanup();
--- a/examples/rtai/rtai_sample.c	Fri Oct 27 09:19:58 2006 +0000
+++ b/examples/rtai/rtai_sample.c	Fri Oct 27 09:29:46 2006 +0000
@@ -202,7 +202,6 @@
 
     rt_task_delete(&task);
     stop_rt_timer();
-    ecrt_master_deactivate(master);
     ecrt_release_master(master);
     rt_sem_delete(&master_sem);
 
--- a/include/ecrt.h	Fri Oct 27 09:19:58 2006 +0000
+++ b/include/ecrt.h	Fri Oct 27 09:29:46 2006 +0000
@@ -109,7 +109,7 @@
 ec_domain_t *ecrt_master_create_domain(ec_master_t *master);
 
 int ecrt_master_activate(ec_master_t *master);
-void ecrt_master_deactivate(ec_master_t *master);
+void ecrt_master_deactivate(ec_master_t *master); // deprecated!
 
 void ecrt_master_prepare(ec_master_t *master);
 
--- a/master/master.c	Fri Oct 27 09:19:58 2006 +0000
+++ b/master/master.c	Fri Oct 27 09:29:46 2006 +0000
@@ -417,6 +417,25 @@
                                     /**< EtherCAT master */)
 {
     ec_slave_t *slave;
+    ec_fsm_t *fsm = &master->fsm;
+    ec_datagram_t *datagram = &master->fsm.datagram;
+
+    // wait for FSM datagram
+    if (datagram->state == EC_DATAGRAM_SENT) {
+        while (get_cycles() - datagram->cycles_sent
+               < (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000)) {}
+        ecrt_master_receive(master);
+    }
+
+    // set states for all slaves
+    list_for_each_entry(slave, &master->slaves, list) {
+        ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP);
+    }
+
+    // execute master FSM to deactivate slaves
+    while (ec_fsm_exec(fsm)) {
+        ec_master_sync_io(master);
+    }
 
     ec_master_destroy_domains(master);
 
@@ -1325,31 +1344,14 @@
 
 /**
    Resets all slaves to INIT state.
+   This method is deprecated and will disappear in the next version
+   of the realtime interface. The functionality is moved to
+   ecrt_master_release().
    \ingroup RealtimeInterface
 */
 
 void ecrt_master_deactivate(ec_master_t *master /**< EtherCAT master */)
 {
-    ec_fsm_t *fsm = &master->fsm;
-    ec_slave_t *slave;
-    ec_datagram_t *datagram = &master->fsm.datagram;
-
-    // wait for FSM datagram
-    if (datagram->state == EC_DATAGRAM_SENT) {
-        while (get_cycles() - datagram->cycles_sent
-               < (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000)) {}
-        ecrt_master_receive(master);
-    }
-
-    // set states for all slaves
-    list_for_each_entry(slave, &master->slaves, list) {
-        ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP);
-    }
-
-    // execute master FSM to deactivate slaves
-    while (ec_fsm_exec(fsm)) {
-        ec_master_sync_io(master);
-    }
 }
 
 /*****************************************************************************/