#ifndef APP_DATA_PROCESSING_H #define APP_DATA_PROCESSING_H #ifdef __cplusplus extern "C" { #endif #include #include #include #include "app_frm_monitor.h" #include "app_frm_signal.h" #include "app_frm_timer.h" #define RM3100_TIME 1000 #define GGA_BUF_SIZE 128 #define VTG_BUF_SIZE 64 #define IMU_IIM46234_HEADER1 0x23 #define IMU_IIM46234_HEADER2 0x23 #define IMU_YIS321_HEADER1 0x59 #define IMU_YIS321_HEADER2 0x53 #define SWAP_ENDIAN_16(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF)) #define SWAP_ENDIAN_32(x) (((x) << 24) | (((x) & 0xFF00) << 8) | (((x) >> 8) & 0xFF00) | ((x) >> 24)) #pragma pack(1)//数据结构一个字节对齐 /* * @brief YIS协议标准数据帧结构 */ typedef struct { /*---------- 协议头 ----------*/ uint16_t header; ///< 固定值0x59 0x53(协议6.3.1.1) /*---------- 元数据 ----------*/ uint16_t frame_number; ///< 帧序号(1-60000),小端存储(协议6.3.1.3) uint8_t data_length; ///< 数据域长度(0-255字节) /*---------- 有效载荷 ----------*/ // 加速度计(数据ID 0x10) uint8_t acc_id; ///< 标识符0x10(协议附录A.1) uint8_t acc_len; ///< 数据长度:12字节 int32_t acc_x; ///< X轴加速度,精度 0.000001 单位 m/s2 int32_t acc_y; ///< Y轴加速度 精度 0.000001 单位 m/s2 int32_t acc_z; ///< Z轴加速度 精度 0.000001 单位 m/s2 // 陀螺仪(数据ID 0x20) uint8_t gyro_id; ///< 标识符0x20 uint8_t gyro_len; ///< 数据长度:12字节 int32_t gyro_x; ///< X轴角速度 精度 0.000001 单位 deg/s int32_t gyro_y; ///< Y轴角速度 精度 0.000001 单位 deg/s int32_t gyro_z; ///< Z轴角速度 精度 0.000001 单位 deg/s // 欧拉角(数据ID 0x40)[1,2](@ref) uint8_t euler_id; ///< 标识符:固定值0x40(协议附录A.4,Tait-Bryan角约定) uint8_t euler_len; ///< 数据长度:3轴×4字节=12字节(协议6.3.2.6) // 遵循Z-Y-X旋转顺序(内旋系统),角度值采用Q24定点数存储[2](@ref) int32_t pitch; ///< X轴俯仰角,单位:0.000001°,转换公式:(raw × 1e-6)° int32_t roll; ///< Y轴横滚角,范围:±90 int32_t yaw; ///< Z轴偏航角, // 四元数(数据ID 0x41) uint8_t quat_id; ///< 标识符0x41 uint8_t quat_len; ///< 数据长度:16字节 int32_t q0; ///< 精度 0.000001 int32_t q1; ///< 精度 0.000001 int32_t q2; ///< 精度 0.000001 int32_t q3; ///< 精度 0.000001 // 温度(数据ID 0x01) uint8_t temp_id; ///< 标识符0x01 uint8_t temp_len; ///< 数据长度:2字节 uint16_t temperature; ///< IMU温度 精度 0.01 单位:℃ // 时间戳(协议6.3.3) uint8_t sampletime_id; ///< 标识符0x51 uint8_t sampletime_len; ///< 数据长度:4字节 uint32_t sampletime; ///< 采样时间戳(±1μs同步精度) uint8_t rady_time_id; ///< 标识符0x52 uint8_t rady_time_len; ///< 数据长度:4字节 uint32_t rady_time; ///< 采样时间戳(±1μs同步精度) /*---------- 校验区 ----------*/ uint16_t checksum1; ///< 校验码1(协议6.3.1.2) } StrProtocolFrame; typedef union _UnInfProtocolFrame { StrProtocolFrame bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrProtocolFrame)]; // 通过结构体类型确定大小 } UnInfProtocolFrame; #pragma pack() /* 定义GGA数据结构体 */ typedef struct { double utc_time; // UTC时间(HHMMSS.SSS格式) double latitude; // 纬度(十进制度) char lat_dir; // 纬度方向(N/S) double longitude; // 经度(十进制度) char lon_dir; // 经度方向(E/W) char fix_quality; // 定位质量(0-5) char satellites; // 使用卫星数量 float hdop; // 水平精度因子 float altitude; // 海拔高度(米) } GGA_Data; /* 定义RMC数据结构体 */ typedef struct { double utc_tim; char status; // 定位状态(A=有效) double latitude; char lat_dir; double longitude; char lon_dir; double speed; // 地面速度(节) double course; // 地面航向(度) char date[7]; // 日期(DDMMYY) } RMC_Data; // VTG数据结构体定义(地面航向及速度信息) typedef struct { float course_true; // 真北航向(单位:度) float course_magnetic; // 磁北航向(单位:度) float speed_knots; // 地面速度(单位:节) float speed_kmh; // 地面速度(单位:公里/小时) char mode; // 模式指示(A=有效,V=无效) } VTG_Data; // THS数据结构体定义 typedef struct { float heading; // 航向(单位:度) char mode; // 模式:A/E/M/S/V } THS_Data; // 将度分格式转换为十进制函数 double nmea_to_decimal(double dm, char direction); void gnggaProcess(void *signal_id); void dataProcessingAppInit(void); #ifdef __cplusplus } #endif #endif // APP_DATA_PROCESSING_H