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

AP_GPS_MTK.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 "DIYDrones Custom Binary Sentence Specification V1.1"
00012 //
00013 // Note - see AP_GPS_MTK16.h for firmware 1.6 and later.
00014 //
00015 #ifndef AP_GPS_MTK_h
00016 #define AP_GPS_MTK_h
00017 
00018 #include <GPS.h>
00019 #include "AP_GPS_MTK_Common.h"
00020 
00021 class AP_GPS_MTK : public GPS {
00022 public:
00023         AP_GPS_MTK(Stream *s);
00024         virtual void    init(void);
00025         virtual bool    read(void);
00026 
00027 private:
00028 #pragma pack(1)
00029         struct diyd_mtk_msg {
00030                 int32_t         latitude;
00031                 int32_t         longitude;
00032                 int32_t         altitude;
00033                 int32_t         ground_speed;
00034                 int32_t         ground_course;
00035                 uint8_t         satellites;
00036                 uint8_t         fix_type;
00037                 uint32_t        utc_time;
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 = 0xb5,
00048                 PREAMBLE2 = 0x62,
00049                 MESSAGE_CLASS = 1,
00050                 MESSAGE_ID = 5
00051         };
00052 
00053         // Packet checksum accumulators
00054         uint8_t         _ck_a;
00055         uint8_t         _ck_b;
00056 
00057         // State machine state
00058         uint8_t         _step;
00059         uint8_t         _payload_counter;
00060 
00061         // Receive buffer
00062         union {
00063                 diyd_mtk_msg    msg;
00064                 uint8_t                 bytes[];
00065         } _buffer;
00066 
00067         // Buffer parse & GPS state update
00068         void            _parse_gps();
00069 };
00070 
00071 #endif  // AP_GPS_MTK_H

Generated for ArduPilot Libraries by doxygen