STM_ATEM/User/gps_driver.h
zhoujie 44c37ec769 feat(gps): 新增GPS海拔数据支持并优化系统配置
- 在数据包结构中新增gps_altitude字段以支持海拔数据存储
- 更新PackData和PackCorrectedData系列函数,增加altitude参数
- 移除timestamp字段以精简数据包结构,提高传输效率
- 优化GPS数据处理逻辑,取消GPS有效性检查,直接使用原始GPS数据
- 将调试输出和监控保存间隔统一调整为30秒,降低系统负载
- 将数据存储文件最大大小从20MB提升至100MB,支持更长时间数据采集
- 将GPS数据超时时间从2秒延长至10秒,提高在弱信号环境下的稳定性

🔧 chore(spi): 调整SPI配置以优化通信稳定性

- 将所有SPI接口的时钟相位从SPI_PHASE_1EDGE调整为SPI_PHASE_2EDGE
- 将SPI1的波特率预分频器从4调整为8,降低通信速率以提高稳定性
- 更新STM32CubeMX配置文件(.ioc)以反映SPI配置变更

📝 docs(script): 新增高性能数据分析工具脚本

- 创建atem_parse.py脚本,提供数据解析和可视化功能
- 支持V1/V2数据格式解析,V2版本包含GPS经纬度和海拔数据
- 实现串口实时数据接收和GPS动态模拟输出功能
- 提供波形图、轨迹图和海拔曲线等多标签可视化界面
- 包含数据表格展示和CSV导出功能,支持高性能大数据处理
2026-02-20 23:48:28 +08:00

151 lines
4.0 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
******************************************************************************
* @file gps_driver.h
* @brief GPS NMEA数据接收和解析驱动
* @author Your Name
* @date 2026-02-07
******************************************************************************
* @attention
*
* 本驱动用于通过USART3接收GPS模块的NMEA数据主要解析GPGGA语句
* 提取时间、经纬度等信息
*
******************************************************************************
*/
#ifndef __GPS_DRIVER_H
#define __GPS_DRIVER_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usart.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/* Exported types ------------------------------------------------------------*/
/**
* @brief GPS定位状态
*/
typedef enum {
GPS_FIX_INVALID = 0, // 无效定位
GPS_FIX_GPS = 1, // GPS定位
GPS_FIX_DGPS = 2, // 差分GPS定位
GPS_FIX_PPS = 3, // PPS定位
GPS_FIX_RTK = 4, // RTK固定解
GPS_FIX_RTK_FLOAT = 5, // RTK浮点解
GPS_FIX_ESTIMATED = 6, // 估算
GPS_FIX_MANUAL = 7, // 手动输入
GPS_FIX_SIMULATION = 8 // 模拟模式
} GPS_FixStatus_t;
/**
* @brief GPS时间结构体
*/
typedef struct {
uint8_t hour; // 时 (UTC)
uint8_t minute; // 分
uint8_t second; // 秒
uint16_t millisec; // 毫秒
} GPS_Time_t;
/**
* @brief GPS位置结构体
*/
typedef struct {
double latitude; // 纬度 (度)
char lat_direction; // 纬度方向 ('N' or 'S')
double longitude; // 经度 (度)
char lon_direction; // 经度方向 ('E' or 'W')
double altitude; // 海拔高度 (米)
GPS_FixStatus_t fix_status; // 定位状态
uint8_t satellites; // 使用的卫星数量
float hdop; // 水平精度因子
} GPS_Position_t;
/**
* @brief GPS数据结构体
*/
typedef struct {
GPS_Time_t time; // GPS时间
GPS_Position_t position; // GPS位置
uint8_t data_valid; // 数据有效标志 (1=有效, 0=无效)
uint32_t last_update_tick; // 最后更新时间戳
} GPS_Data_t;
/* Exported constants --------------------------------------------------------*/
#define GPS_UART_HANDLE huart3 // GPS使用的UART句柄
#define GPS_RX_BUFFER_SIZE 512 // 接收缓冲区大小
#define GPS_NMEA_MAX_LENGTH 128 // NMEA语句最大长度
#define GPS_DATA_TIMEOUT_MS 10000 // 数据超时时间(ms)
/* Exported macro ------------------------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/
/**
* @brief 初始化GPS驱动
* @retval HAL状态
*/
HAL_StatusTypeDef GPS_Init(void);
/**
* @brief GPS数据接收处理在主循环中调用
* @retval None
*/
void GPS_Process(void);
/**
* @brief 获取GPS数据
* @param gps_data: 指向GPS数据结构体的指针
* @retval 1=数据有效, 0=数据无效或超时
*/
uint8_t GPS_GetData(GPS_Data_t *gps_data);
/**
* @brief 检查GPS数据是否有效
* @retval 1=有效, 0=无效
*/
uint8_t GPS_IsDataValid(void);
/**
* @brief 获取GPS时间字符串
* @param buffer: 输出缓冲区
* @param size: 缓冲区大小
* @retval None
*/
void GPS_GetTimeString(char *buffer, uint16_t size);
/**
* @brief 获取GPS位置字符串
* @param buffer: 输出缓冲区
* @param size: 缓冲区大小
* @retval None
*/
void GPS_GetPositionString(char *buffer, uint16_t size);
/**
* @brief UART接收完成回调函数在stm32f4xx_it.c中调用
* @param huart: UART句柄
* @retval None
*/
void GPS_UART_RxCpltCallback(UART_HandleTypeDef *huart);
/**
* @brief UART空闲中断回调函数在stm32f4xx_it.c中调用
* @param huart: UART句柄
* @retval None
*/
void GPS_UART_IdleCallback(UART_HandleTypeDef *huart);
#ifdef __cplusplus
}
#endif
#endif /* __GPS_DRIVER_H */