NetBurner 3.5.8
PDF Version
Toggle main menu visibility
GPSChip.h
1
/*NB_REVISION*/
2
3
/*NB_COPYRIGHT*/
4
5
#pragma once
6
7
#include <init.h>
8
#include <nbrtos.h>
9
#include <sys/types.h>
10
#include <system.h>
11
#include <serial.h>
12
#include <iosys.h>
13
#include <sim.h>
14
#include <nbtime.h>
15
#include <pins.h>
16
#include <udp.h>
17
#include <ethervars.h>
18
19
#include "GPSEnum.h"
20
#include "GPSTime.h"
21
#include "GPSLocation.h"
22
#include "GPSSat.h"
23
#include "IEEE1588Timer.h"
24
25
#define GPS_SER_NUM SER_PORT_LPUART8
26
#define PIN_GPS_UART_TX 70
27
#define PIN_GPS_UART_RX 69
28
#define PIN_GPS_RST 40
29
#define PIN_GPS_PPS1 41
30
#define PIN_GPS_PPS2 85
31
32
// Constants for PPS synchronization
33
#define NMEA_PPS_WINDOW_NS (800000000u)
// accept */- 0.8 s
34
35
class
GPSChip
36
{
37
public
:
38
GPSChip();
39
~GPSChip();
40
void
init
();
41
void
start();
42
void
stop();
43
void
reset();
44
void
DecodeGSV(
char
*pGPSData);
45
void
DecodeGSA(
char
*pGPSData);
46
void
DecodeRMC(
char
*pGPSData);
47
void
DecodeGGA(
char
*pGPSData);
48
void
ProcessUbloxMsg(
char
* ublox_buffer);
49
void
SendUbloxMsg(uint8_t msg_class, uint8_t msg_id, uint8_t * payload, uint16_t payload_len);
50
void
WriteRawData(
const
uint8_t *data,
size_t
length);
51
52
// Timer attachment for PPS synchronization
53
void
attachTimer(IEEE1588Timer *t) { timer = t; }
54
55
// Time conversion utility
56
time_t getRMCTimeValue(
const
char
*time,
const
char
*date);
57
58
GPSTime time;
59
GPSLocation location;
60
GPSSatTracker satTracker;
61
62
float
hdop;
63
int
satellitesUsed;
64
65
GPSFixQuality fixQuality;
66
67
// CFG-VALGET response handling
68
static
const
int
CFG_RESPONSE_BUF_SIZE = 4096;
69
uint8_t cfgResponseBuf[CFG_RESPONSE_BUF_SIZE];
70
volatile
uint16_t cfgResponseLen;
71
OS_SEM cfgResponseSem;
72
volatile
bool
cfgResponseReady;
73
74
bool
SendCfgValGet(uint8_t layer, uint16_t position,
const
uint32_t *keys,
int
numKeys);
75
bool
SendCfgValSet(uint8_t layers,
const
uint8_t *cfgData,
int
cfgDataLen);
76
bool
WaitCfgResponse(
int
timeoutTicks = 2 *
TICKS_PER_SECOND
);
77
78
private
:
79
bool
isInitialized;
80
int
gpsSerialPort;
81
uint32_t GPSTaskStack[USER_TASK_STK_SIZE / 2];
82
83
// IEEE1588Timer integration for PPS synchronization
84
IEEE1588Timer *timer;
// Optional PPS timer
85
86
// From ProcessGps state (lines 141-147 in main.cpp)
87
uint32_t start_tt;
88
uint32_t start_captime;
89
char
gpsbuffer[2048];
90
91
// RMC time cache (from lines 82-83 in main.cpp)
92
char
cached_date[7];
93
time_t cached_time_t;
94
95
void
readLoop();
96
static
void
staticreadLoop(
void
*p);
97
};
TICKS_PER_SECOND
#define TICKS_PER_SECOND
System clock ticks per second.
Definition
constants.h:49
init
void init()
System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
examples
PlatformSpecific
NTP1061
src
class
GPSChip.h
Generated by
1.18.0