#pragma once #include #include #include #include "driver/gpio.h" #include "driver/uart.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" typedef struct { uart_port_t uart_port; gpio_num_t tx_pin; gpio_num_t rx_pin; gpio_num_t pps_pin; } gps_sync_config_t; typedef struct { int64_t monotonic_us; // Microseconds - never jumps backward int64_t monotonic_ms; // Milliseconds - for easier logging int64_t gps_us; // GPS UTC time in microseconds int64_t gps_ms; // GPS UTC time in milliseconds struct timespec mono_ts; // POSIX timespec bool synced; // true if GPS has valid fix } gps_timestamp_t; void gps_sync_init(const gps_sync_config_t *config, bool use_gps_log_timestamps); void gps_force_next_update(void); gps_timestamp_t gps_get_timestamp(void); int64_t gps_get_monotonic_ms(void); bool gps_is_synced(void); // Internal logging hooks uint32_t gps_log_timestamp(void); int gps_log_vprintf(const char *fmt, va_list args);