1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use bitflags::bitflags;
#[cfg(feature = "serde")]
use super::SerializeUbxPacketFields;
#[cfg(feature = "serde")]
use crate::serde::ser::SerializeMap;
use crate::{
error::ParserError, ubx_checksum, ubx_packets::packets::ScaleBack, MemWriter, MemWriterError,
UbxPacketCreator, UbxPacketMeta,
};
use ublox_derive::{ubx_extend, ubx_extend_bitflags, ubx_packet_recv_send};
/// TP5: "Time Pulse" Config frame (32.10.38.4)
#[ubx_packet_recv_send]
#[ubx(
class = 0x06,
id = 0x31,
fixed_payload_len = 32,
flags = "default_for_builder"
)]
struct CfgTp5 {
#[ubx(map_type = CfgTp5TimePulseMode, may_fail)]
tp_idx: u8,
version: u8,
reserved1: [u8; 2],
/// Antenna cable delay [ns]
#[ubx(map_type = f32, scale = 1.0)]
ant_cable_delay: i16,
/// RF group delay [ns]
#[ubx(map_type = f32, scale = 1.0)]
rf_group_delay: i16,
/// Frequency in Hz or Period in us,
/// depending on `flags::IS_FREQ` bit
#[ubx(map_type = f64, scale = 1.0)]
freq_period: u32,
/// Frequency in Hz or Period in us,
/// when locked to GPS time.
/// Only used when `flags::LOCKED_OTHER_SET` is set
#[ubx(map_type = f64, scale = 1.0)]
freq_period_lock: u32,
/// Pulse length or duty cycle, [us] or [*2^-32],
/// depending on `flags::LS_LENGTH` bit
#[ubx(map_type = f64, scale = 1.0)]
pulse_len_ratio: u32,
/// Pulse Length in us or duty cycle (*2^-32),
/// when locked to GPS time.
/// Only used when `flags::LOCKED_OTHER_SET` is set
#[ubx(map_type = f64, scale = 1.0)]
pulse_len_ratio_lock: u32,
/// User configurable time pulse delay in [ns]
#[ubx(map_type = f64, scale = 1.0)]
user_delay: i32,
/// Configuration flags, see [CfgTp5Flags]
#[ubx(map_type = CfgTp5Flags)]
flags: u32,
}
/// Time pulse selection, used in CfgTp5 frame
#[derive(Default)]
#[ubx_extend]
#[ubx(from_unchecked, into_raw, rest_error)]
#[repr(u8)]
#[derive(Clone, Copy, Debug)]
pub enum CfgTp5TimePulseMode {
#[default]
TimePulse = 0,
TimePulse2 = 1,
}
#[ubx_extend_bitflags]
#[ubx(from, into_raw, rest_reserved)]
bitflags! {
#[derive(Default, Debug)]
pub struct CfgTp5Flags: u32 {
// Enables time pulse
const ACTIVE = 0x01;
/// Synchronize time pulse to GNSS as
/// soon as GNSS time is valid.
/// Uses local lock otherwise.
const LOCK_GNSS_FREQ = 0x02;
/// use `freq_period_lock` and `pulse_len_ratio_lock`
/// fields as soon as GPS time is valid. Uses
/// `freq_period` and `pulse_len_ratio` when GPS time is invalid.
const LOCKED_OTHER_SET = 0x04;
/// `freq_period` and `pulse_len_ratio` fields
/// are interpreted as frequency when this bit is set
const IS_FREQ = 0x08;
/// Interpret pulse lengths instead of duty cycle
const IS_LENGTH = 0x10;
/// Align pulse to top of second
/// Period time must be integer fraction of `1sec`
/// `LOCK_GNSS_FREQ` is expected, to unlock this feature
const ALIGN_TO_TOW = 0x20;
/// Pulse polarity,
/// 0: falling edge @ top of second,
/// 1: rising edge @ top of second,
const POLARITY = 0x40;
/// UTC time grid
const UTC_TIME_GRID = 0x80;
/// GPS time grid
const GPS_TIME_GRID = 0x100;
/// GLO time grid
const GLO_TIME_GRID = 0x200;
/// BDS time grid
const BDS_TIME_GRID = 0x400;
/// GAL time grid
/// not supported in protocol < 18
const GAL_TIME_GRID = 0x800;
/// Switches to FreqPeriodLock and PulseLenRatio
/// as soon as Sync Manager has an accurate time,
/// never switches back
const SYNC_MODE_0 = 0x1000;
/// Switches to FreqPeriodLock and PulseLenRatioLock
/// as soon as Sync Manager has an accurante time,
/// and switch back to FreqPeriodLock and PulseLenRatio
/// when time gets inaccurate
const SYNC_MODE_1 = 0x2000;
}
}