From 3a41a4df7919d2126b10a00f5914f001ebd64b18 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Wed, 19 Jul 2017 15:03:22 +0200
Subject: [PATCH] Added a module to simulate the AVR EEPROM. Needed for the new
 Dynamixel slave interface of the firmware.

---
 bioloid_controller_cm510/CMakeLists.txt         |  2 ++
 .../include/sim/avr/eeprom.h                    | 17 +++++++++++++++++
 bioloid_controller_cm510/src/sim/avr_eeprom.c   | 15 +++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 bioloid_controller_cm510/include/sim/avr/eeprom.h
 create mode 100644 bioloid_controller_cm510/src/sim/avr_eeprom.c

diff --git a/bioloid_controller_cm510/CMakeLists.txt b/bioloid_controller_cm510/CMakeLists.txt
index 1921211..f9a5fe1 100644
--- a/bioloid_controller_cm510/CMakeLists.txt
+++ b/bioloid_controller_cm510/CMakeLists.txt
@@ -129,7 +129,9 @@ add_library(${PROJECT_NAME} src/bioloid_controller_cm510.cpp
                             ${BIOLOID_FW_PATH}/controllers/src/buzzer.c
                             # communications modules
                             ${BIOLOID_FW_PATH}/communications/src/dynamixel.c
+                            ${BIOLOID_FW_PATH}/communications/src/memory.c
                             # main application module
+#                            ${ProjectPath}/cm510_vision.c
                             ${ProjectPath}/stairs.c
                             # AVR simulation modules
                             src/sim/avr_delay.c
diff --git a/bioloid_controller_cm510/include/sim/avr/eeprom.h b/bioloid_controller_cm510/include/sim/avr/eeprom.h
new file mode 100644
index 0000000..f192459
--- /dev/null
+++ b/bioloid_controller_cm510/include/sim/avr/eeprom.h
@@ -0,0 +1,17 @@
+#ifndef _AVR_EEPROM_H
+#define _AVR_EEPROM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <avr/io.h>
+
+uint8_t eeprom_read_byte(const uint8_t *p);
+void eeprom_write_byte(uint8_t *p, uint8_t value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bioloid_controller_cm510/src/sim/avr_eeprom.c b/bioloid_controller_cm510/src/sim/avr_eeprom.c
new file mode 100644
index 0000000..d9b904b
--- /dev/null
+++ b/bioloid_controller_cm510/src/sim/avr_eeprom.c
@@ -0,0 +1,15 @@
+#include "memory.h"
+
+#define EEPROM_BASE    0x00810000
+
+uint8_t eeprom_mem[2*EEPROM_SIZE]={0xFF};
+
+uint8_t eeprom_read_byte(const uint8_t *p)
+{
+  return eeprom_mem[(int)(p-EEPROM_BASE)];
+}
+
+void eeprom_write_byte(uint8_t *p, uint8_t value)
+{
+  eeprom_mem[(int)(p-EEPROM_BASE)]=value;
+}
-- 
GitLab