PER Firmware
Loading...
Searching...
No Matches
nav_pvt.h
Go to the documentation of this file.
1#ifndef NAV_PVT_H
2#define NAV_PVT_H
3
11#include <stdint.h>
12#include <stddef.h>
13
14// UBX NAV-PVT message header
15static constexpr uint8_t NAV_PVT_HEADER_B0 = 0xB5; // UBX message header sync byte 0
16static constexpr uint8_t NAV_PVT_HEADER_B1 = 0x62; // UBX message header sync byte 1
17static constexpr uint8_t NAV_PVT_CLASS = 0x01; // UBX message class for NAV-PVT
18static constexpr uint8_t NAV_PVT_MSG_ID = 0x07; // UBX message ID for NAV-PVT
19
20static constexpr size_t NAV_PVT_TOTAL_LENGTH = 100;
21
22typedef enum : uint8_t {
23 GPS_VALID_DATE = 0x01, // Valid UTC Date
24 GPS_VALID_TIME = 0x02, // Valid UTC Time
25 GPS_VALID_FULLY_RESOLVED = 0x04, // UTC fully resolved
26 GPS_VALID_MAG = 0x08 // Valid Magnetic Declination
27} gps_valid_flags_t;
28
29typedef enum : uint8_t {
30 GPS_FIX_TYPE_NONE = 0x00, // No fix
31 GPS_FIX_TYPE_DEAD_RECKONING = 0x01, // Dead Reckoning only
32 GPS_FIX_TYPE_GNSS_2D = 0x02, // 2D fix
33 GPS_FIX_TYPE_GNSS_3D = 0x03, // 3D fix
34 GPS_FIX_TYPE_GNSS_DEAD_RECKONING = 0x04, // GNSS + Dead Reckoning
35 GPS_FIX_TYPE_TIME_ONLY = 0x05 // Time only fix
36} gps_fix_type_t;
37
38typedef enum : uint8_t {
39 GPS_FLAG1_GNSS_FIX_OK = 0x01, // GNSS fix OK
40 GPS_FLAG1_DIFF_SOLN = 0x02, // Differential GPS fix
41
42 GPS_FLAG1_PSM_MASK = 0x1C, // PSM (Power Save Mode) mask
43 GPS_FLAG1_PSM_OFF = 0x00, // PSM off
44 GPS_FLAG1_PSM_ENABLED = 0x04, // PSM on
45 GPS_FLAG1_PSM_ACQUIRED = 0x08, // PSM active
46 GPS_FLAG1_PSM_TRACKING = 0x0C, // PSM tracking
47 GPS_FLAG1_PSM_POWER_OPTIMIZED = 0x10, // PSM power optimized
48 GPS_FLAG1_PSM_INACTIVE = 0x14, // PSM inactive
49
50 GPS_FLAG1_HEADING_VALID = 0x20, // Heading is valid
51 GPS_FLAG1_CARRIER_PHASE_MASK = 0xC0, // Carrier phase is valid
52 GPS_FLAG1_CARRIER_PHASE_NONE = 0x00, // No carrier phase
53 GPS_FLAG1_CARRIER_PHASE_FLOAT = 0x40, // Carrier phase float
54 GPS_FLAG1_CARRIER_PHASE_FIXED = 0x80 // Carrier phase fixed
55} gps_flags1_t;
56
57typedef enum : uint8_t {
58 GPS_FLAGS2_CONFIRMED_AVAILABLE = 0x20, // UTC date and time are confirmed available
59 GPS_FLAGS2_CONFIRMED_DATE = 0x40, // UTC date is confirmed
60 GPS_FLAGS2_CONFIRMED_TIME = 0x80 // UTC time is confirmed
61} gps_flags2_t;
62
63typedef struct {
64 uint32_t iTOW;
65 uint16_t year;
66 uint8_t month;
67 uint8_t day;
68 uint8_t hour;
69 uint8_t minute;
70 uint8_t second;
71
72 gps_valid_flags_t valid; // GPS_VALID_*
73
74 uint32_t timeAccuracy; // time accuracy in nanoseconds
75 int32_t nano; // nanoseconds of second
76
77 gps_fix_type_t fixType; // GPS_FIX_TYPE_*
78 gps_flags1_t flags1; // GPS_FIX_FLAG_*
79 gps_flags2_t flags2; // GPS_FLAGS2_*
80
81 uint8_t numSatellites; // Number of satellites used in Nav Solution
82 int32_t longitude; // Longitude in 1e-7 degrees
83 int32_t latitude; // Latitude in 1e-7 degrees
84 int32_t height; // Height above ellipsoid in mm
85 int32_t heightMSL; // Height above mean sea level in mm
86 uint32_t horizontalAccuracy; // Horizontal accuracy estimate in mm
87 uint32_t verticalAccuracy; // Vertical accuracy estimate in mm
88
89 int32_t velNorth; // NED North Velocity in mm/s
90 int32_t velEast; // NED East Velocity in mm/s
91 int32_t velDown; // NED DownVelocity in mm/s
92 int32_t groundSpeed; // Ground Speed in mm/s
93 int32_t headingMotion; // Heading of motion
94 uint32_t speedAccuracy; // Speed accuracy estimate in mm/s
95 uint32_t headingAccuracy; // Heading accuracy estimate in 1e-5 degrees
96
97 uint16_t positionDOP; // Position Dilution of Precision (0.01 scale)
98 uint8_t reserved[6];
99
100 int32_t headingVehicle; // Heading of vehicle in 1e-5 degrees
101
102 int16_t magneticDec; // Magnetic declination in 1e-2 degrees
103 uint16_t magneticAcc; // Magnetic declination accuracy in 1e-2 degrees
105
106static_assert(sizeof(NAV_PVT_data_t) == 92, "NAV_PVT_data_t size must be 92 bytes");
107static_assert(offsetof(NAV_PVT_data_t, iTOW) == 0);
108static_assert(offsetof(NAV_PVT_data_t, year) == 4);
109static_assert(offsetof(NAV_PVT_data_t, month) == 6);
110static_assert(offsetof(NAV_PVT_data_t, valid) == 11);
111static_assert(offsetof(NAV_PVT_data_t, timeAccuracy) == 12);
112static_assert(offsetof(NAV_PVT_data_t, longitude) == 24);
113static_assert(offsetof(NAV_PVT_data_t, headingVehicle) == 84);
114static_assert(offsetof(NAV_PVT_data_t, magneticAcc) == 90);
115
116void NAV_PVT_decode(NAV_PVT_data_t *nav_pvt, const volatile uint8_t *rx_buffer);
117
118#endif // NAV_PVT_H
Definition nav_pvt.h:63