X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_gps.c;h=c06c635fd9fc3d67bf560671cca0572fbde8e974;hp=32a44fb1b24ca8f52c56e132b403633ec5fb3923;hb=5195fcfe239e430e1f9f11774c9a245c7b29dae9;hpb=d6749bf24792bb41ca700cf4b8e5e1ac1a63cbf0 diff --git a/src/ao_gps.c b/src/ao_gps.c index 32a44fb1..c06c635f 100644 --- a/src/ao_gps.c +++ b/src/ao_gps.c @@ -22,9 +22,27 @@ __xdata uint8_t ao_gps_mutex; __xdata struct ao_gps_data ao_gps_data; +#undef AO_GPS_4800 + +#ifdef AO_GPS_4800 static const char ao_gps_set_nmea[] = "$PSRF100,0,57600,8,1,0*37\r\n"; +#else +static const char ao_gps_set_nmea[] = "$PSRF100,0,4800,8,1,0*0F\r\n"; +#endif const char ao_gps_config[] = { + 0xa0, 0xa2, 0x00, 0x19, /* length: 25 bytes */ + 128, /* Initialize Data Source */ + 0, 0, 0, 0, /* ECEF X */ + 0, 0, 0, 0, /* ECEF Y */ + 0, 0, 0, 0, /* ECEF Z */ + 0, 0, 0, 0, /* Clock Drift */ + 0, 0, 0, 0, /* Time of Week */ + 0, 0, /* Week Number */ + 0, /* Channels */ + 0xc6, /* Clear user data, RTC not accurate, Clear history, clear ephemeris */ + 0x01, 0x46, 0xb0, 0xb3, + 0xa0, 0xa2, 0x00, 0x0e, /* length: 14 bytes */ 136, /* mode control */ 0, 0, /* reserved */ @@ -224,17 +242,22 @@ ao_sirf_parse_41(void) } } -void +static void ao_gps_setup(void) __reentrant { - uint8_t i; + uint8_t i, k; +#ifdef AO_GPS_4800 ao_serial_set_speed(AO_SERIAL_SPEED_4800); - for (i = 0; i < 16; i++) +#endif + for (i = 0; i < 64; i++) ao_serial_putchar(0x00); - for (i = 0; i < sizeof (ao_gps_set_nmea) - 1; i++) - ao_serial_putchar(ao_gps_set_nmea[i]); + for (k = 0; k < 3; k++) + for (i = 0; i < sizeof (ao_gps_set_nmea); i++) + ao_serial_putchar(ao_gps_set_nmea[i]); +#ifdef AO_GPS_4800 ao_serial_set_speed(AO_SERIAL_SPEED_57600); - for (i = 0; i < 16; i++) +#endif + for (i = 0; i < 64; i++) ao_serial_putchar(0x00); } @@ -279,6 +302,7 @@ ao_gps(void) __reentrant uint8_t i, k; uint16_t cksum; + ao_gps_setup(); for (k = 0; k < 5; k++) { for (i = 0; i < sizeof (ao_gps_config); i++) @@ -289,9 +313,9 @@ ao_gps(void) __reentrant } for (;;) { /* Locate the begining of the next record */ - while (ao_sirf_byte() != 0xa0) + while (ao_sirf_byte() != (uint8_t) 0xa0) ; - if (ao_sirf_byte() != 0xa2) + if (ao_sirf_byte() != (uint8_t) 0xa2) continue; /* Length */ @@ -321,9 +345,9 @@ ao_gps(void) __reentrant cksum |= ao_sirf_byte(); if (ao_sirf_cksum != cksum) continue; - if (ao_sirf_byte() != 0xb0) + if (ao_sirf_byte() != (uint8_t) 0xb0) continue; - if (ao_sirf_byte() != 0xb3) + if (ao_sirf_byte() != (uint8_t) 0xb3) continue; switch (i) {