Adjusted examples to EtherLab starter kit hardware.
authorFlorian Pose <fp@igh-essen.com>
Mon, 08 Jan 2007 15:02:05 +0000
changeset 516 f703e33ee395
parent 515 37aa1bfa0dee
child 517 b6ebde3d006d
Adjusted examples to EtherLab starter kit hardware.
examples/mini/mini.c
examples/rtai/rtai_sample.c
--- a/examples/mini/mini.c	Mon Jan 08 15:01:18 2007 +0000
+++ b/examples/mini/mini.c	Mon Jan 08 15:02:05 2007 +0000
@@ -41,7 +41,7 @@
 
 #define FREQUENCY 100
 
-#define KBUS
+//#define KBUS
 
 /*****************************************************************************/
 
@@ -58,11 +58,11 @@
 void *r_outputs;
 #endif
 
-void *r_ana_in;
+void *r_dig_out;
 
 #if 1
 ec_pdo_reg_t domain1_pdos[] = {
-    {"2", Beckhoff_EL3102_Input1, &r_ana_in},
+    {"2", Beckhoff_EL2004_Outputs, &r_dig_out},
     {}
 };
 #endif
@@ -82,6 +82,7 @@
 
     // process data
     // k_pos = EC_READ_U32(r_ssi);
+    EC_WRITE_U8(r_dig_out, blink ? 0x0F : 0x00);
 
     if (counter) {
         counter--;
@@ -98,7 +99,11 @@
     // send
     spin_lock(&master_lock);
     ecrt_domain_queue(domain1);
+    spin_unlock(&master_lock);
+
     ecrt_master_run(master);
+
+    spin_lock(&master_lock);
     ecrt_master_send(master);
     spin_unlock(&master_lock);
 
@@ -111,7 +116,7 @@
 
 int request_lock(void *data)
 {
-    spin_lock_bh(&master_lock);
+    spin_lock(&master_lock);
     return 0; // access allowed
 }
 
@@ -119,14 +124,14 @@
 
 void release_lock(void *data)
 {
-    spin_unlock_bh(&master_lock);
+    spin_unlock(&master_lock);
 }
 
 /*****************************************************************************/
 
 int __init init_mini_module(void)
 {
-#if 1
+#if 0
     ec_slave_t *slave;
 #endif
 
@@ -166,7 +171,7 @@
     }
 #endif
 
-#if 1
+#if 0
     if (!(slave = ecrt_master_get_slave(master, "2")))
         goto out_release_master;
 
--- a/examples/rtai/rtai_sample.c	Mon Jan 08 15:01:18 2007 +0000
+++ b/examples/rtai/rtai_sample.c	Mon Jan 08 15:02:05 2007 +0000
@@ -47,7 +47,7 @@
 /*****************************************************************************/
 
 // RTAI task frequency in Hz
-#define FREQUENCY 10000
+#define FREQUENCY 4000
 #define INHIBIT_TIME 20
 
 #define TIMERTICKS (1000000000 / FREQUENCY)
@@ -64,13 +64,10 @@
 ec_domain_t *domain1 = NULL;
 
 // data fields
-void *r_ana_out;
-
-// channels
-uint32_t k_pos;
+void *r_dig_out;
 
 ec_pdo_reg_t domain1_pdos[] = {
-    {"2", Beckhoff_EL4132_Output1, &r_ana_out},
+    {"2", Beckhoff_EL2004_Outputs, &r_dig_out},
     {}
 };
 
@@ -78,6 +75,9 @@
 
 void run(long data)
 {
+    static unsigned int blink = 0;
+    static unsigned int counter = 0;
+
     while (1) {
         t_last_cycle = get_cycles();
 
@@ -87,13 +87,21 @@
         rt_sem_signal(&master_sem);
 
         // process data
-        //k_pos = EC_READ_U32(r_ssi_input);
+        EC_WRITE_U8(r_dig_out, blink ? 0x0F : 0x00);
 
         rt_sem_wait(&master_sem);
         ecrt_domain_queue(domain1);
         ecrt_master_run(master);
         ecrt_master_send(master);
         rt_sem_signal(&master_sem);
+		
+        if (counter) {
+            counter--;
+        }
+        else {
+            counter = FREQUENCY;
+            blink = !blink;
+        }
 
         rt_task_wait_period();
     }