core: gps: use new gps device API
This commit is contained in:
parent
219bb4e986
commit
72845e4c1f
|
|
@ -107,7 +107,7 @@ static inline int gps_getSentence(const struct gpsDevice *dev, char *buf, const
|
||||||
* if available, enabled and ready, decode NMEA sentences and update
|
* if available, enabled and ready, decode NMEA sentences and update
|
||||||
* the radio state with the retrieved data.
|
* the radio state with the retrieved data.
|
||||||
*/
|
*/
|
||||||
void gps_task();
|
void gps_task(const struct gpsDevice *dev);
|
||||||
|
|
||||||
|
|
||||||
#endif /* GPS_H */
|
#endif /* GPS_H */
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
#include <peripherals/gps.h>
|
|
||||||
#include <gps.h>
|
#include <gps.h>
|
||||||
#include <minmea.h>
|
#include <minmea.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -28,17 +27,18 @@
|
||||||
|
|
||||||
#define KNOTS2KMH(x) ((((int) x) * 1852) / 1000)
|
#define KNOTS2KMH(x) ((((int) x) * 1852) / 1000)
|
||||||
|
|
||||||
static char sentence[2*MINMEA_MAX_LENGTH];
|
|
||||||
static bool gpsEnabled = false;
|
static bool gpsEnabled = false;
|
||||||
static bool readNewSentence = true;
|
|
||||||
#ifdef CONFIG_RTC
|
#ifdef CONFIG_RTC
|
||||||
static bool isRtcSyncronised = false;
|
static bool isRtcSyncronised = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void gps_task()
|
void gps_task(const struct gpsDevice *dev)
|
||||||
{
|
{
|
||||||
|
char sentence[2*MINMEA_MAX_LENGTH];
|
||||||
|
int ret;
|
||||||
|
|
||||||
// No GPS, return
|
// No GPS, return
|
||||||
if(state.gpsDetected == false)
|
if(dev == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Handle GPS turn on/off
|
// Handle GPS turn on/off
|
||||||
|
|
@ -47,9 +47,9 @@ void gps_task()
|
||||||
gpsEnabled = state.settings.gps_enabled;
|
gpsEnabled = state.settings.gps_enabled;
|
||||||
|
|
||||||
if(gpsEnabled)
|
if(gpsEnabled)
|
||||||
gps_enable();
|
gps_enable(dev);
|
||||||
else
|
else
|
||||||
gps_disable();
|
gps_disable(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPS disabled, nothing to do
|
// GPS disabled, nothing to do
|
||||||
|
|
@ -57,24 +57,10 @@ void gps_task()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Acquire a new NMEA sentence from GPS
|
// Acquire a new NMEA sentence from GPS
|
||||||
if(readNewSentence)
|
ret = gps_getSentence(dev, sentence, sizeof(sentence));
|
||||||
{
|
if(ret <= 0)
|
||||||
int status = gps_getNmeaSentence(sentence, 2*MINMEA_MAX_LENGTH);
|
|
||||||
if(status != 0) return;
|
|
||||||
readNewSentence = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Waiting for a sentence...
|
|
||||||
if(gps_nmeaSentenceReady() == false)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Discard all non-GPS sentences
|
|
||||||
if((sentence[0] != '$') || (sentence[1] != 'G'))
|
|
||||||
{
|
|
||||||
readNewSentence = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the sentence. Work on a local state copy to minimize the time
|
// Parse the sentence. Work on a local state copy to minimize the time
|
||||||
// spent with the state mutex locked
|
// spent with the state mutex locked
|
||||||
gps_t gps_data;
|
gps_t gps_data;
|
||||||
|
|
@ -207,7 +193,4 @@ void gps_task()
|
||||||
isRtcSyncronised = false;
|
isRtcSyncronised = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Finally, trigger the acquisition of a new NMEA sentence
|
|
||||||
readNewSentence = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include <interfaces/display.h>
|
#include <interfaces/display.h>
|
||||||
#include <interfaces/delays.h>
|
#include <interfaces/delays.h>
|
||||||
#include <interfaces/cps_io.h>
|
#include <interfaces/cps_io.h>
|
||||||
#include <peripherals/gps.h>
|
|
||||||
#include <voicePrompts.h>
|
#include <voicePrompts.h>
|
||||||
#include <graphics.h>
|
#include <graphics.h>
|
||||||
#include <openrtx.h>
|
#include <openrtx.h>
|
||||||
|
|
@ -73,12 +72,6 @@ void openrtx_init()
|
||||||
gfx_render();
|
gfx_render();
|
||||||
sleepFor(0u, 30u);
|
sleepFor(0u, 30u);
|
||||||
display_setBacklightLevel(state.settings.brightness);
|
display_setBacklightLevel(state.settings.brightness);
|
||||||
|
|
||||||
#if defined(CONFIG_GPS)
|
|
||||||
// Detect and initialise GPS
|
|
||||||
state.gpsDetected = gps_detect(1000);
|
|
||||||
if(state.gpsDetected) gps_init(9600);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *openrtx_run(void *arg)
|
void *openrtx_run(void *arg)
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,7 @@
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
#include <input.h>
|
#include <input.h>
|
||||||
#include <backup.h>
|
#include <backup.h>
|
||||||
#ifdef CONFIG_GPS
|
|
||||||
#include <peripherals/gps.h>
|
|
||||||
#include <gps.h>
|
#include <gps.h>
|
||||||
#endif
|
|
||||||
#include <voicePrompts.h>
|
#include <voicePrompts.h>
|
||||||
|
|
||||||
#if defined(PLATFORM_TTWRPLUS)
|
#if defined(PLATFORM_TTWRPLUS)
|
||||||
|
|
@ -137,7 +134,13 @@ void *main_thread(void *arg)
|
||||||
{
|
{
|
||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
long long time = 0;
|
long long time = 0;
|
||||||
|
|
||||||
|
#if defined(CONFIG_GPS)
|
||||||
|
const struct gpsDevice *gps = platform_initGps();
|
||||||
|
if(gps != NULL)
|
||||||
|
state.gpsDetected = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
while(state.devStatus != SHUTDOWN)
|
while(state.devStatus != SHUTDOWN)
|
||||||
{
|
{
|
||||||
|
|
@ -154,8 +157,8 @@ void *main_thread(void *arg)
|
||||||
pthread_mutex_unlock(&state_mutex);
|
pthread_mutex_unlock(&state_mutex);
|
||||||
|
|
||||||
// Run GPS task
|
// Run GPS task
|
||||||
#if defined(CONFIG_GPS) && !defined(MD3x0_ENABLE_DBG)
|
#if defined(CONFIG_GPS)
|
||||||
gps_task();
|
gps_task(gps);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Run state update task
|
// Run state update task
|
||||||
|
|
@ -166,10 +169,6 @@ void *main_thread(void *arg)
|
||||||
sleepUntil(time);
|
sleepUntil(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_GPS)
|
|
||||||
gps_terminate();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue