summaryrefslogtreecommitdiff
path: root/flash.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-16 12:27:50 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-16 12:27:50 -0400
commite94427e2d85dfc409a4f89c263d727dedcdb3a52 (patch)
treee91125a04914344753f86b3d3ddfce9b0740f902 /flash.c
parentd7ab57c08b3fed543492cd258c36996d3c5d59b3 (diff)
put flash functions in separate files
Diffstat (limited to 'flash.c')
-rw-r--r--flash.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/flash.c b/flash.c
new file mode 100644
index 0000000..28dd42a
--- /dev/null
+++ b/flash.c
@@ -0,0 +1,45 @@
+#include "globals.h"
+
+int readUserBlock(FlashStruct *mem)
+{
+ // read the flash.copy file into the globals.Flash struct
+ // and return the number of bytes read in
+
+ // if the file does not exist, then "return 0";
+ return 0;
+}
+
+void writeUserBlock(FlashStruct *mem, int addr, int numbytes)
+{
+ // check if flash.copy file exists
+ // - if it does, update the requested address and
+ // number of bytes
+
+ // - if does not, create the file and
+ // set addr = 0, numbytes = sizeof (mem)
+ // so that entire struct will be written,
+ // instead of just the requested range
+
+ // All writing should be done in a super-safe
+ // way. Non-corruption, even during a power-off transient,
+ // is the priority here. We do not want instruments
+ // losing configuration data ever, because that
+ // means expensive repairs.
+}
+
+void initFlash(FlashStruct *mem)
+{
+ if (readUserBlock(mem) > 0) return;
+
+ // uninitialized device!
+ mem->flash_start = (char) 99;
+ strcpy(mem->aux_error_message,"FIXME");
+ mem->channels = (short) 1;
+ mem->enable_avrq_extra_ampls = (char) 12;
+ mem->ChanKey_frequency = (char) 0;
+
+ // save the default Flash config, for nonvolatile persistence
+ writeUserBlock(mem, 0, sizeof(mem));
+}
+
+