examples/mini/mini.c
changeset 512 24292123d174
parent 509 87baea61d0c7
child 513 d91976aea8c8
--- a/examples/mini/mini.c	Mon Jan 08 08:23:18 2007 +0000
+++ b/examples/mini/mini.c	Mon Jan 08 08:32:10 2007 +0000
@@ -32,7 +32,6 @@
  *****************************************************************************/
 
 #include <linux/module.h>
-#include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
@@ -73,35 +72,36 @@
 void run(unsigned long data)
 {
     static unsigned int counter = 0;
-    static unsigned int einaus = 0;
-
+    static unsigned int blink = 0;
+
+    // receive
     spin_lock(&master_lock);
-
-    // receive
     ecrt_master_receive(master);
     ecrt_domain_process(domain1);
+    spin_unlock(&master_lock);
 
     // process data
-    //k_pos = EC_READ_U32(r_ssi);
+    // k_pos = EC_READ_U32(r_ssi);
+
+    if (counter) {
+        counter--;
+    }
+    else {
+        counter = FREQUENCY;
+        blink = !blink;
+    }
+
 #ifdef KBUS
-    EC_WRITE_U8(r_outputs + 2, einaus ? 0xFF : 0x00);
-#endif
-
+    EC_WRITE_U8(r_outputs + 2, blink ? 0xFF : 0x00);
+#endif
+    
     // send
+    spin_lock(&master_lock);
     ecrt_domain_queue(domain1);
     ecrt_master_run(master);
     ecrt_master_send(master);
-
     spin_unlock(&master_lock);
 
-    if (counter) {
-        counter--;
-    }
-    else {
-        counter = FREQUENCY;
-        einaus = !einaus;
-    }
-
     // restart timer
     timer.expires += HZ / FREQUENCY;
     add_timer(&timer);
@@ -211,8 +211,8 @@
 /*****************************************************************************/
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>");
-MODULE_DESCRIPTION ("EtherCAT minimal test environment");
+MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
+MODULE_DESCRIPTION("EtherCAT minimal test environment");
 
 module_init(init_mini_module);
 module_exit(cleanup_mini_module);