[gps] update some gps for generic device

This commit is contained in:
Gautier Hattenberger
2015-03-16 23:44:32 +01:00
parent a6a328e1c1
commit 34cb20bedc
18 changed files with 141 additions and 124 deletions
@@ -3,9 +3,10 @@
# Furuno NMEA GPS unit
GPS_LED ?= none
FURUNO_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(FURUNO_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
ap.CFLAGS += -DNMEA_PARSE_PROP
@@ -3,9 +3,10 @@
# Mediatek MT3329, DIYDrones V1.4/1.6 protocol
GPS_LED ?= none
MTK_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS -DGPS_CONFIGURE -DGPS_USE_LATLONG
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(MTK_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
@@ -3,9 +3,10 @@
# NMEA GPS unit
GPS_LED ?= none
NMEA_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(NMEA_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
@@ -1,9 +1,10 @@
# Hey Emacs, this is a -*- makefile -*-
GPS_LED ?= none
SKYTRAQ_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS -DGPS_USE_LATLONG
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(SKYTRAQ_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
@@ -2,9 +2,10 @@
# Furuno NMEA GPS unit
FURUNO_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(FURUNO_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
ap.CFLAGS += -DNMEA_PARSE_PROP
@@ -2,9 +2,10 @@
# NMEA GPS unit
NMEA_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(NMEA_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
@@ -3,9 +3,10 @@
# Sirf GPS unit
GPS_LED ?= none
SIRF_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(SIRF_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
@@ -1,9 +1,10 @@
# Hey Emacs, this is a -*- makefile -*-
GPS_LED ?= none
SKYTRAQ_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
ap.CFLAGS += -DUSE_GPS
ap.CFLAGS += -DGPS_LINK=$(GPS_PORT)
ap.CFLAGS += -DGPS_LINK=$(SKYTRAQ_GPS_PORT_LOWER)
ap.CFLAGS += -DUSE_$(GPS_PORT)
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
+4 -2
View File
@@ -47,6 +47,8 @@ static const char *gps_furuno_settings[GPS_FURUNO_SETTINGS_NB] = {
static void nmea_parse_perdcrv(void);
#define GpsLinkDevice (&(GPS_LINK).device)
void nmea_parse_prop_init(void)
{
static uint8_t i = 0;
@@ -64,9 +66,9 @@ void nmea_parse_prop_init(void)
sprintf(buf, "$%s*%02X\r\n", gps_furuno_settings[i], crc);
// Check if there is enough space to send the config msg
if (GpsLink(CheckFreeSpace(len + 6))) {
if (GpsLinkDevice->check_free_space(GpsLinkDevice->periph, len + 6)) {
for (j = 0; j < len + 6; j++) {
GpsLink(Transmit(buf[j]));
GpsLinkDevice->transmit(GpsLinkDevice->periph, buf[j]);
}
} else {
break;
+24
View File
@@ -115,6 +115,30 @@ void gps_impl_init(void)
#endif
}
void gps_mtk_msg(void (* _cb)(void))
{
gps.last_msg_ticks = sys_time.nb_sec_rem;
gps.last_msg_time = sys_time.nb_sec;
gps_mtk_read_message();
if (gps_mtk.msg_class == MTK_DIY14_ID &&
gps_mtk.msg_id == MTK_DIY14_NAV_ID) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_sol_available_callback();
}
if (gps_mtk.msg_class == MTK_DIY16_ID &&
gps_mtk.msg_id == MTK_DIY16_NAV_ID) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_cb();
}
gps_mtk.msg_available = FALSE;
}
static void gps_mtk_time2itow(uint32_t gps_date, uint32_t gps_time,
int16_t *gps_week, uint32_t *gps_itow)
{
+2 -24
View File
@@ -54,10 +54,7 @@ extern struct GpsMtk gps_mtk;
/*
* This part is used by the autopilot to read data from a uart
*/
#define __GpsLink(dev, _x) dev##_x
#define _GpsLink(dev, _x) __GpsLink(dev, _x)
#define GpsLink(_x) _GpsLink(GPS_LINK, _x)
#include "mcu_periph/link_device.h"
#ifdef GPS_CONFIGURE
extern bool_t gps_configuring;
@@ -83,26 +80,7 @@ static inline void GpsEvent(void (* _sol_available_callback)(void))
GpsConfigure();
}
if (gps_mtk.msg_available) {
gps.last_msg_ticks = sys_time.nb_sec_rem;
gps.last_msg_time = sys_time.nb_sec;
gps_mtk_read_message();
if (gps_mtk.msg_class == MTK_DIY14_ID &&
gps_mtk.msg_id == MTK_DIY14_NAV_ID) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_sol_available_callback();
}
if (gps_mtk.msg_class == MTK_DIY16_ID &&
gps_mtk.msg_id == MTK_DIY16_NAV_ID) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_sol_available_callback();
}
gps_mtk.msg_available = FALSE;
gps_mtk_msg(_sol_available_callback);
}
}
+15
View File
@@ -63,6 +63,21 @@ void gps_impl_init(void)
nmea_parse_prop_init();
}
void gps_nmea_msg(void (* _cb)(void))
{
gps.last_msg_ticks = sys_time.nb_sec_rem;
gps.last_msg_time = sys_time.nb_sec;
nmea_parse_msg();
if (gps_nmea.pos_available) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_cb();
}
gps_nmea.msg_available = FALSE;
}
void WEAK nmea_parse_prop_init(void)
{
}
+17 -31
View File
@@ -52,44 +52,30 @@ extern struct GpsNmea gps_nmea;
/*
* This part is used by the autopilot to read data from a uart
*/
#define __GpsLink(dev, _x) dev##_x
#define _GpsLink(dev, _x) __GpsLink(dev, _x)
#define GpsLink(_x) _GpsLink(GPS_LINK, _x)
#define GpsBuffer() GpsLink(ChAvailable())
/** The function to be called when a characted from the device is available */
#include "mcu_periph/link_device.h"
#define GpsEvent(_sol_available_callback) { \
nmea_parse_prop_init(); \
if (GpsBuffer()) { \
ReadGpsBuffer(); \
} \
if (gps_nmea.msg_available) { \
gps.last_msg_ticks = sys_time.nb_sec_rem; \
gps.last_msg_time = sys_time.nb_sec; \
nmea_parse_msg(); \
if (gps_nmea.pos_available) { \
if (gps.fix == GPS_FIX_3D) { \
gps.last_3dfix_ticks = sys_time.nb_sec_rem; \
gps.last_3dfix_time = sys_time.nb_sec; \
} \
_sol_available_callback(); \
} \
gps_nmea.msg_available = FALSE; \
} \
}
#define ReadGpsBuffer() { \
while (GpsLink(ChAvailable())&&!gps_nmea.msg_available) \
nmea_parse_char(GpsLink(Getch())); \
}
/** The function to be called when a characted friom the device is available */
extern void nmea_parse_char(uint8_t c);
extern void nmea_parse_msg(void);
extern uint8_t nmea_calc_crc(const char *buff, int buff_sz);
extern void nmea_parse_prop_init(void);
extern void nmea_parse_prop_msg(void);
extern void gps_nmea_msg(void (* _cb)(void));
static inline void GpsEvent(void (* _sol_available_callback)(void))
{
struct link_device *dev = &((GPS_LINK).device);
if (dev->char_available(dev->periph)) {
while (dev->char_available(dev->periph)) {
nmea_parse_char(dev->getchar(dev->periph));
}
}
if (gps_nmea.msg_available) {
gps_nmea_msg(_sol_available_callback);
}
}
/** Read until a certain character, placed here for proprietary includes */
static inline void nmea_read_until(int *i)
+15
View File
@@ -48,6 +48,21 @@ void gps_impl_init(void)
gps_sirf.read_state = 0;
}
void gps_sirf_msg(void (* _cb)(void))
{
gps.last_msg_ticks = sys_time.nb_sec_rem;
gps.last_msg_time = sys_time.nb_sec;
sirf_parse_msg();
if (gps_sirf.pos_available) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_cb();
}
gps_sirf.msg_available = FALSE;
}
void sirf_parse_char(uint8_t c)
{
switch (gps_sirf.read_state) {
+16 -29
View File
@@ -127,37 +127,24 @@ struct sirf_msg_41 {
/*
* This part is used by the autopilot to read data from a uart
*/
#define __GpsLink(dev, _x) dev##_x
#define _GpsLink(dev, _x) __GpsLink(dev, _x)
#define GpsLink(_x) _GpsLink(GPS_LINK, _x)
#define GpsBuffer() GpsLink(ChAvailable())
#define GpsEvent(_sol_available_callback) { \
if (GpsBuffer()) { \
ReadGpsBuffer(); \
} \
if (gps_sirf.msg_available) { \
gps.last_msg_ticks = sys_time.nb_sec_rem; \
gps.last_msg_time = sys_time.nb_sec; \
sirf_parse_msg(); \
if (gps_sirf.pos_available) { \
if (gps.fix == GPS_FIX_3D) { \
gps.last_3dfix_ticks = sys_time.nb_sec_rem; \
gps.last_3dfix_time = sys_time.nb_sec; \
} \
_sol_available_callback(); \
} \
gps_sirf.msg_available = FALSE; \
} \
}
#define ReadGpsBuffer() { \
while (GpsLink(ChAvailable())&&!gps_sirf.msg_available) \
sirf_parse_char(GpsLink(Getch())); \
}
#include "mcu_periph/link_device.h"
extern void sirf_parse_char(uint8_t c);
extern void sirf_parse_msg(void);
extern void gps_sirf_msg(void (* _cb)(void));
static inline void GpsEvent(void (* _sol_available_callback)(void))
{
struct link_device *dev = &((GPS_LINK).device);
if (dev->char_available(dev->periph)) {
while (dev->char_available(dev->periph)) {
sirf_parse_char(dev->getchar(dev->periph));
}
}
if (gps_sirf.msg_available) {
gps_sirf_msg(_sol_available_callback);
}
}
#endif /* GPS_SIRF_H */
+15
View File
@@ -97,6 +97,21 @@ void gps_impl_init(void)
}
void gps_skytraq_msg(void (* _cb)(void))
{
gps.last_msg_ticks = sys_time.nb_sec_rem;
gps.last_msg_time = sys_time.nb_sec;
gps_skytraq_read_message();
if (gps_skytraq.msg_id == SKYTRAQ_ID_NAVIGATION_DATA) {
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
_cb();
}
gps_skytraq.msg_available = FALSE;
}
void gps_skytraq_read_message(void)
{
+16 -30
View File
@@ -58,38 +58,24 @@ extern struct GpsSkytraq gps_skytraq;
/*
* This part is used by the autopilot to read data from a uart
*/
#define __GpsLink(dev, _x) dev##_x
#define _GpsLink(dev, _x) __GpsLink(dev, _x)
#define GpsLink(_x) _GpsLink(GPS_LINK, _x)
#define GpsBuffer() GpsLink(ChAvailable())
#define GpsEvent(_sol_available_callback) { \
if (GpsBuffer()) { \
ReadGpsBuffer(); \
} \
if (gps_skytraq.msg_available) { \
gps.last_msg_ticks = sys_time.nb_sec_rem; \
gps.last_msg_time = sys_time.nb_sec; \
gps_skytraq_read_message(); \
if (gps_skytraq.msg_id == SKYTRAQ_ID_NAVIGATION_DATA) { \
if (gps.fix == GPS_FIX_3D) { \
gps.last_3dfix_ticks = sys_time.nb_sec_rem; \
gps.last_3dfix_time = sys_time.nb_sec; \
} \
_sol_available_callback(); \
} \
gps_skytraq.msg_available = FALSE; \
} \
}
#define ReadGpsBuffer() { \
while (GpsLink(ChAvailable())&&!gps_skytraq.msg_available) \
gps_skytraq_parse(GpsLink(Getch())); \
}
#include "mcu_periph/link_device.h"
extern void gps_skytraq_read_message(void);
extern void gps_skytraq_parse(uint8_t c);
extern void gps_skytraq_msg(void (* _cb)(void));
static inline void GpsEvent(void (* _sol_available_callback)(void))
{
struct link_device *dev = &((GPS_LINK).device);
if (dev->char_available(dev->periph)) {
while (dev->char_available(dev->periph) && !gps_mtk.msg_available) {
gps_skytraq_parse(dev->getchar(dev->periph));
}
}
if (gps_skytraq.msg_available) {
gps_skytraq_msg(_sol_available_callback);
}
}
#endif /* GPS_SKYTRAQ_H */
+1
View File
@@ -82,6 +82,7 @@ extern struct GpsUbxRaw gps_ubx_raw;
/*
* This part is used by the autopilot to read data from a uart
*/
#include "mcu_periph/link_device.h"
extern void ubx_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len);
extern void ubx_trailer(struct link_device *dev);