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
57 // This is where we go after reset.
58 int main(int argc, char **argv)
60 uint8_t utcSeconds, lockLostCounter;
64 // Configure the basic systems.
67 // Wait for the power converter chains to stabilize.
70 // Setup the subsystems.
82 // Transmit software version packet on start up.
83 tncTxPacket(TNC_MODE_1200_AFSK);
86 // Counters to send packets if the GPS time stamp is not available.
90 // This is the main loop that process GPS data and waits for the once per second timer tick.
93 // Read the GPS engine serial port FIFO and process the GPS data.
98 // Start the flight timer when we get a valid 3D fix.
99 if (gpsGetFixType() == GPS_3D_FIX)
102 // Generate our packets based on the GPS time.
103 if (tncIsTimeSlot(gpsPosition.seconds))
104 tncTxPacket(TNC_MODE_1200_AFSK);
106 // Sync the internal clock to GPS UTC time.
107 utcSeconds = gpsPosition.seconds;
109 // This counter is reset every time we receive the GPS message.
112 // Log the data to flash.
114 } // END if gpsIsReady
116 // Processing that occurs once a second.
119 // We maintain the UTC time in seconds if we shut off the GPS engine or it fails.
120 if (++utcSeconds == 60)
123 // If we loose information for more than 5 seconds,
124 // we will determine when to send a packet based on internal time.
125 if (lockLostCounter == 5)
127 if (tncIsTimeSlot(utcSeconds))
128 tncTxPacket(TNC_MODE_1200_AFSK);
132 // Update the ADC filters.
135 if (timeHours == 5 && timeMinutes == 0 && timeSeconds == 0)
138 } // END if timeIsUpdate