diff --git a/memory/include/mem_module.h b/memory/include/mem_module.h
index 50c085ea6a9a2ebf4c3a074079301f49705e4784..ae07cc71aaddda066c603f50d964257633ce7a82 100644
--- a/memory/include/mem_module.h
+++ b/memory/include/mem_module.h
@@ -15,8 +15,9 @@ typedef struct
   TMemSegment ram_segments[MAX_NUM_SEGMENTS];
   unsigned char num_eeprom_segments;
   TMemSegment eeprom_segments[MAX_NUM_SEGMENTS];
-  void (*write_cmd)(unsigned short int address,unsigned short int length,unsigned char *data);
-  void (*read_cmd)(unsigned short int address,unsigned short int length,unsigned char *data);
+  void (*write_cmd)(void *module,unsigned short int address,unsigned short int length,unsigned char *data);
+  void (*read_cmd)(void *module,unsigned short int address,unsigned short int length,unsigned char *data);
+  void *data;
 }TMemModule;
 
 void mem_module_init(TMemModule *module);
diff --git a/memory/include/memory.h b/memory/include/memory.h
index 21214c5b272a3b2f3beb7dcca18f8939bb361db6..1829fee81dbbb353df3cc2791584e24bde51e00a 100644
--- a/memory/include/memory.h
+++ b/memory/include/memory.h
@@ -4,8 +4,12 @@
 #include "mem_module.h"
 
 #define MAX_NUM_MEM_MODULES       16
-#define EEPROM_SIZE               32
-#define RAM_SIZE                  256
+#ifndef EEPROM_SIZE
+  #define EEPROM_SIZE               32
+#endif
+#ifndef RAM_SIZE
+  #define RAM_SIZE                  256
+#endif
 
 typedef struct
 {
diff --git a/memory/src/mem_module.c b/memory/src/mem_module.c
index cf158d18dbc8dee96ea47d60c519f3e5c8f23d10..e97238840ad1c7030db65bcf3ca494fa56507c16 100644
--- a/memory/src/mem_module.c
+++ b/memory/src/mem_module.c
@@ -17,6 +17,7 @@ void mem_module_init(TMemModule *module)
   }
   module->write_cmd=0x00000000;
   module->read_cmd=0x00000000;
+  module->data=0x00000000;
 }
 
 unsigned char mem_module_add_ram_segment(TMemModule *module,unsigned short int start_address, unsigned short int length)
diff --git a/memory/src/memory.c b/memory/src/memory.c
index c2b2a70def0e0538ab847145e2062ed0f1e33f91..68fbc806be5d15e471023bd8665b03b89caab7fb 100644
--- a/memory/src/memory.c
+++ b/memory/src/memory.c
@@ -66,7 +66,7 @@ void mem_initialize_data(TMemory *memory)
             actual_length=EEPROM_SIZE-mem_module->eeprom_segments[j].start_address;
             if((actual_address+actual_length)>(mem_module->eeprom_segments[j].start_address+mem_module->eeprom_segments[j].length))
               actual_length-=((actual_address+actual_length)-(mem_module->eeprom_segments[j].start_address+mem_module->eeprom_segments[j].length));
-            mem_module->write_cmd(actual_address,actual_length,&eeprom_data[actual_address]);
+            mem_module->write_cmd(mem_module->data,actual_address,actual_length,&eeprom_data[actual_address]);
           }
         }
       }
@@ -171,7 +171,7 @@ void mem_do_write(TMemory *memory,unsigned short int start_address,unsigned shor
           }
           if((actual_address+actual_length)>(mem_module->ram_segments[j].start_address+mem_module->ram_segments[j].length))
             actual_length-=((actual_address+actual_length)-(mem_module->ram_segments[j].start_address+mem_module->ram_segments[j].length));
-          mem_module->write_cmd(actual_address,actual_length,&data[actual_address-start_address]);
+          mem_module->write_cmd(mem_module->data,actual_address,actual_length,&data[actual_address-start_address]);
         }
       }
     }
@@ -192,7 +192,7 @@ void mem_do_write(TMemory *memory,unsigned short int start_address,unsigned shor
         if((actual_address+actual_length)>(mem_module->eeprom_segments[j].start_address+mem_module->eeprom_segments[j].length))
           actual_length-=((actual_address+actual_length)-(mem_module->eeprom_segments[j].start_address+mem_module->eeprom_segments[j].length));
         if(mem_module->write_cmd!=0x00000000)
-          mem_module->write_cmd(actual_address,actual_length,&data[actual_address-start_address]);
+          mem_module->write_cmd(mem_module->data,actual_address,actual_length,&data[actual_address-start_address]);
         if(memory->eeprom_write_data!=0x00000000)
           for(k=actual_address;k<(actual_address+actual_length);k++)
             memory->eeprom_write_data(k,data[k-start_address]);
@@ -228,7 +228,7 @@ void mem_do_read(TMemory *memory,unsigned short int start_address,unsigned short
           }
           if((actual_address+actual_length)>(mem_module->ram_segments[j].start_address+mem_module->ram_segments[j].length))
             actual_length-=((actual_address+actual_length)-(mem_module->ram_segments[j].start_address+mem_module->ram_segments[j].length));
-          mem_module->read_cmd(actual_address,actual_length,&data[actual_address-start_address]);
+          mem_module->read_cmd(mem_module->data,actual_address,actual_length,&data[actual_address-start_address]);
         }
       }
     }
@@ -250,7 +250,7 @@ void mem_do_read(TMemory *memory,unsigned short int start_address,unsigned short
           }
           if((actual_address+actual_length)>(mem_module->eeprom_segments[j].start_address+mem_module->eeprom_segments[j].length))
             actual_length-=((actual_address+actual_length)-(mem_module->eeprom_segments[j].start_address+mem_module->eeprom_segments[j].length));
-          mem_module->read_cmd(actual_address,actual_length,&data[actual_address-start_address]);
+          mem_module->read_cmd(mem_module->data,actual_address,actual_length,&data[actual_address-start_address]);
         }
       }
     }