NetBurner 3.5.7
PDF Version
GPSChip.h
1#pragma once
2
3#include <init.h>
4#include <nbrtos.h>
5#include <sys/types.h>
6#include <system.h>
7#include <serial.h>
8#include <iosys.h>
9#include <sim.h>
10#include <nbtime.h>
11#include <pins.h>
12#include <udp.h>
13#include <ethervars.h>
14
15#include "GPSEnum.h"
16#include "GPSTime.h"
17#include "GPSLocation.h"
18#include "GPSSat.h"
19#include "IEEE1588Timer.h"
20
21#define GPS_SER_NUM SER_PORT_LPUART8
22#define PIN_GPS_UART_TX 70
23#define PIN_GPS_UART_RX 69
24#define PIN_GPS_RST 40
25#define PIN_GPS_PPS1 41
26#define PIN_GPS_PPS2 85
27
28// Constants for PPS synchronization
29#define NMEA_PPS_WINDOW_NS (800000000u) // accept */- 0.8 s
30#define UNIX_NTP_OFFSET (2208988800u) // Offset between Unix epoch and NTP epoch
31
32class GPSChip
33{
34 public:
35 GPSChip();
36 ~GPSChip();
37 void init();
38 void start();
39 void stop();
40 void reset();
41 void DecodeGSV(char *pGPSData);
42 void DecodeGSA(char *pGPSData);
43 void DecodeRMC(char *pGPSData);
44 void DecodeGGA(char *pGPSData);
45 void ProcessUbloxMsg(char * ublox_buffer);
46 void SendUbloxMsg(uint8_t msg_class, uint8_t msg_id, uint8_t * payload, uint16_t payload_len);
47 void WriteRawData(const uint8_t *data, size_t length);
48 void EnableMGAAcknowledgments();
49
50 // Timer attachment for PPS synchronization
51 void attachTimer(IEEE1588Timer *t) { timer = t; }
52
53 // Time conversion utility
54 time_t getRMCTimeValue(const char *time, const char *date);
55
56 GPSTime time;
57 GPSLocation location;
58 GPSSatTracker satTracker;
59
60 float hdop;
61 int sattelitesUsed;
62
63 GPSFixQuality fixQuality;
64
65 private:
66 bool isInitialized;
67 int gpsSerialPort;
68 uint32_t GPSTaskStack[USER_TASK_STK_SIZE / 2];
69
70 // IEEE1588Timer integration for PPS synchronization
71 IEEE1588Timer *timer; // Optional PPS timer
72
73 // From ProcessGps state (lines 141-147 in main.cpp)
74 uint32_t start_tt;
75 uint32_t start_captime;
76 char gpsbuffer[2048];
77
78 // RMC time cache (from lines 82-83 in main.cpp)
79 char cached_date[7];
80 time_t cached_time_t;
81
82 void readLoop();
83 static void staticreadLoop(void *p);
84};
Definition IEEE1588Timer.h:28