Master takes mailbox sync manager configurations from EEPROM words
authorFlorian Pose <fp@igh-essen.com>
Wed, 19 Sep 2007 11:52:58 +0000
changeset 737 5a770085161c
parent 736 53afedcb52f6
child 738 880c6153101f
Master takes mailbox sync manager configurations from EEPROM words
0x0018-0x001b, if no sync manager configurations are provided.
NEWS
master/fsm_slave.c
--- a/NEWS	Wed Sep 19 09:44:48 2007 +0000
+++ b/NEWS	Wed Sep 19 11:52:58 2007 +0000
@@ -6,6 +6,8 @@
 
 Changes in version 1.3.2:
 
+* Master takes mailbox sync manager configurations from EEPROM words
+  0x0018-0x001b, if no sync manager configurations are provided.
 * Calculate checksum when writing EEPROM or alias address.
 * Removed config.kbuild and replaced Kbuild files by Kbuild.in files.
 
--- a/master/fsm_slave.c	Wed Sep 19 09:44:48 2007 +0000
+++ b/master/fsm_slave.c	Wed Sep 19 11:52:58 2007 +0000
@@ -684,8 +684,8 @@
         return;
     }
 
-    if (!slave->sii_mailbox_protocols || slave->sii_sync_count < 2) {
-        // no mailbox sync managers to be configured
+    if (!slave->sii_mailbox_protocols) {
+        // no mailbox protocols supported
         if (master->debug_level)
             EC_DBG("Slave %i does not support mailbox communication.\n",
                     slave->ring_position);
@@ -698,14 +698,41 @@
                slave->ring_position);
     }
 
-    // configure sync managers
-    ec_datagram_npwr(datagram, slave->station_address, 0x0800,
-                     EC_SYNC_SIZE * slave->sii_sync_count);
-    memset(datagram->data, 0x00, EC_SYNC_SIZE * slave->sii_sync_count);
-
-    for (i = 0; i < 2; i++) {
-        ec_sync_config(&slave->sii_syncs[i],
-                datagram->data + EC_SYNC_SIZE * i);
+    if (slave->sii_sync_count >= 2) {
+        // configure sync managers
+        ec_datagram_npwr(datagram, slave->station_address, 0x0800,
+                EC_SYNC_SIZE * slave->sii_sync_count);
+        memset(datagram->data, 0x00, EC_SYNC_SIZE * slave->sii_sync_count);
+
+        for (i = 0; i < 2; i++) {
+            ec_sync_config(&slave->sii_syncs[i],
+                    datagram->data + EC_SYNC_SIZE * i);
+        }
+    } else { // no mailbox sync manager configurations provided
+        ec_sync_t sync;
+
+        if (master->debug_level)
+            EC_DBG("Slave %i does not provide"
+                    " mailbox sync manager configurations.\n",
+                    slave->ring_position);
+
+        ec_datagram_npwr(datagram, slave->station_address, 0x0800,
+                EC_SYNC_SIZE * 2);
+        memset(datagram->data, 0x00, EC_SYNC_SIZE * 2);
+
+        ec_sync_init(&sync, slave, 0);
+        sync.physical_start_address = slave->sii_rx_mailbox_offset;
+        sync.length = slave->sii_rx_mailbox_size;
+        sync.control_register = 0x26;
+        sync.enable = 1;
+        ec_sync_config(&sync, datagram->data + EC_SYNC_SIZE * sync.index);
+
+        ec_sync_init(&sync, slave, 1);
+        sync.physical_start_address = slave->sii_tx_mailbox_offset;
+        sync.length = slave->sii_tx_mailbox_size;
+        sync.control_register = 0x22;
+        sync.enable = 1;
+        ec_sync_config(&sync, datagram->data + EC_SYNC_SIZE * sync.index);
     }
 
     fsm->retries = EC_FSM_RETRIES;