2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 #include <ao_telemetry.h>
31 * @section copyright_sec Copyright
33 * Copyright (c) 2001-2009 Michael Gray, KD7LMO
38 * @section gpl_sec GNU General Public License
40 * This program is free software; you can redistribute it and/or modify
41 * it under the terms of the GNU General Public License as published by
42 * the Free Software Foundation; either version 2 of the License, or
43 * (at your option) any later version.
45 * This program is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU General Public License for more details.
50 * You should have received a copy of the GNU General Public License
51 * along with this program; if not, write to the Free Software
52 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60 int samples = secs * 9600;
66 // This is where we go after reset.
67 int main(int argc, char **argv)
69 uint8_t utcSeconds, lockLostCounter, i;
74 // Transmit software version packet on start up.
75 tncTxPacket(TNC_MODE_1200_AFSK);
77 // Counters to send packets if the GPS time stamp is not available.
81 // This is the main loop that process GPS data and waits for the once per second timer tick.
82 for (i = 0; i < 5; i++)
85 // Read the GPS engine serial port FIFO and process the GPS data.
90 // Start the flight timer when we get a valid 3D fix.
91 if (gpsGetFixType() == GPS_3D_FIX)
94 // Generate our packets based on the GPS time.
95 if (tncIsTimeSlot(gpsPosition.seconds))
96 tncTxPacket(TNC_MODE_1200_AFSK);
98 // Sync the internal clock to GPS UTC time.
99 utcSeconds = gpsPosition.seconds;
101 // This counter is reset every time we receive the GPS message.
104 // Log the data to flash.
106 } // END if gpsIsReady
108 // Processing that occurs once a second.
111 // We maintain the UTC time in seconds if we shut off the GPS engine or it fails.
112 if (++utcSeconds == 60)
115 // If we loose information for more than 5 seconds,
116 // we will determine when to send a packet based on internal time.
117 if (lockLostCounter == 5)
119 if (tncIsTimeSlot(utcSeconds))
120 tncTxPacket(TNC_MODE_1200_AFSK);
124 // Update the ADC filters.
127 if (timeHours == 5 && timeMinutes == 0 && timeSeconds == 0)
130 } // END if timeIsUpdate