Added FMMU debugging.
authorFlorian Pose <fp@igh-essen.com>
Wed, 18 Oct 2006 11:50:31 +0000
changeset 412 2e50ddc3e777
parent 411 42d239bab6ae
child 413 a7144fdf14f5
Added FMMU debugging.
master/master.c
master/slave.c
master/slave.h
--- a/master/master.c	Wed Oct 18 10:30:34 2006 +0000
+++ b/master/master.c	Wed Oct 18 11:50:31 2006 +0000
@@ -710,6 +710,18 @@
 
     sync_size = ec_slave_calc_sync_size(slave, fmmu->sync);
 
+    if (slave->master->debug_level) {
+        EC_DBG("Slave %i, FMMU %i:\n",
+               slave->ring_position, fmmu->index);
+
+        EC_DBG("  Logical address: 0x%04X\n", fmmu->logical_start_address);
+        EC_DBG("             Size: %i\n", sync_size);
+        EC_DBG(" Physical address: 0x%04X\n",
+               fmmu->sync->physical_start_address);
+        EC_DBG("        Direction: %s\n",
+               ((fmmu->sync->control_register & 0x04) ? "output" : "input"));
+    }
+
     EC_WRITE_U32(data,      fmmu->logical_start_address);
     EC_WRITE_U16(data + 4,  sync_size); // size of fmmu
     EC_WRITE_U8 (data + 6,  0x00); // logical start bit
--- a/master/slave.c	Wed Oct 18 10:30:34 2006 +0000
+++ b/master/slave.c	Wed Oct 18 11:50:31 2006 +0000
@@ -464,11 +464,14 @@
                           )
 {
     unsigned int i;
+    ec_fmmu_t *fmmu;
 
     // FMMU configuration already prepared?
-    for (i = 0; i < slave->fmmu_count; i++)
-        if (slave->fmmus[i].domain == domain && slave->fmmus[i].sync == sync)
+    for (i = 0; i < slave->fmmu_count; i++) {
+        fmmu = &slave->fmmus[i];
+        if (fmmu->domain == domain && fmmu->sync == sync)
             return 0;
+    }
 
     // reserve new FMMU...
 
@@ -477,9 +480,13 @@
         return -1;
     }
 
-    slave->fmmus[slave->fmmu_count].domain = domain;
-    slave->fmmus[slave->fmmu_count].sync = sync;
-    slave->fmmus[slave->fmmu_count].logical_start_address = 0;
+    fmmu = &slave->fmmus[slave->fmmu_count];
+
+    fmmu->index = slave->fmmu_count;
+    fmmu->domain = domain;
+    fmmu->sync = sync;
+    fmmu->logical_start_address = 0;
+
     slave->fmmu_count++;
     slave->registered = 1;
 
--- a/master/slave.h	Wed Oct 18 10:30:34 2006 +0000
+++ b/master/slave.h	Wed Oct 18 11:50:31 2006 +0000
@@ -173,6 +173,7 @@
 
 typedef struct
 {
+    unsigned int index; /**< FMMU index */
     const ec_domain_t *domain; /**< domain */
     const ec_sii_sync_t *sync; /**< sync manager */
     uint32_t logical_start_address; /**< logical start address */