summaryrefslogtreecommitdiffstats
path: root/watch-library/simulator
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-05-06 17:06:27 -0400
committerJoey Castillo <joeycastillo@utexas.edu>2022-05-06 17:12:14 -0400
commitd4ebe64af05e2fa163bcea0dd699ae9c8934cc6f (patch)
tree0f9db98200a7fc0028ef2549ddfba15918b7465d /watch-library/simulator
parent21026c8eb750b35c07bb3ae9fb043fd01e502a06 (diff)
downloadSensor-Watch-d4ebe64af05e2fa163bcea0dd699ae9c8934cc6f.tar.gz
Sensor-Watch-d4ebe64af05e2fa163bcea0dd699ae9c8934cc6f.tar.bz2
Sensor-Watch-d4ebe64af05e2fa163bcea0dd699ae9c8934cc6f.zip
add support for a small filesystem on the watch
Diffstat (limited to 'watch-library/simulator')
-rw-r--r--watch-library/simulator/watch/watch_storage.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/watch-library/simulator/watch/watch_storage.c b/watch-library/simulator/watch/watch_storage.c
new file mode 100644
index 00000000..27011807
--- /dev/null
+++ b/watch-library/simulator/watch/watch_storage.c
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "watch_storage.h"
+
+uint8_t storage[NVMCTRL_ROW_SIZE * NVMCTRL_RWWEE_PAGES];
+
+bool watch_storage_read(uint32_t row, uint32_t offset, uint8_t *buffer, uint32_t size) {
+ // printf("read row %ld offset %ld size %ld\n", row, offset, size);
+ memcpy(buffer, storage + row * NVMCTRL_ROW_SIZE + offset, size);
+
+ return true;
+}
+
+bool watch_storage_write(uint32_t row, uint32_t offset, const uint8_t *buffer, uint32_t size) {
+ // printf("write row %ld offset %ld size %ld\n", row, offset, size);
+ memcpy(storage + row * NVMCTRL_ROW_SIZE + offset, buffer, size);
+
+ return true;
+}
+
+bool watch_storage_erase(uint32_t row) {
+ // printf("erase row %ld\n", row);
+ memset(storage + row * NVMCTRL_ROW_SIZE, 0xff, NVMCTRL_ROW_SIZE);
+
+ return true;
+}
+
+bool watch_storage_sync(void) {
+ // nothing to do here!
+ return true;
+}