2010-12-24 02:35:09 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
|
|
|
//
|
|
|
|
// DIYDrones Custom Mediatek GPS driver for ArduPilot and ArduPilotMega.
|
2012-12-14 22:47:35 -04:00
|
|
|
// Code by Michael Smith, Jordi Munoz and Jose Julio, Craig Elder, DIYDrones.com
|
2010-12-24 02:35:09 -04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and / or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
2012-12-14 22:47:35 -04:00
|
|
|
// GPS configuration : Custom protocol per "Customize Function Specification, 3D Robotics, v1.6, v1.7, v1.8"
|
2010-12-24 02:35:09 -04:00
|
|
|
//
|
|
|
|
#ifndef AP_GPS_MTK16_h
|
|
|
|
#define AP_GPS_MTK16_h
|
|
|
|
|
2011-04-30 23:05:17 -03:00
|
|
|
#include "GPS.h"
|
2010-12-24 02:35:09 -04:00
|
|
|
#include "AP_GPS_MTK_Common.h"
|
|
|
|
|
|
|
|
class AP_GPS_MTK16 : public GPS {
|
|
|
|
public:
|
2011-10-28 15:52:50 -03:00
|
|
|
AP_GPS_MTK16(Stream *s);
|
2012-08-17 03:19:44 -03:00
|
|
|
virtual void init(enum GPS_Engine_Setting nav_setting = GPS_ENGINE_NONE);
|
|
|
|
virtual bool read(void);
|
2012-09-17 01:43:07 -03:00
|
|
|
static bool _detect(uint8_t );
|
2010-12-24 02:35:09 -04:00
|
|
|
|
|
|
|
private:
|
2011-05-04 16:12:27 -03:00
|
|
|
// XXX this is being ignored by the compiler #pragma pack(1)
|
2011-10-28 15:52:50 -03:00
|
|
|
struct diyd_mtk_msg {
|
2012-08-17 03:19:44 -03:00
|
|
|
int32_t latitude;
|
|
|
|
int32_t longitude;
|
|
|
|
int32_t altitude;
|
|
|
|
int32_t ground_speed;
|
|
|
|
int32_t ground_course;
|
|
|
|
uint8_t satellites;
|
|
|
|
uint8_t fix_type;
|
|
|
|
uint32_t utc_date;
|
|
|
|
uint32_t utc_time;
|
|
|
|
uint16_t hdop;
|
2011-10-28 15:52:50 -03:00
|
|
|
};
|
2011-05-04 16:12:27 -03:00
|
|
|
// #pragma pack(pop)
|
2011-10-28 15:52:50 -03:00
|
|
|
enum diyd_mtk_fix_type {
|
|
|
|
FIX_NONE = 1,
|
|
|
|
FIX_2D = 2,
|
2012-08-21 21:02:21 -03:00
|
|
|
FIX_3D = 3,
|
|
|
|
FIX_3D_SBAS = 7
|
2011-10-28 15:52:50 -03:00
|
|
|
};
|
2010-12-24 02:35:09 -04:00
|
|
|
|
2011-10-28 15:52:50 -03:00
|
|
|
enum diyd_mtk_protocol_bytes {
|
|
|
|
PREAMBLE1 = 0xd0,
|
|
|
|
PREAMBLE2 = 0xdd,
|
|
|
|
};
|
2010-12-24 02:35:09 -04:00
|
|
|
|
2011-10-28 15:52:50 -03:00
|
|
|
// Packet checksum accumulators
|
2012-08-17 03:19:44 -03:00
|
|
|
uint8_t _ck_a;
|
|
|
|
uint8_t _ck_b;
|
2010-12-24 02:35:09 -04:00
|
|
|
|
2011-10-28 15:52:50 -03:00
|
|
|
// State machine state
|
2012-08-17 03:19:44 -03:00
|
|
|
uint8_t _step;
|
|
|
|
uint8_t _payload_counter;
|
2010-12-24 02:35:09 -04:00
|
|
|
|
2011-10-28 15:52:50 -03:00
|
|
|
// Time from UNIX Epoch offset
|
2012-08-17 03:19:44 -03:00
|
|
|
long _time_offset;
|
|
|
|
bool _offset_calculated;
|
2011-10-28 15:52:50 -03:00
|
|
|
|
|
|
|
// Receive buffer
|
|
|
|
union {
|
2012-08-17 03:19:44 -03:00
|
|
|
diyd_mtk_msg msg;
|
|
|
|
uint8_t bytes[];
|
2011-10-28 15:52:50 -03:00
|
|
|
} _buffer;
|
2010-12-24 02:35:09 -04:00
|
|
|
};
|
|
|
|
|
2012-08-17 03:19:44 -03:00
|
|
|
#endif // AP_GPS_MTK16_H
|