Minor changes to minimal example.
authorFlorian Pose <fp@igh-essen.com>
Wed, 18 Jun 2008 11:21:32 +0000
changeset 1026 021b8cdeb384
parent 1025 ae175095f09a
child 1027 9d37c6d3c80b
Minor changes to minimal example.
examples/mini/mini.c
--- a/examples/mini/mini.c	Wed Jun 18 11:16:30 2008 +0000
+++ b/examples/mini/mini.c	Wed Jun 18 11:21:32 2008 +0000
@@ -50,6 +50,9 @@
 
 #define PFX "ec_mini: "
 
+#define AnaInPos  0, 5
+#define DigOutPos 0, 3
+
 /*****************************************************************************/
 
 // EtherCAT
@@ -80,8 +83,8 @@
 #define Beckhoff_EL3162 0x00000002, 0x0C5A3052
 
 const static ec_pdo_entry_reg_t domain1_regs[] = {
-    {0, 1, Beckhoff_EL3162, 0x3101, 2, &off_ana_in},
-    {0, 3, Beckhoff_EL2004, 0x3001, 1, &off_dig_out},
+    {AnaInPos,  Beckhoff_EL3162, 0x3101, 2, &off_ana_in},
+    {DigOutPos, Beckhoff_EL2004, 0x3001, 1, &off_dig_out},
     {}
 };
 
@@ -116,6 +119,7 @@
     {EC_DIR_OUTPUT, 0x1601, 1, &el2004_channels[1]},
     {EC_DIR_OUTPUT, 0x1602, 1, &el2004_channels[2]},
     {EC_DIR_OUTPUT, 0x1603, 1, &el2004_channels[3]},
+    {EC_END}
 };
 #endif
 
@@ -191,7 +195,6 @@
 {
     switch (ecrt_sdo_request_state(sdo)) {
         case EC_SDO_REQUEST_UNUSED: // request was not used yet
-            ecrt_sdo_request_timeout(sdo, 500); // ms
             ecrt_sdo_request_read(sdo); // trigger first read
             break;
         case EC_SDO_REQUEST_BUSY:
@@ -299,7 +302,7 @@
     }
 
     if (!(sc_ana_in = ecrt_master_slave_config(
-                    master, 0, 1, Beckhoff_EL3162))) {
+                    master, AnaInPos, Beckhoff_EL3162))) {
         printk(KERN_ERR PFX "Failed to get slave configuration.\n");
         goto out_release_master;
     }
@@ -311,12 +314,12 @@
         goto out_release_master;
     }
 
-    if (!(sc = ecrt_master_slave_config(master, 0, 3, Beckhoff_EL2004))) {
+    if (!(sc = ecrt_master_slave_config(master, DigOutPos, Beckhoff_EL2004))) {
         printk(KERN_ERR PFX "Failed to get slave configuration.\n");
         goto out_release_master;
     }
 
-    if (ecrt_slave_config_pdos(sc, 4, el2004_pdos)) {
+    if (ecrt_slave_config_pdos(sc, EC_END, el2004_pdos)) {
         printk(KERN_ERR PFX "Failed to configure Pdos.\n");
         goto out_release_master;
     }
@@ -324,15 +327,11 @@
 
 #ifdef SDO_ACCESS
     printk(KERN_INFO PFX "Creating Sdo requests...\n");
-    if (!(sc = ecrt_master_slave_config(master, 0, 1, Beckhoff_EL3162))) {
-        printk(KERN_ERR PFX "Failed to get slave configuration.\n");
-        goto out_release_master;
-    }
-
-    if (!(sdo = ecrt_slave_config_create_sdo_request(sc, 0x3102, 2, 2))) {
+    if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) {
         printk(KERN_ERR PFX "Failed to create Sdo request.\n");
         goto out_release_master;
     }
+    ecrt_sdo_request_timeout(sdo, 500); // ms
 #endif
 
     printk(KERN_INFO PFX "Registering Pdo entries...\n");