2 * Copyright © 2009 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.
20 __xdata struct ao_task ao_gps_task;
22 #define AO_GPS_MAX_LINE 80
24 #define AO_GPS_LEADER 6
26 __xdata uint8_t ao_gps_line[AO_GPS_MAX_LINE+1] = "GPGGA,";
27 __xdata uint8_t ao_gps_mutex;
28 __xdata uint8_t ao_gps_data;
30 const uint8_t ao_gps_config[] =
31 "$PSRF103,00,00,01,01*25\r\n" /* GGA 1 per sec */
32 "$PSRF103,01,00,00,01*25\r\n" /* GLL disable */
33 "$PSRF103,02,00,00,01*26\r\n" /* GSA disable */
34 "$PSRF103,03,00,00,01*27\r\n" /* GSV disable */
35 "$PSRF103,04,00,00,01*20\r\n" /* RMC disable */
36 "$PSRF103,05,00,00,01*21\r\n"; /* VTG disable */
45 for (i = 0; (c = ao_gps_config[i]); i++)
49 c = ao_serial_getchar();
53 for (i = 0; i < AO_GPS_LEADER; i++)
54 if (ao_serial_getchar() != ao_gps_line[i])
56 if (i != AO_GPS_LEADER)
58 ao_mutex_get(&ao_gps_mutex);
60 c = ao_serial_getchar();
63 if (i < AO_GPS_MAX_LINE)
66 ao_gps_line[i] = '\0';
68 ao_mutex_put(&ao_gps_mutex);
69 ao_wakeup(&ao_gps_data);
78 ao_add_task(&ao_gps_task, ao_gps);