DC shift time working.
authorFlorian Pose <fp@igh-essen.com>
Thu, 23 Apr 2009 12:25:09 +0000
changeset 1412 8f7bbbd3b7ac
parent 1411 3ebef749275c
child 1413 44c2b7c0ae1a
DC shift time working.
documentation/graphs/fsm_slave_conf.dot
master/fsm_slave_config.c
master/slave_config.c
master/slave_config.h
--- a/documentation/graphs/fsm_slave_conf.dot	Thu Apr 23 12:20:35 2009 +0000
+++ b/documentation/graphs/fsm_slave_conf.dot	Thu Apr 23 12:25:09 2009 +0000
@@ -92,6 +92,7 @@
     enter_dc_cycle -> enter_safeop [fontname="Helvetica", label="DC not\nconfigured"]
 
     dc_cycle [fontname="Helvetica"]
+    dc_cycle -> reconfigure
     dc_cycle -> dc_start [weight=10]
 
     dc_start [fontname="Helvetica"]
--- a/master/fsm_slave_config.c	Thu Apr 23 12:20:35 2009 +0000
+++ b/master/fsm_slave_config.c	Thu Apr 23 12:25:09 2009 +0000
@@ -1062,8 +1062,14 @@
 {
     ec_datagram_t *datagram = fsm->datagram;
     ec_slave_t *slave = fsm->slave;
+    ec_slave_config_t *config = slave->config;
     u64 start_time;
 
+    if (!config) { // config removed in the meantime
+        ec_fsm_slave_config_reconfigure(fsm);
+        return;
+    }
+
     if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
         return;
 
@@ -1085,7 +1091,8 @@
     }
 
     // set DC start time
-    start_time = slave->master->app_time + 10000000ULL; // now + 100 ms
+    start_time = slave->master->app_time +
+        config->dc_sync_shift_times[0] + 100000000ULL; // now + shift + x ns
     if (slave->master->debug_level)
         EC_DBG("Slave %u: Setting DC cyclic operation start time to %llu.\n",
                 slave->ring_position, start_time);
--- a/master/slave_config.c	Thu Apr 23 12:20:35 2009 +0000
+++ b/master/slave_config.c	Thu Apr 23 12:25:09 2009 +0000
@@ -77,6 +77,8 @@
 	sc->dc_assign_activate = 0x0000;
 	sc->dc_sync_cycle_times[0] = 0x00000000;
 	sc->dc_sync_cycle_times[1] = 0x00000000;
+	sc->dc_sync_shift_times[0] = 0x00000000;
+	sc->dc_sync_shift_times[1] = 0x00000000;
 
     INIT_LIST_HEAD(&sc->sdo_configs);
     INIT_LIST_HEAD(&sc->sdo_requests);
@@ -690,6 +692,15 @@
 
 /*****************************************************************************/
 
+void ecrt_slave_config_dc_sync_shift_times(ec_slave_config_t *sc,
+        uint32_t sync0_shift_time, uint32_t sync1_shift_time)
+{
+	sc->dc_sync_shift_times[0] = sync0_shift_time;
+	sc->dc_sync_shift_times[1] = sync1_shift_time;
+}
+
+/*****************************************************************************/
+
 int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
         uint8_t subindex, const uint8_t *data, size_t size)
 {
@@ -904,6 +915,7 @@
 EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry);
 EXPORT_SYMBOL(ecrt_slave_config_dc_assign_activate);
 EXPORT_SYMBOL(ecrt_slave_config_dc_sync_cycle_times);
+EXPORT_SYMBOL(ecrt_slave_config_dc_sync_shift_times);
 EXPORT_SYMBOL(ecrt_slave_config_sdo);
 EXPORT_SYMBOL(ecrt_slave_config_sdo8);
 EXPORT_SYMBOL(ecrt_slave_config_sdo16);
--- a/master/slave_config.h	Thu Apr 23 12:20:35 2009 +0000
+++ b/master/slave_config.h	Thu Apr 23 12:25:09 2009 +0000
@@ -68,6 +68,7 @@
 
 	uint16_t dc_assign_activate; /**< Vendor-specific AssignActivate word. */
 	uint32_t dc_sync_cycle_times[2]; /**< SYNC[0,1] cycle times. */
+	uint32_t dc_sync_shift_times[2]; /**< SYNC[0,1] shift times. */
 
     struct list_head sdo_configs; /**< List of SDO configurations. */
     struct list_head sdo_requests; /**< List of SDO requests. */