Adding support for Time Pulse Parameters

This commit is contained in:
PaulZC
2021-01-13 12:00:14 +00:00
parent e3e9b83d4d
commit 34f15c25f3
4 changed files with 200 additions and 0 deletions
@@ -4252,6 +4252,81 @@ boolean SFE_UBLOX_GNSS::resetIMUalignment(uint16_t maxWait)
return (sendCommand(&packetCfg, maxWait, true) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}
//Get the time pulse parameters using UBX_CFG_TP5
boolean SFE_UBLOX_GNSS::getTimePulseParameters(UBX_CFG_TP5_data_t *data, uint16_t maxWait)
{
if (data == NULL) // Check if the user forgot to include the data pointer
return (false); // Bail
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_TP5;
packetCfg.len = 0;
packetCfg.startingSpot = 0;
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (false);
// Extract the data
data->tpIdx = extractByte(&packetCfg, 0);
data->version = extractByte(&packetCfg, 1);
data->antCableDelay = extractSignedInt(&packetCfg, 4);
data->rfGroupDelay = extractSignedInt(&packetCfg, 6);
data->freqPeriod = extractLong(&packetCfg, 8);
data->freqPeriodLock = extractLong(&packetCfg, 12);
data->pulseLenRatio = extractLong(&packetCfg, 16);
data->pulseLenRatioLock = extractLong(&packetCfg, 20);
data->userConfigDelay = extractSignedLong(&packetCfg, 24);
data->flags.all = extractLong(&packetCfg, 28);
return(true);
}
//Set the time pulse parameters using UBX_CFG_TP5
boolean SFE_UBLOX_GNSS::setTimePulseParameters(UBX_CFG_TP5_data_t *data, uint16_t maxWait)
{
if (data == NULL) // Check if the user forgot to include the data pointer
return (false); // Bail
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_TP5;
packetCfg.len = UBX_CFG_TP5_LEN;
packetCfg.startingSpot = 0;
// Insert the data
payloadCfg[0] = data->tpIdx;
payloadCfg[1] = data->version;
payloadCfg[4] = data->antCableDelay & 0xFF; // Little Endian
payloadCfg[5] = data->antCableDelay >> 8;
payloadCfg[6] = data->rfGroupDelay & 0xFF; // Little Endian
payloadCfg[7] = data->rfGroupDelay >> 8;
payloadCfg[8] = data->freqPeriod & 0xFF; // Little Endian
payloadCfg[9] = (data->freqPeriod >> 8) & 0xFF;
payloadCfg[10] = (data->freqPeriod >> 16) & 0xFF;
payloadCfg[11] = (data->freqPeriod >> 24) & 0xFF;
payloadCfg[12] = data->freqPeriodLock & 0xFF; // Little Endian
payloadCfg[13] = (data->freqPeriodLock >> 8) & 0xFF;
payloadCfg[14] = (data->freqPeriodLock >> 16) & 0xFF;
payloadCfg[15] = (data->freqPeriodLock >> 24) & 0xFF;
payloadCfg[16] = data->pulseLenRatio & 0xFF; // Little Endian
payloadCfg[17] = (data->pulseLenRatio >> 8) & 0xFF;
payloadCfg[18] = (data->pulseLenRatio >> 16) & 0xFF;
payloadCfg[19] = (data->pulseLenRatio >> 24) & 0xFF;
payloadCfg[20] = data->pulseLenRatioLock & 0xFF; // Little Endian
payloadCfg[21] = (data->pulseLenRatioLock >> 8) & 0xFF;
payloadCfg[22] = (data->pulseLenRatioLock >> 16) & 0xFF;
payloadCfg[23] = (data->pulseLenRatioLock >> 24) & 0xFF;
payloadCfg[24] = data->userConfigDelay & 0xFF; // Little Endian
payloadCfg[25] = (data->userConfigDelay >> 8) & 0xFF;
payloadCfg[26] = (data->userConfigDelay >> 16) & 0xFF;
payloadCfg[27] = (data->userConfigDelay >> 24) & 0xFF;
payloadCfg[28] = data->flags.all & 0xFF; // Little Endian
payloadCfg[29] = (data->flags.all >> 8) & 0xFF;
payloadCfg[30] = (data->flags.all >> 16) & 0xFF;
payloadCfg[31] = (data->flags.all >> 24) & 0xFF;
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}
// CONFIGURATION INTERFACE (protocol v27 and above)
//Form 32-bit key from group/id/size
@@ -645,6 +645,10 @@ public:
//Reset ESF automatic IMU-mount alignment
boolean resetIMUalignment(uint16_t maxWait = defaultMaxWait);
//Configure Time Pulse Parameters
boolean getTimePulseParameters(UBX_CFG_TP5_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Get the time pulse parameters using UBX_CFG_TP5
boolean setTimePulseParameters(UBX_CFG_TP5_data_t *data = NULL, uint16_t maxWait = defaultMaxWait); // Set the time pulse parameters using UBX_CFG_TP5
//General configuration (used only on protocol v27 and higher - ie, ZED-F9P)
//It is probably safe to assume that users of the ZED-F9P will be using I2C / Qwiic.
+35
View File
@@ -1789,4 +1789,39 @@ typedef struct
UBX_HNR_INS_data_t *callbackData;
} UBX_HNR_INS_t;
// UBX-CFG-TP5 (0x06 0x31): Time pulse parameters
const uint16_t UBX_CFG_TP5_LEN = 32;
typedef struct
{
uint8_t tpIdx; // Time pulse selection (0 = TIMEPULSE, 1 = TIMEPULSE2)
uint8_t version; // Message version (0x01 for this version)
uint8_t reserved1[2];
int16_t antCableDelay; // Antenna cable delay: ns
int16_t rfGroupDelay; // RF group delay: ns
uint32_t freqPeriod; // Frequency or period time, depending on setting of bit 'isFreq': Hz_or_us
uint32_t freqPeriodLock; // Frequency or period time when locked to GNSS time, only used if 'lockedOtherSet' is set: Hz_or_us
uint32_t pulseLenRatio; // Pulse length or duty cycle, depending on 'isLength': us_or_2^-32
uint32_t pulseLenRatioLock; // Pulse length or duty cycle when locked to GNSS time, only used if 'lockedOtherSet' is set: us_or_2^-32
int32_t userConfigDelay; // User-configurable time pulse delay: ns
union
{
uint32_t all;
struct
{
uint32_t active : 1; // If set enable time pulse; if pin assigned to another function, other function takes precedence.
uint32_t lockGnssFreq : 1; // If set, synchronize time pulse to GNSS as soon as GNSS time is valid. If not set, or before GNSS time is valid, use local clock.
uint32_t lockedOtherSet : 1; // If set the receiver switches between the timepulse settings given by 'freqPeriodLocked' & 'pulseLenLocked' and those given by 'freqPeriod' & 'pulseLen'.
uint32_t isFreq : 1; // If set 'freqPeriodLock' and 'freqPeriod' are interpreted as frequency, otherwise interpreted as period.
uint32_t isLength : 1; // If set 'pulseLenRatioLock' and 'pulseLenRatio' interpreted as pulse length, otherwise interpreted as duty cycle.
uint32_t alignToTow : 1; // Align pulse to top of second (period time must be integer fraction of 1s). Also set 'lockGnssFreq' to use this feature.
uint32_t polarity : 1; // Pulse polarity: 0: falling edge at top of second; 1: rising edge at top of second
uint32_t gridUtcGnss : 4; // Timegrid to use: 0: UTC; 1: GPS; 2: GLONASS; 3: BeiDou; 4: Galileo
uint32_t syncMode : 3; // Sync Manager lock mode to use:
// 0: switch to 'freqPeriodLock' and 'pulseLenRatioLock' as soon as Sync Manager has an accurate time, never switch back to 'freqPeriod' and 'pulseLenRatio'
// 1: switch to 'freqPeriodLock' and 'pulseLenRatioLock' as soon as Sync Manager has an accurate time, and switch back to 'freqPeriod' and 'pulseLenRatio' as soon as time gets inaccurate
} bits;
} flags;
} UBX_CFG_TP5_data_t;
#endif