|
@@ -98,6 +98,10 @@ unsigned int get_stack_free_bytes(void) {
|
|
|
return count;
|
|
return count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void request_immediate_sync(void) {
|
|
|
|
|
+ FLAGS |= F_SYNC;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void io_mark(unsigned long int start_ms) {
|
|
void io_mark(unsigned long int start_ms) {
|
|
|
unsigned int dt = (unsigned int)(get_uptime_ms() - start_ms);
|
|
unsigned int dt = (unsigned int)(get_uptime_ms() - start_ms);
|
|
|
if (dt > io_max_ms)
|
|
if (dt > io_max_ms)
|
|
@@ -229,8 +233,10 @@ ISR(ADC_vect)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (bat_volt < VI_LVL) {
|
|
if (bat_volt < VI_LVL) {
|
|
|
- if (++lvt >= 3)
|
|
|
|
|
|
|
+ if (++lvt >= 3) {
|
|
|
FLAGS |= F_LVD;
|
|
FLAGS |= F_LVD;
|
|
|
|
|
+ FLAGS |= F_SYNC; /* flush now, as early as possible before an imminent brownout */
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
lvt = 0;
|
|
lvt = 0;
|
|
|
}
|
|
}
|
|
@@ -428,6 +434,7 @@ int main (void)
|
|
|
settings_load();
|
|
settings_load();
|
|
|
reset_counters();
|
|
reset_counters();
|
|
|
log_boot_record();
|
|
log_boot_record();
|
|
|
|
|
+ request_immediate_sync(); /* flush the boot/config lines as soon as a log file opens, not after up to IVT_SYNC seconds */
|
|
|
|
|
|
|
|
menu_push(default_menu);
|
|
menu_push(default_menu);
|
|
|
|
|
|
|
@@ -450,6 +457,7 @@ int main (void)
|
|
|
|
|
|
|
|
display_event(DISPLAY_EVENT_INITIALIZED);
|
|
display_event(DISPLAY_EVENT_INITIALIZED);
|
|
|
log_loop_status(System.status);
|
|
log_loop_status(System.status);
|
|
|
|
|
+ request_immediate_sync(); /* flush the just-logged loop/error status promptly */
|
|
|
utc = 0;
|
|
utc = 0;
|
|
|
localtime = 0;
|
|
localtime = 0;
|
|
|
prev_status = System.status;
|
|
prev_status = System.status;
|