mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 03:57:45 +08:00
[gps] update some gps for generic device
This commit is contained in:
@@ -3,9 +3,10 @@
|
|||||||
# Furuno NMEA GPS unit
|
# Furuno NMEA GPS unit
|
||||||
|
|
||||||
GPS_LED ?= none
|
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 += -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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
ap.CFLAGS += -DNMEA_PARSE_PROP
|
ap.CFLAGS += -DNMEA_PARSE_PROP
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
# Mediatek MT3329, DIYDrones V1.4/1.6 protocol
|
# Mediatek MT3329, DIYDrones V1.4/1.6 protocol
|
||||||
|
|
||||||
GPS_LED ?= none
|
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 += -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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
# NMEA GPS unit
|
# NMEA GPS unit
|
||||||
|
|
||||||
GPS_LED ?= none
|
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 += -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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Hey Emacs, this is a -*- makefile -*-
|
# Hey Emacs, this is a -*- makefile -*-
|
||||||
|
|
||||||
GPS_LED ?= none
|
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 += -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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
# Furuno NMEA GPS unit
|
# Furuno NMEA GPS unit
|
||||||
|
|
||||||
|
FURUNO_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
|
||||||
|
|
||||||
ap.CFLAGS += -DUSE_GPS
|
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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
ap.CFLAGS += -DNMEA_PARSE_PROP
|
ap.CFLAGS += -DNMEA_PARSE_PROP
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
# NMEA GPS unit
|
# NMEA GPS unit
|
||||||
|
|
||||||
|
NMEA_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
|
||||||
|
|
||||||
ap.CFLAGS += -DUSE_GPS
|
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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
# Sirf GPS unit
|
# Sirf GPS unit
|
||||||
|
|
||||||
GPS_LED ?= none
|
GPS_LED ?= none
|
||||||
|
SIRF_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
|
||||||
|
|
||||||
ap.CFLAGS += -DUSE_GPS
|
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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
# Hey Emacs, this is a -*- makefile -*-
|
# Hey Emacs, this is a -*- makefile -*-
|
||||||
|
|
||||||
GPS_LED ?= none
|
GPS_LED ?= none
|
||||||
|
SKYTRAQ_GPS_PORT_LOWER=$(shell echo $(GPS_PORT) | tr A-Z a-z)
|
||||||
|
|
||||||
ap.CFLAGS += -DUSE_GPS
|
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 += -DUSE_$(GPS_PORT)
|
||||||
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
ap.CFLAGS += -D$(GPS_PORT)_BAUD=$(GPS_BAUD)
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ static const char *gps_furuno_settings[GPS_FURUNO_SETTINGS_NB] = {
|
|||||||
|
|
||||||
static void nmea_parse_perdcrv(void);
|
static void nmea_parse_perdcrv(void);
|
||||||
|
|
||||||
|
#define GpsLinkDevice (&(GPS_LINK).device)
|
||||||
|
|
||||||
void nmea_parse_prop_init(void)
|
void nmea_parse_prop_init(void)
|
||||||
{
|
{
|
||||||
static uint8_t i = 0;
|
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);
|
sprintf(buf, "$%s*%02X\r\n", gps_furuno_settings[i], crc);
|
||||||
|
|
||||||
// Check if there is enough space to send the config msg
|
// 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++) {
|
for (j = 0; j < len + 6; j++) {
|
||||||
GpsLink(Transmit(buf[j]));
|
GpsLinkDevice->transmit(GpsLinkDevice->periph, buf[j]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -115,6 +115,30 @@ void gps_impl_init(void)
|
|||||||
#endif
|
#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,
|
static void gps_mtk_time2itow(uint32_t gps_date, uint32_t gps_time,
|
||||||
int16_t *gps_week, uint32_t *gps_itow)
|
int16_t *gps_week, uint32_t *gps_itow)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,10 +54,7 @@ extern struct GpsMtk gps_mtk;
|
|||||||
/*
|
/*
|
||||||
* This part is used by the autopilot to read data from a uart
|
* This part is used by the autopilot to read data from a uart
|
||||||
*/
|
*/
|
||||||
#define __GpsLink(dev, _x) dev##_x
|
#include "mcu_periph/link_device.h"
|
||||||
#define _GpsLink(dev, _x) __GpsLink(dev, _x)
|
|
||||||
#define GpsLink(_x) _GpsLink(GPS_LINK, _x)
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GPS_CONFIGURE
|
#ifdef GPS_CONFIGURE
|
||||||
extern bool_t gps_configuring;
|
extern bool_t gps_configuring;
|
||||||
@@ -83,26 +80,7 @@ static inline void GpsEvent(void (* _sol_available_callback)(void))
|
|||||||
GpsConfigure();
|
GpsConfigure();
|
||||||
}
|
}
|
||||||
if (gps_mtk.msg_available) {
|
if (gps_mtk.msg_available) {
|
||||||
gps.last_msg_ticks = sys_time.nb_sec_rem;
|
gps_mtk_msg(_sol_available_callback);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,21 @@ void gps_impl_init(void)
|
|||||||
nmea_parse_prop_init();
|
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)
|
void WEAK nmea_parse_prop_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,44 +52,30 @@ extern struct GpsNmea gps_nmea;
|
|||||||
/*
|
/*
|
||||||
* This part is used by the autopilot to read data from a uart
|
* 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_char(uint8_t c);
|
||||||
extern void nmea_parse_msg(void);
|
extern void nmea_parse_msg(void);
|
||||||
extern uint8_t nmea_calc_crc(const char *buff, int buff_sz);
|
extern uint8_t nmea_calc_crc(const char *buff, int buff_sz);
|
||||||
extern void nmea_parse_prop_init(void);
|
extern void nmea_parse_prop_init(void);
|
||||||
extern void nmea_parse_prop_msg(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 */
|
/** Read until a certain character, placed here for proprietary includes */
|
||||||
static inline void nmea_read_until(int *i)
|
static inline void nmea_read_until(int *i)
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ void gps_impl_init(void)
|
|||||||
gps_sirf.read_state = 0;
|
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)
|
void sirf_parse_char(uint8_t c)
|
||||||
{
|
{
|
||||||
switch (gps_sirf.read_state) {
|
switch (gps_sirf.read_state) {
|
||||||
|
|||||||
@@ -127,37 +127,24 @@ struct sirf_msg_41 {
|
|||||||
/*
|
/*
|
||||||
* This part is used by the autopilot to read data from a uart
|
* This part is used by the autopilot to read data from a uart
|
||||||
*/
|
*/
|
||||||
#define __GpsLink(dev, _x) dev##_x
|
#include "mcu_periph/link_device.h"
|
||||||
#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())); \
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void sirf_parse_char(uint8_t c);
|
extern void sirf_parse_char(uint8_t c);
|
||||||
extern void sirf_parse_msg(void);
|
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 */
|
#endif /* GPS_SIRF_H */
|
||||||
|
|||||||
@@ -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)
|
void gps_skytraq_read_message(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,38 +58,24 @@ extern struct GpsSkytraq gps_skytraq;
|
|||||||
/*
|
/*
|
||||||
* This part is used by the autopilot to read data from a uart
|
* This part is used by the autopilot to read data from a uart
|
||||||
*/
|
*/
|
||||||
#define __GpsLink(dev, _x) dev##_x
|
#include "mcu_periph/link_device.h"
|
||||||
#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())); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern void gps_skytraq_read_message(void);
|
extern void gps_skytraq_read_message(void);
|
||||||
extern void gps_skytraq_parse(uint8_t c);
|
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 */
|
#endif /* GPS_SKYTRAQ_H */
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ extern struct GpsUbxRaw gps_ubx_raw;
|
|||||||
/*
|
/*
|
||||||
* This part is used by the autopilot to read data from a uart
|
* 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_header(struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len);
|
||||||
extern void ubx_trailer(struct link_device *dev);
|
extern void ubx_trailer(struct link_device *dev);
|
||||||
|
|||||||
Reference in New Issue
Block a user