Use jiffies instead of cycles in CoE state machine.
authorFlorian Pose <fp@igh-essen.com>
Thu, 19 Jun 2008 10:17:52 +0000
changeset 1038 7ca4103ba170
parent 1037 59f191c9185b
child 1039 2881a83d084f
Use jiffies instead of cycles in CoE state machine.
master/fsm_coe.c
master/fsm_coe.h
--- a/master/fsm_coe.c	Thu Jun 19 09:24:22 2008 +0000
+++ b/master/fsm_coe.c	Thu Jun 19 10:17:52 2008 +0000
@@ -317,7 +317,7 @@
         return;
     }
 
-    fsm->cycles_start = datagram->cycles_sent;
+    fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
     fsm->retries = EC_FSM_RETRIES;
@@ -355,8 +355,9 @@
     }
 
     if (!ec_slave_mbox_check(datagram)) {
-        if (datagram->cycles_received
-            - fsm->cycles_start >= (cycles_t) 100 * cpu_khz) {
+        unsigned long diff_ms =
+            (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
+        if (diff_ms >= 100) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Timeout while checking Sdo dictionary on slave %u.\n",
                    slave->ring_position);
@@ -494,7 +495,7 @@
     }
 
     if (EC_READ_U8(data + 2) & 0x80 || fragments_left) { // more messages waiting. check again.
-        fsm->cycles_start = datagram->cycles_sent;
+        fsm->jiffies_start = datagram->jiffies_sent;
         ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
         fsm->retries = EC_FSM_RETRIES;
         fsm->state = ec_fsm_coe_dict_check;
@@ -556,7 +557,7 @@
         return;
     }
 
-    fsm->cycles_start = datagram->cycles_sent;
+    fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
     fsm->retries = EC_FSM_RETRIES;
@@ -594,8 +595,9 @@
     }
 
     if (!ec_slave_mbox_check(datagram)) {
-        if (datagram->cycles_received
-            - fsm->cycles_start >= (cycles_t) 100 * cpu_khz) {
+        unsigned long diff_ms =
+            (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
+        if (diff_ms >= 100) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Timeout while checking Sdo description on slave %u.\n",
                    slave->ring_position);
@@ -784,7 +786,7 @@
         return;
     }
 
-    fsm->cycles_start = datagram->cycles_sent;
+    fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail
     fsm->retries = EC_FSM_RETRIES;
@@ -823,8 +825,9 @@
     }
 
     if (!ec_slave_mbox_check(datagram)) {
-        if (datagram->cycles_received
-            - fsm->cycles_start >= (cycles_t) 100 * cpu_khz) {
+        unsigned long diff_ms =
+            (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
+        if (diff_ms >= 100) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Timeout while checking Sdo entry on slave %u.\n",
                    slave->ring_position);
@@ -1113,7 +1116,7 @@
         return;
     }
 
-    fsm->cycles_start = datagram->cycles_sent;
+    fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
     fsm->retries = EC_FSM_RETRIES;
@@ -1151,8 +1154,9 @@
     }
 
     if (!ec_slave_mbox_check(datagram)) {
-        if (datagram->cycles_received
-            - fsm->cycles_start >= (cycles_t) 100 * cpu_khz) {
+        unsigned long diff_ms =
+            (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
+        if (diff_ms >= 100) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Timeout while checking Sdo configuration on slave %u.\n",
                    slave->ring_position);
@@ -1357,7 +1361,7 @@
         return;
     }
 
-    fsm->cycles_start = datagram->cycles_sent;
+    fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
     fsm->retries = EC_FSM_RETRIES;
@@ -1395,8 +1399,9 @@
     }
 
     if (!ec_slave_mbox_check(datagram)) {
-        if (datagram->cycles_received
-            - fsm->cycles_start >= (cycles_t) 100 * cpu_khz) {
+        unsigned long diff_ms =
+            (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
+        if (diff_ms >= 100) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Timeout while checking Sdo upload on slave %u.\n",
                    slave->ring_position);
@@ -1649,7 +1654,7 @@
         return;
     }
 
-    fsm->cycles_start = datagram->cycles_sent;
+    fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
     fsm->retries = EC_FSM_RETRIES;
@@ -1687,8 +1692,9 @@
     }
 
     if (!ec_slave_mbox_check(datagram)) {
-        if (datagram->cycles_received
-            - fsm->cycles_start >= (cycles_t) 100 * cpu_khz) {
+        unsigned long diff_ms =
+            (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
+        if (diff_ms >= 100) {
             fsm->state = ec_fsm_coe_error;
             EC_ERR("Timeout while checking Sdo upload segment on slave %u.\n",
                    slave->ring_position);
--- a/master/fsm_coe.h	Thu Jun 19 09:24:22 2008 +0000
+++ b/master/fsm_coe.h	Thu Jun 19 10:17:52 2008 +0000
@@ -60,7 +60,7 @@
     unsigned int retries; /**< retries upon datagram timeout */
 
     void (*state)(ec_fsm_coe_t *); /**< CoE state function */
-    cycles_t cycles_start; /**< CoE timestamp */
+    unsigned long jiffies_start; /**< CoE timestamp. */
     ec_sdo_t *sdo; /**< current Sdo */
     uint8_t subindex; /**< current subindex */
     ec_sdo_request_t *request; /**< Sdo request */