From 69b73ebb0ab9b85fd2f219fa6ca1e135ba58ac88 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 30 Jul 2024 11:06:50 +1000 Subject: [PATCH] samples: gnss: add timepulse support Output the timestamp of the PPS timepulse when printing the fix information, if the driver support the timepulse and it has started toggling. Signed-off-by: Jordan Yates --- samples/drivers/gnss/src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/drivers/gnss/src/main.c b/samples/drivers/gnss/src/main.c index 06eacb2843d..703595ab0e1 100644 --- a/samples/drivers/gnss/src/main.c +++ b/samples/drivers/gnss/src/main.c @@ -15,8 +15,16 @@ LOG_MODULE_REGISTER(gnss_sample, CONFIG_GNSS_LOG_LEVEL); static void gnss_data_cb(const struct device *dev, const struct gnss_data *data) { + uint64_t timepulse_ns; + k_ticks_t timepulse; + if (data->info.fix_status != GNSS_FIX_STATUS_NO_FIX) { - printf("Got a fix!\n"); + if (gnss_get_latest_timepulse(dev, &timepulse) == 0) { + timepulse_ns = k_ticks_to_ns_near64(timepulse); + printf("Got a fix @ %lld ns\n", timepulse_ns); + } else { + printf("Got a fix!\n"); + } } } GNSS_DATA_CALLBACK_DEFINE(GNSS_MODEM, gnss_data_cb);