NetBurner 3.5.6
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
46 // Timer attachment for PPS synchronization
47 void attachTimer(IEEE1588Timer *t) { timer = t; }
48
49 // Time conversion utility
50 time_t getRMCTimeValue(const char *time, const char *date);
51
52 GPSTime time;
53 GPSLocation location;
54 GPSSatTracker satTracker;
55
56 float hdop;
57 int sattelitesUsed;
58
59 GPSFixQuality fixQuality;
60
61 private:
62 bool isInitialized;
63 int gpsSerialPort;
64 uint32_t GPSTaskStack[USER_TASK_STK_SIZE / 2];
65
66 // IEEE1588Timer integration for PPS synchronization
67 IEEE1588Timer *timer; // Optional PPS timer
68
69 // From ProcessGps state (lines 141-147 in main.cpp)
70 uint32_t edge_1588_count;
71 uint32_t edge_tt_count;
72 uint32_t start_tt;
73 uint32_t start_captime;
74 uint8_t last_pps_index;
75 char gpsbuffer[2048];
76
77 // RMC time cache (from lines 82-83 in main.cpp)
78 char cached_date[7];
79 time_t cached_time_t;
80
81 void readLoop();
82 static void staticreadLoop(void *p);
83};
Definition IEEE1588Timer.h:23