[gps_ubx] improve polling functions, use GPS_MAXIDLE, tidy indent

main-solar-only
Richard Meadows 2016-08-04 12:15:34 +01:00
rodzic d29d7f8176
commit 7505efd54c
3 zmienionych plików z 96 dodań i 89 usunięć

Wyświetl plik

@ -45,7 +45,7 @@ typedef enum {
*/
#define MAXIDLE_WHILE_TELEMETRY_ACTIVE 60000
#define MAXIDLE_WAIT_FOR_NEXT_TELEMETRY 30000
#define MAXIDLE_WAIT_FOR_GPS 30000
#define MAXIDLE_WAIT_FOR_GPS 1000
struct idle_counter {
uint32_t while_telemetry_active;

Wyświetl plik

@ -147,9 +147,10 @@ struct tracker_datapoint* collect_data(void)
* ---- GPS UBX ----
*/
/* wait for GPS, if it takes forever the watchdog will save us */
kick_the_watchdog();
while (gps_update_time_pending() || gps_update_position_pending());
kick_the_watchdog();
while (gps_update_time_pending() || gps_update_position_pending()) {
idle(IDLE_WAIT_FOR_GPS);
}
if (gps_get_error_state() != GPS_NOERROR) {
/* Error updating GPS position */

Wyświetl plik

@ -280,6 +280,16 @@ enum gps_error _ubx_poll(ubx_message_t* message) {
return gps_error_state;
}
/**
* Implements a microsecond delay
*/
static inline void delay_us(uint32_t microseconds)
{
volatile int32_t i = microseconds * 8;
while(i--);
}
/**
* Disable NMEA messages on the uBlox
*/
@ -298,7 +308,7 @@ void gps_set_io_config(uint32_t baud_rate)
(uint8_t*)&ubx_cfg_prt.payload,
sizeof(ubx_cfg_prt.payload));
for (int i = 0; i < 1000*100; i++);
delay_us(1000*50);
}
/**
@ -314,7 +324,7 @@ void gps_cfg_rst(void)
(uint8_t*)&ubx_cfg_rst.payload,
sizeof(ubx_cfg_rst.payload));
for (int i = 0; i < 1000*100; i++);
delay_us(1000*50);
}
@ -668,10 +678,6 @@ void gps_init(void)
/* Incoming ubx messages are handled in an irq */
usart_register_rx_callback(GPS_SERCOM, gps_rx_callback, GPS_SERCOM_INT_PRIO);
kick_the_watchdog();
for (int i = 0; i < 100*1000; i++) { kick_the_watchdog(); }
/* Set the platform model */
gps_set_platform_model();