summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-22 13:21:52 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-22 13:21:52 -0400
commitf9385de372e46de69f2fdd691d0f7eebe19bef8f (patch)
treeb0380b722ff556793bb28039b24f241a891dde9f
parentfc0ac4d9ae743ee855180ccdb8f24a9eeef896cc (diff)
added support for partial flash resets
-rw-r--r--flash.c16
-rw-r--r--flash.h2
-rw-r--r--instr-daemon.c2
3 files changed, 13 insertions, 7 deletions
diff --git a/flash.c b/flash.c
index e6565f5..6eaf6aa 100644
--- a/flash.c
+++ b/flash.c
@@ -695,8 +695,8 @@ static void initFlashValues(FlashStruct *mem)
mem->extended_relay_delay_in_sec=0.5;
mem->wait_states_after_sock_init=10000;
- /*0123456789012345678901234567890123456789*/
- strcpy(mem->aux_error_message,"incorrect polarity - output disabled.");
+ /*0123456789012345678901234567890123456789*/
+ strcpy(mem->aux_error_message,"PRF too high! Output disabled.");
/* default PW DACs */
@@ -735,17 +735,23 @@ static void initFlashValues(FlashStruct *mem)
}
-void initFlash(FlashStruct *mem)
+void initFlash(FlashStruct *mem, int starting_location)
{
int read_size = readUserBlock(mem);
- if ((read_size == 0) || (mem->fully_programmed == Not_Programmed)) {
+ if ( (read_size == 0) ||
+ (mem->fully_programmed == Not_Programmed) ||
+ ((starting_location > 0) && (starting_location < sizeof(*mem))) ) {
// uninitialized device!
initFlashValues(mem);
// save the default Flash config, for nonvolatile persistence
- writeUserBlock(mem, 0, sizeof(*mem));
+ writeUserBlock(mem, starting_location, sizeof(*mem) - starting_location);
+
+ if (starting_location > 0) {
+ readUserBlock(mem);
+ }
}
}
diff --git a/flash.h b/flash.h
index c1de542..183e932 100644
--- a/flash.h
+++ b/flash.h
@@ -3,7 +3,7 @@
#include "globals.h"
-void initFlash(FlashStruct *mem);
+void initFlash(FlashStruct *mem, int starting_location);
int readUserBlock(FlashStruct *mem);
void writeUserBlock(FlashStruct *mem, int addr, int numbytes);
diff --git a/instr-daemon.c b/instr-daemon.c
index b9bbd4d..8205c9a 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -231,7 +231,7 @@ int main(int argc, char **argv)
LCD_initialize();
bus_init();
- initFlash (&globals.Flash);
+ initFlash (&globals.Flash, 0);
//register stdin channel
stdinChannel = g_io_channel_unix_new(0);