summaryrefslogtreecommitdiff
path: root/flash.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-24 14:04:56 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-24 14:04:56 -0400
commitb3c38cf2f99e387359653fc9f9530239c38c381d (patch)
tree781cd5ea77c24a7344bfa4d1d68151c61223143b /flash.c
parent37715d8b1b2a6465f1bb8232df8ae9c73efc743b (diff)
fix writeUserBlock usage, and fix non-obvious rcl values
Diffstat (limited to 'flash.c')
-rw-r--r--flash.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/flash.c b/flash.c
index 89c9c65..f670fa3 100644
--- a/flash.c
+++ b/flash.c
@@ -762,9 +762,9 @@ void initFlash(FlashStruct *mem, gboolean reset_to_defaults, int starting_locati
if ( (read_size == 0) ||
(mem->fully_programmed == Not_Programmed) ||
- (reset_to_defaults &&
- (starting_location >= 0) &&
- (starting_location < sizeof(*mem))) ) {
+ (reset_to_defaults &&
+ (starting_location >= 0) &&
+ (starting_location < sizeof(*mem))) ) {
g_print_debug ("initializing flash memory\n");
LCD_write(0,0,"Initialize Flash Memory ...");
@@ -787,3 +787,54 @@ void initFlash(FlashStruct *mem, gboolean reset_to_defaults, int starting_locati
}
}
+
+void fixFlash(FlashStruct *mem)
+{
+ int i, fix_initial_constants;
+ float composite_min_burst_time[max_channels];
+
+ for (i=0; i<max_channels; i++) {
+
+ composite_min_burst_time[i]=mem->min_burst_gap[i];
+ if ((mem->min_burst_per[i] - mem->min_pw[i]) > composite_min_burst_time[i]) {
+ composite_min_burst_time[i] = mem->min_burst_per[i] - mem->min_pw[i];
+ }
+
+ int j;
+ for (j=0; j<max_stored_settings; j++) {
+ if (mem->rcl_burst_time[i][j] < composite_min_burst_time[i]) {
+ mem->rcl_burst_time[i][j]=composite_min_burst_time[i];
+ ++fix_initial_constants;
+ }
+ if (mem->rcl_rise_time[i][j] < mem->min_rise_time[i]) {
+ mem->rcl_rise_time[i][j]=mem->min_rise_time[i];
+ ++fix_initial_constants;
+ }
+ if (mem->rcl_slew[i][j] < mem->min_slew[i]) {
+ mem->rcl_slew[i][j]=mem->min_slew[i];
+ ++fix_initial_constants;
+ }
+ if (mem->rcl_soft_current_limit[i][j] < mem->min_soft_current_limit[i]) {
+ mem->rcl_soft_current_limit[i][j]=mem->max_soft_current_limit[i];
+ ++fix_initial_constants;
+ }
+ }
+ }
+
+ if (fix_initial_constants) {
+ int eprom_loc;
+
+ eprom_loc = (char *) &(mem->rcl_burst_time) - (char *) &(mem->flash_start);
+ writeUserBlock(&globals.Flash, eprom_loc, sizeof(mem->rcl_burst_time));
+
+ eprom_loc = (char *) &(mem->rcl_rise_time) - (char *) &(mem->flash_start);
+ writeUserBlock(&globals.Flash, eprom_loc, sizeof(mem->rcl_rise_time));
+
+ eprom_loc = (char *) &(mem->rcl_slew) - (char *) &(mem->flash_start);
+ writeUserBlock(&globals.Flash, eprom_loc, sizeof(mem->rcl_slew));
+
+ eprom_loc = (char *) &(mem->rcl_soft_current_limit) - (char *) &(mem->flash_start);
+ writeUserBlock(&globals.Flash, eprom_loc, sizeof(mem->rcl_soft_current_limit));
+ }
+
+}