altos: Move TeleMetrum v2.0 to using internal eeprom for config
[fw/altos] / src / core / ao_log.c
index 6d3ad535971fff508867195c8e748ff9f161e2fd..1a1f5ff6c37a7c56bd4f6944b59616d599c6da5a 100644 (file)
  */
 
 #include "ao.h"
+#include <ao_log.h>
+#include <ao_config.h>
 
 __pdata uint32_t ao_log_current_pos;
 __pdata uint32_t ao_log_end_pos;
 __pdata uint32_t ao_log_start_pos;
 __xdata uint8_t        ao_log_running;
-__pdata enum flight_state ao_log_state;
+__pdata enum ao_flight_state ao_log_state;
 __xdata uint16_t ao_flight_number;
 
-__code uint8_t ao_log_format = AO_LOG_FORMAT_FULL;
-
 void
 ao_log_flush(void)
 {
@@ -49,7 +49,7 @@ static __xdata struct ao_log_erase erase;
 static uint32_t
 ao_log_erase_pos(uint8_t i)
 {
-       return i * sizeof (struct ao_log_erase) + AO_STORAGE_ERASE_LOG;
+       return i * sizeof (struct ao_log_erase);
 }
 
 void
@@ -57,14 +57,14 @@ ao_log_write_erase(uint8_t pos)
 {
        erase.unused = 0x00;
        erase.flight = ao_flight_number;
-       ao_storage_write(ao_log_erase_pos(pos),  &erase, sizeof (erase));
-       ao_storage_flush();
+       ao_config_write(ao_log_erase_pos(pos),  &erase, sizeof (erase));
+       ao_config_flush();
 }
 
 static void
 ao_log_read_erase(uint8_t pos)
 {
-       ao_storage_read(ao_log_erase_pos(pos), &erase, sizeof (erase));
+       ao_config_read(ao_log_erase_pos(pos), &erase, sizeof (erase));
 }
 
 
@@ -88,7 +88,7 @@ ao_log_erase_mark(void)
 static uint8_t
 ao_log_slots()
 {
-       return (uint8_t) (ao_storage_config / ao_config.flight_log_max);
+       return (uint8_t) (ao_storage_log_max / ao_config.flight_log_max);
 }
 
 uint32_t
@@ -264,7 +264,7 @@ ao_log_delete(void) __reentrant
 }
 
 __code struct ao_cmds ao_log_cmds[] = {
-       { ao_log_list,  "l\0List flight logs" },
+       { ao_log_list,  "l\0List logs" },
        { ao_log_delete,        "d <flight-number>\0Delete flight" },
        { 0,    NULL },
 };
@@ -279,6 +279,11 @@ ao_log_init(void)
 
        ao_cmd_register(&ao_log_cmds[0]);
 
+#ifndef HAS_ADC
+#error Define HAS_ADC for ao_log.c
+#endif
+#if HAS_ADC
        /* Create a task to log events to eeprom */
        ao_add_task(&ao_log_task, ao_log, "log");
+#endif
 }