a stab at turning on rudimentary logging for telefiretwo
[fw/altos] / src / kernel / ao_log_micro.c
index d665efb5b56f94e1123afe8df306ad02dc53bbca..aa0f5c76c45f9c3277d638fa090f777b5946d55f 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 
 static uint16_t ao_log_offset = STARTING_LOG_OFFSET;
 
+#define AO_LOG_ID_SHIFT        12
+#define AO_LOG_ID_MASK ((1 << AO_LOG_ID_SHIFT) - 1)
+
 void
 ao_log_micro_save(void)
 {
        uint16_t        n_samples = (ao_log_offset - STARTING_LOG_OFFSET) / sizeof (uint16_t);
+
+#if AO_LOG_ID
+       n_samples |= AO_LOG_ID << AO_LOG_ID_SHIFT;
+#endif
        ao_eeprom_write(PA_GROUND_OFFSET, &pa_ground, sizeof (pa_ground));
        ao_eeprom_write(PA_MIN_OFFSET, &pa_min, sizeof (pa_min));
        ao_eeprom_write(N_SAMPLES_OFFSET, &n_samples, sizeof (n_samples));
@@ -99,8 +107,12 @@ ao_log_micro_dump(void)
        uint16_t        crc = 0xffff;
 
        ao_eeprom_read(N_SAMPLES_OFFSET, &n_samples, sizeof (n_samples));
+
        if (n_samples == 0xffff)
                n_samples = 0;
+#if AO_LOG_ID
+       n_samples &= AO_LOG_ID_MASK;
+#endif
        nbytes = STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples;
        ao_async_start();
        ao_async_byte('M');