• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

AP_GPS_MTK16.h

Go to the documentation of this file.
00001 // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
00002 //
00003 //  DIYDrones Custom Mediatek GPS driver for ArduPilot and ArduPilotMega.
00004 //      Code by Michael Smith, Jordi Munoz and Jose Julio, DIYDrones.com
00005 //
00006 //      This library is free software; you can redistribute it and / or
00007 //      modify it under the terms of the GNU Lesser General Public
00008 //      License as published by the Free Software Foundation; either
00009 //      version 2.1 of the License, or (at your option) any later version.
00010 //
00011 //      GPS configuration : Custom protocol per "Customize Function Specification, 3D Robotics, v1.6"
00012 //
00013 #ifndef AP_GPS_MTK16_h
00014 #define AP_GPS_MTK16_h
00015 
00016 #include <GPS.h>
00017 #include "AP_GPS_MTK_Common.h"
00018 
00019 class AP_GPS_MTK16 : public GPS {
00020 public:
00021         AP_GPS_MTK16(Stream *s);
00022         virtual void    init(void);
00023         virtual bool    read(void);
00024 
00025 private:
00026 #pragma pack(1)
00027         struct diyd_mtk_msg {
00028                 int32_t         latitude;
00029                 int32_t         longitude;
00030                 int32_t         altitude;
00031                 int32_t         ground_speed;
00032                 int32_t         ground_course;
00033                 uint8_t         satellites;
00034                 uint8_t         fix_type;
00035                 uint32_t        utc_date;
00036                 uint32_t        utc_time;
00037                 uint16_t        hdop;
00038         };
00039 #pragma pack(pop)
00040         enum diyd_mtk_fix_type {
00041                 FIX_NONE = 1,
00042                 FIX_2D = 2,
00043                 FIX_3D = 3
00044         };
00045 
00046         enum diyd_mtk_protocol_bytes {
00047                 PREAMBLE1 = 0xd0,
00048                 PREAMBLE2 = 0xdd,
00049         };
00050 
00051         // Packet checksum accumulators
00052         uint8_t         _ck_a;
00053         uint8_t         _ck_b;
00054 
00055         // State machine state
00056         uint8_t         _step;
00057         uint8_t         _payload_counter;
00058 
00059         // Receive buffer
00060         union {
00061                 diyd_mtk_msg    msg;
00062                 uint8_t                 bytes[];
00063         } _buffer;
00064 };
00065 
00066 #endif  // AP_GPS_MTK16_H

Generated for ArduPilot Libraries by doxygen