altos: Define ao_log_mutex in ao_log.c rather than every log product
[fw/altos] / src / kernel / ao_log.c
index 76e0e68c56c89a3286a5f53500210f709b4ef497..d9c3e00f6ce2fb98a40016e161230aae88a02b5e 100644 (file)
@@ -19,6 +19,7 @@
 #include <ao_log.h>
 #include <ao_config.h>
 
+__xdata uint8_t        ao_log_mutex;
 __pdata uint32_t ao_log_current_pos;
 __pdata uint32_t ao_log_end_pos;
 __pdata uint32_t ao_log_start_pos;
@@ -67,6 +68,18 @@ ao_log_write_erase(uint8_t pos)
        erase.mark = LOG_ERASE_MARK;
        erase.flight = ao_flight_number;
        ao_config_write(ao_log_erase_pos(pos),  &erase, sizeof (erase));
+
+#if USE_EEPROM_CONFIG
+       if (pos == 0) {
+               uint8_t i;
+               for (i = 1; i < LOG_MAX_ERASE; i++) {
+                       erase.mark = ~LOG_ERASE_MARK;
+                       erase.flight = 0;
+                       ao_config_write(ao_log_erase_pos(i), &erase, sizeof (erase));
+               }
+       }
+#endif
+
        ao_config_flush();
 }