APM:Libraries
AP_GPS_MTK.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, DIYDrones.com
19 //
20 // GPS configuration : Custom protocol per "DIYDrones Custom Binary Sentence Specification V1.1"
21 //
22 // Note - see AP_GPS_MTK16.h for firmware 1.6 and later.
23 //
24 #pragma once
25 
26 #include "AP_GPS.h"
27 #include "GPS_Backend.h"
28 #include "AP_GPS_MTK_Common.h"
29 
30 class AP_GPS_MTK : public AP_GPS_Backend {
31 public:
32  AP_GPS_MTK(AP_GPS &_gps, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port);
33 
34  bool read(void);
35 
36  static bool _detect(struct MTK_detect_state &state, uint8_t data);
37  static void send_init_blob(uint8_t instance, AP_GPS &gps);
38 
39  const char *name() const override { return "MTK"; }
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_time;
51  };
53  FIX_NONE = 1,
54  FIX_2D = 2,
55  FIX_3D = 3
56  };
57 
59  PREAMBLE1 = 0xb5,
60  PREAMBLE2 = 0x62,
63  };
64 
65  // Packet checksum accumulators
66  uint8_t _ck_a;
67  uint8_t _ck_b;
68 
69  // State machine state
70  uint8_t _step;
72 
73  // Receive buffer
74  union PACKED {
77  } _buffer;
78 
79  // Buffer parse & GPS state update
80  void _parse_gps();
81 
82  static const char _initialisation_blob[];
83 };
Definition: AP_GPS.h:48
const char * name() const override
Definition: AP_GPS_MTK.h:39
uint8_t _ck_b
Definition: AP_GPS_MTK.h:67
#define DEFINE_BYTE_ARRAY_METHODS
Definition: AP_Common.h:58
diyd_mtk_protocol_bytes
Definition: AP_GPS_MTK.h:58
static const char _initialisation_blob[]
Definition: AP_GPS_MTK.h:82
uint8_t _step
Definition: AP_GPS_MTK.h:70
void _parse_gps()
AP_GPS & gps
access to frontend (for parameters)
Definition: GPS_Backend.h:70
AP_GPS::GPS_State & state
public state for this instance
Definition: GPS_Backend.h:71
DEFINE_BYTE_ARRAY_METHODS diyd_mtk_msg msg
Definition: AP_GPS_MTK.h:76
AP_GPS_MTK(AP_GPS &_gps, AP_GPS::GPS_State &_state, AP_HAL::UARTDriver *_port)
Definition: AP_GPS_MTK.cpp:30
bool read(void)
Definition: AP_GPS_MTK.cpp:59
static bool _detect(struct MTK_detect_state &state, uint8_t data)
Definition: AP_GPS_MTK.cpp:170
static void send_init_blob(uint8_t instance, AP_GPS &gps)
Definition: AP_GPS_MTK.cpp:41
union AP_GPS_MTK::PACKED _buffer
uint8_t _ck_a
Definition: AP_GPS_MTK.h:66
uint8_t _payload_counter
Definition: AP_GPS_MTK.h:71