Fixed GPS initialisation

This commit is contained in:
Mark Qvist 2019-11-08 16:36:01 +01:00
parent 07f4b198bc
commit 98d2093485
3 changed files with 28 additions and 15 deletions

View File

@ -43,22 +43,28 @@ void gps_init(Serial *ser) {
if (gps_detect()) { if (gps_detect()) {
gps_installed = true; gps_installed = true;
serial_setbaudrate_9600(1);
delay_ms(100);
gps_send_command(PMTK_SET_BAUD_57600);
delay_ms(100);
serial_setbaudrate_57600(1);
delay_ms(100);
gps_send_command(PMTK_API_SET_FIX_CTL_1HZ);
gps_send_command(PMTK_SET_NMEA_OUTPUT_RMCGGA);
GPS_DDR |= _BV(GPS_EN_PIN); GPS_DDR |= _BV(GPS_EN_PIN);
if (gps_enabled()) { gps_powerup(); } else { gps_powerdown(); }
if (config_gps_mode == CONFIG_GPS_AUTODETECT || config_gps_mode == CONFIG_GPS_REQUIRED) {
serial_setbaudrate_9600(1);
delay_ms(100);
gps_send_command(PMTK_SET_BAUD_57600);
delay_ms(100);
serial_setbaudrate_57600(1);
delay_ms(100);
gps_send_command(PMTK_API_SET_FIX_CTL_1HZ);
gps_send_command(PMTK_SET_NMEA_OUTPUT_RMCGGA);
gps_power = true;
gps_powerup();
} else {
gps_power = false;
gps_powerdown();
}
} else { } else {
gps_installed = false; gps_installed = false;
gps_power = false; gps_power = false;

View File

@ -83,6 +83,8 @@ ISR(USART0_RX_vect) {
if (!fifo_isfull(&uart0FIFO)) { if (!fifo_isfull(&uart0FIFO)) {
char c = uart0_getchar_nowait(); char c = uart0_getchar_nowait();
fifo_push(&uart0FIFO, c); fifo_push(&uart0FIFO, c);
} else {
uart1_getchar_nowait();
} }
} }
} }
@ -92,6 +94,8 @@ ISR(USART1_RX_vect) {
if (!fifo_isfull(&uart1FIFO)) { if (!fifo_isfull(&uart1FIFO)) {
char c = uart1_getchar_nowait(); char c = uart1_getchar_nowait();
fifo_push(&uart1FIFO, c); fifo_push(&uart1FIFO, c);
} else {
uart1_getchar_nowait();
} }
} }
} }

3
main.c
View File

@ -65,6 +65,9 @@ void system_check(void) {
} }
} }
// TODO: Check GPS_REQUIRED and BLUETOOTH_REQUIRED
// here before giving green light.
// Give the green light if everything checks out // Give the green light if everything checks out
LED_STATUS_ON(); LED_STATUS_ON();
} }