APM:Libraries
AP_GPS_MTK19.h
Go to the documentation of this file.
1 /*
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation, either version 3 of the License, or
5  (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 //
17 // DIYDrones Custom Mediatek GPS driver for ArduPilot and ArduPilotMega.
18 // Code by Michael Smith, Jordi Munoz and Jose Julio, Craig Elder, DIYDrones.com
19 //
20 // GPS configuration : Custom protocol per "Customize Function Specification, 3D Robotics, v1.6, v1.7, v1.8, v1.9"
21 //
22 #pragma once
23 
24 #include "AP_GPS.h"
25 #include "GPS_Backend.h"
26 #include "AP_GPS_MTK_Common.h"
27 
28 #define MTK_GPS_REVISION_V16 16
29 #define MTK_GPS_REVISION_V19 19
30 
31 class AP_GPS_MTK19 : public AP_GPS_Backend {
32 public:
34 
35  bool read(void);
36 
37  static bool _detect(struct MTK19_detect_state &state, uint8_t data);
38 
39  const char *name() const override { return "MTK19"; }
40 
41 private:
43  int32_t latitude;
44  int32_t longitude;
45  int32_t altitude;
46  int32_t ground_speed;
47  int32_t ground_course;
48  uint8_t satellites;
49  uint8_t fix_type;
50  uint32_t utc_date;
51  uint32_t utc_time;
52  uint16_t hdop;
53  };
55  FIX_NONE = 1,
56  FIX_2D = 2,
57  FIX_3D = 3,
60  };
61 
63  PREAMBLE1_V16 = 0xd0,
64  PREAMBLE1_V19 = 0xd1,
65  PREAMBLE2 = 0xdd,
66  };
67 
68  // Packet checksum accumulators
69  uint8_t _ck_a;
70  uint8_t _ck_b;
71 
72  // State machine state
73  uint8_t _step;
75  uint8_t _mtk_revision;
76 
77  uint8_t _fix_counter;
78 
79  // Receive buffer
80  union {
83  } _buffer;
84 };
Definition: AP_GPS.h:48
union AP_GPS_MTK19::@29 _buffer
#define DEFINE_BYTE_ARRAY_METHODS
Definition: AP_Common.h:58
uint8_t _mtk_revision
Definition: AP_GPS_MTK19.h:75
uint8_t _ck_b
Definition: AP_GPS_MTK19.h:70
AP_GPS_MTK19(AP_GPS &_gps, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port)
static bool _detect(struct MTK19_detect_state &state, uint8_t data)
AP_GPS::GPS_State & state
public state for this instance
Definition: GPS_Backend.h:71
bool read(void)
uint8_t _fix_counter
Definition: AP_GPS_MTK19.h:77
#define PACKED
Definition: AP_Common.h:28
uint8_t _payload_counter
Definition: AP_GPS_MTK19.h:74
DEFINE_BYTE_ARRAY_METHODS diyd_mtk_msg msg
Definition: AP_GPS_MTK19.h:82
uint8_t _ck_a
Definition: AP_GPS_MTK19.h:69
uint8_t _step
Definition: AP_GPS_MTK19.h:73
const char * name() const override
Definition: AP_GPS_MTK19.h:39