+__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_running = 1;
+ 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 telemetry data to arrive */
+ ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
+ }
+ }
+}
+