altos: Share log code between telescience and telebt. Add telebt log
[fw/altos] / src / core / ao_log_telem.c
index 1b472efe38614a7d2d52cb2dd6b896b3c836a1dc..34abe879b210bf20637f108afe6d0be3c49998f7 100644 (file)
 
 #include "ao.h"
 
+__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEMETRY;
+
+static __data uint8_t  ao_log_monitor_pos;
+
+void
+ao_log_single(void)
+{
+       ao_storage_setup();
+
+       /* This can take a while, so let the rest
+        * of the system finish booting before we start
+        */
+       ao_delay(AO_SEC_TO_TICKS(2));
+
+       ao_log_single_restart();
+       for (;;) {
+               while (!ao_log_running)
+                       ao_sleep(&ao_log_running);
+
+               ao_log_monitor_pos = ao_monitor_head;
+               while (ao_log_running) {
+                       /* Write samples to EEPROM */
+                       while (ao_log_monitor_pos != ao_monitor_head) {
+                               memcpy(&ao_log_single_write_data.telemetry,
+                                      &ao_monitor_ring[ao_log_monitor_pos],
+                                      AO_LOG_SINGLE_SIZE);
+                               ao_log_single_write();
+                               ao_log_monitor_pos = ao_monitor_ring_next(ao_log_monitor_pos);
+                       }
+                       /* Wait for more ADC data to arrive */
+                       ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+               }
+       }
+}
+
 void
-ao_log_write_erase(uint8_t pos)
+ao_log_single_list(void)
 {
-       (void) pos;
+       if (ao_log_current_pos != 0)
+               printf("flight 1 start %x end %x\n",
+                      0,
+                      (uint16_t) ((ao_log_current_pos + 0xff) >> 8));
+       printf ("done\n");
 }
 
-uint8_t
-ao_log_present(void)
+void
+ao_log_single_extra_query(void)
 {
-       return 0;
 }