Always enable a sync manager, if there are registered PDOs conatined (and it stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Mon, 24 Oct 2011 10:47:36 +0200
branchstable-1.5
changeset 2123 4c335a1d4db0
parent 2122 23414e7559de
child 2124 c4afc5fede19
Always enable a sync manager, if there are registered PDOs conatined (and it
is not virtual)
NEWS
master/fsm_slave_config.c
master/sync.c
master/sync.h
--- a/NEWS	Tue Oct 11 14:06:07 2011 +0200
+++ b/NEWS	Mon Oct 24 10:47:36 2011 +0200
@@ -71,6 +71,7 @@
 * Implemented CompleteAccess for SDO downloads.
 * ethercat tool is now able to handle multiple masters. The --masters option
   supports ranges like '0,3,8-10'.
+* A sync manager is always enabled, if it contains registered process data.
 
 Changes in 1.4.0:
 
--- a/master/fsm_slave_config.c	Tue Oct 11 14:06:07 2011 +0200
+++ b/master/fsm_slave_config.c	Mon Oct 24 10:47:36 2011 +0200
@@ -449,6 +449,7 @@
         sync.enable = 1;
         ec_sync_page(&sync, 0, slave->sii.boot_rx_mailbox_size,
                 EC_DIR_INVALID, // use default direction
+                0, // no PDO xfer
                 datagram->data);
         slave->configured_rx_mailbox_offset =
             slave->sii.boot_rx_mailbox_offset;
@@ -461,6 +462,7 @@
         sync.enable = 1;
         ec_sync_page(&sync, 1, slave->sii.boot_tx_mailbox_size,
                 EC_DIR_INVALID, // use default direction
+                0, // no PDO xfer
                 datagram->data + EC_SYNC_PAGE_SIZE);
         slave->configured_tx_mailbox_offset =
             slave->sii.boot_tx_mailbox_offset;
@@ -476,6 +478,7 @@
             ec_sync_page(&slave->sii.syncs[i], i,
                     slave->sii.syncs[i].default_length,
                     NULL, // use default sync manager configuration
+                    0, // no PDO xfer
                     datagram->data + EC_SYNC_PAGE_SIZE * i);
         }
 
@@ -503,6 +506,7 @@
         sync.enable = 1;
         ec_sync_page(&sync, 0, slave->sii.std_rx_mailbox_size,
                 NULL, // use default sync manager configuration
+                0, // no PDO xfer
                 datagram->data);
         slave->configured_rx_mailbox_offset =
             slave->sii.std_rx_mailbox_offset;
@@ -515,6 +519,7 @@
         sync.enable = 1;
         ec_sync_page(&sync, 1, slave->sii.std_tx_mailbox_size,
                 NULL, // use default sync manager configuration
+                0, // no PDO xfer
                 datagram->data + EC_SYNC_PAGE_SIZE);
         slave->configured_tx_mailbox_offset =
             slave->sii.std_tx_mailbox_offset;
@@ -959,7 +964,7 @@
 {
     ec_slave_t *slave = fsm->slave;
     ec_datagram_t *datagram = fsm->datagram;
-    unsigned int i, offset, num_pdo_syncs;
+    unsigned int i, j, offset, num_pdo_syncs;
     uint8_t sync_index;
     const ec_sync_t *sync;
     uint16_t size;
@@ -986,18 +991,30 @@
 
     for (i = 0; i < num_pdo_syncs; i++) {
         const ec_sync_config_t *sync_config;
+        uint8_t pdo_xfer = 0;
         sync_index = i + offset;
         sync = &slave->sii.syncs[sync_index];
 
         if (slave->config) {
-            sync_config = &slave->config->sync_configs[sync_index];
+            const ec_slave_config_t *sc = slave->config;
+            sync_config = &sc->sync_configs[sync_index];
             size = ec_pdo_list_total_size(&sync_config->pdos);
+
+            // determine, if PDOs shall be transferred via this SM
+            // inthat case, enable sync manager in every case
+            for (j = 0; j < sc->used_fmmus; j++) {
+                if (sc->fmmu_configs[j].sync_index == sync_index) {
+                    pdo_xfer = 1;
+                    break;
+                }
+            }
+
         } else {
             sync_config = NULL;
             size = sync->default_length;
         }
 
-        ec_sync_page(sync, sync_index, size, sync_config,
+        ec_sync_page(sync, sync_index, size, sync_config, pdo_xfer,
                 datagram->data + EC_SYNC_PAGE_SIZE * i);
     }
 
--- a/master/sync.c	Tue Oct 11 14:06:07 2011 +0200
+++ b/master/sync.c	Mon Oct 24 10:47:36 2011 +0200
@@ -96,11 +96,14 @@
         uint8_t sync_index, /**< Index of the sync manager. */
         uint16_t data_size, /**< Data size. */
         const ec_sync_config_t *sync_config, /**< Configuration. */
+        uint8_t pdo_xfer, /**< Non-zero, if PDOs will be transferred via this
+                            sync manager. */
         uint8_t *data /**> Configuration memory. */
         )
 {
-    // enable only if SII enable is set and size is > 0 and SM is not virtual
-    uint16_t enable = (sync->enable & 0x01)
+    // enable only if (SII enable is set or PDO xfer)
+    // and size is > 0 and SM is not virtual
+    uint16_t enable = ((sync->enable & 0x01) || pdo_xfer)
                         && data_size
                         && ((sync->enable & 0x04) == 0);
     uint8_t control = sync->control_register;
--- a/master/sync.h	Tue Oct 11 14:06:07 2011 +0200
+++ b/master/sync.h	Mon Oct 24 10:47:36 2011 +0200
@@ -59,7 +59,7 @@
 void ec_sync_init_copy(ec_sync_t *, const ec_sync_t *);
 void ec_sync_clear(ec_sync_t *);
 void ec_sync_page(const ec_sync_t *, uint8_t, uint16_t,
-        const ec_sync_config_t *, uint8_t *);
+        const ec_sync_config_t *, uint8_t, uint8_t *);
 int ec_sync_add_pdo(ec_sync_t *, const ec_pdo_t *);
 ec_direction_t ec_sync_default_direction(const ec_sync_t *);