altos: Add TeleMega v6.0
[fw/altos] / src / kernel / ao_log.h
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AO_LOG_H_
20 #define _AO_LOG_H_
21
22 #include <ao_flight.h>
23
24 /*
25  * ao_log.c
26  */
27
28 /* We record flight numbers in the first record of
29  * the log. Tasks may wait for this to be initialized
30  * by sleeping on this variable.
31  */
32 extern uint16_t ao_flight_number;
33 extern uint8_t  ao_log_mutex;
34 extern uint32_t ao_log_current_pos;
35 extern uint32_t ao_log_end_pos;
36 extern uint32_t ao_log_start_pos;
37 extern uint8_t  ao_log_running;
38 extern enum ao_flight_state ao_log_state;
39
40 /* required functions from the underlying log system */
41
42 #define AO_LOG_FORMAT_UNKNOWN           0       /* unknown; altosui will have to guess */
43 #define AO_LOG_FORMAT_FULL              1       /* 8 byte typed log records */
44 #define AO_LOG_FORMAT_TINY              2       /* two byte state/baro records */
45 #define AO_LOG_FORMAT_TELEMETRY         3       /* 32 byte ao_telemetry records */
46 #define AO_LOG_FORMAT_TELESCIENCE       4       /* 32 byte typed telescience records */
47 #define AO_LOG_FORMAT_TELEMEGA_OLD      5       /* 32 byte typed telemega records */
48 #define AO_LOG_FORMAT_EASYMINI1         6       /* 16-byte MS5607 baro only, 3.0V supply */
49 #define AO_LOG_FORMAT_TELEMETRUM        7       /* 16-byte typed telemetrum records */
50 #define AO_LOG_FORMAT_TELEMINI2         8       /* 16-byte MS5607 baro only, 3.3V supply, cc1111 SoC */
51 #define AO_LOG_FORMAT_TELEGPS           9       /* 32 byte telegps records */
52 #define AO_LOG_FORMAT_TELEMEGA          10      /* 32 byte typed telemega records with 32 bit gyro cal */
53 #define AO_LOG_FORMAT_DETHERM           11      /* 16-byte MS5607 baro only, no ADC */
54 #define AO_LOG_FORMAT_TELEMINI3         12      /* 16-byte MS5607 baro only, 3.3V supply, stm32f042 SoC */
55 #define AO_LOG_FORMAT_TELEFIRETWO       13      /* 32-byte test stand data */
56 #define AO_LOG_FORMAT_EASYMINI2         14      /* 16-byte MS5607 baro only, 3.3V supply, stm32f042 SoC */
57 #define AO_LOG_FORMAT_TELEMEGA_3        15      /* 32 byte typed telemega records with 32 bit gyro cal and mpu9250 */
58 #define AO_LOG_FORMAT_EASYMEGA_2        16      /* 32 byte typed telemega records with 32 bit gyro cal, mpu9250 rotated 90° and adxl375 */
59 #define AO_LOG_FORMAT_TELESTATIC        17      /* 32 byte typed telestatic records */
60 #define AO_LOG_FORMAT_MICROPEAK2        18      /* 2-byte baro values with header */
61 #define AO_LOG_FORMAT_TELEMEGA_4        19      /* 32 byte typed telemega records with 32 bit gyro cal and Bmx160 */
62 #define AO_LOG_FORMAT_EASYMOTOR         20      /* 16 byte typed easymotor records with pressure sensor and adxl375 */
63 #define AO_LOG_FORMAT_TELEMEGA_5        21      /* 32 byte typed telemega records with 32 bit gyro cal, mpu6000 and mmc5983 */
64 #define AO_LOG_FORMAT_TELEMEGA_6        22      /* 32 byte typed telemega records with 32 bit gyro cal, bmi088 and mmc5983 */
65 #define AO_LOG_FORMAT_NONE              127     /* No log at all */
66
67 /* Return the flight number from the given log slot, 0 if none, -slot on failure */
68
69 int32_t
70 ao_log_flight(uint8_t slot);
71
72 /* Checksum the loaded log record */
73 uint8_t
74 ao_log_check_data(void);
75
76 /* Check to see if the loaded log record is empty */
77 uint8_t
78 ao_log_check_clear(void);
79
80 /* Check if there is valid log data at the specified location */
81 #define AO_LOG_VALID    1
82 #define AO_LOG_EMPTY    0
83 #define AO_LOG_INVALID  -1
84
85 int8_t
86 ao_log_check(uint32_t pos);
87
88 /* Flush the log */
89 void
90 ao_log_flush(void);
91
92 /* Logging thread main routine */
93 void
94 ao_log(void);
95
96 /* functions provided in ao_log.c */
97
98 /* Figure out the current flight number */
99 uint8_t
100 ao_log_scan(void);
101
102 /* Start logging to eeprom */
103 void
104 ao_log_start(void);
105
106 /* Stop logging */
107 void
108 ao_log_stop(void);
109
110 /* Initialize the logging system */
111 void
112 ao_log_init(void);
113
114 /* Write out the current flight number to the erase log */
115 void
116 ao_log_write_erase(uint8_t pos);
117
118 /* Returns true if there are any logs stored in eeprom */
119 uint8_t
120 ao_log_present(void);
121
122 /* Returns true if there is no more storage space available */
123 uint8_t
124 ao_log_full(void);
125
126 /*
127  * ao_log_big.c
128  */
129
130 /*
131  * The data log is recorded in the eeprom as a sequence
132  * of data packets.
133  *
134  * Each packet starts with a 4-byte header that has the
135  * packet type, the packet checksum and the tick count. Then
136  * they all contain 2 16 bit values which hold packet-specific
137  * data.
138  *
139  * For each flight, the first packet
140  * is FLIGHT packet, indicating the serial number of the
141  * device and a unique number marking the number of flights
142  * recorded by this device.
143  *
144  * During flight, data from the accelerometer and barometer
145  * are recorded in SENSOR packets, using the raw 16-bit values
146  * read from the A/D converter.
147  *
148  * Also during flight, but at a lower rate, the deployment
149  * sensors are recorded in DEPLOY packets. The goal here is to
150  * detect failure in the deployment circuits.
151  *
152  * STATE packets hold state transitions as the flight computer
153  * transitions through different stages of the flight.
154  */
155 #define AO_LOG_FLIGHT           'F'
156 #define AO_LOG_SENSOR           'A'
157 #define AO_LOG_TEMP_VOLT        'T'
158 #define AO_LOG_DEPLOY           'D'
159 #define AO_LOG_STATE            'S'
160 #define AO_LOG_GPS_TIME         'G'
161 #define AO_LOG_GPS_LAT          'N'
162 #define AO_LOG_GPS_LON          'W'
163 #define AO_LOG_GPS_ALT          'H'
164 #define AO_LOG_GPS_SAT          'V'
165 #define AO_LOG_GPS_DATE         'Y'
166 #define AO_LOG_GPS_POS          'P'
167
168 #define AO_LOG_POS_NONE         (~0UL)
169
170 struct ao_log_record {
171         char                    type;                           /* 0 */
172         uint8_t                 csum;                           /* 1 */
173         uint16_t                tick;                           /* 2 */
174         union {
175                 struct {
176                         int16_t         ground_accel;           /* 4 */
177                         uint16_t        flight;                 /* 6 */
178                 } flight;
179                 struct {
180                         int16_t         accel;                  /* 4 */
181                         int16_t         pres;                   /* 6 */
182                 } sensor;
183                 struct {
184                         int16_t         temp;
185                         int16_t         v_batt;
186                 } temp_volt;
187                 struct {
188                         int16_t         drogue;
189                         int16_t         main;
190                 } deploy;
191                 struct {
192                         uint16_t        state;
193                         uint16_t        reason;
194                 } state;
195                 struct {
196                         uint8_t         hour;
197                         uint8_t         minute;
198                         uint8_t         second;
199                         uint8_t         flags;
200                 } gps_time;
201                 int32_t         gps_latitude;
202                 int32_t         gps_longitude;
203                 struct {
204                         uint16_t        altitude_low;
205                         int16_t         altitude_high;
206                 } gps_altitude;
207                 struct {
208                         uint16_t        svid;
209                         uint8_t         unused;
210                         uint8_t         c_n;
211                 } gps_sat;
212                 struct {
213                         uint8_t         year;
214                         uint8_t         month;
215                         uint8_t         day;
216                         uint8_t         extra;
217                 } gps_date;
218                 struct {
219                         uint16_t        d0;
220                         uint16_t        d1;
221                 } anon;
222         } u;
223 };
224
225 struct ao_log_mega {
226         char                    type;                   /* 0 */
227         uint8_t                 csum;                   /* 1 */
228         uint16_t                tick;                   /* 2 */
229         union {                                         /* 4 */
230                 /* AO_LOG_FLIGHT */
231                 struct {
232                         uint16_t        flight;                 /* 4 */
233                         int16_t         ground_accel;           /* 6 */
234                         int32_t         ground_pres;            /* 8 */
235                         int16_t         ground_accel_along;     /* 12 */
236                         int16_t         ground_accel_across;    /* 14 */
237                         int16_t         ground_accel_through;   /* 16 */
238                         int16_t         pad_18;                 /* 18 */
239                         int32_t         ground_roll;            /* 20 */
240                         int32_t         ground_pitch;           /* 24 */
241                         int32_t         ground_yaw;             /* 28 */
242                 } flight;                                       /* 32 */
243                 struct {
244                         uint16_t        flight;                 /* 4 */
245                         int16_t         ground_accel;           /* 6 */
246                         int32_t         ground_pres;            /* 8 */
247                         int16_t         ground_accel_along;     /* 12 */
248                         int16_t         ground_accel_across;    /* 14 */
249                         int16_t         ground_accel_through;   /* 16 */
250                         int16_t         ground_roll;            /* 18 */
251                         int16_t         ground_pitch;           /* 20 */
252                         int16_t         ground_yaw;             /* 22 */
253                 } flight_old;                                   /* 24 */
254                 /* AO_LOG_STATE */
255                 struct {
256                         uint16_t        state;
257                         uint16_t        reason;
258                 } state;
259                 /* AO_LOG_SENSOR */
260                 struct {
261                         uint32_t        pres;           /* 4 */
262                         uint32_t        temp;           /* 8 */
263                         union {
264                                 struct {
265                                         int16_t         accel_along;    /* 12 */
266                                         int16_t         accel_across;   /* 14 */
267                                         int16_t         accel_through;  /* 16 */
268                                         int16_t         gyro_roll;      /* 18 */
269                                         int16_t         gyro_pitch;     /* 20 */
270                                         int16_t         gyro_yaw;       /* 22 */
271                                         int16_t         mag_along;      /* 24 */
272                                         int16_t         mag_across;     /* 26 */
273                                         int16_t         mag_through;    /* 28 */
274                                 };
275                                 struct {
276                                         int16_t         accel_x;        /* 12 */
277                                         int16_t         accel_y;        /* 14 */
278                                         int16_t         accel_z;        /* 16 */
279                                         int16_t         gyro_x;         /* 18 */
280                                         int16_t         gyro_y;         /* 20 */
281                                         int16_t         gyro_z;         /* 22 */
282                                         int16_t         mag_x;          /* 24 */
283                                         int16_t         mag_z;          /* 26 */
284                                         int16_t         mag_y;          /* 28 */
285                                 };
286                         };
287                         int16_t         accel;          /* 30 */
288                 } sensor;       /* 32 */
289                 /* AO_LOG_TEMP_VOLT */
290                 struct {
291                         int16_t         v_batt;         /* 4 */
292                         int16_t         v_pbatt;        /* 6 */
293                         int16_t         n_sense;        /* 8 */
294                         int16_t         sense[10];      /* 10 */
295                         uint16_t        pyro;           /* 30 */
296                 } volt;                                 /* 32 */
297                 /* AO_LOG_GPS_TIME */
298                 struct {
299                         int32_t         latitude;       /* 4 */
300                         int32_t         longitude;      /* 8 */
301                         uint16_t        altitude_low;   /* 12 */
302                         uint8_t         hour;           /* 14 */
303                         uint8_t         minute;         /* 15 */
304                         uint8_t         second;         /* 16 */
305                         uint8_t         flags;          /* 17 */
306                         uint8_t         year;           /* 18 */
307                         uint8_t         month;          /* 19 */
308                         uint8_t         day;            /* 20 */
309                         uint8_t         course;         /* 21 */
310                         uint16_t        ground_speed;   /* 22 */
311                         int16_t         climb_rate;     /* 24 */
312                         uint8_t         pdop;           /* 26 */
313                         uint8_t         hdop;           /* 27 */
314                         uint8_t         vdop;           /* 28 */
315                         uint8_t         mode;           /* 29 */
316                         int16_t         altitude_high;  /* 30 */
317                 } gps;  /* 32 */
318                 /* AO_LOG_GPS_SAT */
319                 struct {
320                         uint16_t        channels;       /* 4 */
321                         struct {
322                                 uint8_t svid;
323                                 uint8_t c_n;
324                         } sats[12];                     /* 6 */
325                 } gps_sat;                              /* 30 */
326         } u;
327 };
328
329 #define AO_LOG_MEGA_GPS_ALTITUDE(l)     ((int32_t) ((l)->u.gps.altitude_high << 16) | ((l)->u.gps.altitude_low))
330 #define AO_LOG_MEGA_SET_GPS_ALTITUDE(l,a)       (((l)->u.gps.mode |= AO_GPS_MODE_ALTITUDE_24), \
331                                                  ((l)->u.gps.altitude_high = (a) >> 16), \
332                                                  (l)->u.gps.altitude_low = (a))
333
334 struct ao_log_firetwo {
335         char                    type;                   /* 0 */
336         uint8_t                 csum;                   /* 1 */
337         uint16_t                tick;                   /* 2 */
338         union {                                         /* 4 */
339                 /* AO_LOG_FLIGHT */
340                 struct {
341                         uint16_t        flight;         /* 4 */
342                 } flight;       /* 6 */
343                 /* AO_LOG_STATE */
344                 struct {
345                         uint16_t        state;          /* 4 */
346                         uint16_t        reason;         /* 6 */
347                 } state;        /* 8 */
348                 /* AO_LOG_SENSOR */
349                 struct {
350                         uint16_t        pressure;       /* 4 */
351                         uint16_t        thrust;         /* 6 */
352                         uint16_t        thermistor[4];  /* 8 */
353                 } sensor;       /* 24 */
354                 uint8_t         align[28];              /* 4 */
355         } u;    /* 32 */
356 };
357
358 struct ao_log_telestatic {
359         char                    type;                   /* 0 */
360         uint8_t                 csum;                   /* 1 */
361         uint16_t                tick;                   /* 2 */
362         union {                                         /* 4 */
363                 /* AO_LOG_FLIGHT */
364                 struct {
365                         uint16_t        flight;         /* 4 */
366                 } flight;       /* 6 */
367                 /* AO_LOG_STATE */
368                 struct {
369                         uint16_t        state;          /* 4 */
370                         uint16_t        reason;         /* 6 */
371                 } state;        /* 8 */
372                 /* AO_LOG_SENSOR */
373                 struct {
374                         uint32_t        pressure;       /* 4 */
375                         uint32_t        pressure2;      /* 8 */
376                         uint32_t        thrust;         /* 12 */
377                         uint32_t        mass;           /* 16 */
378                         uint16_t        t_low;          /* 20 */
379                         uint16_t        t_high[4];      /* 22 */
380                 } sensor;       /* 30 */
381                 uint8_t         align[28];              /* 4 */
382         } u;    /* 32 */
383 };
384
385 struct ao_log_metrum {
386         char                    type;                   /* 0 */
387         uint8_t                 csum;                   /* 1 */
388         uint16_t                tick;                   /* 2 */
389         union {                                         /* 4 */
390                 /* AO_LOG_FLIGHT */
391                 struct {
392                         uint16_t        flight;         /* 4 */
393                         int16_t         ground_accel;   /* 6 */
394                         int32_t         ground_pres;    /* 8 */
395                         uint32_t        ground_temp;    /* 12 */
396                 } flight;       /* 16 */
397                 /* AO_LOG_STATE */
398                 struct {
399                         uint16_t        state;          /* 4 */
400                         uint16_t        reason;         /* 6 */
401                 } state;        /* 8 */
402                 /* AO_LOG_SENSOR */
403                 struct {
404                         uint32_t        pres;           /* 4 */
405                         uint32_t        temp;           /* 8 */
406                         int16_t         accel;          /* 12 */
407                 } sensor;       /* 14 */
408                 /* AO_LOG_TEMP_VOLT */
409                 struct {
410                         int16_t         v_batt;         /* 4 */
411                         int16_t         sense_a;        /* 6 */
412                         int16_t         sense_m;        /* 8 */
413                 } volt;         /* 10 */
414                 /* AO_LOG_GPS_POS */
415                 struct {
416                         int32_t         latitude;       /* 4 */
417                         int32_t         longitude;      /* 8 */
418                         uint16_t        altitude_low;   /* 12 */
419                         int16_t         altitude_high;  /* 14 */
420                 } gps;          /* 16 */
421                 /* AO_LOG_GPS_TIME */
422                 struct {
423                         uint8_t         hour;           /* 4 */
424                         uint8_t         minute;         /* 5 */
425                         uint8_t         second;         /* 6 */
426                         uint8_t         flags;          /* 7 */
427                         uint8_t         year;           /* 8 */
428                         uint8_t         month;          /* 9 */
429                         uint8_t         day;            /* 10 */
430                         uint8_t         pdop;           /* 11 */
431                 } gps_time;     /* 12 */
432                 /* AO_LOG_GPS_SAT (up to three packets) */
433                 struct {
434                         uint8_t channels;               /* 4 */
435                         uint8_t more;                   /* 5 */
436                         struct {
437                                 uint8_t svid;
438                                 uint8_t c_n;
439                         } sats[4];                      /* 6 */
440                 } gps_sat;                              /* 14 */
441                 uint8_t         raw[12];                /* 4 */
442         } u;    /* 16 */
443 };
444
445 struct ao_log_mini {
446         char            type;                           /* 0 */
447         uint8_t         csum;                           /* 1 */
448         uint16_t        tick;                           /* 2 */
449         union {                                         /* 4 */
450                 /* AO_LOG_FLIGHT */
451                 struct {
452                         uint16_t        flight;         /* 4 */
453                         uint16_t        r6;
454                         int32_t         ground_pres;    /* 8 */
455                 } flight;
456                 /* AO_LOG_STATE */
457                 struct {
458                         uint16_t        state;          /* 4 */
459                         uint16_t        reason;         /* 6 */
460                 } state;
461                 /* AO_LOG_SENSOR */
462                 struct {
463                         uint8_t         pres[3];        /* 4 */
464                         uint8_t         temp[3];        /* 7 */
465                         int16_t         sense_a;        /* 10 */
466                         int16_t         sense_m;        /* 12 */
467                         int16_t         v_batt;         /* 14 */
468                 } sensor;                               /* 16 */
469         } u;                                            /* 16 */
470 };                                                      /* 16 */
471
472 #define ao_log_pack24(dst,value) do {           \
473                 (dst)[0] = (uint8_t) (value);   \
474                 (dst)[1] = (uint8_t) ((value) >> 8);    \
475                 (dst)[2] = (uint8_t) ((value) >> 16);   \
476         } while (0)
477
478 struct ao_log_gps {
479         char                    type;                   /* 0 */
480         uint8_t                 csum;                   /* 1 */
481         uint16_t                tick;                   /* 2 */
482         union {                                         /* 4 */
483                 /* AO_LOG_FLIGHT */
484                 struct {
485                         uint16_t        flight;                 /* 4 */
486                         int16_t         start_altitude;         /* 6 */
487                         int32_t         start_latitude;         /* 8 */
488                         int32_t         start_longitude;        /* 12 */
489                 } flight;                                       /* 16 */
490                 /* AO_LOG_GPS_TIME */
491                 struct {
492                         int32_t         latitude;       /* 4 */
493                         int32_t         longitude;      /* 8 */
494                         uint16_t        altitude_low;   /* 12 */
495                         uint8_t         hour;           /* 14 */
496                         uint8_t         minute;         /* 15 */
497                         uint8_t         second;         /* 16 */
498                         uint8_t         flags;          /* 17 */
499                         uint8_t         year;           /* 18 */
500                         uint8_t         month;          /* 19 */
501                         uint8_t         day;            /* 20 */
502                         uint8_t         course;         /* 21 */
503                         uint16_t        ground_speed;   /* 22 */
504                         int16_t         climb_rate;     /* 24 */
505                         uint8_t         pdop;           /* 26 */
506                         uint8_t         hdop;           /* 27 */
507                         uint8_t         vdop;           /* 28 */
508                         uint8_t         mode;           /* 29 */
509                         int16_t         altitude_high;  /* 30 */
510                 } gps;  /* 31 */
511                 /* AO_LOG_GPS_SAT */
512                 struct {
513                         uint16_t        channels;       /* 4 */
514                         struct {
515                                 uint8_t svid;
516                                 uint8_t c_n;
517                         } sats[12];                     /* 6 */
518                 } gps_sat;                              /* 30 */
519         } u;
520 };
521
522 struct ao_log_motor {
523         char                    type;                   /* 0 */
524         uint8_t                 csum;                   /* 1 */
525         uint16_t                tick;                   /* 2 */
526         union {                                         /* 4 */
527                 /* AO_LOG_FLIGHT */
528                 struct {
529                         uint16_t        flight;                 /* 4 */
530                         int16_t         ground_accel;           /* 6 */
531                         int16_t         ground_accel_along;     /* 8 */
532                         int16_t         ground_accel_across;    /* 10 */
533                         int16_t         ground_accel_through;   /* 12 */
534                         int16_t         ground_motor_pressure;  /* 14 */
535                 } flight;                                       /* 16 */
536                 /* AO_LOG_STATE */
537                 struct {
538                         uint16_t        state;                  /* 4 */
539                         uint16_t        reason;                 /* 6 */
540                 } state;
541                 /* AO_LOG_SENSOR */
542                 struct {
543                         uint16_t        pressure;               /* 4 */
544                         uint16_t        v_batt;                 /* 6 */
545                         int16_t         accel;                  /* 8 */
546                         int16_t         accel_across;           /* 10 */
547                         int16_t         accel_along;            /* 12 */
548                         int16_t         accel_through;          /* 14 */
549                 } sensor;                                       /* 16 */
550         } u;
551 };
552
553 #if AO_LOG_FORMAT == AO_LOG_FOMAT_TELEMEGA_OLD || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA_3 || AO_LOG_FORMAT == AO_LOG_FORMAT_EASYMEGA_2 || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA_4 || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA_5 || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA_6
554 typedef struct ao_log_mega ao_log_type;
555 #endif
556
557 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMETRUM
558 typedef struct ao_log_metrum ao_log_type;
559 #endif
560
561 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TELEFIRETWO
562 typedef struct ao_log_firetwo ao_log_type;
563 #endif
564
565 #if AO_LOG_FORMAT == AO_LOG_FORMAT_EASYMINI1 || AO_LOG_FORMAT == AO_LOG_FORMAT_EASYMINI2 || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMINI2 || AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMINI3
566 typedef struct ao_log_mini ao_log_type;
567 #endif
568
569 #if AO_LOG_FORMAT == AO_LOG_FORMAT_EASYMOTOR
570 typedef struct ao_log_motor ao_log_type;
571 #endif 
572
573 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TELEGPS
574 typedef struct ao_log_gps ao_log_type;
575 #endif
576
577 #if AO_LOG_FORMAT == AO_LOG_FORMAT_FULL
578 typedef struct ao_log_record ao_log_type;
579 #endif
580
581 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TINY
582 #define AO_LOG_UNCOMMON 1
583 #endif
584
585 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMETRY
586 #define AO_LOG_UNCOMMON 1
587 #endif
588
589 #if AO_LOG_FORMAT == AO_LOG_FORMAT_TELESCIENCE
590 #define AO_LOG_UNCOMMON 1
591 #endif
592
593 #if AO_LOG_FORMAT == AO_LOG_FORMAT_MICROPEAK2
594 #define AO_LOG_UNCOMMON 1
595 #endif
596
597 #ifndef AO_LOG_UNCOMMON
598 extern ao_log_type ao_log_data;
599
600 #define AO_LOG_SIZE sizeof(ao_log_type)
601
602 /* Write a record to the eeprom log */
603
604 uint8_t
605 ao_log_write(ao_log_type *log);
606 #endif
607
608 void
609 ao_log_flush(void);
610
611 void
612 ao_gps_report_metrum_init(void);
613
614 #endif /* _AO_LOG_H_ */