Improved dummy module.
authorFlorian Pose <fp@igh-essen.com>
Fri, 08 Jun 2007 12:03:20 +0000
changeset 666 825ead3e0559
parent 665 a9794f927d78
child 667 9feff35c9617
Improved dummy module.
dummy/domain.c
dummy/master.c
dummy/module.c
--- a/dummy/domain.c	Wed Jun 06 17:02:38 2007 +0000
+++ b/dummy/domain.c	Fri Jun 08 12:03:20 2007 +0000
@@ -42,9 +42,7 @@
 #include "../master/domain.h"
 #include "../master/master.h"
 
-/*****************************************************************************/
-
-uint8_t dummy_data[PAGE_SIZE];
+uint8_t *get_dummy_data(void);
 
 /*****************************************************************************/
 
@@ -58,7 +56,7 @@
         void **data_ptr /**< address of the process data pointer */
         )
 {
-	*data_ptr = dummy_data;
+	*data_ptr = get_dummy_data();
 	return 0;
 }
 
@@ -79,7 +77,7 @@
     const ec_pdo_reg_t *reg;
     
     for (reg = pdo_regs; reg->slave_address; reg++) {
-		*(reg->data_ptr) = dummy_data;
+		*(reg->data_ptr) = get_dummy_data();
     }
 
     return 0;
@@ -102,7 +100,7 @@
         void **data_ptr /**< address of the process data pointer */
         )
 {
-	*data_ptr = dummy_data;
+	*data_ptr = get_dummy_data();
     return 0;
 }
 
--- a/dummy/master.c	Wed Jun 06 17:02:38 2007 +0000
+++ b/dummy/master.c	Fri Jun 08 12:03:20 2007 +0000
@@ -49,7 +49,8 @@
 
 ec_domain_t *ecrt_master_create_domain(ec_master_t *master)
 {
-    return (ec_domain_t *) 1;
+    static unsigned int domain = 1;
+    return (ec_domain_t *) domain++;
 }
 
 /*****************************************************************************/
@@ -80,7 +81,8 @@
         uint32_t p
         )
 {
-    return (ec_slave_t *) 1;
+    static unsigned int slave = 1;
+    return (ec_slave_t *) slave++;
 }
 
 /*****************************************************************************/
--- a/dummy/module.c	Wed Jun 06 17:02:38 2007 +0000
+++ b/dummy/module.c	Fri Jun 08 12:03:20 2007 +0000
@@ -65,6 +65,23 @@
 
 /*****************************************************************************/
 
+#define DUMMY_SIZE (PAGE_SIZE * 8)
+
+uint8_t dummy_data[DUMMY_SIZE];
+off_t dummy_off = 0;
+
+uint8_t *get_dummy_data(void)
+{
+    off_t cur = dummy_off;
+
+    dummy_off += 64;
+    dummy_off %= DUMMY_SIZE;
+
+    return dummy_data + cur;
+}
+
+/*****************************************************************************/
+
 /**
  * Module initialization.
  * Initializes \a ec_master_count masters.
@@ -74,6 +91,9 @@
 int __init ec_init_module(void)
 {
     EC_INFO("Master DUMMY driver %s\n", EC_MASTER_VERSION);
+
+    memset(dummy_data, 0x00, DUMMY_SIZE);
+
     return 0;
 }